Expand description
§FN-DSA signature verification
This crate implements signature verification for FN-DSA. A VerifyingKey
instance is created by decoding a verifying key (from its encoded
format). Signatures can be verified with the verify()
method on the
VerifyingKey
instance. verify()
uses stack allocation for its
internal buffers (which are not large). The same VerifyingKey
can be
used for verifying several signatures.
The signature process uses a domain-separation context, which is an
arbitrary binary strings (up to 255 bytes in length). If no such
context is required in an application, use DOMAIN_NONE
(the empty
context).
The message is supposed to be pre-hashed by the caller: the caller
provides the hashed value, along with an identifier of the used hash
function. The HASH_ID_RAW
identifier can be used if the message is
not actually pre-hashed, but is provided directly instead of a hash
value.
FN-DSA is parameterized by a degree, which is a power of two.
Standard versions use degree 512 (“level I security”) or 1024 (“level
V security”); smaller degrees are deemed too weak for production use
and meant only for research and testing. The degree is represented
logarithmically as the logn
value, such that the degree is n = 2^logn
(thus, degrees 512 and 1024 correspond to logn
values 9 and
10, respectively). The signature size is fixed for a given degree
(see signature_size()
).
§WARNING
The FN-DSA standard is currently being drafted, but no version has been published yet. When published, it may differ from the exact scheme implemented in this crate, in particular with regard to key encodings, message pre-hashing, and domain separation. Key pairs generated with this crate MAY fail to be interoperable with the final FN-DSA standard. This implementation is expected to be adjusted to the FN-DSA standard when published (before the 1.0 version release).
§Example usage
use fn_dsa_vrfy::{
vrfy_key_size, signature_size, FN_DSA_LOGN_512,
VerifyingKey, VerifyingKeyStandard,
DOMAIN_NONE, HASH_ID_RAW
};
match VerifyingKeyStandard::decode(encoded_verifying_key) {
Some(vk) => {
if vk.verify(sig, &DOMAIN_NONE, &HASH_ID_RAW, b"message") {
// signature is valid
} else {
// signature is not valid
}
}
_ => {
// could not decode verifying key
}
}
Structs§
- Domain
Context - When a message is signed or verified, it is accompanied with a domain
separation context, which is an arbitrary sequence of bytes of length
at most 255. Such a context is wrapped in a
DomainContext
structure. - Hash
Identifier - The message for which a signature is to be generated or verified is pre-hashed by the caller and provided as a hash value along with an identifier of the used hash function. The identifier is normally an encoded ASN.1 OID. A special identifier is used for “raw” messages (i.e. not pre-hashed at all); it uses a single byte of value 0x00.
- Verifying
Key512 - Signature verifier for degrees (
logn
) 9 to 9 only. - Verifying
Key1024 - Signature verifier for degrees (
logn
) 10 to 10 only. - Verifying
KeyStandard - Signature verifier for degrees (
logn
) 9 to 10 only. - Verifying
KeyWeak - Signature verifier for degrees (
logn
) 2 to 8 only.
Constants§
- DOMAIN_
NONE - Empty domain separation context.
- FN_
DSA_ LOGN_ 512 - Symbolic constant for FN-DSA with degree 512 (
logn = 9
). - FN_
DSA_ LOGN_ 1024 - Symbolic constant for FN-DSA with degree 1024 (
logn = 10
). - HASH_
ID_ ORIGINAL_ FALCON - Hash function identifier: original Falcon design.
- HASH_
ID_ RAW - Hash function identifier: none.
- HASH_
ID_ SHA3_ 256 - Hash function identifier: SHA3-256
- HASH_
ID_ SHA3_ 384 - Hash function identifier: SHA3-384
- HASH_
ID_ SHA3_ 512 - Hash function identifier: SHA3-512
- HASH_
ID_ SHA256 - Hash function identifier: SHA-256
- HASH_
ID_ SHA384 - Hash function identifier: SHA-384
- HASH_
ID_ SHA512 - Hash function identifier: SHA-512
- HASH_
ID_ SHA512_ 256 - Hash function identifier: SHA-512-256
- HASH_
ID_ SHAK E128 - Hash function identifier: SHAKE128
- HASH_
ID_ SHAK E256 - Hash function identifier: SHAKE256
Traits§
- Verifying
Key - Verifying key handler.
Functions§
- signature_
size - Get the size (in bytes) of a signature for the provided degree
(degree is
n = 2^logn
, with2 <= logn <= 10
). - vrfy_
key_ size - Get the size (in bytes) of a verifying key for the provided degree
(degree is
n = 2^logn
, with2 <= logn <= 10
).