miden_lib/account/auth/
mod.rs

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