diff --git a/Cargo.lock b/Cargo.lock index 4fb0418e52..e23daa5ecc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1396,7 +1396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2 1.0.66", - "quote 1.0.32", + "quote 1.0.33", "syn 2.0.28", ] @@ -1521,6 +1521,7 @@ dependencies = [ "borsh", "clap", "const-rollup-config", + "demo-stf", "hex", "jsonrpsee 0.18.2", "rand 0.8.5", @@ -6763,6 +6764,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.7", + "sov-modules-api", "sov-modules-macros", "sov-rollup-interface", "sov-state", diff --git a/examples/demo-prover/Cargo.lock b/examples/demo-prover/Cargo.lock index 31390ad55a..ea7ec34dfc 100644 --- a/examples/demo-prover/Cargo.lock +++ b/examples/demo-prover/Cargo.lock @@ -751,7 +751,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] diff --git a/examples/demo-prover/methods/guest/Cargo.lock b/examples/demo-prover/methods/guest/Cargo.lock index 855d6f4f76..1e35fa11c8 100644 --- a/examples/demo-prover/methods/guest/Cargo.lock +++ b/examples/demo-prover/methods/guest/Cargo.lock @@ -394,15 +394,29 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.2.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "f711ade317dd348950a9910f81c5947e3d8907ebd2b83f76203ff1807e6a2bc2" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "platforms", + "rustc_version", "subtle", - "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", ] [[package]] @@ -413,7 +427,7 @@ checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" dependencies = [ "byteorder", "digest 0.9.0", - "rand_core 0.6.4", + "rand_core", "subtle-ng", "zeroize", ] @@ -548,15 +562,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ed25519" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" -dependencies = [ - "signature 1.6.4", -] - [[package]] name = "ed25519" version = "2.2.1" @@ -564,7 +569,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fb04eee5d9d907f29e80ee6b0e78f7e2c82342c63e3580d8c4f69d9d5aad963" dependencies = [ "pkcs8", - "signature 2.1.0", + "signature", ] [[package]] @@ -575,21 +580,20 @@ checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" dependencies = [ "curve25519-dalek-ng", "hex", - "rand_core 0.6.4", + "rand_core", "sha2 0.9.9", "zeroize", ] [[package]] name = "ed25519-dalek" -version = "1.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" dependencies = [ "curve25519-dalek", - "ed25519 1.5.3", - "sha2 0.9.9", - "zeroize", + "ed25519", + "sha2 0.10.6", ] [[package]] @@ -653,6 +657,12 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +[[package]] +name = "fiat-crypto" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" + [[package]] name = "fixedbitset" version = "0.4.2" @@ -1315,7 +1325,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" dependencies = [ "base64ct", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -1391,6 +1401,12 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "platforms" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1496,7 +1512,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1506,15 +1522,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" - [[package]] name = "rand_core" version = "0.6.4" @@ -1663,7 +1673,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ea0e9d6d5845f11157728c494541c42559357fee35afce767b3d3610ef7494b" dependencies = [ "bytemuck", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1679,7 +1689,7 @@ dependencies = [ "hex", "log", "paste", - "rand_core 0.6.4", + "rand_core", "risc0-core", "risc0-zkvm-platform", "serde", @@ -1934,12 +1944,6 @@ dependencies = [ "keccak", ] -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" - [[package]] name = "signature" version = "2.1.0" @@ -2247,7 +2251,7 @@ checksum = "3f0a7d05cf78524782337f8edd55cbc578d159a16ad4affe2135c92f7dbac7f0" dependencies = [ "bytes", "digest 0.10.7", - "ed25519 2.2.1", + "ed25519", "ed25519-consensus", "flex-error", "futures", @@ -2260,7 +2264,7 @@ dependencies = [ "serde_json", "serde_repr", "sha2 0.10.6", - "signature 2.1.0", + "signature", "subtle", "subtle-encoding", "tendermint-proto", diff --git a/examples/demo-stf/Cargo.toml b/examples/demo-stf/Cargo.toml index 629e45b6e5..2436a284c7 100644 --- a/examples/demo-stf/Cargo.toml +++ b/examples/demo-stf/Cargo.toml @@ -45,6 +45,7 @@ sov-evm = { path = "../../module-system/module-implementations/sov-evm", optiona [dev-dependencies] sov-rollup-interface = { path = "../../rollup-interface", features = ["mocks"] } sov-data-generators = { path = "../../module-system/utils/sov-data-generators" } +demo-stf = { path = ".", features = ["native"] } tempfile = { workspace = true } rand = "0.8" diff --git a/examples/demo-stf/src/sov-cli/native.rs b/examples/demo-stf/src/sov-cli/native.rs index 630c70942d..df8c7529ec 100644 --- a/examples/demo-stf/src/sov-cli/native.rs +++ b/examples/demo-stf/src/sov-cli/native.rs @@ -1,7 +1,7 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::{Path, PathBuf}; -use std::{fs, vec}; +use std::vec; use anyhow::Context; use borsh::BorshSerialize; @@ -136,9 +136,9 @@ impl PrivKeyAndAddress { fn generate_and_save_to_file(priv_key_path: &Path) -> anyhow::Result<()> { let priv_key = Self::generate(); let data = serde_json::to_string(&priv_key)?; - fs::create_dir_all(priv_key_path)?; + std::fs::create_dir_all(priv_key_path)?; let path = Path::new(priv_key_path).join(format!("{}.json", priv_key.address)); - fs::write(&path, data)?; + std::fs::write(&path, data)?; println!( "private key written to path: {}", path.into_os_string().into_string().unwrap() @@ -180,6 +180,7 @@ impl SerializedTx { let sender_priv_key_data = serde_json::from_str::(&priv_key_data)?; + println!("HA: {}", &sender_priv_key_data.hex_priv_key); Ok(DefaultPrivateKey::from_hex( &sender_priv_key_data.hex_priv_key, )?) diff --git a/module-system/sov-modules-api/Cargo.toml b/module-system/sov-modules-api/Cargo.toml index 803af0d909..d6cb7ce5a9 100644 --- a/module-system/sov-modules-api/Cargo.toml +++ b/module-system/sov-modules-api/Cargo.toml @@ -37,6 +37,7 @@ risc0-zkvm-platform = { version = "0.16", optional = true } [dev-dependencies] bincode = { workspace = true } +sov-modules-api = { path = "../sov-modules-api", version = "0.1" } [features] bench = ["zk-cycle-macros", "risc0-zkvm", "risc0-zkvm-platform"] diff --git a/module-system/sov-modules-api/src/default_signature.rs b/module-system/sov-modules-api/src/default_signature.rs index 4b5516ecd2..f58c9e26d0 100644 --- a/module-system/sov-modules-api/src/default_signature.rs +++ b/module-system/sov-modules-api/src/default_signature.rs @@ -2,8 +2,6 @@ use std::str::FromStr; use borsh::{BorshDeserialize, BorshSerialize}; -use ed25519_dalek::ed25519::SignatureBytes; -// use ed25519_dalek::{ Signature as DalekSignature, VerifyingKey as DalekPublicKey, PUBLIC_KEY_LENGTH, }; @@ -12,8 +10,7 @@ use crate::{SigVerificationError, Signature}; #[cfg(feature = "native")] pub mod private_key { - - use ed25519_dalek::{SecretKey, Signer, SigningKey, SECRET_KEY_LENGTH}; + use ed25519_dalek::{Signer, SigningKey, KEYPAIR_LENGTH}; use rand::rngs::OsRng; use thiserror::Error; @@ -48,15 +45,16 @@ pub mod private_key { type Error = anyhow::Error; fn try_from(value: &[u8]) -> Result { - if value.len() != SECRET_KEY_LENGTH { + if value.len() != KEYPAIR_LENGTH { anyhow::bail!( "Invalid private key length: {}, expected {}", value.len(), - SECRET_KEY_LENGTH + KEYPAIR_LENGTH ); } - let secret_key: SecretKey = value.try_into()?; - let key_pair = SigningKey::from_bytes(&secret_key); + let reference = value.as_ptr() as *const [u8; KEYPAIR_LENGTH]; + let value = unsafe { &*reference }; + let key_pair = SigningKey::from_keypair_bytes(value)?; Ok(Self { key_pair }) } } @@ -94,8 +92,7 @@ pub mod private_key { pub fn from_hex(hex: &str) -> Result { let bytes = hex::decode(hex)?; - Self::try_from(&bytes[..]) - .map_err(DefaultPrivateKeyHexDeserializationError::PrivateKeyError) + Self::try_from(&bytes[..]).map_err(|e| e.into()) } pub fn default_address(&self) -> Address { @@ -208,7 +205,7 @@ impl FromStr for DefaultSignature { fn from_str(s: &str) -> Result { let bytes = hex::decode(s)?; - let bytes: SignatureBytes = bytes + let bytes: ed25519_dalek::ed25519::SignatureBytes = bytes .try_into() .map_err(|_| anyhow::anyhow!("Invalid signature"))?;