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

Contains the primary public API for the Falcon asymmetric signature scheme implementation. More...

#include "common.h"

Go to the source code of this file.

Macros

#define QSC_FALCON_PRIVATEKEY_SIZE   2305ULL
 [uint8_t] The byte size of the secret private-key array.
 
#define QSC_FALCON_PUBLICKEY_SIZE   1793ULL
 [uint8_t] The byte size of the public-key array.
 
#define QSC_FALCON_SIGNATURE_SIZE   1276ULL
 [uint8_t] The byte size of the signature array.
 
#define QSC_FALCON_ALGNAME   "FALCON"
 [char*] The formal algorithm name.
 

Functions

QSC_EXPORT_API void qsc_falcon_generate_keypair (uint8_t *publickey, uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
 Generates a Falcon public/private key-pair.
 
QSC_EXPORT_API void qsc_falcon_sign (uint8_t *signedmsg, size_t *smsglen, const uint8_t *message, size_t msglen, const uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
 Signs a message and returns an array containing the signature followed by the message.
 
QSC_EXPORT_API bool qsc_falcon_verify (uint8_t *message, size_t *msglen, const uint8_t *signedmsg, size_t smsglen, const uint8_t *publickey)
 Verifies a signature-message pair with the public key.
 

Detailed Description

Contains the primary public API for the Falcon asymmetric signature scheme implementation.

This file provides the API for the Falcon signature scheme implementation. It defines functions to generate key pairs, sign messages, and verify signature-message pairs using the Falcon algorithm. The implementation is based on the NIST PQC Round 3 submission, with parameters selected via preprocessor definitions.

// Example of key-pair creation, signing, and verification:
#define MSGLEN 32
uint8_t msg[MSGLEN];
uint8_t smsg[QSC_FALCON_SIGNATURE_SIZE + MSGLEN];
uint8_t rmsg[MSGLEN];
uint32_t smsglen = 0;
// Create the public and secret keys
qsc_falcon_generate_keypair(pk, sk, rng_generate);
// Sign the message; the signed message contains the signature followed by the message
qsc_falcon_sign(smsg, &smsglen, msg, MSGLEN, sk, rng_generate);
// Verify the signature and recover the message in rmsg
if (qsc_falcon_verify(rmsg, &smsglen, smsg, smsglen, pk) != true)
{
// Authentication failed, handle accordingly...
}
QSC_EXPORT_API void qsc_falcon_sign(uint8_t *signedmsg, size_t *smsglen, const uint8_t *message, size_t msglen, const uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
Signs a message and returns an array containing the signature followed by the message.
Definition falcon.c:26
QSC_EXPORT_API bool qsc_falcon_verify(uint8_t *message, size_t *msglen, const uint8_t *signedmsg, size_t smsglen, const uint8_t *publickey)
Verifies a signature-message pair with the public key.
Definition falcon.c:41
#define QSC_FALCON_PUBLICKEY_SIZE
[uint8_t] The byte size of the public-key array.
Definition falcon.h:103
#define QSC_FALCON_SIGNATURE_SIZE
[uint8_t] The byte size of the signature array.
Definition falcon.h:115
QSC_EXPORT_API void qsc_falcon_generate_keypair(uint8_t *publickey, uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
Generates a Falcon public/private key-pair.
Definition falcon.c:13
#define QSC_FALCON_PRIVATEKEY_SIZE
[uint8_t] The byte size of the secret private-key array.
Definition falcon.h:91

Reference Links:

Function Documentation

◆ qsc_falcon_generate_keypair()

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

Generates a Falcon public/private key-pair.

Warning
Arrays must be sized to QSC_FALCON_PUBLICKEY_SIZE and QSC_FALCON_PRIVATEKEY_SIZE.
Parameters
publickey[uint8_t*] Pointer to the public verification-key array.
privatekey[uint8_t*] Pointer to the private signature-key array.
rng_generate[bool (*)(uint8_t*, size_t)] Pointer to the random generator function.

◆ qsc_falcon_sign()

QSC_EXPORT_API void qsc_falcon_sign ( uint8_t * signedmsg,
size_t * smsglen,
const uint8_t * message,
size_t msglen,
const uint8_t * privatekey,
bool(* rng_generate )(uint8_t *, size_t) )

Signs a message and returns an array containing the signature followed by the message.

Warning
The signed message array must be sized to the size of the message plus QSC_FALCON_SIGNATURE_SIZE.
Parameters
signedmsg[uint8_t*] Pointer to the signed-message array.
smsglen[size_t*] Pointer to the signed message length.
message[const uint8_t*] Pointer to the message array.
msglen[size_t] The message array length.
privatekey[const uint8_t*] Pointer to the private signature-key.
rng_generate[bool (*)(uint8_t*, size_t)] Pointer to the random generator function.

◆ qsc_falcon_verify()

QSC_EXPORT_API bool qsc_falcon_verify ( uint8_t * message,
size_t * msglen,
const uint8_t * signedmsg,
size_t smsglen,
const uint8_t * publickey )

Verifies a signature-message pair with the public key.

Parameters
message[uint8_t*] Pointer to the message output array.
msglen[size_t*] Pointer to the message length.
signedmsg[const uint8_t*] Pointer to the signed message array.
smsglen[size_t] The signed message length.
publickey[const uint8_t*] Pointer to the public verification-key array.
Returns
[bool] Returns true for success.