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
use alloc::vec::Vec;
use miden_protocol::account::auth::{AuthScheme, PublicKeyCommitment};
/// Defines standard authentication methods supported by account auth components.
pub enum AuthMethod {
/// A minimal authentication method 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 method which relies on either ECDSA or Falcon512Poseidon2
/// signatures.
SingleSig {
approver: (PublicKeyCommitment, AuthScheme),
},
/// A multi-signature authentication method using either ECDSA or Falcon512Poseidon2 signatures.
///
/// Requires a threshold number of signatures from the provided public keys.
Multisig {
threshold: u32,
approvers: Vec<(PublicKeyCommitment, AuthScheme)>,
},
/// A non-standard authentication method.
Unknown,
}
impl AuthMethod {
/// Returns all public key commitments associated with this authentication method.
///
/// For unknown methods, an empty vector is returned.
pub fn get_public_key_commitments(&self) -> Vec<PublicKeyCommitment> {
match self {
AuthMethod::NoAuth => Vec::new(),
AuthMethod::SingleSig { approver: (pub_key, _) } => vec![*pub_key],
AuthMethod::Multisig { approvers, .. } => {
approvers.iter().map(|(pub_key, _)| *pub_key).collect()
},
AuthMethod::Unknown => Vec::new(),
}
}
}