miden_lib/account/auth/rpo_falcon_512.rs
1use miden_objects::account::auth::PublicKeyCommitment;
2use miden_objects::account::{AccountComponent, StorageSlot};
3
4use crate::account::components::rpo_falcon_512_library;
5
6/// An [`AccountComponent`] implementing the RpoFalcon512 signature scheme for authentication of
7/// transactions.
8///
9/// It reexports the procedures from `miden::contracts::auth::basic`. When linking against this
10/// component, the `miden` library (i.e. [`MidenLib`](crate::MidenLib)) must be available to the
11/// assembler which is the case when using [`TransactionKernel::assembler()`][kasm]. The procedures
12/// of this component are:
13/// - `auth_tx_rpo_falcon512`, which can be used to verify a signature provided via the advice stack
14/// to authenticate a transaction.
15///
16/// This component supports all account types.
17///
18/// [kasm]: crate::transaction::TransactionKernel::assembler
19pub struct AuthRpoFalcon512 {
20 pub_key: PublicKeyCommitment,
21}
22
23impl AuthRpoFalcon512 {
24 /// Creates a new [`AuthRpoFalcon512`] component with the given `public_key`.
25 pub fn new(pub_key: PublicKeyCommitment) -> Self {
26 Self { pub_key }
27 }
28}
29
30impl From<AuthRpoFalcon512> for AccountComponent {
31 fn from(falcon: AuthRpoFalcon512) -> Self {
32 AccountComponent::new(
33 rpo_falcon_512_library(),
34 vec![StorageSlot::Value(falcon.pub_key.into())],
35 )
36 .expect("falcon component should satisfy the requirements of a valid account component")
37 .with_supports_all_types()
38 }
39}