QSC Post Quantum Cryptographic Library 1.1.0.2 (B2)
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 "qsccommon.h"

Go to the source code of this file.

Macros

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

Functions

QSC_EXPORT_API bool 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 bool 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))
 Takes the message as input 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.

Example
// An example of key-pair creation, encryption, and decryption
#define MSGLEN 32
uint8_t sk[QSC_FALCON_SECRETKEY_SIZE];
uint8_t msg[32];
uint8_t smsg[QSC_FALCON_SIGNATURE_SIZE + MSGLEN];
uint8_t rmsg[32];
uint32_t rmsglen = 0;
uint32_t smsglen = 0;
// create the public and secret keys
qsc_falcon_generate(pk, sk);
// returns the signed the message in smsg
qsc_falcon_sign(smsg, &smsglen, msg, MSGLEN, sk);
// test the signature and return the message bytes in rmsg
if (qsc_falcon_verify(rmsg, &rmsglen, smsg, smsglen, pk) != true)
{
// authentication failed, do something..
}
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:45
#define QSC_FALCON_PUBLICKEY_SIZE
The byte size of the public-key array.
Definition falcon.h:122
#define QSC_FALCON_SIGNATURE_SIZE
The byte size of the signature array.
Definition falcon.h:128
QSC_EXPORT_API bool 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))
Takes the message as input and returns an array containing the signature followed by the message.
Definition falcon.c:26

Based entirely on the C reference branch of Falcon taken from the NIST Post Quantum Competition Round 3 submission.
The NIST Post Quantum Competition Round 3 Finalists.
The Falcon website.
The Falcon Algorithm Specification.

Function Documentation

◆ qsc_falcon_generate_keypair()

QSC_EXPORT_API bool 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_SECRETKEY_SIZE.
Parameters
publickeyPointer to the public verification-key array
privatekeyPointer to the private signature-key array
rng_generatePointer to the random generator
Returns
Returns true for success

◆ qsc_falcon_sign()

QSC_EXPORT_API bool 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) )

Takes the message as input and returns an array containing the signature followed by the message.

Warning
Signature array must be sized to the size of the message plus QSC_FALCON_SIGNATURE_SIZE.
Parameters
signedmsgPointer to the signed-message array
smsglenThe signed message length
message[const] Pointer to the message array
msglenThe message array length
privatekey[const] Pointer to the private signature-key
rng_generatePointer to the random generator
Returns
Returns true for success

◆ 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
messagePointer to the message output array
msglenLength of the message array
signedmsg[const] Pointer to the signed message array
smsglenThe signed message length
publickey[const] Pointer to the public verification-key array
Returns
Returns true for success