![]() |
PQLR
Postquantum Crypto Library by QAPP
|
Typedefs | |
| typedef struct falcon_st * | falcon_t |
| Falcon algorithm instance handle. More... | |
Enumerations | |
| enum | falcon_parameterset_t { falcon_default , falcon_parameterset_last } |
| Parameter set. More... | |
Functions | |
| PQLR_API falcon_t | falcon_new (falcon_parameterset_t parameterset) |
| Creates new falcon instance with selected parameter set. More... | |
| PQLR_API void | falcon_free (falcon_t falcon) |
| Frees falcon instance and all corresponding resources. More... | |
| PQLR_API falcon_t | falcon_duplicate (const falcon_t src) |
| Duplicates context copying all related resources. More... | |
| PQLR_API pqlr_t | falcon_to_pqlr (falcon_t falcon) |
| Casts falcon instance to pqlr instance. More... | |
| PQLR_API size_t | falcon_get_public_key_bytes_len (falcon_t falcon) |
| Obtains public key buffer length in bytes for current falcon instance. More... | |
| PQLR_API size_t | falcon_get_secret_key_bytes_len (falcon_t falcon) |
| Obtains secret key buffer length in bytes for current falcon instance. More... | |
| PQLR_API size_t | falcon_get_signature_bytes_len (falcon_t falcon) |
| Obtains signature buffer length in bytes for current falcon instance. More... | |
| PQLR_API void | falcon_generate_keys (const falcon_t falcon, uint8_t *result_sk, uint8_t *result_pk) |
| Generates random secret key and public key for given context. More... | |
| PQLR_API void | falcon_sign (const falcon_t falcon, const uint8_t *sk, const uint8_t *msg, size_t msg_len, uint8_t *result_sig, size_t *result_sig_len) |
| Generates signature for given message according to context and secret key. The signature is non-deterministic, i.e. there are different results for the same message. More... | |
| PQLR_API int | falcon_verify (const falcon_t falcon, const uint8_t *pk, const uint8_t *sig, size_t sig_len, const uint8_t *msg, size_t msg_len) |
| Verifies that given signature is the signature of given message. More... | |
This module provides Falcon algorithm implementation, which is a stateless hash-based signature scheme.
At first, initialize algorithm's instance with parameters you want with falcon_new(). After that, you can generate secret and public keys using falcon_generate_keys, or sign your message with falcon_sign, or verify message wasn't changed with falcon_verify. You are able to interact with this algorithm likewise pqlr_t instance (change error handler, source of entropy input, e.t.c) via falcon_to_pqlr() call.
After there are no more need in signature scheme it's resources must be made free by falcon_free.
In order to use any Falcon signature scheme functions, add the following include:
Example code is listed below:
| typedef struct falcon_st* falcon_t |
Falcon algorithm instance handle.
Duplicates context copying all related resources.
| src | non-null context to duplicate |
Frees falcon instance and all corresponding resources.
| falcon | instance to free |
| PQLR_API void falcon_generate_keys | ( | const falcon_t | falcon, |
| uint8_t * | result_sk, | ||
| uint8_t * | result_pk | ||
| ) |
Generates random secret key and public key for given context.
Usage:
| falcon | Instance of falcon created with falcon_new(). If NULL, the fatal error occurs. | |
| [out] | result_sk | Contiguous array to receive secret key, of size falcon_get_secret_key_bytes_len. If NULL, the fatal error occurs. |
| [out] | result_pk | Contiguous array to receive public key, of size falcon_get_public_key_bytes_len. If NULL, the fatal error occurs. |
Obtains public key buffer length in bytes for current falcon instance.
| falcon | initialized falcon instance |
Obtains secret key buffer length in bytes for current falcon instance.
| falcon | initialized falcon instance |
Obtains signature buffer length in bytes for current falcon instance.
| falcon | initialized falcon instance |
| PQLR_API falcon_t falcon_new | ( | falcon_parameterset_t | parameterset | ) |
Creates new falcon instance with selected parameter set.
Usage:
NULL if out of memory | PQLR_API void falcon_sign | ( | const falcon_t | falcon, |
| const uint8_t * | sk, | ||
| const uint8_t * | msg, | ||
| size_t | msg_len, | ||
| uint8_t * | result_sig, | ||
| size_t * | result_sig_len | ||
| ) |
Generates signature for given message according to context and secret key. The signature is non-deterministic, i.e. there are different results for the same message.
Usage:
get_signature_bytes_len, while the actual length may be smaller and is returned in sig_len.| falcon | Instance of falcon created with falcon_new(). If NULL, the fatal error occurs. | |
| sk | Secret key, the contiguous array of size falcon_get_secret_key_bytes_len. If NULL, the fatal error occurs. | |
| msg | Message to generate signature of, the contiguous array. If NULL, the fatal error occurs. | |
| msg_len | The length of a message in bytes. If 0, the fatal error occurs. | |
| [out] | result_sig | Contiguous array to receive signature, of size sig_len. If NULL, the fatal error occurs. |
| [out] | result_sig_len | The result signature size. |
Casts falcon instance to pqlr instance.
| falcon | initialized falcon instance |
NULL if falcon is NULL | PQLR_API int falcon_verify | ( | const falcon_t | falcon, |
| const uint8_t * | pk, | ||
| const uint8_t * | sig, | ||
| size_t | sig_len, | ||
| const uint8_t * | msg, | ||
| size_t | msg_len | ||
| ) |
Verifies that given signature is the signature of given message.
Usage:
| falcon | Context, initialized with falcon_new(). If NULL, the fatal error occurs. |
| pk | Public key, the contiguous array of size falcon_get_public_key_bytes_len. If NULL, the fatal error occurs. |
| sig | Signature, the contiguous array of size ‘sig_len’. If NULL, the fatal error occurs. |
| sig_len | Signature size. |
| msg | Message to verify signature of, the contiguous array. If NULL, the fatal error occurs. |
| msg_len | The length of a message in bytes. If 0, the fatal error occurs. |
0 if given signature is the signature of given message, otherwise non-zero value.