QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
ntru.h File Reference

Contains the public API for the NTRU CCA-secure Key Encapsulation Mechanism implementation. More...

#include "common.h"
#include "ntrubase.h"

Go to the source code of this file.

Macros

#define QSC_NTRU_CIPHERTEXT_SIZE   1230ULL
 The size of the ciphertext array.
 
#define QSC_NTRU_PRIVATEKEY_SIZE   1590ULL
 The size of the secret private-key array.
 
#define QSC_NTRU_PUBLICKEY_SIZE   1230ULL
 The size of the public-key array.
 
#define QSC_NTRU_SEED_SIZE   32ULL
 The size of the seed array.
 
#define QSC_NTRU_SHAREDSECRET_SIZE   32ULL
 The size of the shared secret-key array.
 
#define QSC_NTRU_ALGNAME   "NTRU"
 The formal algorithm name.
 

Functions

QSC_EXPORT_API bool qsc_ntru_decapsulate (uint8_t *secret, const uint8_t *ciphertext, const uint8_t *privatekey)
 Decapsulates the shared secret using a private-key.
 
QSC_EXPORT_API bool qsc_ntru_decrypt (uint8_t *secret, const uint8_t *ciphertext, const uint8_t *privatekey)
 Decrypts the shared secret using a private-key.
 
QSC_EXPORT_API void qsc_ntru_encapsulate (uint8_t *secret, uint8_t *ciphertext, const uint8_t *publickey, bool(*rng_generate)(uint8_t *, size_t))
 Encapsulates a shared secret using a public-key.
 
QSC_EXPORT_API void qsc_ntru_encrypt (uint8_t *secret, uint8_t *ciphertext, const uint8_t *publickey, const uint8_t seed[QSC_NTRU_SEED_SIZE])
 Encrypts and encapsulates a shared secret using a public-key.
 
QSC_EXPORT_API void qsc_ntru_generate_keypair (uint8_t *publickey, uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
 Generates a public/private key pair for NTRU.
 

Detailed Description

Contains the public API for the NTRU CCA-secure Key Encapsulation Mechanism implementation.

This header provides function declarations for generating key pairs, encapsulating and decapsulating shared secrets using the NTRU algorithm. Multiple parameter sets are supported and are selected at compile-time via definitions (e.g. QSC_NTRU_S1HPS2048509, QSC_NTRU_S3HPS2048677, etc.). The API is designed for secure post-quantum cryptographic applications.

Reference Links:

Function Documentation

◆ qsc_ntru_decapsulate()

QSC_EXPORT_API bool qsc_ntru_decapsulate ( uint8_t * secret,
const uint8_t * ciphertext,
const uint8_t * privatekey )

Decapsulates the shared secret using a private-key.

Parameters
secret[uint8_t*] Pointer to the output shared secret key (size: QSC_NTRU_SHAREDSECRET_SIZE).
ciphertext[const uint8_t*] Pointer to the ciphertext array (size: QSC_NTRU_CIPHERTEXT_SIZE).
privatekey[const uint8_t*] Pointer to the secret-key array (size: QSC_NTRU_PRIVATEKEY_SIZE).
Returns
[bool] Returns true if decapsulation is successful.

◆ qsc_ntru_decrypt()

QSC_EXPORT_API bool qsc_ntru_decrypt ( uint8_t * secret,
const uint8_t * ciphertext,
const uint8_t * privatekey )

Decrypts the shared secret using a private-key.

Parameters
secret[uint8_t*] Pointer to the output shared secret key (size: QSC_KYBER_SHAREDSECRET_SIZE).
ciphertext[const uint8_t*] Pointer to the ciphertext array (size: QSC_KYBER_CIPHERTEXT_SIZE).
privatekey[const uint8_t*] Pointer to the secret-key array (size: QSC_KYBER_PRIVATEKEY_SIZE).
Returns
[bool] Returns true if decryption is successful.

◆ qsc_ntru_encapsulate()

QSC_EXPORT_API void qsc_ntru_encapsulate ( uint8_t * secret,
uint8_t * ciphertext,
const uint8_t * publickey,
bool(* rng_generate )(uint8_t *, size_t) )

Encapsulates a shared secret using a public-key.

Warning
The ciphertext array must be sized to QSC_NTRU_CIPHERTEXT_SIZE.
Parameters
secret[uint8_t*] Pointer to the shared secret key (size: QSC_NTRU_SHAREDSECRET_SIZE).
ciphertext[uint8_t*] Pointer to the ciphertext array (size: QSC_NTRU_CIPHERTEXT_SIZE).
publickey[const uint8_t*] Pointer to the public-key array (size: QSC_NTRU_PUBLICKEY_SIZE).
rng_generate[function pointer] Pointer to the random generator function.

◆ qsc_ntru_encrypt()

QSC_EXPORT_API void qsc_ntru_encrypt ( uint8_t * secret,
uint8_t * ciphertext,
const uint8_t * publickey,
const uint8_t seed[QSC_NTRU_SEED_SIZE] )

Encrypts and encapsulates a shared secret using a public-key.

Warning
The ciphertext array must be sized to QSC_KYBER_CIPHERTEXT_SIZE.
Parameters
secret[uint8_t*] Pointer to the shared secret key (size: QSC_KYBER_SHAREDSECRET_SIZE).
ciphertext[uint8_t*] Pointer to the ciphertext array (size: QSC_KYBER_CIPHERTEXT_SIZE).
publickey[const uint8_t*] Pointer to the public-key array (size: QSC_KYBER_PUBLICKEY_SIZE).
seed[const uint8_t[QSC_NTRU_SEED_SIZE]] Pointer to the random seed array.

◆ qsc_ntru_generate_keypair()

QSC_EXPORT_API void qsc_ntru_generate_keypair ( uint8_t * publickey,
uint8_t * privatekey,
bool(* rng_generate )(uint8_t *, size_t) )

Generates a public/private key pair for NTRU.

Warning
Arrays must be sized to QSC_NTRU_PUBLICKEY_SIZE and QSC_NTRU_PRIVATEKEY_SIZE.
Parameters
publickey[uint8_t*] Pointer to the output public-key array (size: QSC_NTRU_PUBLICKEY_SIZE).
privatekey[uint8_t*] Pointer to the output private-key array (size: QSC_NTRU_PRIVATEKEY_SIZE).
rng_generate[function pointer] Pointer to the random generator function.