PQLR
Postquantum Crypto Library by QAPP
|
Typedefs | |
typedef struct sphincs_plus_st * | sphincs_plus_t |
Sphincs_plus algorithm instance handle. More... | |
Functions | |
PQLR_API sphincs_plus_t | sphincs_plus_new (sphincs_plus_parameterset_t parameterset) |
Creates new sphincs_plus instance with selected parameter set. More... | |
PQLR_API void | sphincs_plus_free (sphincs_plus_t sphincs_plus) |
Frees sphincs_plus instance and all corresponding resources. More... | |
PQLR_API sphincs_plus_t | sphincs_plus_duplicate (const sphincs_plus_t sphincs_plus) |
Duplicates sphincs_plus context. More... | |
PQLR_API pqlr_t | sphincs_plus_to_pqlr (sphincs_plus_t sphincs_plus) |
Casts sphincs_plus instance to pqlr instance. More... | |
PQLR_API size_t | sphincs_plus_get_signature_bytes_len (sphincs_plus_t sphincs_plus) |
Obtains signature buffer length in bytes for current sphincs_plus instance. More... | |
PQLR_API size_t | sphincs_plus_get_public_key_bytes_len (sphincs_plus_t sphincs_plus) |
Obtains public key buffer length in bytes for current sphincs_plus instance. More... | |
PQLR_API size_t | sphincs_plus_get_secret_key_bytes_len (sphincs_plus_t sphincs_plus) |
Obtains secret key buffer length in bytes for current sphincs_plus instance. More... | |
PQLR_API void | sphincs_plus_generate_keys (const sphincs_plus_t sphincs_plus, uint8_t *result_sk, uint8_t *result_pk) |
Generates random secret key and public key for given context. More... | |
PQLR_API void | sphincs_plus_sign (const sphincs_plus_t sphincs_plus, 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 | sphincs_plus_verify (const sphincs_plus_t sphincs_plus, 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 SPHINCS+ algorithm implementation, which is a stateless hash-based signature scheme. The basic idea is to authenticate a huge number of few-time signature (FTS) key pairs using a so-called hypertree. FTS schemes are signature schemes that allow a key pair to produce a small number of signatures, e.g., in the order of ten for our parameter sets. For each new message, a (pseudo)random FTS key pair is chosen to sign the message. Signature consists of FTS signature and corresponding authentication information. The authentication information is roughly a hypertree signature, i.e. a signature using a certification tree of Merkle tree signatures.
At first, initialize algorithm's instance with parameters you want with sphincs_plus_new(). After that, you can generate secret and public keys using sphincs_plus_generate_keys(), or sign your message with sphincs_plus_sign(), or verify message wasn't changed with sphincs_plus_verify(). You are able to interact with this algorithm likewise pqlr_t instance(change error handler, source of entropy input, e.t.c) via sphincs_plus_to_pqlr() call.
After there are no more need in signature scheme it's resources must be made free by sphincs_plus_free.
In order to use any SPHINCS+ signature scheme functions, add following include:
Example code is listed below:
typedef struct sphincs_plus_st* sphincs_plus_t |
Sphincs_plus algorithm instance handle.
Parameter set.
SPHINCS+ can be parametrized with one of predefined parameter sets. Based on parameter set, following algorithm properties are changed:
Property values summarized in table below.
Paramset | Security level | Private key size | Public key size | Signature size | Hash count |
---|---|---|---|---|---|
128s | 133 | 64 | 32 | 8 080 | 2 205 679 |
128f | 128 | 64 | 32 | 16 976 | 141 551 |
192s | 196 | 96 | 48 | 17 064 | 4 532 203 |
192f | 194 | 96 | 48 | 35 664 | 178 234 |
256s | 255 | 128 | 64 | 29 792 | 3 418 083 |
256f | 254 | 128 | 64 | 49 216 | 402 466 |
Computation speed will differ depending on chosen parameter sets due to different count of internal hash operations performed.
PQLR_API sphincs_plus_t sphincs_plus_duplicate | ( | const sphincs_plus_t | sphincs_plus | ) |
Duplicates sphincs_plus context.
sphincs_plus | context to duplicate |
PQLR_API void sphincs_plus_free | ( | sphincs_plus_t | sphincs_plus | ) |
Frees sphincs_plus instance and all corresponding resources.
sphincs_plus | instance to free |
PQLR_API void sphincs_plus_generate_keys | ( | const sphincs_plus_t | sphincs_plus, |
uint8_t * | result_sk, | ||
uint8_t * | result_pk | ||
) |
Generates random secret key and public key for given context.
Usage:
sphincs_plus | Instance of sphincs_plus created with sphincs_plus_new(). If NULL , the fatal error occurs. | |
[out] | result_sk | Contiguous array to receive secret key, of size sphincs_plus_get_secret_key_bytes_len . If NULL , the fatal error occurs. |
[out] | result_pk | Contiguous array to receive public key, of size sphincs_plus_get_public_key_bytes_len . If NULL , the fatal error occurs. |
PQLR_API size_t sphincs_plus_get_public_key_bytes_len | ( | sphincs_plus_t | sphincs_plus | ) |
Obtains public key buffer length in bytes for current sphincs_plus instance.
sphincs_plus | initialized sphincs_plus instance |
PQLR_API size_t sphincs_plus_get_secret_key_bytes_len | ( | sphincs_plus_t | sphincs_plus | ) |
Obtains secret key buffer length in bytes for current sphincs_plus instance.
sphincs_plus | initialized sphincs_plus instance |
PQLR_API size_t sphincs_plus_get_signature_bytes_len | ( | sphincs_plus_t | sphincs_plus | ) |
Obtains signature buffer length in bytes for current sphincs_plus instance.
sphincs_plus | initialized sphincs_plus instance |
PQLR_API sphincs_plus_t sphincs_plus_new | ( | sphincs_plus_parameterset_t | parameterset | ) |
Creates new sphincs_plus instance with selected parameter set.
Usage:
parameterset | Parameter set (see sphincs_plus_parameterset_t for available options) |
NULL
if out of memory PQLR_API void sphincs_plus_sign | ( | const sphincs_plus_t | sphincs_plus, |
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:
sphincs_plus | Instance of sphincs_plus created with sphincs_plus_new(). If NULL , the fatal error occurs. | |
sk | Secret key, the contiguous array of size sphincs_plus_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 sphincs_plus_get_signature_bytes_len . If NULL , the fatal error occurs. |
[out] | result_sig_len | The length of a signature in bytes. If NULL , the fatal error occurs. |
PQLR_API pqlr_t sphincs_plus_to_pqlr | ( | sphincs_plus_t | sphincs_plus | ) |
Casts sphincs_plus instance to pqlr instance.
sphincs_plus | initialized sphincs_plus instance |
NULL
if sphincs_plus is NULL
PQLR_API int sphincs_plus_verify | ( | const sphincs_plus_t | sphincs_plus, |
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:
sphincs_plus | Context, initialized with sphincs_plus_new(). If NULL , the fatal error occurs. |
pk | Public key, the contiguous array of size sphincs_plus_get_public_key_bytes_len . If NULL , the fatal error occurs. |
sig | Signature, the contiguous array of size ‘sphincs_plus_get_signature_bytes_len’. If NULL , the fatal error occurs. |
sig_len | The length of a signature in bytes. |
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.