sntrup(3)
π sntrup(3) π
okay bestie, sit DOWN, because today we're talking about sntrup β the C API for the libntruprime implementation of the Streamlined NTRU Prime cryptosystem. it's giving cryptography, it's giving post-quantum, it's giving actually kind of iconic. π¦
β¨ NAME β¨
sntrup β the C API for the libntruprime implementation of the Streamlined NTRU Prime cryptosystem. no cap, that's the whole name, that's the whole vibe. π
πΈ SYNOPSIS πΈ
so when you're using libntruprime, first things first, you gotta include the header:
#include <ntruprime.h>
and link with -lntruprime. yes, that's the flag, don't forget it, she's important. π
Key generation (using, like, sntrup1277 as our example, because she's the moment):
unsigned char pk[sntrup1277_PUBLICKEYBYTES];
unsigned char sk[sntrup1277_SECRETKEYBYTES];
sntrup1277_keypair(pk,sk);
Encapsulation (again, sntrup1277, our beloved):
unsigned char ct[sntrup1277_CIPHERTEXTBYTES];
unsigned char k[sntrup1277_BYTES];
const unsigned char pk[sntrup1277_PUBLICKEYBYTES];
sntrup1277_enc(ct,k,pk);
Decapsulation (you guessed it, sntrup1277):
unsigned char k[sntrup1277_BYTES];
const unsigned char ct[sntrup1277_CIPHERTEXTBYTES];
const unsigned char sk[sntrup1277_SECRETKEYBYTES];
sntrup1277_dec(k,ct,sk);
π DESCRIPTION π
libntruprime is an implementation of the Streamlined NTRU Prime cryptosystem, and you can find it over at <https://ntruprime.cr.yp.to>. π
the C API for libntruprime hands you these functions, and yes, the curly braces are doing the lord's work here:
sntrup{653,761,857,953,1013,1277}_keypair
sntrup{653,761,857,953,1013,1277}_enc
sntrup{653,761,857,953,1013,1277}_dec
every single one of these functions follows the SUPERCOP API for KEMs (<https://bench.cr.yp.to/call-kem.html>) β except for these three little differences, and they matter, so pay attention bestie:
- the function names are
libntruprime-specific instead ofcrypto_kem_*, - message lengths are
long longinstead ofunsigned long long, and - the functions return
voidinstead ofint.
and for everything below, we're using sntrup1277 as our example. she's the main character. π
π KEY GENERATION π
the sntrup1277_keypair function randomly generates Alice's secret key sk[0], sk[1], ..., sk[sntrup1277_SECRETKEYBYTES-1] and Alice's corresponding public key pk[0], pk[1], ..., pk[sntrup1277_PUBLICKEYBYTES-1]. π
π ENCAPSULATION π
the sntrup1277_enc function randomly generates a ciphertext ct[0], ct[1], ..., ct[sntrup1277_CIPHERTEXTBYTES-1] and the corresponding session key k[0], k[1], ..., k[sntrup1277_BYTES-1] β all of that, given Alice's public key pk[0], pk[1], ..., pk[sntrup1277_PUBLICKEYBYTES-1]. β¨
π«Ά DECAPSULATION π«Ά
the sntrup1277_dec function, given Alice's secret key sk[0], sk[1], ..., sk[sntrup1277_SECRETKEYBYTES-1], computes the session key k[0], k[1], ..., k[sntrup1277_BYTES-1] corresponding to a ciphertext ct[0], ct[1], ..., ct[sntrup1277_CIPHERTEXTBYTES-1] that was encapsulated to Alice. π
π¦ SEE ALSO π¦
okay that's the whole page, bestie, you ate that. π
this was sntrup(3) β page three of the manual, the crypto girlies' section β and yeah, she signs off as sntrup(3) one more time at the bottom, because she's consistent like that. now go forth and encapsulate. π§β¨
π¦ where this page comes from
- debian trixie: libntruprime-dev 0~20241021-2 Β· LicenseRef-PD-hp OR CC0-1.0 OR 0BSD OR MIT-0 OR MIT
- ubuntu questing: libntruprime-dev 0~20241021-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms