diff --git a/Cargo.lock b/Cargo.lock index 402c1541f..5119d2ae6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1537,6 +1537,15 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8591b0bcc8a98a64310a2fae1bb3e9b8564dd10e381e6e28010fde8e8e8568db" +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "static_assertions", +] + [[package]] name = "fixedbitset" version = "0.5.7" @@ -2074,7 +2083,7 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2 0.6.2", + "socket2 0.5.10", "system-configuration", "tokio", "tower-service", @@ -2620,7 +2629,7 @@ checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "miden-agglayer" version = "0.14.0" -source = "git+https://github.com/0xMiden/miden-base?branch=next#0904e2c610ab49bf6ee13cf349c05c8621f23cd2" +source = "git+https://github.com/0xMiden/miden-base?branch=next#3154a371939125e5cc3faf39a7c42447db67584f" dependencies = [ "fs-err", "miden-assembly", @@ -2630,7 +2639,9 @@ dependencies = [ "miden-protocol", "miden-standards", "miden-utils-sync", + "primitive-types", "regex", + "thiserror 2.0.18", "walkdir", ] @@ -2689,7 +2700,7 @@ dependencies = [ [[package]] name = "miden-block-prover" version = "0.14.0" -source = "git+https://github.com/0xMiden/miden-base?branch=next#0904e2c610ab49bf6ee13cf349c05c8621f23cd2" +source = "git+https://github.com/0xMiden/miden-base?branch=next#3154a371939125e5cc3faf39a7c42447db67584f" dependencies = [ "miden-protocol", "thiserror 2.0.18", @@ -3224,7 +3235,7 @@ dependencies = [ [[package]] name = "miden-protocol" version = "0.14.0" -source = "git+https://github.com/0xMiden/miden-base?branch=next#0904e2c610ab49bf6ee13cf349c05c8621f23cd2" +source = "git+https://github.com/0xMiden/miden-base?branch=next#3154a371939125e5cc3faf39a7c42447db67584f" dependencies = [ "bech32", "fs-err", @@ -3254,7 +3265,7 @@ dependencies = [ [[package]] name = "miden-protocol-macros" version = "0.14.0" -source = "git+https://github.com/0xMiden/miden-base?branch=next#0904e2c610ab49bf6ee13cf349c05c8621f23cd2" +source = "git+https://github.com/0xMiden/miden-base?branch=next#3154a371939125e5cc3faf39a7c42447db67584f" dependencies = [ "proc-macro2", "quote", @@ -3336,7 +3347,7 @@ dependencies = [ [[package]] name = "miden-standards" version = "0.14.0" -source = "git+https://github.com/0xMiden/miden-base?branch=next#0904e2c610ab49bf6ee13cf349c05c8621f23cd2" +source = "git+https://github.com/0xMiden/miden-base?branch=next#3154a371939125e5cc3faf39a7c42447db67584f" dependencies = [ "fs-err", "miden-assembly", @@ -3353,7 +3364,7 @@ dependencies = [ [[package]] name = "miden-testing" version = "0.14.0" -source = "git+https://github.com/0xMiden/miden-base?branch=next#0904e2c610ab49bf6ee13cf349c05c8621f23cd2" +source = "git+https://github.com/0xMiden/miden-base?branch=next#3154a371939125e5cc3faf39a7c42447db67584f" dependencies = [ "anyhow", "itertools 0.14.0", @@ -3376,7 +3387,7 @@ dependencies = [ [[package]] name = "miden-tx" version = "0.14.0" -source = "git+https://github.com/0xMiden/miden-base?branch=next#0904e2c610ab49bf6ee13cf349c05c8621f23cd2" +source = "git+https://github.com/0xMiden/miden-base?branch=next#3154a371939125e5cc3faf39a7c42447db67584f" dependencies = [ "miden-processor", "miden-protocol", @@ -3389,7 +3400,7 @@ dependencies = [ [[package]] name = "miden-tx-batch-prover" version = "0.14.0" -source = "git+https://github.com/0xMiden/miden-base?branch=next#0904e2c610ab49bf6ee13cf349c05c8621f23cd2" +source = "git+https://github.com/0xMiden/miden-base?branch=next#3154a371939125e5cc3faf39a7c42447db67584f" dependencies = [ "miden-protocol", "miden-tx", @@ -4014,6 +4025,16 @@ dependencies = [ "syn 2.0.114", ] +[[package]] +name = "primitive-types" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721a1da530b5a2633218dc9f75713394c983c352be88d2d7c9ee85e2c4c21794" +dependencies = [ + "fixed-hash", + "uint", +] + [[package]] name = "proc-macro-crate" version = "3.4.0" @@ -4194,7 +4215,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls 0.23.36", - "socket2 0.6.2", + "socket2 0.5.10", "thiserror 2.0.18", "tokio", "tracing", @@ -4232,7 +4253,7 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.6.2", + "socket2 0.5.10", "tracing", "windows-sys 0.60.2", ] @@ -4541,7 +4562,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -5035,6 +5056,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "string_cache" version = "0.8.9" @@ -5812,6 +5839,18 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +[[package]] +name = "uint" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unarray" version = "0.1.4" @@ -6259,15 +6298,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-sys" version = "0.60.2" diff --git a/bin/network-monitor/src/deploy/wallet.rs b/bin/network-monitor/src/deploy/wallet.rs index de687ab6d..ba074a60f 100644 --- a/bin/network-monitor/src/deploy/wallet.rs +++ b/bin/network-monitor/src/deploy/wallet.rs @@ -4,10 +4,10 @@ use std::path::Path; use anyhow::Result; use miden_node_utils::crypto::get_rpo_random_coin; -use miden_protocol::account::auth::AuthSecretKey; +use miden_protocol::account::auth::{AuthScheme, AuthSecretKey}; use miden_protocol::account::{Account, AccountFile, AccountStorageMode, AccountType}; use miden_protocol::crypto::dsa::falcon512_rpo::SecretKey; -use miden_standards::AuthScheme; +use miden_standards::AuthMethod; use miden_standards::account::wallets::create_basic_wallet; use rand::{Rng, SeedableRng}; use rand_chacha::ChaCha20Rng; @@ -22,7 +22,9 @@ use crate::COMPONENT; pub fn create_wallet_account() -> Result<(Account, SecretKey)> { let mut rng = ChaCha20Rng::from_seed(rand::random()); let secret_key = SecretKey::with_rng(&mut get_rpo_random_coin(&mut rng)); - let auth = AuthScheme::Falcon512Rpo { pub_key: secret_key.public_key().into() }; + let auth = AuthMethod::SingleSig { + approver: (secret_key.public_key().into(), AuthScheme::Falcon512Rpo), + }; let init_seed: [u8; 32] = rng.random(); let wallet_account = create_basic_wallet( diff --git a/bin/network-monitor/src/remote_prover.rs b/bin/network-monitor/src/remote_prover.rs index 791315d3b..b103a60c4 100644 --- a/bin/network-monitor/src/remote_prover.rs +++ b/bin/network-monitor/src/remote_prover.rs @@ -8,6 +8,7 @@ use std::time::Duration; use anyhow::Context; use miden_node_proto::clients::{Builder as ClientBuilder, RemoteProverClient}; use miden_node_proto::generated as proto; +use miden_protocol::account::auth::AuthScheme; use miden_protocol::asset::{Asset, FungibleAsset}; use miden_protocol::note::NoteType; use miden_protocol::testing::account_id::{ACCOUNT_ID_PUBLIC_FUNGIBLE_FAUCET, ACCOUNT_ID_SENDER}; @@ -277,7 +278,7 @@ pub async fn generate_mock_transaction() -> anyhow::Result { // Create an account with basic authentication let account = mock_chain_builder - .add_existing_wallet(Auth::BasicAuth) + .add_existing_wallet(Auth::BasicAuth { auth_scheme: AuthScheme::Falcon512Rpo }) .context("Failed to add wallet to mock chain")?; // Create a fungible asset diff --git a/bin/remote-prover/src/server/tests.rs b/bin/remote-prover/src/server/tests.rs index 46bea96e7..d51b5c1da 100644 --- a/bin/remote-prover/src/server/tests.rs +++ b/bin/remote-prover/src/server/tests.rs @@ -5,6 +5,7 @@ use std::time::Duration; use assert_matches::assert_matches; use miden_protocol::MIN_PROOF_SECURITY_LEVEL; +use miden_protocol::account::auth::AuthScheme; use miden_protocol::asset::{Asset, FungibleAsset}; use miden_protocol::batch::{ProposedBatch, ProvenBatch}; use miden_protocol::note::NoteType; @@ -61,7 +62,9 @@ impl ProofRequest { async fn mock_tx() -> ExecutedTransaction { // Create a mock transaction to send to the server let mut mock_chain_builder = MockChainBuilder::new(); - let account = mock_chain_builder.add_existing_wallet(Auth::BasicAuth).unwrap(); + let account = mock_chain_builder + .add_existing_wallet(Auth::BasicAuth { auth_scheme: AuthScheme::Falcon512Rpo }) + .unwrap(); let fungible_asset_1: Asset = FungibleAsset::new(ACCOUNT_ID_PUBLIC_FUNGIBLE_FAUCET.try_into().unwrap(), 100) @@ -91,7 +94,9 @@ impl ProofRequest { async fn mock_batch() -> ProposedBatch { // Create a mock transaction to send to the server let mut mock_chain_builder = MockChainBuilder::new(); - let account = mock_chain_builder.add_existing_wallet(Auth::BasicAuth).unwrap(); + let account = mock_chain_builder + .add_existing_wallet(Auth::BasicAuth { auth_scheme: AuthScheme::Falcon512Rpo }) + .unwrap(); let fungible_asset_1: Asset = FungibleAsset::new(ACCOUNT_ID_PUBLIC_FUNGIBLE_FAUCET.try_into().unwrap(), 100) diff --git a/bin/stress-test/src/seeding/mod.rs b/bin/stress-test/src/seeding/mod.rs index 70cbf04fd..777ac993e 100644 --- a/bin/stress-test/src/seeding/mod.rs +++ b/bin/stress-test/src/seeding/mod.rs @@ -10,6 +10,7 @@ use miden_node_proto::domain::batch::BatchInputs; use miden_node_proto::generated::store::rpc_client::RpcClient; use miden_node_store::{DataDirectory, GenesisState, Store}; use miden_node_utils::tracing::grpc::OtelInterceptor; +use miden_protocol::account::auth::AuthScheme; use miden_protocol::account::delta::AccountUpdateDetails; use miden_protocol::account::{ Account, @@ -46,7 +47,7 @@ use miden_protocol::transaction::{ }; use miden_protocol::utils::Serializable; use miden_protocol::{Felt, ONE, Word}; -use miden_standards::account::auth::AuthFalcon512Rpo; +use miden_standards::account::auth::AuthSingleSig; use miden_standards::account::faucets::BasicFungibleFaucet; use miden_standards::account::wallets::BasicWallet; use miden_standards::note::P2idNote; @@ -325,7 +326,7 @@ fn create_account(public_key: PublicKey, index: u64, storage_mode: AccountStorag AccountBuilder::new(init_seed.try_into().unwrap()) .account_type(AccountType::RegularAccountImmutableCode) .storage_mode(storage_mode) - .with_auth_component(AuthFalcon512Rpo::new(public_key.into())) + .with_auth_component(AuthSingleSig::new(public_key.into(), AuthScheme::Falcon512Rpo)) .with_component(BasicWallet) .build() .unwrap() @@ -343,7 +344,10 @@ fn create_faucet() -> Account { .account_type(AccountType::FungibleFaucet) .storage_mode(AccountStorageMode::Private) .with_component(BasicFungibleFaucet::new(token_symbol, 2, Felt::new(u64::MAX)).unwrap()) - .with_auth_component(AuthFalcon512Rpo::new(key_pair.public_key().into())) + .with_auth_component(AuthSingleSig::new( + key_pair.public_key().into(), + AuthScheme::Falcon512Rpo, + )) .build() .unwrap() } diff --git a/crates/ntx-builder/src/db/models/queries/tests.rs b/crates/ntx-builder/src/db/models/queries/tests.rs index 7bd9b2cfe..2b558a49d 100644 --- a/crates/ntx-builder/src/db/models/queries/tests.rs +++ b/crates/ntx-builder/src/db/models/queries/tests.rs @@ -540,9 +540,9 @@ fn note_script_insert_is_idempotent() { /// /// Uses `AccountBuilder` with minimal components needed for serialization. fn mock_account(_account_id: NetworkAccountId) -> miden_protocol::account::Account { - use miden_protocol::account::auth::PublicKeyCommitment; + use miden_protocol::account::auth::{AuthScheme, PublicKeyCommitment}; use miden_protocol::account::{AccountBuilder, AccountComponent}; - use miden_standards::account::auth::AuthFalcon512Rpo; + use miden_standards::account::auth::AuthSingleSig; let component_code = miden_standards::code_builder::CodeBuilder::default() .compile_component_code("test::interface", "pub proc test_proc push.1.2 add end") @@ -559,7 +559,10 @@ fn mock_account(_account_id: NetworkAccountId) -> miden_protocol::account::Accou .account_type(AccountType::RegularAccountImmutableCode) .storage_mode(AccountStorageMode::Network) .with_component(component) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(Word::default()))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(Word::default()), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap() } diff --git a/crates/store/Cargo.toml b/crates/store/Cargo.toml index f9be6de10..17dcf9619 100644 --- a/crates/store/Cargo.toml +++ b/crates/store/Cargo.toml @@ -55,6 +55,7 @@ fs-err = { workspace = true } miden-agglayer = { branch = "next", features = ["testing"], git = "https://github.com/0xMiden/miden-base" } miden-node-rocksdb-cxx-linkage-fix = { workspace = true } miden-protocol = { features = ["std"], workspace = true } +miden-standards = { workspace = true } [dev-dependencies] assert_matches = { workspace = true } diff --git a/crates/store/build.rs b/crates/store/build.rs index f7ba0825c..c03975760 100644 --- a/crates/store/build.rs +++ b/crates/store/build.rs @@ -4,9 +4,18 @@ use std::path::PathBuf; use std::sync::Arc; -use miden_agglayer::{create_existing_agglayer_faucet, create_existing_bridge_account}; -use miden_protocol::account::{Account, AccountCode, AccountFile}; +use miden_agglayer::{ + EthAddressFormat, + create_existing_agglayer_faucet, + create_existing_bridge_account, +}; +use miden_protocol::account::auth::AuthScheme; +use miden_protocol::account::{Account, AccountCode, AccountFile, AccountStorageMode, AccountType}; +use miden_protocol::crypto::dsa::falcon512_rpo::SecretKey; +use miden_protocol::crypto::rand::RpoRandomCoin; use miden_protocol::{Felt, Word}; +use miden_standards::AuthMethod; +use miden_standards::account::wallets::create_basic_wallet; fn main() { build_rs::output::rerun_if_changed("src/db/migrations"); @@ -35,25 +44,65 @@ fn generate_agglayer_sample_accounts() { // Create the directory if it doesn't exist fs_err::create_dir_all(&samples_dir).expect("Failed to create samples directory"); - // Use deterministic seeds for reproducible builds - // WARNING: DO NOT USE THIS IN PRODUCTION + // Use deterministic seeds for reproducible builds. + // WARNING: DO NOT USE THESE IN PRODUCTION let bridge_seed: Word = Word::new([Felt::new(1u64); 4]); let eth_faucet_seed: Word = Word::new([Felt::new(2u64); 4]); let usdc_faucet_seed: Word = Word::new([Felt::new(3u64); 4]); + // Create bridge admin and GER manager as proper wallet accounts. + // WARNING: DO NOT USE THESE IN PRODUCTION + let bridge_admin_key = + SecretKey::with_rng(&mut RpoRandomCoin::new(Word::new([Felt::new(4u64); 4]))); + let ger_manager_key = + SecretKey::with_rng(&mut RpoRandomCoin::new(Word::new([Felt::new(5u64); 4]))); + + let bridge_admin = create_basic_wallet( + [4u8; 32], + AuthMethod::SingleSig { + approver: (bridge_admin_key.public_key().into(), AuthScheme::Falcon512Rpo), + }, + AccountType::RegularAccountImmutableCode, + AccountStorageMode::Public, + ) + .expect("bridge admin account should be valid"); + + let ger_manager = create_basic_wallet( + [5u8; 32], + AuthMethod::SingleSig { + approver: (ger_manager_key.public_key().into(), AuthScheme::Falcon512Rpo), + }, + AccountType::RegularAccountImmutableCode, + AccountStorageMode::Public, + ) + .expect("GER manager account should be valid"); + + let bridge_admin_id = bridge_admin.id(); + let ger_manager_id = ger_manager.id(); + // Create the bridge account first (faucets need to reference it) // Use "existing" variant so accounts have nonce > 0 (required for genesis) - let bridge_account = create_existing_bridge_account(bridge_seed); + let bridge_account = + create_existing_bridge_account(bridge_seed, bridge_admin_id, ger_manager_id); let bridge_account_id = bridge_account.id(); + // Placeholder Ethereum addresses for sample faucets. + // WARNING: DO NOT USE THESE ADDRESSES IN PRODUCTION + let eth_origin_address = EthAddressFormat::new([1u8; 20]); + let usdc_origin_address = EthAddressFormat::new([2u8; 20]); + // Create AggLayer faucets using "existing" variant - // ETH: 18 decimals, max supply of 1 billion tokens + // ETH: 8 decimals (protocol max is 12), max supply of 1 billion tokens let eth_faucet = create_existing_agglayer_faucet( eth_faucet_seed, "ETH", - 18, + 8, Felt::new(1_000_000_000), + Felt::new(0), bridge_account_id, + ð_origin_address, + 0u32, + 10u8, ); // USDC: 6 decimals, max supply of 10 billion tokens @@ -62,7 +111,11 @@ fn generate_agglayer_sample_accounts() { "USDC", 6, Felt::new(10_000_000_000), + Felt::new(0), bridge_account_id, + &usdc_origin_address, + 0u32, + 10u8, ); // Strip source location decorators from account code to ensure deterministic output. diff --git a/crates/store/src/db/models/queries/accounts/tests.rs b/crates/store/src/db/models/queries/accounts/tests.rs index e9f529855..0065a1e2c 100644 --- a/crates/store/src/db/models/queries/accounts/tests.rs +++ b/crates/store/src/db/models/queries/accounts/tests.rs @@ -13,7 +13,7 @@ use diesel::{ }; use diesel_migrations::MigrationHarness; use miden_node_utils::fee::test_fee_params; -use miden_protocol::account::auth::PublicKeyCommitment; +use miden_protocol::account::auth::{AuthScheme, PublicKeyCommitment}; use miden_protocol::account::component::AccountComponentMetadata; use miden_protocol::account::delta::AccountUpdateDetails; use miden_protocol::account::{ @@ -36,7 +36,7 @@ use miden_protocol::block::{BlockAccountUpdate, BlockHeader, BlockNumber}; use miden_protocol::crypto::dsa::ecdsa_k256_keccak::SecretKey; use miden_protocol::utils::{Deserializable, Serializable}; use miden_protocol::{EMPTY_WORD, Felt, Word}; -use miden_standards::account::auth::AuthFalcon512Rpo; +use miden_standards::account::auth::AuthSingleSig; use miden_standards::code_builder::CodeBuilder; use super::*; @@ -156,7 +156,10 @@ fn create_test_account_with_storage() -> (Account, AccountId) { .account_type(AccountType::RegularAccountImmutableCode) .storage_mode(AccountStorageMode::Public) .with_component(component) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); @@ -423,7 +426,10 @@ fn test_upsert_accounts_updates_is_latest_flag() { .account_type(AccountType::RegularAccountImmutableCode) .storage_mode(AccountStorageMode::Public) .with_component(component_2) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); @@ -520,7 +526,10 @@ fn test_upsert_accounts_with_multiple_storage_slots() { .account_type(AccountType::RegularAccountImmutableCode) .storage_mode(AccountStorageMode::Public) .with_component(component) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); @@ -547,11 +556,12 @@ fn test_upsert_accounts_with_multiple_storage_slots() { "Storage commitment mismatch" ); - // Note: Auth component adds 1 storage slot, so 3 component slots + 1 auth = 4 total + // Note: AuthSingleSig adds 2 storage slots (pub key + scheme id), so 3 component slots + 2 auth + // = 5 total assert_eq!( queried_storage.slots().len(), - 4, - "Expected 4 storage slots (3 component + 1 auth)" + 5, + "Expected 5 storage slots (3 component + 2 auth)" ); // The storage commitment matching proves that all values are correctly preserved. @@ -586,7 +596,10 @@ fn test_upsert_accounts_with_empty_storage() { .account_type(AccountType::RegularAccountImmutableCode) .storage_mode(AccountStorageMode::Public) .with_component(component) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); @@ -613,8 +626,8 @@ fn test_upsert_accounts_with_empty_storage() { "Storage commitment mismatch for empty storage" ); - // Note: Auth component adds 1 storage slot, so even "empty" accounts have 1 slot - assert_eq!(queried_storage.slots().len(), 1, "Expected 1 storage slot (auth component)"); + // Note: AuthSingleSig adds 2 storage slots (pub key + scheme id) + assert_eq!(queried_storage.slots().len(), 2, "Expected 2 storage slots (auth component)"); // Verify the storage header blob exists in database let storage_header_exists: Option = SelectDsl::select( diff --git a/crates/store/src/db/tests.rs b/crates/store/src/db/tests.rs index 7bc633f95..679186079 100644 --- a/crates/store/src/db/tests.rs +++ b/crates/store/src/db/tests.rs @@ -4,7 +4,7 @@ use std::sync::{Arc, Mutex}; use diesel::{Connection, SqliteConnection}; use miden_node_proto::domain::account::AccountSummary; use miden_node_utils::fee::{test_fee, test_fee_params}; -use miden_protocol::account::auth::PublicKeyCommitment; +use miden_protocol::account::auth::{AuthScheme, PublicKeyCommitment}; use miden_protocol::account::component::AccountComponentMetadata; use miden_protocol::account::delta::AccountUpdateDetails; use miden_protocol::account::{ @@ -62,7 +62,7 @@ use miden_protocol::transaction::{ }; use miden_protocol::utils::{Deserializable, Serializable}; use miden_protocol::{EMPTY_WORD, Felt, FieldElement, Word}; -use miden_standards::account::auth::AuthFalcon512Rpo; +use miden_standards::account::auth::AuthSingleSig; use miden_standards::code_builder::CodeBuilder; use miden_standards::note::{NetworkAccountTarget, NoteExecutionHint, P2idNote}; use pretty_assertions::assert_eq; @@ -1148,7 +1148,10 @@ fn create_account_with_code(code_str: &str, seed: [u8; 32]) -> Account { .account_type(AccountType::RegularAccountUpdatableCode) .storage_mode(AccountStorageMode::Public) .with_component(component) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap() } @@ -1246,7 +1249,10 @@ fn mock_account_code_and_storage( .storage_mode(storage_mode) .with_assets(assets) .with_component(account_component) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap() } @@ -1410,7 +1416,10 @@ async fn genesis_with_account_assets() { .storage_mode(AccountStorageMode::Public) .with_component(account_component) .with_assets([fungible_asset.into()]) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); @@ -1462,7 +1471,10 @@ async fn genesis_with_account_storage_map() { .account_type(AccountType::RegularAccountImmutableCode) .storage_mode(AccountStorageMode::Public) .with_component(account_component) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); @@ -1512,7 +1524,10 @@ async fn genesis_with_account_assets_and_storage() { .storage_mode(AccountStorageMode::Public) .with_component(account_component) .with_assets([fungible_asset.into()]) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); @@ -1546,7 +1561,10 @@ async fn genesis_with_multiple_accounts() { .account_type(AccountType::RegularAccountImmutableCode) .storage_mode(AccountStorageMode::Public) .with_component(account_component1) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); @@ -1568,7 +1586,10 @@ async fn genesis_with_multiple_accounts() { .storage_mode(AccountStorageMode::Public) .with_component(account_component2) .with_assets([fungible_asset.into()]) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); @@ -1594,7 +1615,10 @@ async fn genesis_with_multiple_accounts() { .account_type(AccountType::RegularAccountUpdatableCode) .storage_mode(AccountStorageMode::Public) .with_component(account_component3) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); @@ -2058,7 +2082,10 @@ fn db_roundtrip_account_storage_with_maps() { .account_type(AccountType::RegularAccountUpdatableCode) .storage_mode(AccountStorageMode::Public) .with_component(account_component) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap(); diff --git a/crates/store/src/genesis/config/mod.rs b/crates/store/src/genesis/config/mod.rs index ae071c175..f2cfe40b8 100644 --- a/crates/store/src/genesis/config/mod.rs +++ b/crates/store/src/genesis/config/mod.rs @@ -7,7 +7,7 @@ use std::str::FromStr; use indexmap::IndexMap; use miden_node_utils::crypto::get_rpo_random_coin; use miden_node_utils::signer::BlockSigner; -use miden_protocol::account::auth::AuthSecretKey; +use miden_protocol::account::auth::{AuthScheme, AuthSecretKey}; use miden_protocol::account::{ Account, AccountBuilder, @@ -26,8 +26,8 @@ use miden_protocol::block::FeeParameters; use miden_protocol::crypto::dsa::falcon512_rpo::SecretKey as RpoSecretKey; use miden_protocol::errors::TokenSymbolError; use miden_protocol::{Felt, FieldElement, ONE}; -use miden_standards::AuthScheme; -use miden_standards::account::auth::AuthFalcon512Rpo; +use miden_standards::AuthMethod; +use miden_standards::account::auth::AuthSingleSig; use miden_standards::account::faucets::{BasicFungibleFaucet, TokenMetadata}; use miden_standards::account::wallets::create_basic_wallet; use rand::distr::weighted::Weight; @@ -221,7 +221,9 @@ impl GenesisConfig { let mut rng = ChaCha20Rng::from_seed(rand::random()); let secret_key = RpoSecretKey::with_rng(&mut get_rpo_random_coin(&mut rng)); - let auth = AuthScheme::Falcon512Rpo { pub_key: secret_key.public_key().into() }; + let auth = AuthMethod::SingleSig { + approver: (secret_key.public_key().into(), AuthScheme::Falcon512Rpo), + }; let init_seed: [u8; 32] = rng.random(); let account_type = if has_updatable_code { @@ -429,7 +431,7 @@ impl FungibleFaucetConfig { } = self; let mut rng = ChaCha20Rng::from_seed(rand::random()); let secret_key = RpoSecretKey::with_rng(&mut get_rpo_random_coin(&mut rng)); - let auth = AuthFalcon512Rpo::new(secret_key.public_key().into()); + let auth = AuthSingleSig::new(secret_key.public_key().into(), AuthScheme::Falcon512Rpo); let init_seed: [u8; 32] = rng.random(); let max_supply = Felt::try_from(max_supply) diff --git a/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_eth.mac b/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_eth.mac index 6bd49fefd..b76116b57 100644 Binary files a/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_eth.mac and b/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_eth.mac differ diff --git a/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_usdc.mac b/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_usdc.mac index fcd0e4f9b..8e0c2650b 100644 Binary files a/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_usdc.mac and b/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_usdc.mac differ diff --git a/crates/store/src/genesis/config/samples/02-with-account-files/bridge.mac b/crates/store/src/genesis/config/samples/02-with-account-files/bridge.mac index bf7a8dea2..9bab86857 100644 Binary files a/crates/store/src/genesis/config/samples/02-with-account-files/bridge.mac and b/crates/store/src/genesis/config/samples/02-with-account-files/bridge.mac differ diff --git a/crates/store/src/genesis/config/tests.rs b/crates/store/src/genesis/config/tests.rs index 0a36bc788..ebcb61e8e 100644 --- a/crates/store/src/genesis/config/tests.rs +++ b/crates/store/src/genesis/config/tests.rs @@ -82,8 +82,9 @@ async fn genesis_accounts_have_nonce_one() -> TestResult { #[test] fn parsing_account_from_file() -> TestResult { + use miden_protocol::account::auth::AuthScheme; use miden_protocol::account::{AccountFile, AccountStorageMode, AccountType}; - use miden_standards::AuthScheme; + use miden_standards::AuthMethod; use miden_standards::account::wallets::create_basic_wallet; use tempfile::tempdir; @@ -97,7 +98,9 @@ fn parsing_account_from_file() -> TestResult { let secret_key = miden_protocol::crypto::dsa::falcon512_rpo::SecretKey::with_rng( &mut miden_node_utils::crypto::get_rpo_random_coin(&mut rng), ); - let auth = AuthScheme::Falcon512Rpo { pub_key: secret_key.public_key().into() }; + let auth = AuthMethod::SingleSig { + approver: (secret_key.public_key().into(), AuthScheme::Falcon512Rpo), + }; let test_account = create_basic_wallet( init_seed, @@ -138,8 +141,9 @@ path = "test_account.mac" #[test] fn parsing_native_faucet_from_file() -> TestResult { + use miden_protocol::account::auth::AuthScheme; use miden_protocol::account::{AccountBuilder, AccountFile, AccountStorageMode, AccountType}; - use miden_standards::account::auth::AuthFalcon512Rpo; + use miden_standards::account::auth::AuthSingleSig; use tempfile::tempdir; // Create a temporary directory for our test files @@ -152,7 +156,7 @@ fn parsing_native_faucet_from_file() -> TestResult { let secret_key = miden_protocol::crypto::dsa::falcon512_rpo::SecretKey::with_rng( &mut miden_node_utils::crypto::get_rpo_random_coin(&mut rng), ); - let auth = AuthFalcon512Rpo::new(secret_key.public_key().into()); + let auth = AuthSingleSig::new(secret_key.public_key().into(), AuthScheme::Falcon512Rpo); let faucet_component = BasicFungibleFaucet::new(TokenSymbol::new("MIDEN").unwrap(), 6, Felt::new(1_000_000_000))?; @@ -198,8 +202,9 @@ verification_base_fee = 0 #[test] fn native_faucet_from_file_must_be_faucet_type() -> TestResult { + use miden_protocol::account::auth::AuthScheme; use miden_protocol::account::{AccountFile, AccountStorageMode, AccountType}; - use miden_standards::AuthScheme; + use miden_standards::AuthMethod; use miden_standards::account::wallets::create_basic_wallet; use tempfile::tempdir; @@ -213,7 +218,9 @@ fn native_faucet_from_file_must_be_faucet_type() -> TestResult { let secret_key = miden_protocol::crypto::dsa::falcon512_rpo::SecretKey::with_rng( &mut miden_node_utils::crypto::get_rpo_random_coin(&mut rng), ); - let auth = AuthScheme::Falcon512Rpo { pub_key: secret_key.public_key().into() }; + let auth = AuthMethod::SingleSig { + approver: (secret_key.public_key().into(), AuthScheme::Falcon512Rpo), + }; let regular_account = create_basic_wallet( init_seed, diff --git a/crates/store/src/inner_forest/tests.rs b/crates/store/src/inner_forest/tests.rs index 9e90bfa29..79bdbd0c8 100644 --- a/crates/store/src/inner_forest/tests.rs +++ b/crates/store/src/inner_forest/tests.rs @@ -447,7 +447,7 @@ fn test_storage_map_incremental_updates() { #[test] fn test_empty_storage_map_entries_query() { - use miden_protocol::account::auth::PublicKeyCommitment; + use miden_protocol::account::auth::{AuthScheme, PublicKeyCommitment}; use miden_protocol::account::component::AccountComponentMetadata; use miden_protocol::account::{ AccountBuilder, @@ -457,7 +457,7 @@ fn test_empty_storage_map_entries_query() { StorageMap, StorageSlot, }; - use miden_standards::account::auth::AuthFalcon512Rpo; + use miden_standards::account::auth::AuthSingleSig; use miden_standards::code_builder::CodeBuilder; let mut forest = InnerForest::new(); @@ -482,7 +482,10 @@ fn test_empty_storage_map_entries_query() { .account_type(AccountType::RegularAccountImmutableCode) .storage_mode(AccountStorageMode::Public) .with_component(account_component) - .with_auth_component(AuthFalcon512Rpo::new(PublicKeyCommitment::from(EMPTY_WORD))) + .with_auth_component(AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Rpo, + )) .build_existing() .unwrap();