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