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