miden-crypto/src/dsa/rpo_falcon512/mod.rs
src/dsa/rpo_falcon512/mod.rsRaw
1use crate::{
2 hash::rpo::Rpo256,
3 utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable},
4 Felt, Word, ZERO,
5};
6
7#[cfg(feature = "std")]
8mod ffi;
9
10mod error;
11mod keys;
12mod polynomial;
13mod signature;
14
15pub use error::FalconError;
16pub use keys::{KeyPair, PublicKey};
17pub use polynomial::Polynomial;
18pub use signature::Signature;
19
20// CONSTANTS
21// ================================================================================================
22
23// The Falcon modulus.
24const MODULUS: u16 = 12289;
25const MODULUS_MINUS_1_OVER_TWO: u16 = 6144;
26
27// The Falcon parameters for Falcon-512. This is the degree of the polynomial `phi := x^N + 1`
28// defining the ring Z_p[x]/(phi).
29const N: usize = 512;
30const LOG_N: usize = 9;
31
32/// Length of nonce used for key-pair generation.
33const NONCE_LEN: usize = 40;
34
35/// Number of filed elements used to encode a nonce.
36const NONCE_ELEMENTS: usize = 8;
37
38/// Public key length as a u8 vector.
39pub const PK_LEN: usize = 897;
40
41/// Secret key length as a u8 vector.
42pub const SK_LEN: usize = 1281;
43
44/// Signature length as a u8 vector.
45const SIG_LEN: usize = 626;
46
47/// Bound on the squared-norm of the signature.
48const SIG_L2_BOUND: u64 = 34034726;
49
50// TYPE ALIASES
51// ================================================================================================
52
53type SignatureBytes = [u8; NONCE_LEN + SIG_LEN];
54type PublicKeyBytes = [u8; PK_LEN];
55type SecretKeyBytes = [u8; SK_LEN];
56type NonceBytes = [u8; NONCE_LEN];
57type NonceElements = [Felt; NONCE_ELEMENTS];