miden_lib/
auth.rs

1use alloc::vec::Vec;
2
3use miden_objects::account::auth::PublicKeyCommitment;
4
5/// Defines authentication schemes available to standard and faucet accounts.
6pub enum AuthScheme {
7    /// A minimal authentication scheme that provides no cryptographic authentication.
8    ///
9    /// It only increments the nonce if the account state has actually changed during transaction
10    /// execution, avoiding unnecessary nonce increments for transactions that don't modify the
11    /// account state.
12    NoAuth,
13    /// A single-key authentication scheme which relies RPO Falcon512 signatures.
14    ///
15    /// RPO Falcon512 is a variant of the [Falcon](https://falcon-sign.info/) signature scheme.
16    /// This variant differs from the standard in that instead of using SHAKE256 hash function in
17    /// the hash-to-point algorithm we use RPO256. This makes the signature more efficient to
18    /// verify in Miden VM.
19    RpoFalcon512 { pub_key: PublicKeyCommitment },
20    /// A multi-signature authentication scheme using RPO Falcon512 signatures.
21    ///
22    /// Requires a threshold number of signatures from the provided public keys.
23    RpoFalcon512Multisig {
24        threshold: u32,
25        pub_keys: Vec<PublicKeyCommitment>,
26    },
27    /// A non-standard authentication scheme.
28    Unknown,
29}
30
31impl AuthScheme {
32    /// Returns all public key commitments associated with this authentication scheme.
33    ///
34    /// For unknown schemes, an empty vector is returned.
35    pub fn get_public_key_commitments(&self) -> Vec<PublicKeyCommitment> {
36        match self {
37            AuthScheme::NoAuth => Vec::new(),
38            AuthScheme::RpoFalcon512 { pub_key } => vec![*pub_key],
39            AuthScheme::RpoFalcon512Multisig { pub_keys, .. } => pub_keys.clone(),
40            AuthScheme::Unknown => Vec::new(),
41        }
42    }
43}