sntrup(3)

πŸ“¦
version 0~20241021 Β· 3 versions
, in debian trixie, ubuntu questing

πŸ’– 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 of crypto_kem_*,
  • message lengths are long long instead of unsigned long long, and
  • the functions return void instead of int.

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