miden_lib/account/auth/
ecdsa_k256_keccak.rs

1use miden_objects::account::auth::PublicKeyCommitment;
2use miden_objects::account::{AccountComponent, StorageSlot};
3
4use crate::account::components::ecdsa_k256_keccak_library;
5
6/// An [`AccountComponent`] implementing the ECDSA K256 Keccak signature scheme for authentication
7/// of 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_ecdsa_k256_keccak`, which can be used to verify a signature provided via the advice
14///   stack to authenticate a transaction.
15///
16/// This component supports all account types.
17///
18/// [kasm]: crate::transaction::TransactionKernel::assembler
19pub struct AuthEcdsaK256Keccak {
20    pub_key: PublicKeyCommitment,
21}
22
23impl AuthEcdsaK256Keccak {
24    /// Creates a new [`AuthEcdsaK256Keccak`] component with the given `public_key`.
25    pub fn new(pub_key: PublicKeyCommitment) -> Self {
26        Self { pub_key }
27    }
28}
29
30impl From<AuthEcdsaK256Keccak> for AccountComponent {
31    fn from(ecdsa: AuthEcdsaK256Keccak) -> Self {
32        AccountComponent::new(
33            ecdsa_k256_keccak_library(),
34            vec![StorageSlot::Value(ecdsa.pub_key.into())],
35        )
36        .expect("ecdsa component should satisfy the requirements of a valid account component")
37        .with_supports_all_types()
38    }
39}