From f38a91bbe2932c3438734f274bd9b494163f633e Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Mon, 29 Jan 2024 14:25:55 -0700 Subject: [PATCH 01/66] Setup stub --- Cargo.toml | 1 + protocols/zcash-frost/Cargo.toml | 38 +++++++ protocols/zcash-frost/src/lib.rs | 78 +++++++++++++++ protocols/zcash-frost/src/network.rs | 21 ++++ protocols/zcash-frost/src/protocol.rs | 138 ++++++++++++++++++++++++++ 5 files changed, 276 insertions(+) create mode 100644 protocols/zcash-frost/Cargo.toml create mode 100644 protocols/zcash-frost/src/lib.rs create mode 100644 protocols/zcash-frost/src/network.rs create mode 100644 protocols/zcash-frost/src/protocol.rs diff --git a/Cargo.toml b/Cargo.toml index ee9ba472c..2c613c5cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ "protocols/mp-ecdsa", "protocols/dfns-cggmp21", "protocols/zk-saas", + "protocols/zcash-frost", "protocols/stub", "test-utils", "protocol-macros" diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml new file mode 100644 index 000000000..083732e0f --- /dev/null +++ b/protocols/zcash-frost/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "zcash-frost-protocol" +version = "0.1.0" +edition = "2021" + +[dependencies] +tokio = { workspace = true, features = ["macros", "rt-multi-thread", "time", "net"] } +gadget-common = { workspace = true } +gadget-core = { workspace = true } +protocol-macros = { workspace = true } +async-trait = { workspace = true } +log = { workspace = true } +curv = { workspace = true } +futures = { workspace = true } +itertools = { workspace = true } +bincode2 = { workspace = true } + +pallet-jobs-rpc-runtime-api = { workspace = true, features = ["std"] } +pallet-jobs = { workspace = true, features = ["std"] } +tangle-primitives = { workspace = true, features = ["std"] } + +sp-core = { workspace = true, features = ["std"] } +sp-io = { workspace = true, features = ["std"] } +sp-api = { workspace = true, features = ["std"] } +sp-runtime = { workspace = true, features = ["std"] } +sp-application-crypto = { workspace = true, features = ["std"] } + +sc-client-api = { workspace = true } + +frame-support = { workspace = true } +parity-scale-codec = { workspace = true } + +serde = { version = "1.0.193", features = ["derive"] } +rand = { workspace = true } +hex = { workspace = true } + +[dev-dependencies] +test-utils = { workspace = true } diff --git a/protocols/zcash-frost/src/lib.rs b/protocols/zcash-frost/src/lib.rs new file mode 100644 index 000000000..585de0eb8 --- /dev/null +++ b/protocols/zcash-frost/src/lib.rs @@ -0,0 +1,78 @@ +use async_trait::async_trait; +use gadget_common::client::*; +use gadget_common::config::*; +use gadget_common::Error; +use network::ZCashFrostNetworkService; +use protocol::ZCashFrostProtocol; +use protocol_macros::protocol; +use std::sync::Arc; + +pub mod network; +pub mod protocol; + +#[protocol] +pub struct ZCashFrostProtocolConfig, C: ClientWithApi> +where + >::Api: JobsApi, +{ + pallet_tx: Arc, + logger: DebugLogger, + client: C, + _pd: std::marker::PhantomData<(B, BE)>, +} + +#[async_trait] +impl, C: ClientWithApi> NetworkAndProtocolSetup + for ZCashFrostProtocolConfig +where + >::Api: JobsApi, +{ + type Network = ZCashFrostNetworkService; + type Protocol = ZCashFrostProtocol; + type Client = C; + type Block = B; + type Backend = BE; + + async fn build_network_and_protocol( + &self, + jobs_client: JobsClient, + ) -> Result<(Self::Network, Self::Protocol), Error> { + let frost_protocol = ZCashFrostProtocol { + jobs_client, + account_id: AccountId::from_raw([0u8; 33]), + logger: self.logger.clone(), + }; + + Ok((ZCashFrostNetworkService, frost_protocol)) + } + + fn pallet_tx(&self) -> Arc { + self.pallet_tx.clone() + } + + fn logger(&self) -> DebugLogger { + self.logger.clone() + } + + fn client(&self) -> Self::Client { + self.client.clone() + } +} + +pub async fn run + 'static, C: ClientWithApi>( + client: C, + pallet_tx: Arc, + logger: DebugLogger, +) -> Result<(), Error> +where + >::Api: JobsApi, +{ + let config = ZCashFrostProtocolConfig { + pallet_tx, + logger, + client, + _pd: std::marker::PhantomData, + }; + + config.execute().await +} diff --git a/protocols/zcash-frost/src/network.rs b/protocols/zcash-frost/src/network.rs new file mode 100644 index 000000000..fd4419881 --- /dev/null +++ b/protocols/zcash-frost/src/network.rs @@ -0,0 +1,21 @@ +use async_trait::async_trait; +use gadget_common::config::Network; +use gadget_common::gadget::work_manager::WorkManager; +use gadget_common::{Error, WorkManagerInterface}; + +#[derive(Clone)] +pub struct ZCashFrostNetworkService; + +#[async_trait] +impl Network for ZCashFrostNetworkService { + async fn next_message(&self) -> Option<::ProtocolMessage> { + futures::future::pending().await + } + + async fn send_message( + &self, + _message: ::ProtocolMessage, + ) -> Result<(), Error> { + Ok(()) + } +} diff --git a/protocols/zcash-frost/src/protocol.rs b/protocols/zcash-frost/src/protocol.rs new file mode 100644 index 000000000..4f7c2aec2 --- /dev/null +++ b/protocols/zcash-frost/src/protocol.rs @@ -0,0 +1,138 @@ +use std::collections::HashMap; +use std::sync::Arc; + +use async_trait::async_trait; +use gadget_common::client::{AccountId, ClientWithApi, JobsClient}; +use gadget_common::config::{DebugLogger, JobsApi, ProvideRuntimeApi}; +use gadget_common::gadget::message::GadgetProtocolMessage; +use gadget_common::gadget::work_manager::WorkManager; +use gadget_common::gadget::{GadgetProtocol, JobInitMetadata}; +use gadget_common::protocol::AsyncProtocol; +use gadget_common::gadget::message::UserID; +use gadget_common::{ + Backend, Block, BuiltExecutableJobWrapper, Error, JobBuilder, JobError, ProtocolWorkManager, WorkManagerInterface +}; +use sc_client_api::BlockImportNotification; +use tangle_primitives::jobs::{JobId, JobType}; +use tangle_primitives::roles::RoleType; + +pub struct ZCashFrostProtocol, C: ClientWithApi> +where + >::Api: JobsApi, +{ + pub jobs_client: JobsClient, + pub account_id: AccountId, + pub logger: DebugLogger, +} + +pub type Curve = u8; + +pub struct ZCashFrostKeygenExtraParams { + i: u16, + t: u16, + n: u16, + job_id: JobId, + role_type: RoleType, + user_id_to_account_id_mapping: Arc>, +} + +#[async_trait] +impl, C: ClientWithApi> GadgetProtocol + for ZCashFrostProtocol +where + >::Api: JobsApi, +{ + async fn create_next_job( + &self, + job: JobInitMetadata, + ) -> Result<::AdditionalParams, Error> { + let now = job.now; + self.logger.info(format!("At finality notification {now}")); + + let job_id = job.job_id; + let role_type = job.job_type.get_role_type(); + // ZcashFrostSr25519 | ZcashFrostP256 | ZcashFrostSecp256k1 | ZcashFrostRistretto255 | ZcashFrostEd25519 + + + // We can safely make this assumption because we are only creating jobs for phase one + let JobType::DKGTSSPhaseOne(p1_job) = job.job_type else { + panic!("Should be valid type") + }; + + let participants = p1_job.participants; + let threshold = p1_job.threshold; + + let user_id_to_account_id_mapping = Arc::new( + participants + .clone() + .into_iter() + .enumerate() + .map(|r| (r.0 as UserID, r.1)) + .collect(), + ); + + let params = ZCashFrostKeygenExtraParams { + i: participants + .iter() + .position(|p| p == &self.account_id) + .expect("Should exist") as u16, + t: threshold as u16, + n: participants.len() as u16, + role_type, + job_id, + user_id_to_account_id_mapping, + }; + + Ok(params) + } + + async fn process_block_import_notification( + &self, + _notification: BlockImportNotification, + _job_manager: &ProtocolWorkManager, + ) -> Result<(), Error> { + Ok(()) + } + + async fn process_error(&self, _error: Error, _job_manager: &ProtocolWorkManager) {} + + fn account_id(&self) -> &AccountId { + &self.account_id + } + + fn role_type(&self) -> RoleType { + RoleType::LightClientRelaying + } + + fn is_phase_one(&self) -> bool { + true + } + + fn client(&self) -> &JobsClient { + &self.jobs_client + } + + fn logger(&self) -> &DebugLogger { + &self.logger + } +} + +#[async_trait] +impl, C: ClientWithApi> AsyncProtocol for ZCashFrostProtocol +where + >::Api: JobsApi, +{ + type AdditionalParams = ZCashFrostKeygenExtraParams; + + async fn generate_protocol_from( + &self, + _associated_block_id: ::Clock, + _associated_retry_id: ::RetryID, + _associated_session_id: ::SessionID, + _associated_task_id: ::TaskID, + _protocol_message_rx: tokio::sync::mpsc::UnboundedReceiver, + _additional_params: Self::AdditionalParams, + ) -> Result { + Ok(JobBuilder::new().protocol(async move { Ok(()) }).build()) + } +} From a0245a323b5d610c028f99bb37e561adca0b8e9e Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 31 Jan 2024 11:25:05 -0500 Subject: [PATCH 02/66] Integrate frost keygen and sign --- Cargo.lock | 475 ++++++++++++-- Cargo.toml | 13 + .../src/protocols/state_machine.rs | 163 ----- protocols/dfns-cggmp21/src/protocols/util.rs | 2 +- protocols/zcash-frost/Cargo.toml | 19 + protocols/zcash-frost/src/constants.rs | 29 + protocols/zcash-frost/src/lib.rs | 172 ++++-- protocols/zcash-frost/src/protocols/keygen.rs | 581 ++++++++++++++++++ protocols/zcash-frost/src/protocols/mod.rs | 3 + protocols/zcash-frost/src/protocols/sign.rs | 468 ++++++++++++++ protocols/zcash-frost/src/protocols/util.rs | 507 +++++++++++++++ protocols/zcash-frost/src/rounds/errors.rs | 43 ++ protocols/zcash-frost/src/rounds/keygen.rs | 274 +++++++++ protocols/zcash-frost/src/rounds/mod.rs | 123 ++++ protocols/zcash-frost/src/rounds/sign.rs | 245 ++++++++ 15 files changed, 2858 insertions(+), 259 deletions(-) delete mode 100644 protocols/dfns-cggmp21/src/protocols/state_machine.rs create mode 100644 protocols/zcash-frost/src/constants.rs create mode 100644 protocols/zcash-frost/src/protocols/keygen.rs create mode 100644 protocols/zcash-frost/src/protocols/mod.rs create mode 100644 protocols/zcash-frost/src/protocols/sign.rs create mode 100644 protocols/zcash-frost/src/protocols/util.rs create mode 100644 protocols/zcash-frost/src/rounds/errors.rs create mode 100644 protocols/zcash-frost/src/rounds/keygen.rs create mode 100644 protocols/zcash-frost/src/rounds/mod.rs create mode 100644 protocols/zcash-frost/src/rounds/sign.rs diff --git a/Cargo.lock b/Cargo.lock index 3c533e55b..70029f370 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -770,6 +770,15 @@ dependencies = [ "pin-project-lite 0.2.13", ] +[[package]] +name = "atomic-polyfill" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" +dependencies = [ + "critical-section", +] + [[package]] name = "atomic-take" version = "1.1.0" @@ -1085,6 +1094,23 @@ dependencies = [ "tracing", ] +[[package]] +name = "bls12_381_plus" +version = "0.8.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7533858fe2da020c4fba936036e702de0f73144fe13f9c71113f6f804cde3466" +dependencies = [ + "arrayref", + "elliptic-curve 0.13.8", + "ff 0.13.0", + "group 0.13.0", + "hex", + "rand_core 0.6.4", + "serde", + "subtle", + "zeroize", +] + [[package]] name = "bounded-collections" version = "0.1.9" @@ -1261,7 +1287,7 @@ dependencies = [ "paillier-zk", "rand_chacha 0.3.1", "rand_core 0.6.4", - "round-based 0.2.0", + "round-based 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_with 2.3.3", "sha2 0.10.8", @@ -1341,6 +1367,12 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "cobs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" + [[package]] name = "color-eyre" version = "0.6.2" @@ -1407,6 +1439,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "const-crc32" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68d13f542d70e5b339bf46f6f74704ac052cfd526c58cd87996bd1ef4615b9a0" + [[package]] name = "const-hex" version = "1.10.0" @@ -1728,6 +1766,12 @@ dependencies = [ "itertools 0.10.5", ] +[[package]] +name = "critical-section" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -1815,9 +1859,9 @@ dependencies = [ [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" dependencies = [ "generic-array 0.14.7", "subtle", @@ -1931,7 +1975,9 @@ dependencies = [ "digest 0.10.7", "fiat-crypto", "platforms", + "rand_core 0.6.4", "rustc_version", + "serde", "subtle", "zeroize", ] @@ -1959,12 +2005,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.3" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "da01daa5f6d41c91358398e8db4dde38e292378da1f28300b59ef4732b879454" dependencies = [ - "darling_core 0.20.3", - "darling_macro 0.20.3", + "darling_core 0.20.4", + "darling_macro 0.20.4", ] [[package]] @@ -1983,9 +2029,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "f44f6238b948a3c6c3073cdf53bb0c2d5e024ee27e0f35bfe9d556a12395808a" dependencies = [ "fnv", "ident_case", @@ -2008,11 +2054,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "0d2d88bd93979b1feb760a6b5c531ac5ba06bd63e74894c377af02faee07b9cd" dependencies = [ - "darling_core 0.20.3", + "darling_core 0.20.4", "quote", "syn 2.0.48", ] @@ -2043,6 +2089,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "debugless-unwrap" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f400d0750c0c069e8493f2256cb4da6f604b6d2eeb69a0ca8863acde352f8400" + [[package]] name = "der" version = "0.6.1" @@ -2099,6 +2151,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive-getters" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2c35ab6e03642397cdda1dd58abbc05d418aef8e36297f336d5aba060fe8df" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive-syn-parse" version = "0.1.5" @@ -2136,7 +2199,7 @@ dependencies = [ "gadget-common", "gadget-core", "hex", - "itertools 0.12.0", + "itertools 0.12.1", "log", "pallet-jobs", "pallet-jobs-rpc-runtime-api", @@ -2291,6 +2354,15 @@ dependencies = [ "walkdir", ] +[[package]] +name = "document-features" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" +dependencies = [ + "litrs", +] + [[package]] name = "downcast" version = "0.11.0" @@ -2416,6 +2488,21 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ed448-goldilocks-plus" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54ab14053f15938903e6fd9fa467f225525812c5995b465167a2eb4941498c51" +dependencies = [ + "elliptic-curve 0.13.8", + "hex", + "rand_core 0.6.4", + "serde", + "sha3 0.10.8", + "subtle", + "zeroize", +] + [[package]] name = "educe" version = "0.4.23" @@ -2466,6 +2553,7 @@ dependencies = [ "ff 0.13.0", "generic-array 0.14.7", "group 0.13.0", + "hkdf", "pem-rfc7468", "pkcs8 0.10.2", "rand_core 0.6.4", @@ -2474,6 +2562,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + [[package]] name = "enum-as-inner" version = "0.5.1" @@ -2534,7 +2628,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ - "darling 0.20.3", + "darling 0.20.4", "proc-macro2", "quote", "syn 2.0.48", @@ -3137,6 +3231,146 @@ dependencies = [ "sp-weights 20.0.0", ] +[[package]] +name = "frost-core" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "byteorder", + "const-crc32", + "debugless-unwrap", + "derive-getters", + "document-features", + "hex", + "itertools 0.12.1", + "postcard", + "rand_core 0.6.4", + "serde", + "serdect", + "subtle", + "thiserror", + "visibility", + "zeroize", +] + +[[package]] +name = "frost-ed25519" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "curve25519-dalek 4.1.1", + "document-features", + "frost-core", + "frost-rerandomized", + "rand_core 0.6.4", + "sha2 0.10.8", +] + +[[package]] +name = "frost-ed448" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "document-features", + "ed448-goldilocks-plus", + "frost-core", + "frost-rerandomized", + "rand_core 0.6.4", + "sha3 0.10.8", +] + +[[package]] +name = "frost-p256" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "document-features", + "frost-core", + "frost-rerandomized", + "p256 0.13.2", + "rand_core 0.6.4", + "sha2 0.10.8", +] + +[[package]] +name = "frost-p384" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "document-features", + "frost-core", + "frost-rerandomized", + "p384", + "rand_core 0.6.4", + "sha2 0.10.8", +] + +[[package]] +name = "frost-redjubjub" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "blake2b_simd", + "document-features", + "frost-core", + "frost-rerandomized", + "group 0.13.0", + "jubjub", + "rand_core 0.6.4", + "sha2 0.10.8", +] + +[[package]] +name = "frost-rerandomized" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "derive-getters", + "document-features", + "frost-core", + "rand_core 0.6.4", +] + +[[package]] +name = "frost-ristretto255" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "curve25519-dalek 4.1.1", + "document-features", + "frost-core", + "frost-rerandomized", + "rand_core 0.6.4", + "sha2 0.10.8", +] + +[[package]] +name = "frost-secp256k1" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "document-features", + "frost-core", + "frost-rerandomized", + "k256", + "rand_core 0.6.4", + "sha2 0.10.8", +] + +[[package]] +name = "frost-taproot" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "document-features", + "frost-core", + "frost-rerandomized", + "k256", + "rand_core 0.6.4", + "sha2 0.10.8", + "signature 2.2.0", +] + [[package]] name = "fs-err" version = "2.11.0" @@ -3606,6 +3840,15 @@ dependencies = [ "crunchy", ] +[[package]] +name = "hash32" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" +dependencies = [ + "byteorder", +] + [[package]] name = "hashbrown" version = "0.11.2" @@ -3644,6 +3887,20 @@ dependencies = [ "serde", ] +[[package]] +name = "heapless" +version = "0.7.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" +dependencies = [ + "atomic-polyfill", + "hash32", + "rustc_version", + "serde", + "spin 0.9.8", + "stable_deref_trait", +] + [[package]] name = "heck" version = "0.3.3" @@ -3714,7 +3971,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ - "crypto-mac 0.11.1", + "crypto-mac 0.11.0", "digest 0.9.0", ] @@ -4119,9 +4376,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] @@ -4238,6 +4495,22 @@ dependencies = [ "tracing", ] +[[package]] +name = "jubjub" +version = "0.10.4" +source = "git+https://github.com/LIT-Protocol/jubjub.git#b4aa27ecd61558dc50656d5810d62457dc31ce8c" +dependencies = [ + "bitvec 1.0.1", + "bls12_381_plus", + "elliptic-curve 0.13.8", + "ff 0.13.0", + "group 0.13.0", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "serde", + "subtle", +] + [[package]] name = "k256" version = "0.13.3" @@ -4805,6 +5078,12 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + [[package]] name = "lock_api" version = "0.4.11" @@ -5126,7 +5405,7 @@ dependencies = [ "futures", "gadget-common", "gadget-core", - "itertools 0.12.0", + "itertools 0.12.1", "log", "multi-party-ecdsa", "pallet-jobs", @@ -5687,7 +5966,18 @@ checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" dependencies = [ "ecdsa 0.16.9", "elliptic-curve 0.13.8", - "primeorder", + "primeorder 0.13.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.10.8", +] + +[[package]] +name = "p384" +version = "0.13.0" +source = "git+https://github.com/LIT-Protocol/elliptic-curves.git#67924afc93d236e1508afd5f55bbf738e1c41eaa" +dependencies = [ + "ecdsa 0.16.9", + "elliptic-curve 0.13.8", + "primeorder 0.13.6 (git+https://github.com/LIT-Protocol/elliptic-curves.git)", "sha2 0.10.8", ] @@ -5740,7 +6030,7 @@ dependencies = [ [[package]] name = "pallet-dkg" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#420c8eb15c564dfa6909a9b57b38ca9e80ffcef2" +source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" dependencies = [ "frame-support", "frame-system", @@ -5758,7 +6048,7 @@ dependencies = [ [[package]] name = "pallet-jobs" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#420c8eb15c564dfa6909a9b57b38ca9e80ffcef2" +source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5775,7 +6065,7 @@ dependencies = [ [[package]] name = "pallet-jobs-rpc-runtime-api" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#420c8eb15c564dfa6909a9b57b38ca9e80ffcef2" +source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", @@ -5806,7 +6096,7 @@ dependencies = [ [[package]] name = "pallet-zksaas" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#420c8eb15c564dfa6909a9b57b38ca9e80ffcef2" +source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5953,7 +6243,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" dependencies = [ - "crypto-mac 0.11.1", + "crypto-mac 0.11.0", ] [[package]] @@ -6198,6 +6488,18 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "postcard" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" +dependencies = [ + "cobs", + "embedded-io", + "heapless", + "serde", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -6259,6 +6561,14 @@ dependencies = [ "elliptic-curve 0.13.8", ] +[[package]] +name = "primeorder" +version = "0.13.6" +source = "git+https://github.com/LIT-Protocol/elliptic-curves.git#67924afc93d236e1508afd5f55bbf738e1c41eaa" +dependencies = [ + "elliptic-curve 0.13.8", +] + [[package]] name = "primitive-types" version = "0.10.1" @@ -7139,6 +7449,17 @@ dependencies = [ "tracing", ] +[[package]] +name = "round-based" +version = "0.2.0" +source = "git+https://github.com/ZenGo-X/round-based-protocol#1b372fe7d19de8cc5236cfcd0bcd92d610dacecd" +dependencies = [ + "futures-util", + "phantom-type 0.3.1", + "thiserror", + "tracing", +] + [[package]] name = "round-based-derive" version = "0.2.0" @@ -8025,7 +8346,7 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" dependencies = [ - "darling 0.20.3", + "darling 0.20.4", "proc-macro2", "quote", "syn 2.0.48", @@ -8037,12 +8358,22 @@ version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbff351eb4b33600a2e138dfa0b10b65a238ea8ff8fb2387c422c5022a3e8298" dependencies = [ - "darling 0.20.3", + "darling 0.20.4", "proc-macro2", "quote", "syn 2.0.48", ] +[[package]] +name = "serdect" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177" +dependencies = [ + "base16ct 0.2.0", + "serde", +] + [[package]] name = "sha-1" version = "0.9.8" @@ -9266,6 +9597,9 @@ name = "spin" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] [[package]] name = "spki" @@ -9316,7 +9650,7 @@ checksum = "f357220731130667173ede5f8f9763eba482bdec60cd91a535156537635cdbcc" dependencies = [ "ff 0.13.0", "hex-literal", - "primeorder", + "primeorder 0.13.6 (registry+https://github.com/rust-lang/crates.io-index)", "subtle", "zeroize", ] @@ -9424,9 +9758,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "subxt" @@ -9506,7 +9840,7 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5086ce2a90e723083ff19b77f06805d00e732eac3e19c86f6cd643d4255d334" dependencies = [ - "darling 0.20.3", + "darling 0.20.4", "parity-scale-codec 3.6.9", "proc-macro-error", "subxt-codegen", @@ -9584,7 +9918,7 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#420c8eb15c564dfa6909a9b57b38ca9e80ffcef2" +source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -9594,7 +9928,7 @@ dependencies = [ [[package]] name = "tangle-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#420c8eb15c564dfa6909a9b57b38ca9e80ffcef2" +source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" dependencies = [ "ark-bn254", "ark-crypto-primitives", @@ -10354,6 +10688,17 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "visibility" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3fd98999db9227cf28e59d83e1f120f42bc233d4b152e8fab9bc87d5bb1e0f8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "void" version = "1.0.2" @@ -10489,9 +10834,9 @@ checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "wasm-encoder" -version = "0.40.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d162eb64168969ae90e8668ca0593b0e47667e315aa08e717a9c9574d700d826" +checksum = "e09bca7d6388637d27fb5edbeab11f56bfabcef8743c55ae34370e1e5030a071" dependencies = [ "leb128", ] @@ -11004,10 +11349,11 @@ dependencies = [ [[package]] name = "wast" -version = "70.0.1" +version = "70.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d415036fe747a32b30c76c8bd6c73f69b7705fb7ebca5f16e852eef0c95802" +checksum = "a3d5061300042ff5065123dae1e27d00c03f567d34a2937c8472255148a216dc" dependencies = [ + "bumpalo", "leb128", "memchr", "unicode-width", @@ -11016,9 +11362,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8241f34599d413d2243a21015ab43aef68bfb32a0e447c54eef8d423525ca15e" +checksum = "afd7357b6cc46d46a2509c43dcb1dd4131dafbf4e75562d87017b5a05ffad2d6" dependencies = [ "wast", ] @@ -11066,9 +11412,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.14" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b31891d644eba1789fb6715f27fbc322e4bdf2ecdc412ede1993246159271613" +checksum = "89beec544f246e679fc25490e3f8e08003bc4bf612068f325120dad4cea02c1c" dependencies = [ "bytemuck", "safe_arch", @@ -11484,6 +11830,55 @@ dependencies = [ "time", ] +[[package]] +name = "zcash-frost-protocol" +version = "0.1.0" +dependencies = [ + "async-trait", + "bincode2", + "cggmp21", + "curv-kzen", + "digest 0.10.7", + "frame-support", + "frost-core", + "frost-ed25519", + "frost-ed448", + "frost-p256", + "frost-p384", + "frost-redjubjub", + "frost-rerandomized", + "frost-ristretto255", + "frost-secp256k1", + "frost-taproot", + "futures", + "gadget-common", + "gadget-core", + "hex", + "itertools 0.12.1", + "log", + "pallet-jobs", + "pallet-jobs-rpc-runtime-api", + "parity-scale-codec 3.6.9", + "protocol-macros", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "round-based 0.2.0 (git+https://github.com/ZenGo-X/round-based-protocol)", + "sc-client-api", + "serde", + "sha2 0.10.8", + "sp-api", + "sp-application-crypto 23.0.0", + "sp-core 21.0.0", + "sp-io 23.0.0", + "sp-runtime 24.0.0", + "tangle-primitives", + "test-utils", + "thiserror", + "tokio", + "udigest", +] + [[package]] name = "zerocopy" version = "0.7.32" diff --git a/Cargo.toml b/Cargo.toml index 841401c24..51c6b3f8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ stub-protocol = { path = "./protocols/stub" } test-utils = { path = "./test-utils" } protocol-macros = { path = "./protocol-macros" } dfns-cggmp21-protocol = { path = "./protocols/dfns-cggmp21" } +zcash-frost-protocol = { path = "./protocols/zcash-frost" } pallet-jobs-rpc-runtime-api = { git = "https://github.com/webb-tools/tangle" } pallet-jobs = { git = "https://github.com/webb-tools/tangle" } @@ -35,6 +36,17 @@ multi-party-ecdsa = { git = "https://github.com/webb-tools/cggmp-threshold-ecdsa round-based = { git = "https://github.com/webb-tools/round-based-protocol", features = [] } curv = { package = "curv-kzen", version = "0.10.0" } dfns-cggmp21 = { package = "cggmp21", version = "0.1.1", default-features = false } +udigest = { version = "0.1", features = ["std", "derive"]} +frost-core = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-ed25519 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-ed448 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-p256 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-p384 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-redjubjub = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-ristretto255 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-secp256k1 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-rerandomized = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-taproot = { git = "https://github.com/LIT-Protocol/frost.git" } sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } @@ -129,3 +141,4 @@ subxt = "0.33.0" anyhow = "1.0.79" libsecp256k1 = "0.7.1" rayon = { version = "1.8.0" } +thiserror = { version = "1.0" } diff --git a/protocols/dfns-cggmp21/src/protocols/state_machine.rs b/protocols/dfns-cggmp21/src/protocols/state_machine.rs deleted file mode 100644 index db6c6ab9a..000000000 --- a/protocols/dfns-cggmp21/src/protocols/state_machine.rs +++ /dev/null @@ -1,163 +0,0 @@ -use gadget_common::debug_logger::DebugLogger; -use multi_party_ecdsa::gg_2020::state_machine::traits::RoundBlame; -use multi_party_ecdsa::MessageRoundID; -use round_based::{Msg, StateMachine}; -use sp_application_crypto::serde::Serialize; -use std::collections::HashSet; -use std::fmt::Debug; - -pub(crate) struct StateMachineWrapper { - sm: T, - current_round_blame: tokio::sync::watch::Sender, - // stores a list of received messages - received_messages: HashSet>, - logger: DebugLogger, -} - -impl StateMachineWrapper { - pub fn new( - sm: T, - current_round_blame: tokio::sync::watch::Sender, - logger: DebugLogger, - ) -> Self { - Self { - sm, - current_round_blame, - logger, - received_messages: HashSet::new(), - } - } -} - -impl StateMachine for StateMachineWrapper -where - T: StateMachine + RoundBlame + Debug, - ::Err: Debug, - ::MessageBody: Serialize + MessageRoundID, -{ - type Err = T::Err; - type Output = T::Output; - type MessageBody = T::MessageBody; - - fn handle_incoming(&mut self, msg: Msg) -> Result<(), Self::Err> { - let (round, sender, _receiver) = (msg.body.round_id(), msg.sender, msg.receiver); - - self.logger.trace(format!( - "Handling incoming message round={}, sender={}", - round, sender - )); - - if round < self.current_round() { - self.logger - .trace(format!("Message for round={round} is outdated, ignoring",)); - return Ok(()); - } - - // Before passing to the state machine, make sure that we haven't already received the same - // message (this is needed as we use a gossiping protocol to send messages, and we don't - // want to process the same message twice) - let msg_serde = bincode2::serialize(&msg).expect("Failed to serialize message"); - if !self.received_messages.insert(msg_serde) { - self.logger.trace(format!( - "Already received message for round={}, sender={}", - round, sender - )); - return Ok(()); - } - - let result = self.sm.handle_incoming(msg.clone()); - - if let Some(err) = result.as_ref().err() { - self.logger.error(format!("StateMachine error: {err:?}")); - } - - // Get the round blame to update round blame - let round_blame = self.round_blame(); - - self.logger.trace(format!( - "SM After: {:?} || round_blame: {:?}", - &self.sm, round_blame - )); - - result - } - - fn message_queue(&mut self) -> &mut Vec> { - self.sm.message_queue() - } - - fn wants_to_proceed(&self) -> bool { - self.sm.wants_to_proceed() - } - - fn proceed(&mut self) -> Result<(), Self::Err> { - self.logger.trace(format!( - "Trying to proceed: current round ({:?}), waiting for msgs from parties: ({:?})", - self.current_round(), - self.round_blame(), - )); - let now = std::time::Instant::now(); - let result = self.sm.proceed(); - - let elapsed = now.elapsed(); - self.logger.trace(format!( - "Proceeded through SM in {}ms. New current round ({:?}), waiting for msgs from parties: ({:?})", - elapsed.as_millis(), - self.current_round(), - self.round_blame(), - )); - - result - } - - fn round_timeout(&self) -> Option { - self.sm.round_timeout() - } - - fn round_timeout_reached(&mut self) -> Self::Err { - self.sm.round_timeout_reached() - } - - fn is_finished(&self) -> bool { - self.sm.is_finished() - } - - fn pick_output(&mut self) -> Option> { - self.sm.pick_output() - } - - fn current_round(&self) -> u16 { - self.sm.current_round() - } - - fn total_rounds(&self) -> Option { - self.sm.total_rounds() - } - - fn party_ind(&self) -> u16 { - self.sm.party_ind() - } - - fn parties(&self) -> u16 { - self.sm.parties() - } -} - -impl RoundBlame for StateMachineWrapper { - fn round_blame(&self) -> (u16, Vec) { - let (unreceived_messages, blamed_parties) = self.sm.round_blame(); - self.logger - .debug(format!("Not received messages from : {blamed_parties:?}")); - let _ = self.current_round_blame.send(CurrentRoundBlame { - unreceived_messages, - blamed_parties: blamed_parties.clone(), - }); - (unreceived_messages, blamed_parties) - } -} - -#[derive(Default, Debug)] -pub struct CurrentRoundBlame { - pub unreceived_messages: u16, - pub blamed_parties: Vec, -} diff --git a/protocols/dfns-cggmp21/src/protocols/util.rs b/protocols/dfns-cggmp21/src/protocols/util.rs index 3146752be..481bc6330 100644 --- a/protocols/dfns-cggmp21/src/protocols/util.rs +++ b/protocols/dfns-cggmp21/src/protocols/util.rs @@ -1,5 +1,5 @@ #![allow(clippy::type_complexity, clippy::too_many_arguments)] -//! When delivering messages to an async protocol, we want o make sure we don't mix up voting and public key gossip messages +//! When delivering messages to an async protocol, we want to make sure we don't mix up voting and public key gossip messages //! Thus, this file contains a function that takes a channel from the gadget to the async protocol and splits it into two channels use dfns_cggmp21::round_based::{Incoming, MessageDestination, MessageType, Outgoing, PartyIndex}; use futures::{Stream, StreamExt}; diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml index 083732e0f..d26661ea6 100644 --- a/protocols/zcash-frost/Cargo.toml +++ b/protocols/zcash-frost/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +thiserror = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread", "time", "net"] } gadget-common = { workspace = true } gadget-core = { workspace = true } @@ -14,6 +15,24 @@ curv = { workspace = true } futures = { workspace = true } itertools = { workspace = true } bincode2 = { workspace = true } +round-based = { git = "https://github.com/ZenGo-X/round-based-protocol" } +digest = "0.10" +sha2 = "0.10" +rand_core = "0.6" +rand_chacha = { version = "0.3", default-features = false } +dfns-cggmp21 = { workspace = true } + +udigest = { workspace = true } +frost-core = { workspace = true } +frost-ed25519 = { workspace = true } +frost-ed448 = { workspace = true } +frost-p256 = { workspace = true } +frost-p384 = { workspace = true } +frost-redjubjub = { workspace = true } +frost-ristretto255 = { workspace = true } +frost-secp256k1 = { workspace = true } +frost-rerandomized = { workspace = true } +frost-taproot = { workspace = true } pallet-jobs-rpc-runtime-api = { workspace = true, features = ["std"] } pallet-jobs = { workspace = true, features = ["std"] } diff --git a/protocols/zcash-frost/src/constants.rs b/protocols/zcash-frost/src/constants.rs new file mode 100644 index 000000000..8db1d8d75 --- /dev/null +++ b/protocols/zcash-frost/src/constants.rs @@ -0,0 +1,29 @@ +// ================= Common ======================== // +pub const ZCASH_FROST_KEYGEN_PROTOCOL_NAME: &str = "/tangle/zcash-frost/keygen/1"; +pub const ZCASH_FROST_SIGNING_PROTOCOL_NAME: &str = "/tangle/zcash-frost/signing/1"; + +// ============= Signing Protocol ======================= // + +pub mod signing_worker { + use std::time::Duration; + + // the maximum number of tasks that the work manager tries to assign + pub const MAX_RUNNING_TASKS: usize = 2; + + // the maximum number of tasks that can be enqueued, + // enqueued here implies not actively running but listening for messages + pub const MAX_ENQUEUED_TASKS: usize = 10; + + // How often to poll the jobs to check completion status + pub const JOB_POLL_INTERVAL: Duration = Duration::from_millis(500); +} + +// ============= Keygen Protocol ======================= // + +pub mod keygen_worker { + /// the maximum number of tasks that the work manager tries to assign + /// at any given time for the keygen protocol. + pub const MAX_RUNNING_TASKS: usize = 2; + /// the maximum number of tasks that can be enqueued. + pub const MAX_ENQUEUED_TASKS: usize = 10; +} diff --git a/protocols/zcash-frost/src/lib.rs b/protocols/zcash-frost/src/lib.rs index 585de0eb8..8ceb2831a 100644 --- a/protocols/zcash-frost/src/lib.rs +++ b/protocols/zcash-frost/src/lib.rs @@ -1,78 +1,140 @@ -use async_trait::async_trait; use gadget_common::client::*; use gadget_common::config::*; -use gadget_common::Error; -use network::ZCashFrostNetworkService; -use protocol::ZCashFrostProtocol; +use gadget_common::keystore::ECDSAKeyStore; +use gadget_common::keystore::KeystoreBackend; use protocol_macros::protocol; +use protocols::keygen::ZCashFrostKeygenProtocol; +use protocols::sign::ZCashFrostSigningProtocol; use std::sync::Arc; +pub mod constants; pub mod network; -pub mod protocol; +pub mod protocols; +pub mod rounds; -#[protocol] -pub struct ZCashFrostProtocolConfig, C: ClientWithApi> -where - >::Api: JobsApi, -{ - pallet_tx: Arc, - logger: DebugLogger, - client: C, - _pd: std::marker::PhantomData<(B, BE)>, -} +/// A Helper macro to declare a protocol, used +/// to avoid code duplication. +macro_rules! decl_porto { + ($name:ident + $proto:ident = $im:path) => { -#[async_trait] -impl, C: ClientWithApi> NetworkAndProtocolSetup - for ZCashFrostProtocolConfig -where - >::Api: JobsApi, -{ - type Network = ZCashFrostNetworkService; - type Protocol = ZCashFrostProtocol; - type Client = C; - type Block = B; - type Backend = BE; + #[protocol] + pub struct $name< + N: Network, + B: Block, + BE: Backend, + KBE: KeystoreBackend, + C: ClientWithApi, + > where + >::Api: JobsApi, + { + pub account_id: AccountId, + pub network: N, + pub keystore_backend: ECDSAKeyStore, + pub client: C, + pub logger: DebugLogger, + pub pallet_tx: Arc, + pub _pd: std::marker::PhantomData<(B, BE)>, + } - async fn build_network_and_protocol( - &self, - jobs_client: JobsClient, - ) -> Result<(Self::Network, Self::Protocol), Error> { - let frost_protocol = ZCashFrostProtocol { - jobs_client, - account_id: AccountId::from_raw([0u8; 33]), - logger: self.logger.clone(), - }; + #[async_trait::async_trait] + impl, KBE: KeystoreBackend, C: ClientWithApi> + NetworkAndProtocolSetup for $name + where + >::Api: JobsApi, + { + type Network = N; + type Protocol = $proto; + type Client = C; + type Block = B; + type Backend = BE; - Ok((ZCashFrostNetworkService, frost_protocol)) - } + async fn build_network_and_protocol( + &self, + jobs_client: JobsClient, + ) -> Result<(Self::Network, Self::Protocol), gadget_common::Error> { + use $im as m; + let protocol = m::create_protocol( + self.account_id, + jobs_client, + self.network.clone(), + self.logger.clone(), + self.keystore_backend.clone(), + ) + .await; - fn pallet_tx(&self) -> Arc { - self.pallet_tx.clone() - } + Ok((self.network.clone(), protocol)) + } - fn logger(&self) -> DebugLogger { - self.logger.clone() - } + fn pallet_tx(&self) -> Arc { + self.pallet_tx.clone() + } - fn client(&self) -> Self::Client { - self.client.clone() - } + fn logger(&self) -> DebugLogger { + self.logger.clone() + } + + fn client(&self) -> Self::Client { + self.client.clone() + } + } + + }; + // recursive case with optional trailing comma + ($($name:ident + $proto:ident = $im:path),+ $(,)?) => { + $(decl_porto!($name + $proto = $im);)+ + }; } -pub async fn run + 'static, C: ClientWithApi>( - client: C, - pallet_tx: Arc, +// A macro to declare all the protocols +decl_porto!( + ZCashFrostKeygenConfig + ZCashFrostKeygenProtocol = protocols::keygen, + ZCashFrostSigningConfig + ZCashFrostSigningProtocol = protocols::sign, +); + +#[allow(clippy::too_many_arguments)] +pub async fn run( + account_id: AccountId, logger: DebugLogger, -) -> Result<(), Error> + keystore: ECDSAKeyStore, + pallet_tx: Tx, + (client_keygen, client_signing): (C, C), + (network_keygen, network_signing): (N, N), +) -> Result<(), gadget_common::Error> where + B: Block, + BE: Backend + 'static, + C: ClientWithApi, + KBE: KeystoreBackend, + N: Network, + Tx: PalletSubmitter, >::Api: JobsApi, { - let config = ZCashFrostProtocolConfig { - pallet_tx, - logger, - client, + let pallet_tx = Arc::new(pallet_tx) as Arc; + let keygen_config = ZCashFrostKeygenConfig { + account_id, + network: network_keygen, + keystore_backend: keystore.clone(), + client: client_keygen, + logger: logger.clone(), + pallet_tx: pallet_tx.clone(), _pd: std::marker::PhantomData, }; - config.execute().await + let sign_config = ZCashFrostSigningConfig { + account_id, + network: network_signing, + keystore_backend: keystore.clone(), + client: client_signing, + logger: logger.clone(), + pallet_tx: pallet_tx.clone(), + _pd: std::marker::PhantomData, + }; + + let keygen_future = keygen_config.execute(); + let sign_future = sign_config.execute(); + + tokio::select! { + res0 = keygen_future => res0, + res1 = sign_future => res1, + } } diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs new file mode 100644 index 000000000..c2743bbbf --- /dev/null +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -0,0 +1,581 @@ +use async_trait::async_trait; +use frost_core::Ciphersuite; +use frost_ed25519::Ed25519Sha512; +use frost_p256::P256Sha256; +use frost_ristretto255::Ristretto255Sha512; +use frost_secp256k1::Secp256K1Sha256; +use futures::StreamExt; +use gadget_common::client::{AccountId, ClientWithApi, JobsClient}; +use gadget_common::debug_logger::DebugLogger; +use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; +use gadget_common::gadget::network::Network; +use gadget_common::gadget::work_manager::WorkManager; +use gadget_common::gadget::{GadgetProtocol, JobInitMetadata, WorkManagerConfig}; +use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; +use gadget_common::protocol::AsyncProtocol; +use gadget_common::{Block, BlockImportNotification}; +use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; +use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; +use itertools::Itertools; +use pallet_jobs_rpc_runtime_api::JobsApi; +use rand::SeedableRng; +use sc_client_api::Backend; +use sp_api::ProvideRuntimeApi; +use sp_application_crypto::sp_core::keccak_256; +use sp_core::{ecdsa, Pair}; +use std::collections::{BTreeMap, HashMap}; +use std::sync::Arc; +use tangle_primitives::jobs::{ + DKGTSSKeySubmissionResult, DigitalSignatureType, JobId, JobResult, JobType, +}; +use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; +use tokio::sync::mpsc::UnboundedReceiver; + +use crate::rounds; + +use super::util::PublicKeyGossipMessage; + +pub struct ZCashFrostKeygenProtocol { + client: JobsClient, + key_store: ECDSAKeyStore, + network: N, + logger: DebugLogger, + account_id: AccountId, +} + +pub async fn create_protocol( + account_id: AccountId, + client: JobsClient, + network: N, + logger: DebugLogger, + key_store: ECDSAKeyStore, +) -> ZCashFrostKeygenProtocol +where + B: Block, + BE: Backend, + C: ClientWithApi, + KBE: KeystoreBackend, + N: Network, + >::Api: JobsApi, +{ + ZCashFrostKeygenProtocol { + client, + network, + key_store, + logger, + account_id, + } +} + +#[async_trait] +impl< + B: Block, + BE: Backend + 'static, + C: ClientWithApi, + KBE: KeystoreBackend, + N: Network, + > GadgetProtocol for ZCashFrostKeygenProtocol +where + >::Api: JobsApi, +{ + fn name(&self) -> String { + "zcash-frost-keygen".to_string() + } + + async fn create_next_job( + &self, + job: JobInitMetadata, + ) -> Result<::AdditionalParams, gadget_common::Error> { + let job_id = job.job_id; + let role_type = job.job_type.get_role_type(); + + // We can safely make this assumption because we are only creating jobs for phase one + let JobType::DKGTSSPhaseOne(p1_job) = job.job_type else { + panic!("Should be valid type") + }; + + let participants = p1_job.participants; + let threshold = p1_job.threshold; + + let user_id_to_account_id_mapping = Arc::new( + participants + .clone() + .into_iter() + .enumerate() + .map(|r| (r.0 as UserID, r.1)) + .collect(), + ); + + let params = ZCashFrostKeygenExtraParams { + i: participants + .iter() + .position(|p| p == &self.account_id) + .expect("Should exist") as u16, + t: threshold as u16, + n: participants.len() as u16, + role_type, + job_id, + user_id_to_account_id_mapping, + }; + + Ok(params) + } + + async fn process_block_import_notification( + &self, + _notification: BlockImportNotification, + _job_manager: &ProtocolWorkManager, + ) -> Result<(), gadget_common::Error> { + Ok(()) + } + + async fn process_error( + &self, + error: gadget_common::Error, + _job_manager: &ProtocolWorkManager, + ) { + log::error!(target: "zcash_frost", "Error: {error:?}"); + } + + fn account_id(&self) -> &AccountId { + &self.account_id + } + + fn role_filter(&self, role: RoleType) -> bool { + matches!( + role, + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) + ) + } + + fn phase_filter(&self, job: JobType) -> bool { + matches!(job, JobType::DKGTSSPhaseOne(_)) + } + + fn client(&self) -> &JobsClient { + &self.client + } + + fn logger(&self) -> &DebugLogger { + &self.logger + } + + fn get_work_manager_config(&self) -> WorkManagerConfig { + WorkManagerConfig { + interval: None, // Manual polling + max_active_tasks: crate::constants::keygen_worker::MAX_RUNNING_TASKS, + max_pending_tasks: crate::constants::keygen_worker::MAX_ENQUEUED_TASKS, + } + } +} + +pub struct ZCashFrostKeygenExtraParams { + i: u16, + t: u16, + n: u16, + job_id: JobId, + role_type: RoleType, + user_id_to_account_id_mapping: Arc>, +} + +#[async_trait] +impl< + B: Block, + BE: Backend + 'static, + KBE: KeystoreBackend, + C: ClientWithApi, + N: Network, + > AsyncProtocol for ZCashFrostKeygenProtocol +where + >::Api: JobsApi, +{ + type AdditionalParams = ZCashFrostKeygenExtraParams; + async fn generate_protocol_from( + &self, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + protocol_message_channel: UnboundedReceiver, + additional_params: Self::AdditionalParams, + ) -> Result { + let key_store = self.key_store.clone(); + let key_store2 = self.key_store.clone(); + let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); + let protocol_output_clone = protocol_output.clone(); + let client = self.client.clone(); + let id = self.account_id; + let logger = self.logger.clone(); + let network = self.network.clone(); + + let (i, t, n, mapping, role_type) = ( + additional_params.i, + additional_params.t, + additional_params.n, + additional_params.user_id_to_account_id_mapping, + additional_params.role_type, + ); + + let role = match role_type { + RoleType::Tss(role) => role, + _ => { + return Err(JobError { + reason: "Invalid role type".to_string(), + }) + } + }; + + Ok(JobBuilder::new() + .protocol(async move { + let mut rng = rand::rngs::StdRng::from_entropy(); + let protocol_message_channel = + super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + logger.info(format!( + "Starting Keygen Protocol with params: i={i}, t={t}, n={n}" + )); + + let ( + keygen_tx_to_outbound, + keygen_rx_async_proto, + broadcast_tx_to_outbound, + broadcast_rx_from_gadget, + ) = super::util::create_job_manager_to_async_protocol_channel_split( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); + let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); + let party = round_based::MpcParty::connected(delivery); + let frost_key_share_package = match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 => { + rounds::keygen::run_threshold_keygen::( + Some(&mut tracer), + i, + t, + n, + role, + &mut rng, + party, + ) + .await + .map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })? + } + ThresholdSignatureRoleType::ZcashFrostP256 => { + rounds::keygen::run_threshold_keygen::( + Some(&mut tracer), + i, + t, + n, + role, + &mut rng, + party, + ) + .await + .map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })? + } + ThresholdSignatureRoleType::ZcashFrostRistretto255 => { + rounds::keygen::run_threshold_keygen::( + Some(&mut tracer), + i, + t, + n, + role, + &mut rng, + party, + ) + .await + .map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })? + } + ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { + rounds::keygen::run_threshold_keygen::( + Some(&mut tracer), + i, + t, + n, + role, + &mut rng, + party, + ) + .await + .map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })? + } + _ => unreachable!("Invalid role"), + }; + + let perf_report = tracer.get_report().map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })?; + logger.trace(format!("Incomplete Keygen protocol report: {perf_report}")); + logger.debug("Finished AsyncProtocol - Incomplete Keygen"); + + let job_result = handle_public_key_gossip( + key_store2, + &logger, + &frost_key_share_package.pubkey_package, + role, + t, + i, + broadcast_tx_to_outbound, + broadcast_rx_from_gadget, + ) + .await?; + + *protocol_output.lock().await = Some((frost_key_share_package, job_result)); + Ok(()) + }) + .post(async move { + // TODO: handle protocol blames + // Store the keys locally, as well as submitting them to the blockchain + if let Some((local_key, job_result)) = protocol_output_clone.lock().await.take() { + key_store + .set_job_result(additional_params.job_id, local_key) + .await + .map_err(|err| JobError { + reason: format!("Failed to store key: {err:?}"), + })?; + + client + .submit_job_result( + additional_params.role_type, + additional_params.job_id, + job_result, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to submit job result: {err:?}"), + })?; + } + + Ok(()) + }) + .build()) + } +} + +#[allow(clippy::too_many_arguments)] +async fn handle_public_key_gossip( + key_store: ECDSAKeyStore, + logger: &DebugLogger, + public_key_package: &Vec, + role: ThresholdSignatureRoleType, + t: u16, + i: u16, + broadcast_tx_to_outbound: futures::channel::mpsc::UnboundedSender, + mut broadcast_rx_from_gadget: futures::channel::mpsc::UnboundedReceiver, +) -> Result { + let key_hashed = keccak_256(&public_key_package); + let signature = key_store.pair().sign_prehashed(&key_hashed).0.to_vec(); + let my_id = key_store.pair().public(); + let mut received_keys = BTreeMap::new(); + received_keys.insert(i, signature.clone()); + let mut received_participants = BTreeMap::new(); + received_participants.insert(i, my_id); + + broadcast_tx_to_outbound + .unbounded_send(PublicKeyGossipMessage { + from: i as _, + to: None, + signature, + id: my_id, + }) + .map_err(|err| JobError { + reason: format!("Failed to send public key: {err:?}"), + })?; + + for _ in 0..t { + let message = broadcast_rx_from_gadget + .next() + .await + .ok_or_else(|| JobError { + reason: "Failed to receive public key".to_string(), + })?; + + let from = message.from; + logger.debug(format!("Received public key from {from}")); + + if received_keys.contains_key(&(from as u16)) { + logger.warn("Received duplicate key"); + continue; + } + // verify signature + let maybe_signature = sp_core::ecdsa::Signature::from_slice(&message.signature); + match maybe_signature.and_then(|s| s.recover_prehashed(&key_hashed)) { + Some(p) if p != message.id => { + logger.warn(format!( + "Received invalid signature from {from} not signed by them" + )); + } + Some(p) if p == message.id => { + logger.debug(format!("Received valid signature from {from}")); + } + Some(_) => unreachable!("Should not happen"), + None => { + logger.warn(format!("Received invalid signature from {from}")); + continue; + } + } + + received_keys.insert(from as u16, message.signature); + received_participants.insert(from as u16, message.id); + logger.debug(format!( + "Received {}/{} signatures", + received_keys.len(), + t + 1 + )); + } + + // Order and collect the map to ensure symmetric submission to blockchain + let signatures = received_keys + .into_iter() + .sorted_by_key(|x| x.0) + .map(|r| r.1) + .collect::>(); + + let participants = received_participants + .into_iter() + .sorted_by_key(|x| x.0) + .map(|r| r.1 .0.to_vec()) + .collect(); + + if signatures.len() < t as usize { + return Err(JobError { + reason: format!( + "Received {} signatures, expected at least {}", + signatures.len(), + t + 1, + ), + }); + } + + let res = DKGTSSKeySubmissionResult { + signature_type: match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 => DigitalSignatureType::SchnorrEd25519, + ThresholdSignatureRoleType::ZcashFrostP256 => DigitalSignatureType::SchnorrP256, + ThresholdSignatureRoleType::ZcashFrostRistretto255 => { + DigitalSignatureType::SchnorrSr25519 + } + ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { + DigitalSignatureType::SchnorrSecp256k1 + } + _ => unreachable!("Invalid role"), + }, + key: public_key_package.clone(), + participants, + signatures, + threshold: t as _, + }; + verify_generated_dkg_key_ecdsa(res.clone(), logger); + Ok(JobResult::DKGPhaseOne(res)) +} + +fn verify_generated_dkg_key_ecdsa(data: DKGTSSKeySubmissionResult, logger: &DebugLogger) { + // Ensure participants and signatures are not empty + assert!(!data.participants.is_empty(), "NoParticipantsFound",); + assert!(!data.signatures.is_empty(), "NoSignaturesFound"); + + // Generate the required ECDSA signers + let maybe_signers = data + .participants + .iter() + .map(|x| { + ecdsa::Public( + to_slice_33(x) + .unwrap_or_else(|| panic!("Failed to convert input to ecdsa public key")), + ) + }) + .collect::>(); + + assert!(!maybe_signers.is_empty(), "NoParticipantsFound"); + + let mut known_signers: Vec = Default::default(); + + for signature in data.signatures { + // Ensure the required signer signature exists + let (maybe_authority, success) = + verify_signer_from_set_ecdsa(maybe_signers.clone(), &data.key, &signature); + + if success { + let authority = maybe_authority.expect("CannotRetreiveSigner"); + + // Ensure no duplicate signatures + assert!(!known_signers.contains(&authority), "DuplicateSignature"); + + logger.debug(format!("Verified signature from {}", authority)); + known_signers.push(authority); + } + } + + // Ensure a sufficient number of unique signers are present + assert!( + known_signers.len() > data.threshold as usize, + "NotEnoughSigners" + ); + logger.debug(format!( + "Verified {}/{} signatures", + known_signers.len(), + data.threshold + 1 + )); +} + +pub fn verify_signer_from_set_ecdsa( + maybe_signers: Vec, + msg: &[u8], + signature: &[u8], +) -> (Option, bool) { + let mut signer = None; + let res = maybe_signers.iter().any(|x| { + if let Some(data) = recover_ecdsa_pub_key(msg, signature) { + let recovered = &data[..32]; + if x.0[1..].to_vec() == recovered.to_vec() { + signer = Some(*x); + true + } else { + false + } + } else { + false + } + }); + + (signer, res) +} + +pub fn recover_ecdsa_pub_key(data: &[u8], signature: &[u8]) -> Option> { + const SIGNATURE_LENGTH: usize = 65; + if signature.len() != SIGNATURE_LENGTH { + return None; + } + let mut sig = [0u8; SIGNATURE_LENGTH]; + sig[..SIGNATURE_LENGTH].copy_from_slice(signature); + + let hash = keccak_256(data); + + sp_io::crypto::secp256k1_ecdsa_recover(&sig, &hash) + .ok() + .map(|x| x.to_vec()) +} + +pub fn to_slice_33(val: &[u8]) -> Option<[u8; 33]> { + const ECDSA_KEY_LENGTH: usize = 33; + if val.len() == ECDSA_KEY_LENGTH { + let mut key = [0u8; ECDSA_KEY_LENGTH]; + key[..ECDSA_KEY_LENGTH].copy_from_slice(val); + + return Some(key); + } + None +} diff --git a/protocols/zcash-frost/src/protocols/mod.rs b/protocols/zcash-frost/src/protocols/mod.rs new file mode 100644 index 000000000..16b9199e9 --- /dev/null +++ b/protocols/zcash-frost/src/protocols/mod.rs @@ -0,0 +1,3 @@ +pub mod keygen; +pub mod sign; +pub mod util; diff --git a/protocols/zcash-frost/src/protocols/sign.rs b/protocols/zcash-frost/src/protocols/sign.rs new file mode 100644 index 000000000..4d55defe0 --- /dev/null +++ b/protocols/zcash-frost/src/protocols/sign.rs @@ -0,0 +1,468 @@ +use async_trait::async_trait; +use frost_core::keys::{KeyPackage, PublicKeyPackage}; +use frost_ed25519::Ed25519Sha512; +use frost_p256::P256Sha256; +use frost_ristretto255::Ristretto255Sha512; +use frost_secp256k1::Secp256K1Sha256; +use gadget_common::client::{AccountId, ClientWithApi, JobsClient}; +use gadget_common::debug_logger::DebugLogger; +use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; +use gadget_common::gadget::network::Network; +use gadget_common::gadget::work_manager::WorkManager; +use gadget_common::gadget::{GadgetProtocol, JobInitMetadata, WorkManagerConfig}; +use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; +use gadget_common::protocol::AsyncProtocol; +use gadget_common::{Block, BlockImportNotification}; +use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; +use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; +use pallet_jobs_rpc_runtime_api::JobsApi; +use rand::SeedableRng; +use round_based::MpcParty; +use sc_client_api::Backend; +use sp_api::ProvideRuntimeApi; +use sp_core::keccak_256; +use std::collections::HashMap; +use std::sync::Arc; +use tangle_primitives::jobs::{ + DKGTSSSignatureResult, DigitalSignatureType, JobId, JobResult, JobType, +}; +use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; +use tokio::sync::mpsc::UnboundedReceiver; + +use crate::rounds; +use crate::rounds::keygen::FrostKeyShare; + +pub struct ZCashFrostSigningProtocol { + client: JobsClient, + key_store: ECDSAKeyStore, + network: N, + logger: DebugLogger, + account_id: AccountId, +} + +pub async fn create_protocol( + account_id: AccountId, + client: JobsClient, + network: N, + logger: DebugLogger, + key_store: ECDSAKeyStore, +) -> ZCashFrostSigningProtocol +where + B: Block, + BE: Backend, + C: ClientWithApi, + KBE: KeystoreBackend, + N: Network, + >::Api: JobsApi, +{ + ZCashFrostSigningProtocol { + client, + network, + key_store, + logger, + account_id, + } +} + +#[async_trait] +impl< + B: Block, + BE: Backend + 'static, + C: ClientWithApi, + KBE: KeystoreBackend, + N: Network, + > GadgetProtocol for ZCashFrostSigningProtocol +where + >::Api: JobsApi, +{ + fn name(&self) -> String { + "zcash-frost-signing".to_string() + } + + async fn create_next_job( + &self, + job: JobInitMetadata, + ) -> Result<::AdditionalParams, gadget_common::Error> { + let job_id = job.job_id; + + let JobType::DKGTSSPhaseTwo(p2_job) = job.job_type else { + panic!("Should be valid type") + }; + let input_data_to_sign = p2_job.submission; + let previous_job_id = p2_job.phase_one_id; + + let phase1_job = job.phase1_job.expect("Should exist for a phase 2 job"); + let participants = phase1_job.clone().get_participants().expect("Should exist"); + let t = phase1_job.get_threshold().expect("Should exist") as u16; + + let seed = + keccak_256(&[&job_id.to_be_bytes()[..], &job.retry_id.to_be_bytes()[..]].concat()); + let mut rng = rand_chacha::ChaChaRng::from_seed(seed); + + let (i, signers, mapping) = + super::util::choose_signers(&mut rng, &self.account_id, &participants, t)?; + let key = self + .key_store + .get_job_result(previous_job_id) + .await + .map_err(|err| gadget_common::Error::ClientError { + err: err.to_string(), + })? + .ok_or_else(|| gadget_common::Error::ClientError { + err: format!("No key found for job ID: {job_id:?}"), + })?; + + let user_id_to_account_id_mapping = Arc::new(mapping); + + let params = ZCashFrostSigningExtraParams { + i, + t, + signers, + job_id, + role_type: job.role_type, + frost_keyshare: key, + input_data_to_sign, + user_id_to_account_id_mapping, + }; + Ok(params) + } + + async fn process_block_import_notification( + &self, + _notification: BlockImportNotification, + _job_manager: &ProtocolWorkManager, + ) -> Result<(), gadget_common::Error> { + Ok(()) + } + + async fn process_error( + &self, + error: gadget_common::Error, + _job_manager: &ProtocolWorkManager, + ) { + log::error!(target: "gadget", "Error: {error:?}"); + } + + fn account_id(&self) -> &AccountId { + &self.account_id + } + + fn role_filter(&self, role: RoleType) -> bool { + matches!( + role, + RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) + ) + } + + fn phase_filter(&self, job: JobType) -> bool { + matches!(job, JobType::DKGTSSPhaseTwo(_)) + } + + fn client(&self) -> &JobsClient { + &self.client + } + + fn logger(&self) -> &DebugLogger { + &self.logger + } + + fn get_work_manager_config(&self) -> WorkManagerConfig { + WorkManagerConfig { + interval: Some(crate::constants::signing_worker::JOB_POLL_INTERVAL), + max_active_tasks: crate::constants::signing_worker::MAX_RUNNING_TASKS, + max_pending_tasks: crate::constants::signing_worker::MAX_ENQUEUED_TASKS, + } + } +} + +pub struct ZCashFrostSigningExtraParams { + i: u16, + t: u16, + signers: Vec, + job_id: JobId, + role_type: RoleType, + frost_keyshare: FrostKeyShare, + input_data_to_sign: Vec, + user_id_to_account_id_mapping: Arc>, +} + +#[async_trait] +impl< + B: Block, + BE: Backend + 'static, + KBE: KeystoreBackend, + C: ClientWithApi, + N: Network, + > AsyncProtocol for ZCashFrostSigningProtocol +where + >::Api: JobsApi, +{ + type AdditionalParams = ZCashFrostSigningExtraParams; + async fn generate_protocol_from( + &self, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + protocol_message_channel: UnboundedReceiver, + additional_params: Self::AdditionalParams, + ) -> Result { + let debug_logger_post = self.logger.clone(); + let logger = debug_logger_post.clone(); + let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); + let protocol_output_clone = protocol_output.clone(); + let client = self.client.clone(); + let id = self.account_id; + let network = self.network.clone(); + + let (i, signers, t, frost_keyshare, role_type, input_data_to_sign, mapping) = ( + additional_params.i, + additional_params.signers, + additional_params.t, + additional_params.frost_keyshare, + additional_params.role_type, + additional_params.input_data_to_sign.clone(), + additional_params.user_id_to_account_id_mapping.clone(), + ); + + let role = match role_type { + RoleType::Tss(role) => role, + _ => { + return Err(JobError { + reason: "Invalid role type".to_string(), + }) + } + }; + + let frost_keyshare2 = frost_keyshare.clone(); + + Ok(JobBuilder::new() + .protocol(async move { + let mut rng = rand::rngs::StdRng::from_entropy(); + let protocol_message_channel = + super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + + logger.info(format!( + "Starting Signing Protocol with params: i={i}, t={t}" + )); + + let ( + signing_tx_to_outbound, + signing_rx_async_proto, + _broadcast_tx_to_outbound, + _broadcast_rx_from_gadget, + ) = super::util::create_job_manager_to_async_protocol_channel_split::<_, (), _>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + + let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); + let delivery = (signing_rx_async_proto, signing_tx_to_outbound); + let party = MpcParty::connected(delivery); + let data_hash = keccak_256(&input_data_to_sign); + let signature = match role { + ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { + let key_package = + KeyPackage::::deserialize(&frost_keyshare.key_package) + .map_err(|err| JobError { + reason: format!("Failed to deserialize key share: {err:?}"), + })?; + + let public_key_package = PublicKeyPackage::::deserialize( + &frost_keyshare.pubkey_package, + ) + .map_err(|err| JobError { + reason: format!("Failed to deserialize public key package: {err:?}"), + })?; + rounds::sign::run_threshold_sign( + Some(&mut tracer), + i, + signers, + (key_package, public_key_package), + &data_hash, + role, + &mut rng, + party, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to run threshold sign: {err:?}"), + })? + } + ThresholdSignatureRoleType::ZcashFrostEd25519 => { + let key_package = + KeyPackage::::deserialize(&frost_keyshare.key_package) + .map_err(|err| JobError { + reason: format!("Failed to deserialize key share: {err:?}"), + })?; + + let public_key_package = PublicKeyPackage::::deserialize( + &frost_keyshare.pubkey_package, + ) + .map_err(|err| JobError { + reason: format!("Failed to deserialize public key package: {err:?}"), + })?; + rounds::sign::run_threshold_sign( + Some(&mut tracer), + i, + signers, + (key_package, public_key_package), + &data_hash, + role, + &mut rng, + party, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to run threshold sign: {err:?}"), + })? + } + ThresholdSignatureRoleType::ZcashFrostP256 => { + let key_package = + KeyPackage::::deserialize(&frost_keyshare.key_package) + .map_err(|err| JobError { + reason: format!("Failed to deserialize key share: {err:?}"), + })?; + + let public_key_package = PublicKeyPackage::::deserialize( + &frost_keyshare.pubkey_package, + ) + .map_err(|err| JobError { + reason: format!("Failed to deserialize public key package: {err:?}"), + })?; + rounds::sign::run_threshold_sign( + Some(&mut tracer), + i, + signers, + (key_package, public_key_package), + &data_hash, + role, + &mut rng, + party, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to run threshold sign: {err:?}"), + })? + } + ThresholdSignatureRoleType::ZcashFrostRistretto255 => { + let key_package = KeyPackage::::deserialize( + &frost_keyshare.key_package, + ) + .map_err(|err| JobError { + reason: format!("Failed to deserialize key share: {err:?}"), + })?; + + let public_key_package = + PublicKeyPackage::::deserialize( + &frost_keyshare.pubkey_package, + ) + .map_err(|err| JobError { + reason: format!( + "Failed to deserialize public key package: {err:?}" + ), + })?; + rounds::sign::run_threshold_sign( + Some(&mut tracer), + i, + signers, + (key_package, public_key_package), + &data_hash, + role, + &mut rng, + party, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to run threshold sign: {err:?}"), + })? + } + _ => { + return Err(JobError { + reason: "Invalid role type".to_string(), + }) + } + }; + let perf_report = tracer.get_report().map_err(|err| JobError { + reason: format!("Signing protocol error: {err:?}"), + })?; + logger.trace(format!("Signing protocol report: {perf_report}")); + logger.debug("Finished AsyncProtocol - Signing"); + *protocol_output.lock().await = Some(signature); + Ok(()) + }) + .post(async move { + // Submit the protocol output to the blockchain + if let Some(signature) = protocol_output_clone.lock().await.take() { + // Compute the signature bytes by first converting the signature + // to a fixed byte array and then converting that to a Vec. + let (signature, signature_type) = match role { + ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { + let mut signature_bytes = [0u8; 64]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec(), + DigitalSignatureType::SchnorrSecp256k1, + ) + } + ThresholdSignatureRoleType::ZcashFrostEd25519 => { + let mut signature_bytes = [0u8; 64]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec(), + DigitalSignatureType::SchnorrEd25519, + ) + } + ThresholdSignatureRoleType::ZcashFrostP256 => { + let mut signature_bytes = [0u8; 64]; + signature_bytes.copy_from_slice(&signature.group_signature); + (signature_bytes.to_vec(), DigitalSignatureType::SchnorrP256) + } + ThresholdSignatureRoleType::ZcashFrostRistretto255 => { + let mut signature_bytes = [0u8; 64]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec(), + DigitalSignatureType::SchnorrSr25519, + ) + } + _ => { + return Err(JobError { + reason: "Invalid role type".to_string(), + }) + } + }; + + let job_result = JobResult::DKGPhaseTwo(DKGTSSSignatureResult { + signature_type, + signature, + data: additional_params.input_data_to_sign, + signing_key: frost_keyshare2.pubkey_package, + }); + + client + .submit_job_result( + additional_params.role_type, + additional_params.job_id, + job_result, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to submit job result: {err:?}"), + })?; + } + + Ok(()) + }) + .build()) + } +} diff --git a/protocols/zcash-frost/src/protocols/util.rs b/protocols/zcash-frost/src/protocols/util.rs new file mode 100644 index 000000000..952347990 --- /dev/null +++ b/protocols/zcash-frost/src/protocols/util.rs @@ -0,0 +1,507 @@ +#![allow(clippy::type_complexity, clippy::too_many_arguments)] +//! When delivering messages to an async protocol, we want to make sure we don't mix up voting and public key gossip messages +//! Thus, this file contains a function that takes a channel from the gadget to the async protocol and splits it into two channels +use futures::{Stream, StreamExt}; +use gadget_common::client::AccountId; +use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; +use gadget_common::gadget::network::Network; +use gadget_common::gadget::work_manager::WorkManager; +use gadget_core::job_manager::WorkManagerInterface; +use rand::seq::SliceRandom; +use round_based::{Incoming, MessageDestination, MessageType, Outgoing, PartyIndex}; +use serde::de::DeserializeOwned; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use std::sync::atomic::AtomicBool; +use std::sync::Arc; +use tokio::sync::mpsc::UnboundedReceiver; + +/// A Channel Receiver that can be cloned. +/// +/// On the second clone, the original channel will stop sending messages +/// and the new channel will start sending messages. +pub struct CloneableUnboundedReceiver { + rx: Arc>>, + is_in_use: Arc, +} + +impl Clone for CloneableUnboundedReceiver { + fn clone(&self) -> Self { + // on the clone, we switch the is_in_use flag to false + // and we return a new channel + self.is_in_use + .store(false, std::sync::atomic::Ordering::SeqCst); + Self { + rx: self.rx.clone(), + is_in_use: Arc::new(AtomicBool::new(true)), + } + } +} + +impl From> for CloneableUnboundedReceiver { + fn from(rx: UnboundedReceiver) -> Self { + Self { + rx: Arc::new(tokio::sync::Mutex::new(rx)), + is_in_use: Arc::new(AtomicBool::new(false)), + } + } +} + +impl Stream for CloneableUnboundedReceiver { + type Item = T; + fn poll_next( + self: std::pin::Pin<&mut Self>, + cx: &mut std::task::Context<'_>, + ) -> std::task::Poll> { + if !self.is_in_use.load(std::sync::atomic::Ordering::SeqCst) { + return std::task::Poll::Ready(None); + } + let mut rx = match self.rx.try_lock() { + Ok(rx) => rx, + Err(_) => return std::task::Poll::Pending, + }; + let rx = &mut *rx; + tokio::pin!(rx); + rx.poll_recv(cx) + } +} + +#[derive(Serialize, Deserialize, Debug)] +pub enum SplitChannelMessage { + Channel1(C1), + Channel2(C2), +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct VotingMessage { + pub from: UserID, + pub to: Option, + pub payload: Vec, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct PublicKeyGossipMessage { + pub from: UserID, + pub to: Option, + pub signature: Vec, + pub id: AccountId, +} + +/// All possible senders of a message +#[derive(Debug, Default, Serialize, Deserialize)] +pub enum MaybeSender { + /// We are the sender of the message + Myself, + /// The sender is someone else + /// it could also be us, double check the [`UserID`] + SomeoneElse(UserID), + /// The sender is unknown. + #[default] + Unknown, +} + +impl MaybeSender { + /// Returns `true` if the maybe sender is [`Myself`]. + /// + /// [`Myself`]: MaybeSender::Myself + #[must_use] + pub fn is_myself(&self) -> bool { + matches!(self, Self::Myself) + } + + /// Returns `true` if the maybe sender is [`Myself`]. + /// Or if the sender is [`SomeoneElse`] but the [`UserID`] is the same as `my_user_id` + /// + /// [`Myself`]: MaybeSender::Myself + /// [`SomeoneElse`]: MaybeSender::SomeoneElse + #[must_use] + pub fn is_myself_check(&self, my_user_id: UserID) -> bool { + match self { + Self::Myself => true, + Self::SomeoneElse(id) if (*id == my_user_id) => true, + _ => false, + } + } + + /// Returns `true` if the maybe sender is [`SomeoneElse`]. + /// + /// [`SomeoneElse`]: MaybeSender::SomeoneElse + #[must_use] + pub fn is_someone_else(&self) -> bool { + matches!(self, Self::SomeoneElse(..)) + } + + /// Returns `true` if the maybe sender is [`Unknown`]. + /// + /// [`Unknown`]: MaybeSender::Unknown + #[must_use] + pub fn is_unknown(&self) -> bool { + matches!(self, Self::Unknown) + } + + /// Returns the sender as [`UserID`] if it is knwon. + #[must_use] + pub fn as_user_id(&self) -> Option { + match self { + Self::Myself => None, + Self::SomeoneElse(id) => Some(*id), + Self::Unknown => None, + } + } +} + +#[derive(Debug, Default, Serialize, Deserialize)] +pub enum MaybeReceiver { + /// The message is broadcasted to everyone + Broadcast, + /// The message is sent to a specific party + P2P(UserID), + /// The receiver is us. + Myself, + /// The receiver is unknown. + #[default] + Unknown, +} + +impl MaybeReceiver { + /// Returns `true` if the maybe receiver is [`Broadcast`]. + /// + /// [`Broadcast`]: MaybeReceiver::Broadcast + #[must_use] + pub fn is_broadcast(&self) -> bool { + matches!(self, Self::Broadcast) + } + + /// Returns `true` if the maybe receiver is [`P2P`]. + /// + /// [`P2P`]: MaybeReceiver::P2P + #[must_use] + pub fn is_p2_p(&self) -> bool { + matches!(self, Self::P2P(..)) + } + + /// Returns `true` if the maybe receiver is [`Myself`]. + /// + /// [`Myself`]: MaybeReceiver::Myself + #[must_use] + pub fn is_myself(&self) -> bool { + matches!(self, Self::Myself) + } + + /// Returns `true` if the maybe receiver is [`Myself`] + /// Or if the receiver is [`P2P`] but the [`UserID`] is the same as `my_user_id` + /// + /// [`Myself`]: MaybeReceiver::Myself + /// [`P2P`]: MaybeReceiver::P2P + #[must_use] + pub fn is_myself_check(&self, my_user_id: UserID) -> bool { + match self { + Self::Myself => true, + Self::P2P(id) if (*id == my_user_id) => true, + _ => false, + } + } + + /// Returns `true` if the maybe receiver is [`Unknown`]. + /// + /// [`Unknown`]: MaybeReceiver::Unknown + #[must_use] + pub fn is_unknown(&self) -> bool { + matches!(self, Self::Unknown) + } + + /// Returns the receiver as [`UserID`] if it is knwon. + #[must_use] + pub fn as_user_id(&self) -> Option { + match self { + Self::Broadcast => None, + Self::P2P(id) => Some(*id), + Self::Myself => None, + Self::Unknown => None, + } + } +} + +/// A Simple trait to extract the sender and the receiver from a message +pub trait MaybeSenderReceiver { + fn maybe_sender(&self) -> MaybeSender; + fn maybe_receiver(&self) -> MaybeReceiver; +} + +impl MaybeSenderReceiver for PublicKeyGossipMessage { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::SomeoneElse(self.from) + } + fn maybe_receiver(&self) -> MaybeReceiver { + match self.to { + Some(id) => MaybeReceiver::P2P(id), + None => MaybeReceiver::Broadcast, + } + } +} + +impl MaybeSenderReceiver for VotingMessage { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::SomeoneElse(self.from) + } + fn maybe_receiver(&self) -> MaybeReceiver { + match self.to { + Some(id) => MaybeReceiver::P2P(id), + None => MaybeReceiver::Broadcast, + } + } +} + +impl MaybeSenderReceiver for Outgoing { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::Myself + } + + fn maybe_receiver(&self) -> MaybeReceiver { + match self.recipient { + MessageDestination::AllParties => MaybeReceiver::Broadcast, + MessageDestination::OneParty(i) => MaybeReceiver::P2P(i as UserID), + } + } +} + +impl MaybeSenderReceiver for Incoming { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::SomeoneElse(self.sender as UserID) + } + + fn maybe_receiver(&self) -> MaybeReceiver { + match self.msg_type { + MessageType::Broadcast => MaybeReceiver::Broadcast, + MessageType::P2P => MaybeReceiver::Myself, + } + } +} + +impl MaybeSenderReceiver for () { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::Unknown + } + + fn maybe_receiver(&self) -> MaybeReceiver { + MaybeReceiver::Unknown + } +} + +pub(crate) fn create_job_manager_to_async_protocol_channel_split< + N: Network + 'static, + C2: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, + M: Serialize + DeserializeOwned + Send + 'static, +>( + mut rx_gadget: CloneableUnboundedReceiver, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + user_id_mapping: Arc>, + my_account_id: AccountId, + network: N, +) -> ( + futures::channel::mpsc::UnboundedSender>, + futures::channel::mpsc::UnboundedReceiver< + Result, futures::channel::mpsc::TryRecvError>, + >, + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver, +) { + let (tx_to_async_proto_1, rx_for_async_proto_1) = futures::channel::mpsc::unbounded(); + let (tx_to_async_proto_2, rx_for_async_proto_2) = futures::channel::mpsc::unbounded(); + + // Take the messages from the gadget and send them to the async protocol + tokio::task::spawn(async move { + let mut id = 0; + while let Some(msg_orig) = rx_gadget.next().await { + if msg_orig.payload.is_empty() { + log::warn!(target: "gadget", "Received empty message from Peer {}", msg_orig.from); + continue; + } + match bincode2::deserialize::>(&msg_orig.payload) { + Ok(msg) => match msg { + SplitChannelMessage::Channel1(msg) => { + let msg_type = if msg_orig.to.is_some() { + MessageType::P2P + } else { + MessageType::Broadcast + }; + let incoming = Incoming { + id, + sender: msg_orig.from as PartyIndex, + msg_type, + msg, + }; + + if tx_to_async_proto_1.unbounded_send(Ok(incoming)).is_err() { + log::error!(target: "gadget", "Failed to send Incoming message to protocol"); + } + + id += 1; + } + SplitChannelMessage::Channel2(msg) => { + if tx_to_async_proto_2.unbounded_send(msg).is_err() { + log::error!(target: "gadget", "Failed to send C2 message to protocol"); + } + } + }, + Err(err) => { + log::error!(target: "gadget", "Failed to deserialize message: {err:?}"); + } + } + } + }); + + let (tx_to_outbound_1, mut rx_to_outbound_1) = + futures::channel::mpsc::unbounded::>(); + let (tx_to_outbound_2, mut rx_to_outbound_2) = futures::channel::mpsc::unbounded::(); + let network_clone = network.clone(); + let user_id_mapping_clone = user_id_mapping.clone(); + let my_user_id = user_id_mapping + .iter() + .find_map(|(user_id, account_id)| { + if *account_id == my_account_id { + Some(*user_id) + } else { + None + } + }) + .expect("Failed to find my user id"); + // Take the messages from the async protocol and send them to the gadget + tokio::task::spawn(async move { + let offline_task = async move { + while let Some(msg) = rx_to_outbound_1.next().await { + let from = msg.maybe_sender(); + let to = msg.maybe_receiver(); + let (to_account_id, from_account_id) = get_to_and_from_account_id( + &user_id_mapping_clone, + from.as_user_id().unwrap_or(my_user_id), + to.as_user_id(), + ); + let msg = SplitChannelMessage::::Channel1(msg.msg); + let msg = GadgetProtocolMessage { + associated_block_id, + associated_session_id, + associated_retry_id, + task_hash: associated_task_id, + from: from.as_user_id().unwrap_or(my_user_id), + to: to.as_user_id(), + payload: bincode2::serialize(&msg).expect("Failed to serialize message"), + from_network_id: from_account_id, + to_network_id: to_account_id, + }; + + if let Err(err) = network.send_message(msg).await { + log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + } + } + }; + + let voting_task = async move { + while let Some(msg) = rx_to_outbound_2.next().await { + let from = msg.maybe_sender(); + let to = msg.maybe_receiver(); + let (to_account_id, from_account_id) = get_to_and_from_account_id( + &user_id_mapping, + from.as_user_id().unwrap_or(my_user_id), + to.as_user_id(), + ); + let msg = SplitChannelMessage::::Channel2(msg); + let msg = GadgetProtocolMessage { + associated_block_id, + associated_session_id, + associated_retry_id, + task_hash: associated_task_id, + from: from.as_user_id().unwrap_or(my_user_id), + to: to.as_user_id(), + payload: bincode2::serialize(&msg).expect("Failed to serialize message"), + from_network_id: from_account_id, + to_network_id: to_account_id, + }; + + if let Err(err) = network_clone.send_message(msg).await { + log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + } + } + }; + + tokio::join!(offline_task, voting_task); + }); + + ( + tx_to_outbound_1, + rx_for_async_proto_1, + tx_to_outbound_2, + rx_for_async_proto_2, + ) +} + +fn get_to_and_from_account_id( + mapping: &HashMap, + from: UserID, + to: Option, +) -> (Option, Option) { + let from_account_id = mapping.get(&from).cloned(); + let to_account_id = if let Some(to) = to { + mapping.get(&to).cloned() + } else { + None + }; + + (to_account_id, from_account_id) +} + +/// Given a list of participants, choose `t` of them and return the index of the current participant +/// and the indices of the chosen participants, as well as a mapping from the index to the account +/// id. +/// +/// # Errors +/// If we are not selected to sign the message it will return an error +/// [`gadget_common::Error::ParticipantNotSelected`]. +/// +/// # Panics +/// If the current participant is not in the list of participants it will panic. +pub fn choose_signers( + rng: &mut R, + my_account_id: &AccountId, + participants: &[AccountId], + t: u16, +) -> Result<(u16, Vec, HashMap), gadget_common::Error> { + let selected_participants = participants + .choose_multiple(rng, t as usize) + .cloned() + .collect::>(); + + let selected_participants_indices = selected_participants + .iter() + .map(|p| participants.iter().position(|x| x == p).unwrap() as u16) + .collect::>(); + + let j = participants + .iter() + .position(|p| p == my_account_id) + .expect("Should exist") as u16; + + let i = selected_participants_indices + .iter() + .position(|p| p == &j) + .map(|i| i as u16) + .ok_or_else(|| gadget_common::Error::ParticipantNotSelected { + id: *my_account_id, + reason: String::from("we are not selected to sign"), + })?; + + let user_id_to_account_id_mapping = selected_participants + .clone() + .into_iter() + .enumerate() + .map(|(i, p)| (i as UserID, p)) + .collect(); + Ok(( + i, + selected_participants_indices, + user_id_to_account_id_mapping, + )) +} diff --git a/protocols/zcash-frost/src/rounds/errors.rs b/protocols/zcash-frost/src/rounds/errors.rs new file mode 100644 index 000000000..18abec701 --- /dev/null +++ b/protocols/zcash-frost/src/rounds/errors.rs @@ -0,0 +1,43 @@ +use std::convert::Infallible; + +use round_based::rounds_router::{ + errors::{self as router_error, CompleteRoundError}, + simple_store::RoundInputError, +}; +use thiserror::Error; + +pub type BoxedError = Box; + +#[derive(Debug, Error)] +pub enum IoError { + #[error("send message")] + SendMessage(#[source] BoxedError), + #[error("receive message")] + ReceiveMessage(#[source] BoxedError), + #[error("got eof while recieving messages")] + ReceiveMessageEof, + #[error("route received message (possibly malicious behavior)")] + RouteReceivedError(router_error::CompleteRoundError), +} + +impl IoError { + pub fn send_message(err: E) -> Self { + Self::SendMessage(Box::new(err)) + } + + pub fn receive_message( + err: CompleteRoundError, + ) -> Self { + match err { + CompleteRoundError::Io(router_error::IoError::Io(e)) => { + Self::ReceiveMessage(Box::new(e)) + } + CompleteRoundError::Io(router_error::IoError::UnexpectedEof) => Self::ReceiveMessageEof, + + CompleteRoundError::ProcessMessage(e) => { + Self::RouteReceivedError(CompleteRoundError::ProcessMessage(e)) + } + CompleteRoundError::Other(e) => Self::RouteReceivedError(CompleteRoundError::Other(e)), + } + } +} diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs new file mode 100644 index 000000000..aee199520 --- /dev/null +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -0,0 +1,274 @@ +use std::collections::BTreeMap; + +use dfns_cggmp21::{progress::Tracer, round_based::ProtocolMessage}; +use digest::Digest; +use frost_core::Field; +use frost_core::{ + keys::{ + dkg::{round1, round2}, + KeyPackage, PublicKeyPackage, + }, + Ciphersuite, Error, Group, Identifier, +}; +use futures::SinkExt; +use rand_core::{CryptoRng, RngCore}; +use round_based::{ + rounds_router::simple_store::RoundInput, + rounds_router::{simple_store::RoundMsgs, RoundsRouter}, + Delivery, Mpc, MpcParty, Outgoing, +}; +use serde::{Deserialize, Serialize}; +use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; + +use super::{errors::IoError, KeygenAborted, KeygenError, Reason}; + +/// Message of key generation protocol +#[derive(ProtocolMessage, Clone, Serialize, Deserialize)] +#[serde(bound = "")] +pub enum Msg { + /// Round 1 message + Round1(MsgRound1), + /// Round 2 message + Round2(MsgRound2), + /// Round 3 message + Round3(MsgRound3), +} + +/// Message from round 1 +#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] +#[serde(bound = "")] +#[udigest(bound = "")] +#[udigest(tag = "zcash.frost.keygen.threshold.round1")] +pub struct MsgRound1 { + pub msg: Vec, +} +/// Message from round 2 +#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] +#[serde(bound = "")] +#[udigest(bound = "")] +#[udigest(tag = "zcash.frost.keygen.threshold.round2")] +pub struct MsgRound2 { + pub msg: Vec, +} +/// Message from round 3 +#[derive(Clone, Serialize, Deserialize)] +#[serde(bound = "")] +pub struct MsgRound3 { + pub msg: Vec, +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct FrostKeyShare { + pub key_package: Vec, + pub pubkey_package: Vec, +} + +pub async fn run_threshold_keygen( + mut tracer: Option<&mut dyn Tracer>, + i: u16, + t: u16, + n: u16, + role: ThresholdSignatureRoleType, + rng: &mut R, + party: M, +) -> Result> +where + R: RngCore + CryptoRng, + M: Mpc, + C: Ciphersuite, +{ + tracer.protocol_begins(); + + tracer.stage("Setup networking"); + let MpcParty { delivery, .. } = party.into_party(); + let (incomings, mut outgoings) = delivery.split(); + + let mut rounds = RoundsRouter::::builder(); + let round1 = rounds.add_round(RoundInput::::broadcast(i, n)); + let round2 = rounds.add_round(RoundInput::::p2p(i, n)); + let mut rounds = rounds.listen(incomings); + + // Round 1 + tracer.round_begins(); + + tracer.stage("Compute round 1 dkg secret package"); + let (round1_secret_package, round1_package) = dkg_part1(i, n, t, role, rng).map_err(|e| { + KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { + parties: vec![], + error: e, + })) + })?; + + tracer.send_msg(); + let my_round1_msg = MsgRound1 { + msg: round1_package.serialize().unwrap_or_default(), + }; + outgoings + .send(Outgoing::broadcast(Msg::Round1(my_round1_msg.clone()))) + .await + .map_err(|e| KeygenError(Reason::IoError(IoError::send_message(e))))?; + tracer.msg_sent(); + + // Round 2 + tracer.round_begins(); + + tracer.receive_msgs(); + let round1_packages: Vec> = rounds + .complete(round1) + .await + .map_err(|e| KeygenError(Reason::IoError(IoError::receive_message(e))))? + .into_vec_including_me(my_round1_msg) + .into_iter() + .map(|msg| { + round1::Package::deserialize(&msg.msg) + .unwrap_or_else(|_| panic!("Failed to deserialize round 1 package")) + }) + .collect(); + tracer.msgs_received(); + + tracer.stage("Compute round 2 dkg secret package"); + let round1_packages_map: BTreeMap, round1::Package> = round1_packages + .iter() + .enumerate() + .map(|(inx, p)| { + ( + ((inx + 1) as u16).try_into().expect("should be nonzero"), + p.clone(), + ) + }) + .collect(); + let (round2_secret_package, round2_packages_map) = + dkg_part2(role, round1_secret_package, &round1_packages_map).map_err(|e| { + KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { + parties: vec![], + error: e, + })) + })?; + + tracer.send_msg(); + for (receiver_identifier, round2_package) in round2_packages_map { + let receiver_index_be_bytes: [u8; 2] = receiver_identifier + .serialize() + .as_ref() + .try_into() + .expect("should be 2 bytes"); + let receiver_index = u16::from_be_bytes(receiver_index_be_bytes); + outgoings + .send(Outgoing::p2p( + receiver_index, + Msg::Round2(MsgRound2 { + msg: round2_package.serialize().unwrap_or_default(), + }), + )) + .await + .map_err(|e| KeygenError(Reason::IoError(IoError::send_message(e))))?; + } + tracer.msg_sent(); + + // Round 3 + tracer.round_begins(); + + tracer.receive_msgs(); + let round2_packages: RoundMsgs = rounds + .complete(round2) + .await + .map_err(|e| KeygenError(Reason::IoError(IoError::receive_message(e))))?; + tracer.msgs_received(); + + tracer.stage("Compute round 3 dkg secret package"); + let round2_packages_map: BTreeMap, round2::Package> = round2_packages + .into_iter_indexed() + .map(|(inx, msg_id, msg)| { + let identifier = (inx as u16 + 1).try_into().expect("should be nonzero"); + let package = round2::Package::deserialize(&msg.msg) + .unwrap_or_else(|_| panic!("Failed to deserialize round 2 package")); + (identifier, package) + }) + .collect(); + let (key_package, pubkey_package) = dkg_part3( + role, + &round2_secret_package, + &round1_packages_map, + &round2_packages_map, + ) + .map_err(|e| { + KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { + parties: vec![], + error: e, + })) + })?; + + tracer.protocol_ends(); + + Ok(FrostKeyShare { + key_package: key_package.serialize().unwrap_or_default(), + pubkey_package: pubkey_package.serialize().unwrap_or_default(), + }) +} + +pub fn dkg_part1( + i: u16, + t: u16, + n: u16, + role: ThresholdSignatureRoleType, + mut rng: R, +) -> Result<(round1::SecretPackage, round1::Package), Error> +where + R: RngCore + CryptoRng, + C: Ciphersuite, +{ + match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostP256 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} + _ => panic!("Invalid role"), + }; + let participant_identifier = i.try_into().expect("should be nonzero"); + frost_core::keys::dkg::part1::(participant_identifier, t, n, rng) +} + +pub fn dkg_part2( + role: ThresholdSignatureRoleType, + secret_package: round1::SecretPackage, + round1_packages: &BTreeMap, round1::Package>, +) -> Result< + ( + round2::SecretPackage, + BTreeMap, round2::Package>, + ), + Error, +> +where + C: Ciphersuite, +{ + match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostP256 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} + _ => panic!("Invalid role"), + }; + + frost_core::keys::dkg::part2::(secret_package, round1_packages) +} + +pub fn dkg_part3( + role: ThresholdSignatureRoleType, + round2_secret_package: &round2::SecretPackage, + round1_packages: &BTreeMap, round1::Package>, + round2_packages: &BTreeMap, round2::Package>, +) -> Result<(KeyPackage, PublicKeyPackage), Error> +where + C: Ciphersuite, +{ + match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostP256 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} + _ => panic!("Invalid role"), + }; + + frost_core::keys::dkg::part3::(round2_secret_package, round1_packages, round2_packages) +} diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs new file mode 100644 index 000000000..1ed1f48a6 --- /dev/null +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -0,0 +1,123 @@ +use frost_core::{Ciphersuite, FieldError}; +use frost_ed25519::Ed25519Sha512; +use frost_ed448::Ed448Shake256; +use frost_p256::P256Sha256; +use frost_p384::P384Sha384; +use frost_redjubjub::JubjubBlake2b512; +use frost_ristretto255::Ristretto255Sha512; +use frost_secp256k1::Secp256K1Sha256; +use frost_taproot::Secp256K1Taproot; +use thiserror::Error; + +use self::errors::{BoxedError, IoError}; + +pub mod errors; +pub mod keygen; +pub mod sign; + +/// Keygen protocol error +#[derive(Debug, Error)] +#[error("keygen protocol is failed to complete")] +pub struct KeygenError(#[source] Reason); + +macro_rules! impl_keygen_error_from { + ($ciphersuite:ty) => { + impl From> for KeygenError<$ciphersuite> { + fn from(err: KeygenAborted<$ciphersuite>) -> Self { + KeygenError(Reason::KeygenFailure(err)) + } + } + + impl From for KeygenError<$ciphersuite> { + fn from(err: IoError) -> Self { + KeygenError(Reason::IoError(err)) + } + } + }; +} + +impl_keygen_error_from!(Ed25519Sha512); +impl_keygen_error_from!(P256Sha256); +impl_keygen_error_from!(P384Sha384); +impl_keygen_error_from!(Ristretto255Sha512); +impl_keygen_error_from!(Secp256K1Sha256); +impl_keygen_error_from!(Ed448Shake256); +impl_keygen_error_from!(JubjubBlake2b512); +impl_keygen_error_from!(Secp256K1Taproot); + +/// Sign protocol error +#[derive(Debug, Error)] +#[error("keygen protocol is failed to complete")] +pub struct SignError(#[source] Reason); + +macro_rules! impl_sign_error_from { + ($ciphersuite:ty) => { + impl From> for SignError<$ciphersuite> { + fn from(err: SignAborted<$ciphersuite>) -> Self { + SignError(Reason::SignFailure(err)) + } + } + + impl From for SignError<$ciphersuite> { + fn from(err: IoError) -> Self { + SignError(Reason::IoError(err)) + } + } + }; +} + +impl_sign_error_from!(Ed25519Sha512); +impl_sign_error_from!(P256Sha256); +impl_sign_error_from!(P384Sha384); +impl_sign_error_from!(Ristretto255Sha512); +impl_sign_error_from!(Secp256K1Sha256); +impl_sign_error_from!(Ed448Shake256); +impl_sign_error_from!(JubjubBlake2b512); +impl_sign_error_from!(Secp256K1Taproot); + +#[derive(Debug, Error)] +enum Reason { + /// Keygen protocol was maliciously aborted by another party + #[error("keygen protocol was aborted by malicious party")] + KeygenFailure( + #[source] + #[from] + KeygenAborted, + ), + #[error("sign protocol was aborted by malicious party")] + SignFailure( + #[source] + #[from] + SignAborted, + ), + #[error("field error")] + FieldError(#[source] FieldError), + #[error("i/o error")] + IoError(#[source] IoError), + #[error("unknown error")] + SerializationError, +} + +/// Error indicating that protocol was aborted by malicious party +/// +/// It _can be_ cryptographically proven, but we do not support it yet. +#[derive(Debug, Error)] +enum KeygenAborted { + #[error("Frost keygen error")] + FrostError { + parties: Vec, + error: frost_core::Error, + }, +} + +/// Sign protocol error +/// +/// It _can be_ cryptographically proven, but we do not support it yet. +#[derive(Debug, Error)] +enum SignAborted { + #[error("Frost sign error")] + FrostError { + parties: Vec, + error: frost_core::Error, + }, +} diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs new file mode 100644 index 000000000..d154a1038 --- /dev/null +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -0,0 +1,245 @@ +use dfns_cggmp21::progress::Tracer; +use dfns_cggmp21::round_based::ProtocolMessage; +use frost_core::keys::{KeyPackage, PublicKeyPackage}; +use frost_core::round1::{SigningCommitments, SigningNonces}; +use frost_core::round2::{self, SignatureShare}; +use frost_core::{ + aggregate, round1, Ciphersuite, Field, Group, Identifier, Signature, SigningPackage, +}; +use futures::SinkExt; +use rand_core::{CryptoRng, RngCore}; +use round_based::rounds_router::simple_store::RoundInput; +use round_based::rounds_router::RoundsRouter; +use round_based::{Delivery, Mpc, MpcParty, Outgoing}; +use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; +use tangle_primitives::roles::ThresholdSignatureRoleType; + +use super::errors::IoError; +use super::{Reason, SignAborted, SignError}; + +/// Message of key generation protocol +#[derive(ProtocolMessage, Clone, Serialize, Deserialize)] +#[serde(bound = "")] +pub enum Msg { + /// Round 1 message + Round1(MsgRound1), + /// Round 2 message + Round2(MsgRound2), +} + +/// Message from round 1 +#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] +#[serde(bound = "")] +#[udigest(bound = "")] +#[udigest(tag = "zcash.frost.sign.threshold.round1")] +pub struct MsgRound1 { + pub msg: Vec, +} +/// Message from round 2 +#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] +#[serde(bound = "")] +#[udigest(bound = "")] +#[udigest(tag = "zcash.frost.sign.threshold.round2")] +pub struct MsgRound2 { + pub msg: Vec, +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct FrostSignature { + pub group_signature: Vec, +} + +pub async fn run_threshold_sign( + mut tracer: Option<&mut dyn Tracer>, + i: u16, + signers: Vec, + frost_keyshare: (KeyPackage, PublicKeyPackage), + message_to_sign: &[u8], + role: ThresholdSignatureRoleType, + rng: &mut R, + party: M, +) -> Result> +where + R: RngCore + CryptoRng, + M: Mpc, + C: Ciphersuite, +{ + tracer.protocol_begins(); + + tracer.stage("Setup networking"); + let MpcParty { delivery, .. } = party.into_party(); + let (incomings, mut outgoings) = delivery.split(); + + let mut rounds = RoundsRouter::::builder(); + let round1 = rounds.add_round(RoundInput::::broadcast(i, signers.len() as u16)); + let round2 = rounds.add_round(RoundInput::::broadcast(i, signers.len() as u16)); + let mut rounds = rounds.listen(incomings); + + // Round 1 + tracer.round_begins(); + + tracer.send_msg(); + tracer.stage("Generate nonces and commitments for Round 1"); + let (nonces, commitments) = participant_round1(role, &frost_keyshare.0, rng); + let my_round1_msg = MsgRound1 { + msg: commitments.serialize().unwrap_or_default(), + }; + outgoings + .send(Outgoing::broadcast(Msg::Round1(my_round1_msg.clone()))) + .await + .map_err(|e| SignError(Reason::IoError(IoError::send_message(e))))?; + tracer.msg_sent(); + + // Round 2 + tracer.round_begins(); + + tracer.receive_msgs(); + let round1_signing_commitments: BTreeMap, SigningCommitments> = rounds + .complete(round1) + .await + .map_err(|e| SignError(Reason::IoError(IoError::receive_message(e))))? + .into_iter_indexed() + .map(|(party_inx, msg_id, msg)| { + let msg = SigningCommitments::::deserialize(&msg.msg) + .unwrap_or_else(|_| panic!("Failed to deserialize round 1 signing commitments")); + let participant_identifier = Identifier::::try_from(party_inx) + .expect("Failed to convert party index to identifier"); + (participant_identifier, msg) + }) + .collect(); + tracer.msgs_received(); + + tracer.send_msg(); + tracer.stage( + "Produce signature share using the `SigningPackage` and `SigningNonces` from Round 1", + ); + let signing_package = SigningPackage::::new(round1_signing_commitments, message_to_sign); + let signature_share = participant_round2(role, &signing_package, &nonces, &frost_keyshare.0)?; + outgoings + .send(Outgoing::broadcast(Msg::Round2(MsgRound2 { + msg: signature_share.serialize().as_ref().to_vec(), + }))) + .await + .map_err(|e| SignError(Reason::IoError(IoError::send_message(e))))?; + tracer.msg_sent(); + + // Aggregation / output round + tracer.round_begins(); + + tracer.receive_msgs(); + let round2_signature_shares: BTreeMap, SignatureShare> = rounds + .complete(round2) + .await + .map_err(|e| SignError(Reason::IoError(IoError::receive_message(e))))? + .into_vec_including_me(MsgRound2 { + msg: signature_share.serialize().as_ref().to_vec(), + }) + .into_iter() + .enumerate() + .map(|(party_inx, msg)| { + let participant_identifier = Identifier::::try_from(party_inx as u16) + .expect("Failed to convert party index to identifier"); + let ser = <::Field as Field>::Serialization::try_from(msg.msg) + .map_err(|e| SignError(Reason::::SerializationError)) + .expect("Failed to deserialize round 2 signature share"); + let sig_share = SignatureShare::::deserialize(ser) + .unwrap_or_else(|_| panic!("Failed to deserialize round 2 signature share")); + (participant_identifier, sig_share) + }) + .collect(); + tracer.msgs_received(); + + let group_signature = aggregate( + &signing_package, + &round2_signature_shares, + &frost_keyshare.1, + ) + .map_err(|e| { + SignError(Reason::SignFailure(SignAborted::FrostError { + parties: vec![], + error: e, + })) + })?; + + tracer.protocol_ends(); + + Ok(FrostSignature { + group_signature: group_signature.serialize().as_ref().to_vec(), + }) +} + +/// Participant generates nonces and commitments for Round 1. +fn participant_round1( + role: ThresholdSignatureRoleType, + key_package: &KeyPackage, + rng: &mut R, +) -> (SigningNonces, SigningCommitments) { + match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostP256 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} + _ => panic!("Invalid role"), + }; + + round1::commit(key_package.signing_share(), rng) +} + +/// Participant produces their signature share using the `SigningPackage` and their `SigningNonces` from Round 1. +fn participant_round2( + role: ThresholdSignatureRoleType, + signing_package: &SigningPackage, + nonces: &SigningNonces, + key_package: &KeyPackage, +) -> Result, SignError> { + match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostP256 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} + _ => panic!("Invalid role"), + }; + + round2::sign(signing_package, nonces, key_package).map_err(|e| { + SignError(Reason::SignFailure(SignAborted::FrostError { + parties: vec![], + error: e, + })) + }) +} + +/// Aggregates the `SignatureShares` from the participants to produce the final group signature. +fn signature_share_aggregate( + role: ThresholdSignatureRoleType, + signing_package: &SigningPackage, + signature_shares: &BTreeMap, SignatureShare>, + pubkey_package: &PublicKeyPackage, +) -> Result, SignError> { + match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostP256 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} + _ => panic!("Invalid role"), + }; + + aggregate(signing_package, signature_shares, pubkey_package).map_err(|e| { + SignError(Reason::SignFailure(SignAborted::FrostError { + parties: vec![], + error: e, + })) + }) +} + +/// Verifies the group signature. +fn verify_signature( + pubkey_package: &PublicKeyPackage, + message: &[u8], + group_signature: &Signature, +) -> bool { + pubkey_package + .verifying_key() + .verify(message, group_signature) + .is_ok() +} From fa91973b57dccd1166d9e740a41ebdc8ee2aaa75 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 31 Jan 2024 14:22:49 -0500 Subject: [PATCH 03/66] Clippy, fmt, renaming --- protocols/zcash-frost/src/lib.rs | 12 +- protocols/zcash-frost/src/network.rs | 4 +- protocols/zcash-frost/src/protocol.rs | 12 +- protocols/zcash-frost/src/protocols/keygen.rs | 23 +- protocols/zcash-frost/src/protocols/sign.rs | 16 +- protocols/zcash-frost/src/rounds/keygen.rs | 13 +- protocols/zcash-frost/src/rounds/mod.rs | 6 +- protocols/zcash-frost/src/rounds/sign.rs | 50 +--- protocols/zcash-frost/tests/frost.rs | 260 ++++++++++++++++++ 9 files changed, 311 insertions(+), 85 deletions(-) create mode 100644 protocols/zcash-frost/tests/frost.rs diff --git a/protocols/zcash-frost/src/lib.rs b/protocols/zcash-frost/src/lib.rs index 8ceb2831a..58693e891 100644 --- a/protocols/zcash-frost/src/lib.rs +++ b/protocols/zcash-frost/src/lib.rs @@ -3,8 +3,8 @@ use gadget_common::config::*; use gadget_common::keystore::ECDSAKeyStore; use gadget_common::keystore::KeystoreBackend; use protocol_macros::protocol; -use protocols::keygen::ZCashFrostKeygenProtocol; -use protocols::sign::ZCashFrostSigningProtocol; +use protocols::keygen::ZcashFrostKeygenProtocol; +use protocols::sign::ZcashFrostSigningProtocol; use std::sync::Arc; pub mod constants; @@ -87,8 +87,8 @@ macro_rules! decl_porto { // A macro to declare all the protocols decl_porto!( - ZCashFrostKeygenConfig + ZCashFrostKeygenProtocol = protocols::keygen, - ZCashFrostSigningConfig + ZCashFrostSigningProtocol = protocols::sign, + ZcashFrostKeygenConfig + ZcashFrostKeygenProtocol = protocols::keygen, + ZcashFrostSigningConfig + ZcashFrostSigningProtocol = protocols::sign, ); #[allow(clippy::too_many_arguments)] @@ -110,7 +110,7 @@ where >::Api: JobsApi, { let pallet_tx = Arc::new(pallet_tx) as Arc; - let keygen_config = ZCashFrostKeygenConfig { + let keygen_config = ZcashFrostKeygenConfig { account_id, network: network_keygen, keystore_backend: keystore.clone(), @@ -120,7 +120,7 @@ where _pd: std::marker::PhantomData, }; - let sign_config = ZCashFrostSigningConfig { + let sign_config = ZcashFrostSigningConfig { account_id, network: network_signing, keystore_backend: keystore.clone(), diff --git a/protocols/zcash-frost/src/network.rs b/protocols/zcash-frost/src/network.rs index fd4419881..87ca56d0f 100644 --- a/protocols/zcash-frost/src/network.rs +++ b/protocols/zcash-frost/src/network.rs @@ -4,10 +4,10 @@ use gadget_common::gadget::work_manager::WorkManager; use gadget_common::{Error, WorkManagerInterface}; #[derive(Clone)] -pub struct ZCashFrostNetworkService; +pub struct ZcashFrostNetworkService; #[async_trait] -impl Network for ZCashFrostNetworkService { +impl Network for ZcashFrostNetworkService { async fn next_message(&self) -> Option<::ProtocolMessage> { futures::future::pending().await } diff --git a/protocols/zcash-frost/src/protocol.rs b/protocols/zcash-frost/src/protocol.rs index 4f7c2aec2..ecf09b5a0 100644 --- a/protocols/zcash-frost/src/protocol.rs +++ b/protocols/zcash-frost/src/protocol.rs @@ -16,7 +16,7 @@ use sc_client_api::BlockImportNotification; use tangle_primitives::jobs::{JobId, JobType}; use tangle_primitives::roles::RoleType; -pub struct ZCashFrostProtocol, C: ClientWithApi> +pub struct ZcashFrostProtocol, C: ClientWithApi> where >::Api: JobsApi, { @@ -27,7 +27,7 @@ where pub type Curve = u8; -pub struct ZCashFrostKeygenExtraParams { +pub struct ZcashFrostKeygenExtraParams { i: u16, t: u16, n: u16, @@ -38,7 +38,7 @@ pub struct ZCashFrostKeygenExtraParams { #[async_trait] impl, C: ClientWithApi> GadgetProtocol - for ZCashFrostProtocol + for ZcashFrostProtocol where >::Api: JobsApi, { @@ -71,7 +71,7 @@ where .collect(), ); - let params = ZCashFrostKeygenExtraParams { + let params = ZcashFrostKeygenExtraParams { i: participants .iter() .position(|p| p == &self.account_id) @@ -118,11 +118,11 @@ where } #[async_trait] -impl, C: ClientWithApi> AsyncProtocol for ZCashFrostProtocol +impl, C: ClientWithApi> AsyncProtocol for ZcashFrostProtocol where >::Api: JobsApi, { - type AdditionalParams = ZCashFrostKeygenExtraParams; + type AdditionalParams = ZcashFrostKeygenExtraParams; async fn generate_protocol_from( &self, diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index c2743bbbf..bc769ba02 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -1,5 +1,4 @@ use async_trait::async_trait; -use frost_core::Ciphersuite; use frost_ed25519::Ed25519Sha512; use frost_p256::P256Sha256; use frost_ristretto255::Ristretto255Sha512; @@ -35,7 +34,7 @@ use crate::rounds; use super::util::PublicKeyGossipMessage; -pub struct ZCashFrostKeygenProtocol { +pub struct ZcashFrostKeygenProtocol { client: JobsClient, key_store: ECDSAKeyStore, network: N, @@ -49,7 +48,7 @@ pub async fn create_protocol( network: N, logger: DebugLogger, key_store: ECDSAKeyStore, -) -> ZCashFrostKeygenProtocol +) -> ZcashFrostKeygenProtocol where B: Block, BE: Backend, @@ -58,7 +57,7 @@ where N: Network, >::Api: JobsApi, { - ZCashFrostKeygenProtocol { + ZcashFrostKeygenProtocol { client, network, key_store, @@ -74,7 +73,7 @@ impl< C: ClientWithApi, KBE: KeystoreBackend, N: Network, - > GadgetProtocol for ZCashFrostKeygenProtocol + > GadgetProtocol for ZcashFrostKeygenProtocol where >::Api: JobsApi, { @@ -106,7 +105,7 @@ where .collect(), ); - let params = ZCashFrostKeygenExtraParams { + let params = ZcashFrostKeygenExtraParams { i: participants .iter() .position(|p| p == &self.account_id) @@ -169,7 +168,7 @@ where } } -pub struct ZCashFrostKeygenExtraParams { +pub struct ZcashFrostKeygenExtraParams { i: u16, t: u16, n: u16, @@ -185,11 +184,11 @@ impl< KBE: KeystoreBackend, C: ClientWithApi, N: Network, - > AsyncProtocol for ZCashFrostKeygenProtocol + > AsyncProtocol for ZcashFrostKeygenProtocol where >::Api: JobsApi, { - type AdditionalParams = ZCashFrostKeygenExtraParams; + type AdditionalParams = ZcashFrostKeygenExtraParams; async fn generate_protocol_from( &self, associated_block_id: ::Clock, @@ -370,14 +369,14 @@ where async fn handle_public_key_gossip( key_store: ECDSAKeyStore, logger: &DebugLogger, - public_key_package: &Vec, + public_key_package: &[u8], role: ThresholdSignatureRoleType, t: u16, i: u16, broadcast_tx_to_outbound: futures::channel::mpsc::UnboundedSender, mut broadcast_rx_from_gadget: futures::channel::mpsc::UnboundedReceiver, ) -> Result { - let key_hashed = keccak_256(&public_key_package); + let key_hashed = keccak_256(public_key_package); let signature = key_store.pair().sign_prehashed(&key_hashed).0.to_vec(); let my_id = key_store.pair().public(); let mut received_keys = BTreeMap::new(); @@ -473,7 +472,7 @@ async fn handle_public_key_gossip( } _ => unreachable!("Invalid role"), }, - key: public_key_package.clone(), + key: public_key_package.to_vec(), participants, signatures, threshold: t as _, diff --git a/protocols/zcash-frost/src/protocols/sign.rs b/protocols/zcash-frost/src/protocols/sign.rs index 4d55defe0..84802532f 100644 --- a/protocols/zcash-frost/src/protocols/sign.rs +++ b/protocols/zcash-frost/src/protocols/sign.rs @@ -32,7 +32,7 @@ use tokio::sync::mpsc::UnboundedReceiver; use crate::rounds; use crate::rounds::keygen::FrostKeyShare; -pub struct ZCashFrostSigningProtocol { +pub struct ZcashFrostSigningProtocol { client: JobsClient, key_store: ECDSAKeyStore, network: N, @@ -46,7 +46,7 @@ pub async fn create_protocol( network: N, logger: DebugLogger, key_store: ECDSAKeyStore, -) -> ZCashFrostSigningProtocol +) -> ZcashFrostSigningProtocol where B: Block, BE: Backend, @@ -55,7 +55,7 @@ where N: Network, >::Api: JobsApi, { - ZCashFrostSigningProtocol { + ZcashFrostSigningProtocol { client, network, key_store, @@ -71,7 +71,7 @@ impl< C: ClientWithApi, KBE: KeystoreBackend, N: Network, - > GadgetProtocol for ZCashFrostSigningProtocol + > GadgetProtocol for ZcashFrostSigningProtocol where >::Api: JobsApi, { @@ -114,7 +114,7 @@ where let user_id_to_account_id_mapping = Arc::new(mapping); - let params = ZCashFrostSigningExtraParams { + let params = ZcashFrostSigningExtraParams { i, t, signers, @@ -178,7 +178,7 @@ where } } -pub struct ZCashFrostSigningExtraParams { +pub struct ZcashFrostSigningExtraParams { i: u16, t: u16, signers: Vec, @@ -196,11 +196,11 @@ impl< KBE: KeystoreBackend, C: ClientWithApi, N: Network, - > AsyncProtocol for ZCashFrostSigningProtocol + > AsyncProtocol for ZcashFrostSigningProtocol where >::Api: JobsApi, { - type AdditionalParams = ZCashFrostSigningExtraParams; + type AdditionalParams = ZcashFrostSigningExtraParams; async fn generate_protocol_from( &self, associated_block_id: ::Clock, diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index aee199520..59ecb8205 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -1,14 +1,12 @@ use std::collections::BTreeMap; use dfns_cggmp21::{progress::Tracer, round_based::ProtocolMessage}; -use digest::Digest; -use frost_core::Field; use frost_core::{ keys::{ dkg::{round1, round2}, KeyPackage, PublicKeyPackage, }, - Ciphersuite, Error, Group, Identifier, + Ciphersuite, Error, Identifier, }; use futures::SinkExt; use rand_core::{CryptoRng, RngCore}; @@ -18,7 +16,7 @@ use round_based::{ Delivery, Mpc, MpcParty, Outgoing, }; use serde::{Deserialize, Serialize}; -use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; +use tangle_primitives::roles::ThresholdSignatureRoleType; use super::{errors::IoError, KeygenAborted, KeygenError, Reason}; @@ -178,8 +176,8 @@ where tracer.stage("Compute round 3 dkg secret package"); let round2_packages_map: BTreeMap, round2::Package> = round2_packages .into_iter_indexed() - .map(|(inx, msg_id, msg)| { - let identifier = (inx as u16 + 1).try_into().expect("should be nonzero"); + .map(|(inx, _msg_id, msg)| { + let identifier = (inx + 1).try_into().expect("should be nonzero"); let package = round2::Package::deserialize(&msg.msg) .unwrap_or_else(|_| panic!("Failed to deserialize round 2 package")); (identifier, package) @@ -211,7 +209,7 @@ pub fn dkg_part1( t: u16, n: u16, role: ThresholdSignatureRoleType, - mut rng: R, + rng: R, ) -> Result<(round1::SecretPackage, round1::Package), Error> where R: RngCore + CryptoRng, @@ -228,6 +226,7 @@ where frost_core::keys::dkg::part1::(participant_identifier, t, n, rng) } +#[allow(clippy::type_complexity)] pub fn dkg_part2( role: ThresholdSignatureRoleType, secret_package: round1::SecretPackage, diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index 1ed1f48a6..6205b01fd 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -1,4 +1,4 @@ -use frost_core::{Ciphersuite, FieldError}; +use frost_core::Ciphersuite; use frost_ed25519::Ed25519Sha512; use frost_ed448::Ed448Shake256; use frost_p256::P256Sha256; @@ -9,7 +9,7 @@ use frost_secp256k1::Secp256K1Sha256; use frost_taproot::Secp256K1Taproot; use thiserror::Error; -use self::errors::{BoxedError, IoError}; +use self::errors::IoError; pub mod errors; pub mod keygen; @@ -90,8 +90,6 @@ enum Reason { #[from] SignAborted, ), - #[error("field error")] - FieldError(#[source] FieldError), #[error("i/o error")] IoError(#[source] IoError), #[error("unknown error")] diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index d154a1038..72dad203f 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -3,9 +3,7 @@ use dfns_cggmp21::round_based::ProtocolMessage; use frost_core::keys::{KeyPackage, PublicKeyPackage}; use frost_core::round1::{SigningCommitments, SigningNonces}; use frost_core::round2::{self, SignatureShare}; -use frost_core::{ - aggregate, round1, Ciphersuite, Field, Group, Identifier, Signature, SigningPackage, -}; +use frost_core::{aggregate, round1, Ciphersuite, Field, Group, Identifier, SigningPackage}; use futures::SinkExt; use rand_core::{CryptoRng, RngCore}; use round_based::rounds_router::simple_store::RoundInput; @@ -50,6 +48,7 @@ pub struct FrostSignature { pub group_signature: Vec, } +#[allow(clippy::too_many_arguments)] pub async fn run_threshold_sign( mut tracer: Option<&mut dyn Tracer>, i: u16, @@ -100,7 +99,7 @@ where .await .map_err(|e| SignError(Reason::IoError(IoError::receive_message(e))))? .into_iter_indexed() - .map(|(party_inx, msg_id, msg)| { + .map(|(party_inx, _msg_id, msg)| { let msg = SigningCommitments::::deserialize(&msg.msg) .unwrap_or_else(|_| panic!("Failed to deserialize round 1 signing commitments")); let participant_identifier = Identifier::::try_from(party_inx) @@ -141,7 +140,7 @@ where let participant_identifier = Identifier::::try_from(party_inx as u16) .expect("Failed to convert party index to identifier"); let ser = <::Field as Field>::Serialization::try_from(msg.msg) - .map_err(|e| SignError(Reason::::SerializationError)) + .map_err(|_e| SignError(Reason::::SerializationError)) .expect("Failed to deserialize round 2 signature share"); let sig_share = SignatureShare::::deserialize(ser) .unwrap_or_else(|_| panic!("Failed to deserialize round 2 signature share")); @@ -162,6 +161,12 @@ where })) })?; + assert!(frost_keyshare + .1 + .verifying_key() + .verify(message_to_sign, &group_signature) + .is_ok()); + tracer.protocol_ends(); Ok(FrostSignature { @@ -208,38 +213,3 @@ fn participant_round2( })) }) } - -/// Aggregates the `SignatureShares` from the participants to produce the final group signature. -fn signature_share_aggregate( - role: ThresholdSignatureRoleType, - signing_package: &SigningPackage, - signature_shares: &BTreeMap, SignatureShare>, - pubkey_package: &PublicKeyPackage, -) -> Result, SignError> { - match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 - | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), - }; - - aggregate(signing_package, signature_shares, pubkey_package).map_err(|e| { - SignError(Reason::SignFailure(SignAborted::FrostError { - parties: vec![], - error: e, - })) - }) -} - -/// Verifies the group signature. -fn verify_signature( - pubkey_package: &PublicKeyPackage, - message: &[u8], - group_signature: &Signature, -) -> bool { - pubkey_package - .verifying_key() - .verify(message, group_signature) - .is_ok() -} diff --git a/protocols/zcash-frost/tests/frost.rs b/protocols/zcash-frost/tests/frost.rs new file mode 100644 index 000000000..936425184 --- /dev/null +++ b/protocols/zcash-frost/tests/frost.rs @@ -0,0 +1,260 @@ +#[cfg(test)] +mod tests { + use futures::stream::FuturesUnordered; + use futures::StreamExt; + use tangle_primitives::jobs::{ + DKGTSSPhaseFourJobType, DKGTSSPhaseOneJobType, DKGTSSPhaseThreeJobType, + DKGTSSPhaseTwoJobType, JobId, JobSubmission, JobType, + }; + use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; + use test_utils::mock::{id_to_public, Jobs, MockBackend, RuntimeOrigin}; + use test_utils::sync::substrate_test_channel::MultiThreadedTestExternalities; + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_gadget_starts() { + test_utils::setup_log(); + new_test_ext::<1>() + .await + .execute_with_async(|| { + assert_eq!(1, 1); + }) + .await + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_keygen() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + assert_eq!(wait_for_keygen::(&ext).await, 0); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_signing() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + let keygen_job_id = wait_for_keygen::(&ext).await; + assert_eq!(wait_for_signing::(&ext, keygen_job_id).await, 1); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_keyrefresh() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + let keygen_job_id = wait_for_keygen::(&ext).await; + assert_eq!(wait_for_keyrefresh::(&ext, keygen_job_id).await, 1); + // try to sign with the key that was just refreshed. + assert_eq!(wait_for_signing::(&ext, keygen_job_id).await, 2); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_keyrotation() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + let keygen_job_id = wait_for_keygen::(&ext).await; + let new_keygen_job_id = wait_for_keygen::(&ext).await; + assert_eq!( + wait_for_keyrotation::(&ext, keygen_job_id, new_keygen_job_id).await, + 2 + ); + } + + #[tokio::test(flavor = "multi_thread")] + #[ignore = "takes a long time to work on CI"] + async fn test_externalities_parallel_jobs() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + const TEST_COUNT: usize = 2; + + let ext = new_test_ext::().await; + let futures = FuturesUnordered::new(); + + for _ in 0..TEST_COUNT { + let ext = ext.clone(); + futures.push(Box::pin(async move { + let keygen_job_id = wait_for_keygen::(&ext).await; + wait_for_signing::(&ext, keygen_job_id).await; + })); + } + + futures.collect::<()>().await; + } + + async fn wait_for_keygen( + ext: &MultiThreadedTestExternalities, + ) -> JobId { + let job_id = ext + .execute_with_async(|| { + let job_id = Jobs::next_job_id(); + let identities = (0..N).map(|i| id_to_public(i as u8)).collect::>(); + + let submission = JobSubmission { + expiry: 100, + ttl: 100, + job_type: JobType::DKGTSSPhaseOne(DKGTSSPhaseOneJobType { + participants: identities.clone(), + threshold: T as _, + permitted_caller: None, + role_type: ThresholdSignatureRoleType::ZcashFrostEd25519, + }), + }; + + assert!(Jobs::submit_job(RuntimeOrigin::signed(identities[0]), submission).is_ok()); + + log::info!(target: "gadget", "******* Submitted Keygen Job {job_id}"); + job_id + }) + .await; + + test_utils::wait_for_job_completion( + ext, + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1), + job_id, + ) + .await; + job_id + } + + async fn wait_for_signing( + ext: &MultiThreadedTestExternalities, + keygen_job_id: JobId, + ) -> JobId { + let job_id = ext + .execute_with_async(move || { + let submission = Vec::from("Hello, world!"); + let job_id = Jobs::next_job_id(); + let identities = (0..N).map(|i| id_to_public(i as u8)).collect::>(); + let submission = JobSubmission { + expiry: 100, + ttl: 100, + job_type: JobType::DKGTSSPhaseTwo(DKGTSSPhaseTwoJobType { + phase_one_id: keygen_job_id, + submission, + role_type: ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1, + }), + }; + + assert!(Jobs::submit_job(RuntimeOrigin::signed(identities[0]), submission).is_ok()); + + log::info!(target: "gadget", "******* Submitted Signing Job {job_id}"); + job_id + }) + .await; + + test_utils::wait_for_job_completion( + ext, + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1), + job_id, + ) + .await; + job_id + } + + async fn wait_for_keyrefresh( + ext: &MultiThreadedTestExternalities, + keygen_job_id: JobId, + ) -> JobId { + let job_id = ext + .execute_with_async(move || { + let job_id = Jobs::next_job_id(); + let identities = (0..N).map(|i| id_to_public(i as u8)).collect::>(); + let submission = JobSubmission { + expiry: 100, + ttl: 100, + job_type: JobType::DKGTSSPhaseThree(DKGTSSPhaseThreeJobType { + phase_one_id: keygen_job_id, + role_type: ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1, + }), + }; + + assert!(Jobs::submit_job(RuntimeOrigin::signed(identities[0]), submission).is_ok()); + + log::info!(target: "gadget", "******* Submitted KeyRefresh Job {job_id}"); + job_id + }) + .await; + + test_utils::wait_for_job_completion( + ext, + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1), + job_id, + ) + .await; + job_id + } + + async fn wait_for_keyrotation( + ext: &MultiThreadedTestExternalities, + keygen_job_id: JobId, + new_keygen_job_id: JobId, + ) -> JobId { + let job_id = ext + .execute_with_async(move || { + let job_id = Jobs::next_job_id(); + let identities = (0..N).map(|i| id_to_public(i as u8)).collect::>(); + let submission = JobSubmission { + expiry: 100, + ttl: 100, + job_type: JobType::DKGTSSPhaseFour(DKGTSSPhaseFourJobType { + phase_one_id: keygen_job_id, + new_phase_one_id: new_keygen_job_id, + role_type: ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1, + }), + }; + + assert!(Jobs::submit_job(RuntimeOrigin::signed(identities[0]), submission).is_ok()); + + log::info!(target: "gadget", "******* Submitted KeyRotation Job {job_id}"); + job_id + }) + .await; + + test_utils::wait_for_job_completion( + ext, + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1), + job_id, + ) + .await; + job_id + } + + async fn new_test_ext() -> MultiThreadedTestExternalities { + test_utils::mock::new_test_ext::((), |_, mut node_input| async move { + let keygen_client = node_input.mock_clients.pop().expect("No keygen client"); + let signing_client = node_input.mock_clients.pop().expect("No signing client"); + + let keygen_network = node_input.mock_networks.pop().expect("No keygen network"); + let signing_network = node_input.mock_networks.pop().expect("No signing network"); + let account_id = node_input.account_id; + + let logger = node_input.logger.clone(); + let (pallet_tx, keystore) = (node_input.pallet_tx, node_input.keystore); + logger.info("Starting gadget"); + if let Err(err) = zcash_frost_protocol::run::<_, MockBackend, _, _, _, _>( + account_id, + logger.clone(), + keystore, + pallet_tx, + (keygen_client, signing_client), + (keygen_network, signing_network), + ) + .await + { + log::error!(target: "gadget", "Error running gadget: {err:?}"); + } + }) + .await + } +} From fbe1d7af6a22839a2218dabc83e0941691e8ed76 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 31 Jan 2024 15:07:13 -0500 Subject: [PATCH 04/66] cleanup: remove refresh/rotation, unused imports for test --- protocols/zcash-frost/tests/frost.rs | 107 ++------------------------- 1 file changed, 5 insertions(+), 102 deletions(-) diff --git a/protocols/zcash-frost/tests/frost.rs b/protocols/zcash-frost/tests/frost.rs index 936425184..0441bcc75 100644 --- a/protocols/zcash-frost/tests/frost.rs +++ b/protocols/zcash-frost/tests/frost.rs @@ -3,8 +3,7 @@ mod tests { use futures::stream::FuturesUnordered; use futures::StreamExt; use tangle_primitives::jobs::{ - DKGTSSPhaseFourJobType, DKGTSSPhaseOneJobType, DKGTSSPhaseThreeJobType, - DKGTSSPhaseTwoJobType, JobId, JobSubmission, JobType, + DKGTSSPhaseOneJobType, DKGTSSPhaseTwoJobType, JobId, JobSubmission, JobType, }; use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use test_utils::mock::{id_to_public, Jobs, MockBackend, RuntimeOrigin}; @@ -42,34 +41,6 @@ mod tests { assert_eq!(wait_for_signing::(&ext, keygen_job_id).await, 1); } - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_keyrefresh() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - let keygen_job_id = wait_for_keygen::(&ext).await; - assert_eq!(wait_for_keyrefresh::(&ext, keygen_job_id).await, 1); - // try to sign with the key that was just refreshed. - assert_eq!(wait_for_signing::(&ext, keygen_job_id).await, 2); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_keyrotation() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - let keygen_job_id = wait_for_keygen::(&ext).await; - let new_keygen_job_id = wait_for_keygen::(&ext).await; - assert_eq!( - wait_for_keyrotation::(&ext, keygen_job_id, new_keygen_job_id).await, - 2 - ); - } - #[tokio::test(flavor = "multi_thread")] #[ignore = "takes a long time to work on CI"] async fn test_externalities_parallel_jobs() { @@ -107,7 +78,7 @@ mod tests { participants: identities.clone(), threshold: T as _, permitted_caller: None, - role_type: ThresholdSignatureRoleType::ZcashFrostEd25519, + role_type: ThresholdSignatureRoleType::ZcashFrostRistretto255, }), }; @@ -120,7 +91,7 @@ mod tests { test_utils::wait_for_job_completion( ext, - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1), + RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255), job_id, ) .await; @@ -142,7 +113,7 @@ mod tests { job_type: JobType::DKGTSSPhaseTwo(DKGTSSPhaseTwoJobType { phase_one_id: keygen_job_id, submission, - role_type: ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1, + role_type: ThresholdSignatureRoleType::ZcashFrostRistretto255, }), }; @@ -155,75 +126,7 @@ mod tests { test_utils::wait_for_job_completion( ext, - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1), - job_id, - ) - .await; - job_id - } - - async fn wait_for_keyrefresh( - ext: &MultiThreadedTestExternalities, - keygen_job_id: JobId, - ) -> JobId { - let job_id = ext - .execute_with_async(move || { - let job_id = Jobs::next_job_id(); - let identities = (0..N).map(|i| id_to_public(i as u8)).collect::>(); - let submission = JobSubmission { - expiry: 100, - ttl: 100, - job_type: JobType::DKGTSSPhaseThree(DKGTSSPhaseThreeJobType { - phase_one_id: keygen_job_id, - role_type: ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1, - }), - }; - - assert!(Jobs::submit_job(RuntimeOrigin::signed(identities[0]), submission).is_ok()); - - log::info!(target: "gadget", "******* Submitted KeyRefresh Job {job_id}"); - job_id - }) - .await; - - test_utils::wait_for_job_completion( - ext, - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1), - job_id, - ) - .await; - job_id - } - - async fn wait_for_keyrotation( - ext: &MultiThreadedTestExternalities, - keygen_job_id: JobId, - new_keygen_job_id: JobId, - ) -> JobId { - let job_id = ext - .execute_with_async(move || { - let job_id = Jobs::next_job_id(); - let identities = (0..N).map(|i| id_to_public(i as u8)).collect::>(); - let submission = JobSubmission { - expiry: 100, - ttl: 100, - job_type: JobType::DKGTSSPhaseFour(DKGTSSPhaseFourJobType { - phase_one_id: keygen_job_id, - new_phase_one_id: new_keygen_job_id, - role_type: ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1, - }), - }; - - assert!(Jobs::submit_job(RuntimeOrigin::signed(identities[0]), submission).is_ok()); - - log::info!(target: "gadget", "******* Submitted KeyRotation Job {job_id}"); - job_id - }) - .await; - - test_utils::wait_for_job_completion( - ext, - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1), + RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255), job_id, ) .await; From 7ff50fbc2301cba8f6b9cbd0a8395d35d8795a62 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 31 Jan 2024 15:11:09 -0500 Subject: [PATCH 05/66] fix: return err if invalid signature --- protocols/zcash-frost/src/rounds/sign.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index 72dad203f..4a5d71816 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -161,11 +161,17 @@ where })) })?; - assert!(frost_keyshare + if !frost_keyshare .1 .verifying_key() .verify(message_to_sign, &group_signature) - .is_ok()); + .is_ok() + { + return Err(SignError(Reason::SignFailure(SignAborted::FrostError { + parties: vec![], + error: frost_core::Error::::InvalidSignature, + }))); + } tracer.protocol_ends(); From 5500f5a4405f1135806e3d0f4a8b16445beca104 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 1 Feb 2024 10:58:54 +0200 Subject: [PATCH 06/66] feat: add repair protocol rounds --- protocols/zcash-frost/src/protocols/mod.rs | 1 + protocols/zcash-frost/src/protocols/repair.rs | 1 + protocols/zcash-frost/src/rounds/mod.rs | 45 ++- protocols/zcash-frost/src/rounds/repair.rs | 267 ++++++++++++++++++ protocols/zcash-frost/src/rounds/sign.rs | 4 +- 5 files changed, 312 insertions(+), 6 deletions(-) create mode 100644 protocols/zcash-frost/src/protocols/repair.rs create mode 100644 protocols/zcash-frost/src/rounds/repair.rs diff --git a/protocols/zcash-frost/src/protocols/mod.rs b/protocols/zcash-frost/src/protocols/mod.rs index 16b9199e9..36a8a722d 100644 --- a/protocols/zcash-frost/src/protocols/mod.rs +++ b/protocols/zcash-frost/src/protocols/mod.rs @@ -1,3 +1,4 @@ pub mod keygen; +pub mod repair; pub mod sign; pub mod util; diff --git a/protocols/zcash-frost/src/protocols/repair.rs b/protocols/zcash-frost/src/protocols/repair.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/protocols/zcash-frost/src/protocols/repair.rs @@ -0,0 +1 @@ + diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index 6205b01fd..644549e23 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -13,6 +13,7 @@ use self::errors::IoError; pub mod errors; pub mod keygen; +pub mod repair; pub mod sign; /// Keygen protocol error @@ -75,6 +76,30 @@ impl_sign_error_from!(Ed448Shake256); impl_sign_error_from!(JubjubBlake2b512); impl_sign_error_from!(Secp256K1Taproot); +/// Repair protocol error +#[derive(Debug, Error)] +#[error("repair protocol is failed to complete")] +pub struct RepairError(Reason); + +macro_rules! impl_repair_error_from { + ($ciphersuite:ty) => { + impl From for RepairError<$ciphersuite> { + fn from(err: IoError) -> Self { + RepairError(Reason::IoError(err)) + } + } + }; +} + +impl_repair_error_from!(Ed25519Sha512); +impl_repair_error_from!(P256Sha256); +impl_repair_error_from!(P384Sha384); +impl_repair_error_from!(Ristretto255Sha512); +impl_repair_error_from!(Secp256K1Sha256); +impl_repair_error_from!(Ed448Shake256); +impl_repair_error_from!(JubjubBlake2b512); +impl_repair_error_from!(Secp256K1Taproot); + #[derive(Debug, Error)] enum Reason { /// Keygen protocol was maliciously aborted by another party @@ -90,6 +115,12 @@ enum Reason { #[from] SignAborted, ), + #[error("repair protocol was aborted by malicious party")] + RepairFailure( + #[source] + #[from] + RepairAborted, + ), #[error("i/o error")] IoError(#[source] IoError), #[error("unknown error")] @@ -97,8 +128,6 @@ enum Reason { } /// Error indicating that protocol was aborted by malicious party -/// -/// It _can be_ cryptographically proven, but we do not support it yet. #[derive(Debug, Error)] enum KeygenAborted { #[error("Frost keygen error")] @@ -109,8 +138,6 @@ enum KeygenAborted { } /// Sign protocol error -/// -/// It _can be_ cryptographically proven, but we do not support it yet. #[derive(Debug, Error)] enum SignAborted { #[error("Frost sign error")] @@ -119,3 +146,13 @@ enum SignAborted { error: frost_core::Error, }, } + +/// Repair protocol error +#[derive(Debug, Error)] +enum RepairAborted { + #[error("Frost repair error")] + FrostError { + parties: Vec, + error: frost_core::Error, + }, +} diff --git a/protocols/zcash-frost/src/rounds/repair.rs b/protocols/zcash-frost/src/rounds/repair.rs new file mode 100644 index 000000000..d5c9a4a63 --- /dev/null +++ b/protocols/zcash-frost/src/rounds/repair.rs @@ -0,0 +1,267 @@ +use dfns_cggmp21::progress::Tracer; +use dfns_cggmp21::round_based::ProtocolMessage; +use frost_core::keys::repairable::{repair_share_step_1, repair_share_step_2, repair_share_step_3}; +use frost_core::keys::{SecretShare, VerifiableSecretSharingCommitment}; + +use frost_core::{Ciphersuite, Field, Group, Identifier, Scalar}; +use futures::SinkExt; +use rand_core::{CryptoRng, RngCore}; +use round_based::rounds_router::simple_store::RoundInput; +use round_based::rounds_router::RoundsRouter; +use round_based::{Delivery, Mpc, MpcParty, Outgoing}; +use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; +use tangle_primitives::roles::ThresholdSignatureRoleType; + +use super::errors::IoError; +use super::{Reason, RepairAborted, RepairError}; + +/// Message of key generation protocol +#[derive(ProtocolMessage, Clone, Serialize, Deserialize)] +#[serde(bound = "")] +pub enum Msg { + /// Round 1 message + Round1(MsgRound1), + /// Round 2 message + Round2(MsgRound2), +} + +/// Message from round 1 +#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] +#[serde(bound = "")] +#[udigest(bound = "")] +#[udigest(tag = "zcash.frost.sign.threshold.round1")] +pub struct MsgRound1 { + pub msg: Vec, +} +/// Message from round 2 +#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] +#[serde(bound = "")] +#[udigest(bound = "")] +#[udigest(tag = "zcash.frost.sign.threshold.round2")] +pub struct MsgRound2 { + pub msg: Vec, +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct FrostSignature { + pub group_signature: Vec, +} + +#[allow(clippy::too_many_arguments)] +pub async fn run_threshold_repair( + mut tracer: Option<&mut dyn Tracer>, + i: u16, + helpers: Vec, + share_i: &SecretShare, + commitment: Option>, + participant: u16, + role: ThresholdSignatureRoleType, + rng: &mut R, + party: M, +) -> Result>, RepairError> +where + R: RngCore + CryptoRng, + M: Mpc, + C: Ciphersuite, +{ + tracer.protocol_begins(); + + tracer.stage("Setup networking"); + let MpcParty { delivery, .. } = party.into_party(); + let (incomings, mut outgoings) = delivery.split(); + + let mut rounds = RoundsRouter::::builder(); + let round1 = rounds.add_round(RoundInput::::p2p(i, helpers.len() as u16)); + let round2 = rounds.add_round(RoundInput::::broadcast(i, helpers.len() as u16)); + let mut rounds = rounds.listen(incomings); + + // Round 1 + tracer.round_begins(); + let helpers: Vec> = helpers + .iter() + .map(|i| Identifier::try_from(*i).expect("should be nonzero")) + .collect(); + let lost_share_participant_identifier = + Identifier::::try_from(participant).expect("should be nonzero"); + let _my_identifier = Identifier::::try_from(i).expect("should be nonzero"); + + tracer.send_msg(); + tracer.stage("Repair share step 1"); + // Calculate the messages to be sent to each party + let round1_msg_map: BTreeMap, Scalar> = helper_round1( + role, + &helpers, + share_i, + lost_share_participant_identifier, + rng, + )?; + for (identifier, msg) in round1_msg_map { + let receiver_index_be_bytes: [u8; 2] = identifier + .serialize() + .as_ref() + .try_into() + .expect("should be 2 bytes"); + let receiver_index = u16::from_be_bytes(receiver_index_be_bytes); + outgoings + .send(Outgoing::p2p( + receiver_index, + Msg::Round1(MsgRound1 { + msg: ::Field::serialize(&msg) + .as_ref() + .to_vec(), + }), + )) + .await + .map_err(|e| RepairError(Reason::IoError(IoError::send_message(e))))?; + } + tracer.msg_sent(); + + // Round 2 + tracer.round_begins(); + + tracer.receive_msgs(); + let delta_js: Vec> = rounds + .complete(round1) + .await + .map_err(|e| RepairError(Reason::IoError(IoError::receive_message(e))))? + .into_vec_without_me() + .into_iter() + .map(|msg| { + let ser = <::Field as Field>::Serialization::try_from(msg.msg) + .map_err(|_e| RepairError(Reason::::SerializationError)) + .expect("Failed to deserialize round 1 scalar"); + ::Field::deserialize(&ser) + .unwrap_or(::Field::zero()) + }) + .collect(); + tracer.msgs_received(); + + tracer.send_msg(); + tracer.stage("Repair share step 2"); + let round2_msg: Scalar = helper_round2::(role, delta_js.as_ref()); + outgoings + .send(Outgoing::p2p( + participant, + Msg::Round2(MsgRound2 { + msg: ::Field::serialize(&round2_msg) + .as_ref() + .to_vec(), + }), + )) + .await + .map_err(|e| RepairError(Reason::IoError(IoError::send_message(e))))?; + tracer.msg_sent(); + + // TODO: Figure out how to properly represent the participant requesting the + // TODO: share repairing. They do not run `helper_round1` or `helper_round2`. + // TODO: Instead they just run reconstruct. + tracer.round_begins(); + tracer.stage("Repair step 3 (run by participant requesting repairing)"); + tracer.receive_msgs(); + let sigmas: Vec> = rounds + .complete(round2) + .await + .map_err(|e| RepairError(Reason::IoError(IoError::receive_message(e))))? + .into_vec_without_me() + .into_iter() + .map(|msg| { + let ser = <::Field as Field>::Serialization::try_from(msg.msg) + .map_err(|_e| RepairError(Reason::::SerializationError)) + .expect("Failed to deserialize round 1 scalar"); + ::Field::deserialize(&ser) + .unwrap_or(::Field::zero()) + }) + .collect(); + tracer.msgs_received(); + tracer.stage("Repair secret share w/ sigmas from helpers"); + let mut secret_share: Option> = None; + if i == participant { + let commitment = commitment.unwrap(); + secret_share = Some(repair_round3( + role, + &sigmas, + lost_share_participant_identifier, + &commitment, + )); + } + tracer.protocol_ends(); + + Ok(secret_share) +} + +/// Step 1 of RTS. +/// +/// Generates the "delta" values from `helper_i` to help `participant` recover their share +/// where `helpers` contains the identifiers of all the helpers (including `helper_i`), and `share_i` +/// is the share of `helper_i`. +/// +/// Returns a BTreeMap mapping which value should be sent to which participant. +/// Taken from https://github.com/LIT-Protocol/frost/blob/main/frost-ed25519/src/keys/repairable.rs +fn helper_round1( + role: ThresholdSignatureRoleType, + helpers: &[Identifier], + share_i: &SecretShare, + participant: Identifier, + rng: &mut R, +) -> Result, Scalar>, RepairError> { + match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostP256 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} + _ => panic!("Invalid role"), + }; + + repair_share_step_1(helpers, share_i, rng, participant).map_err(|e| { + RepairError(Reason::RepairFailure(RepairAborted::FrostError { + parties: vec![], + error: e, + })) + }) +} + +/// Step 2 of RTS. +/// +/// Generates the `sigma` values from all `deltas` received from `helpers` +/// to help `participant` recover their share. +/// `sigma` is the sum of all received `delta` and the `delta_i` generated for `helper_i`. +/// +/// Returns a scalar +/// Taken from https://github.com/LIT-Protocol/frost/blob/main/frost-ed25519/src/keys/repairable.rs +fn helper_round2( + role: ThresholdSignatureRoleType, + deltas_j: &[Scalar], +) -> Scalar { + match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostP256 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} + _ => panic!("Invalid role"), + }; + + repair_share_step_2::(deltas_j) +} + +/// Step 3 of RTS +/// +/// The `participant` sums all `sigma_j` received to compute the `share`. The `SecretShare` +/// is made up of the `identifier`and `commitment` of the `participant` as well as the +/// `value` which is the `SigningShare`. +pub fn repair_round3( + role: ThresholdSignatureRoleType, + sigmas: &[Scalar], + identifier: Identifier, + commitment: &VerifiableSecretSharingCommitment, +) -> SecretShare { + match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostP256 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} + _ => panic!("Invalid role"), + }; + + repair_share_step_3(sigmas, identifier, commitment) +} diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index 4a5d71816..2be5d2e71 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -161,11 +161,11 @@ where })) })?; - if !frost_keyshare + if frost_keyshare .1 .verifying_key() .verify(message_to_sign, &group_signature) - .is_ok() + .is_err() { return Err(SignError(Reason::SignFailure(SignAborted::FrostError { parties: vec![], From 22ef1294281a10fe90c26b148fafcd89aa67a494 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 1 Feb 2024 14:55:54 +0200 Subject: [PATCH 07/66] fix: use macros to reduce code duplication --- protocols/zcash-frost/src/protocols/keygen.rs | 63 ++++---- protocols/zcash-frost/src/protocols/sign.rs | 148 +++++++----------- 2 files changed, 92 insertions(+), 119 deletions(-) diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index bc769ba02..ba20a08d0 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -168,6 +168,24 @@ where } } +macro_rules! run_threshold_keygen { + ($impl_type:ty, $tracer:expr, $i:expr, $t:expr, $n:expr, $role:expr, $rng:expr, $party:expr) => { + rounds::keygen::run_threshold_keygen::<$impl_type, _, _>( + Some($tracer), + $i, + $t, + $n, + $role, + $rng, + $party, + ) + .await + .map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })? + }; +} + pub struct ZcashFrostKeygenExtraParams { i: u16, t: u16, @@ -253,68 +271,55 @@ where let party = round_based::MpcParty::connected(delivery); let frost_key_share_package = match role { ThresholdSignatureRoleType::ZcashFrostEd25519 => { - rounds::keygen::run_threshold_keygen::( - Some(&mut tracer), + run_threshold_keygen!( + Ed25519Sha512, + &mut tracer, i, t, n, role, &mut rng, - party, + party ) - .await - .map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - })? } ThresholdSignatureRoleType::ZcashFrostP256 => { - rounds::keygen::run_threshold_keygen::( - Some(&mut tracer), + run_threshold_keygen!( + P256Sha256, + &mut tracer, i, t, n, role, &mut rng, - party, + party ) - .await - .map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - })? } ThresholdSignatureRoleType::ZcashFrostRistretto255 => { - rounds::keygen::run_threshold_keygen::( - Some(&mut tracer), + run_threshold_keygen!( + Ristretto255Sha512, + &mut tracer, i, t, n, role, &mut rng, - party, + party ) - .await - .map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - })? } ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { - rounds::keygen::run_threshold_keygen::( - Some(&mut tracer), + run_threshold_keygen!( + Secp256K1Sha256, + &mut tracer, i, t, n, role, &mut rng, - party, + party ) - .await - .map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - })? } _ => unreachable!("Invalid role"), }; - let perf_report = tracer.get_report().map_err(|err| JobError { reason: format!("Keygen protocol error: {err:?}"), })?; diff --git a/protocols/zcash-frost/src/protocols/sign.rs b/protocols/zcash-frost/src/protocols/sign.rs index 84802532f..346a449e3 100644 --- a/protocols/zcash-frost/src/protocols/sign.rs +++ b/protocols/zcash-frost/src/protocols/sign.rs @@ -120,7 +120,7 @@ where signers, job_id, role_type: job.role_type, - frost_keyshare: key, + keyshare: key, input_data_to_sign, user_id_to_account_id_mapping, }; @@ -178,13 +178,45 @@ where } } +macro_rules! deserialize_and_run_threshold_sign { + ($impl_type:ty, $keyshare:expr, $tracer:expr, $i:expr, $signers:expr, $data_hash:expr, $role:expr, $rng:expr, $party:expr) => {{ + let key_package = + KeyPackage::<$impl_type>::deserialize(&$keyshare.key_package).map_err(|err| { + JobError { + reason: format!("Failed to deserialize key share: {err:?}"), + } + })?; + + let public_key_package = PublicKeyPackage::<$impl_type>::deserialize( + &$keyshare.pubkey_package, + ) + .map_err(|err| JobError { + reason: format!("Failed to deserialize public key package: {err:?}"), + })?; + rounds::sign::run_threshold_sign( + Some($tracer), + $i, + $signers, + (key_package, public_key_package), + $data_hash, + $role, + $rng, + $party, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to run threshold sign: {err:?}"), + })? + }}; +} + pub struct ZcashFrostSigningExtraParams { i: u16, t: u16, signers: Vec, job_id: JobId, role_type: RoleType, - frost_keyshare: FrostKeyShare, + keyshare: FrostKeyShare, input_data_to_sign: Vec, user_id_to_account_id_mapping: Arc>, } @@ -218,11 +250,11 @@ where let id = self.account_id; let network = self.network.clone(); - let (i, signers, t, frost_keyshare, role_type, input_data_to_sign, mapping) = ( + let (i, signers, t, keyshare, role_type, input_data_to_sign, mapping) = ( additional_params.i, additional_params.signers, additional_params.t, - additional_params.frost_keyshare, + additional_params.keyshare, additional_params.role_type, additional_params.input_data_to_sign.clone(), additional_params.user_id_to_account_id_mapping.clone(), @@ -237,7 +269,7 @@ where } }; - let frost_keyshare2 = frost_keyshare.clone(); + let keyshare2 = keyshare.clone(); Ok(JobBuilder::new() .protocol(async move { @@ -271,120 +303,56 @@ where let data_hash = keccak_256(&input_data_to_sign); let signature = match role { ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { - let key_package = - KeyPackage::::deserialize(&frost_keyshare.key_package) - .map_err(|err| JobError { - reason: format!("Failed to deserialize key share: {err:?}"), - })?; - - let public_key_package = PublicKeyPackage::::deserialize( - &frost_keyshare.pubkey_package, - ) - .map_err(|err| JobError { - reason: format!("Failed to deserialize public key package: {err:?}"), - })?; - rounds::sign::run_threshold_sign( - Some(&mut tracer), + deserialize_and_run_threshold_sign!( + Secp256K1Sha256, + keyshare, + &mut tracer, i, signers, - (key_package, public_key_package), &data_hash, role, &mut rng, - party, + party ) - .await - .map_err(|err| JobError { - reason: format!("Failed to run threshold sign: {err:?}"), - })? } ThresholdSignatureRoleType::ZcashFrostEd25519 => { - let key_package = - KeyPackage::::deserialize(&frost_keyshare.key_package) - .map_err(|err| JobError { - reason: format!("Failed to deserialize key share: {err:?}"), - })?; - - let public_key_package = PublicKeyPackage::::deserialize( - &frost_keyshare.pubkey_package, - ) - .map_err(|err| JobError { - reason: format!("Failed to deserialize public key package: {err:?}"), - })?; - rounds::sign::run_threshold_sign( - Some(&mut tracer), + deserialize_and_run_threshold_sign!( + Ed25519Sha512, + keyshare, + &mut tracer, i, signers, - (key_package, public_key_package), &data_hash, role, &mut rng, - party, + party ) - .await - .map_err(|err| JobError { - reason: format!("Failed to run threshold sign: {err:?}"), - })? } ThresholdSignatureRoleType::ZcashFrostP256 => { - let key_package = - KeyPackage::::deserialize(&frost_keyshare.key_package) - .map_err(|err| JobError { - reason: format!("Failed to deserialize key share: {err:?}"), - })?; - - let public_key_package = PublicKeyPackage::::deserialize( - &frost_keyshare.pubkey_package, - ) - .map_err(|err| JobError { - reason: format!("Failed to deserialize public key package: {err:?}"), - })?; - rounds::sign::run_threshold_sign( - Some(&mut tracer), + deserialize_and_run_threshold_sign!( + P256Sha256, + keyshare, + &mut tracer, i, signers, - (key_package, public_key_package), &data_hash, role, &mut rng, - party, + party ) - .await - .map_err(|err| JobError { - reason: format!("Failed to run threshold sign: {err:?}"), - })? } ThresholdSignatureRoleType::ZcashFrostRistretto255 => { - let key_package = KeyPackage::::deserialize( - &frost_keyshare.key_package, - ) - .map_err(|err| JobError { - reason: format!("Failed to deserialize key share: {err:?}"), - })?; - - let public_key_package = - PublicKeyPackage::::deserialize( - &frost_keyshare.pubkey_package, - ) - .map_err(|err| JobError { - reason: format!( - "Failed to deserialize public key package: {err:?}" - ), - })?; - rounds::sign::run_threshold_sign( - Some(&mut tracer), + deserialize_and_run_threshold_sign!( + Ristretto255Sha512, + keyshare, + &mut tracer, i, signers, - (key_package, public_key_package), &data_hash, role, &mut rng, - party, + party ) - .await - .map_err(|err| JobError { - reason: format!("Failed to run threshold sign: {err:?}"), - })? } _ => { return Err(JobError { @@ -446,7 +414,7 @@ where signature_type, signature, data: additional_params.input_data_to_sign, - signing_key: frost_keyshare2.pubkey_package, + signing_key: keyshare2.pubkey_package, }); client From b2cf48d2f9f73f3f9df05e631f51ffe4a19a1d1e Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 1 Feb 2024 19:34:21 +0200 Subject: [PATCH 08/66] Update before removing repair --- protocols/zcash-frost/src/protocols/repair.rs | 400 ++++++++++++++++++ protocols/zcash-frost/src/rounds/repair.rs | 9 +- 2 files changed, 405 insertions(+), 4 deletions(-) diff --git a/protocols/zcash-frost/src/protocols/repair.rs b/protocols/zcash-frost/src/protocols/repair.rs index 8b1378917..43684f5a1 100644 --- a/protocols/zcash-frost/src/protocols/repair.rs +++ b/protocols/zcash-frost/src/protocols/repair.rs @@ -1 +1,401 @@ +use async_trait::async_trait; +use frost_core::keys::{KeyPackage, PublicKeyPackage}; +use frost_ed25519::Ed25519Sha512; +use frost_p256::P256Sha256; +use frost_ristretto255::Ristretto255Sha512; +use frost_secp256k1::Secp256K1Sha256; +use gadget_common::client::{AccountId, ClientWithApi, JobsClient}; +use gadget_common::debug_logger::DebugLogger; +use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; +use gadget_common::gadget::network::Network; +use gadget_common::gadget::work_manager::WorkManager; +use gadget_common::gadget::{GadgetProtocol, JobInitMetadata, WorkManagerConfig}; +use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; +use gadget_common::protocol::AsyncProtocol; +use gadget_common::{Block, BlockImportNotification}; +use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; +use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; +use pallet_jobs_rpc_runtime_api::JobsApi; +use rand::SeedableRng; +use round_based::MpcParty; +use sc_client_api::Backend; +use sp_api::ProvideRuntimeApi; +use sp_core::keccak_256; +use std::collections::HashMap; +use std::sync::Arc; +use tangle_primitives::jobs::{ + DKGTSSSignatureResult, DigitalSignatureType, JobId, JobResult, JobType, +}; +use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; +use tokio::sync::mpsc::UnboundedReceiver; +use crate::rounds; +use crate::rounds::keygen::FrostKeyShare; + +pub struct ZcashFrostRepairProtocol { + client: JobsClient, + key_store: ECDSAKeyStore, + network: N, + logger: DebugLogger, + account_id: AccountId, +} + +pub async fn create_protocol( + account_id: AccountId, + client: JobsClient, + network: N, + logger: DebugLogger, + key_store: ECDSAKeyStore, +) -> ZcashFrostRepairProtocol +where + B: Block, + BE: Backend, + C: ClientWithApi, + KBE: KeystoreBackend, + N: Network, + >::Api: JobsApi, +{ + ZcashFrostRepairProtocol { + client, + network, + key_store, + logger, + account_id, + } +} + +#[async_trait] +impl< + B: Block, + BE: Backend + 'static, + C: ClientWithApi, + KBE: KeystoreBackend, + N: Network, + > GadgetProtocol for ZcashFrostRepairProtocol +where + >::Api: JobsApi, +{ + fn name(&self) -> String { + "zcash-frost-repair".to_string() + } + + async fn create_next_job( + &self, + job: JobInitMetadata, + ) -> Result<::AdditionalParams, gadget_common::Error> { + let job_id = job.job_id; + + let JobType::DKGTSSPhaseThree(p3_job) = job.job_type else { + panic!("Should be valid type") + }; + let previous_job_id = p3_job.phase_one_id; + + let phase1_job = job.phase1_job.expect("Should exist for a phase 2 job"); + let participants = phase1_job.clone().get_participants().expect("Should exist"); + let t = phase1_job.get_threshold().expect("Should exist") as u16; + + let seed = + keccak_256(&[&job_id.to_be_bytes()[..], &job.retry_id.to_be_bytes()[..]].concat()); + let mut rng = rand_chacha::ChaChaRng::from_seed(seed); + + let key = self + .key_store + .get_job_result(previous_job_id) + .await + .map_err(|err| gadget_common::Error::ClientError { + err: err.to_string(), + })? + .ok_or_else(|| gadget_common::Error::ClientError { + err: format!("No key found for job ID: {job_id:?}"), + })?; + + let user_id_to_account_id_mapping = Arc::new( + participants + .clone() + .into_iter() + .enumerate() + .map(|r| (r.0 as UserID, r.1)) + .collect(), + ); + + let params = ZcashFrostRepairExtraParams { + i: participants + .iter() + .position(|p| p == &self.account_id) + .expect("Should exist") as u16, + t, + helpers: participants + .into_iter() + .enumerate() + .map(|r| r.0 as u16) + .collect(), + job_id, + // TODO: Update to use the correct participant once the job type is updated. + participant: 1u16, + role_type: job.role_type, + keyshare: key, + user_id_to_account_id_mapping, + }; + Ok(params) + } + + async fn process_block_import_notification( + &self, + _notification: BlockImportNotification, + _job_manager: &ProtocolWorkManager, + ) -> Result<(), gadget_common::Error> { + Ok(()) + } + + async fn process_error( + &self, + error: gadget_common::Error, + _job_manager: &ProtocolWorkManager, + ) { + log::error!(target: "gadget", "Error: {error:?}"); + } + + fn account_id(&self) -> &AccountId { + &self.account_id + } + + fn role_filter(&self, role: RoleType) -> bool { + matches!( + role, + RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) + ) + } + + fn phase_filter(&self, job: JobType) -> bool { + matches!(job, JobType::DKGTSSPhaseTwo(_)) + } + + fn client(&self) -> &JobsClient { + &self.client + } + + fn logger(&self) -> &DebugLogger { + &self.logger + } + + fn get_work_manager_config(&self) -> WorkManagerConfig { + WorkManagerConfig { + interval: Some(crate::constants::signing_worker::JOB_POLL_INTERVAL), + max_active_tasks: crate::constants::signing_worker::MAX_RUNNING_TASKS, + max_pending_tasks: crate::constants::signing_worker::MAX_ENQUEUED_TASKS, + } + } +} + +macro_rules! run_threshold_repair { + ($impl_type:ty, $keyshare:expr, $tracer:expr, $i:expr, $helpers:expr, $participant:expr, $role:expr, $rng:expr, $party:expr) => {{ + let key_package = + KeyPackage::<$impl_type>::deserialize(&$keyshare.key_package).map_err(|err| { + JobError { + reason: format!("Failed to deserialize key share: {err:?}"), + } + })?; + + let public_key_package = PublicKeyPackage::<$impl_type>::deserialize( + &$keyshare.pubkey_package, + ) + .map_err(|err| JobError { + reason: format!("Failed to deserialize public key package: {err:?}"), + })?; + + let secret_share = SecretShare::<$impl_type> { + header: Header::default(), + identifier: round2_secret_package.identifier, + signing_share: key_package.signing_share, + commitment: commitment.clone(), + }; + + rounds::repair::run_threshold_repair::<$impl_type, _, _>( + Some($tracer), + $i, + $helpers, + $key_package.secret_share, + $commitment, + $participant, + $role, + $rng, + $party, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to run threshold repair: {err:?}"), + })? + }}; +} + +pub struct ZcashFrostRepairExtraParams { + i: u16, + t: u16, + helpers: Vec, + participant: u16, + job_id: JobId, + role_type: RoleType, + keyshare: FrostKeyShare, + user_id_to_account_id_mapping: Arc>, +} + +#[async_trait] +impl< + B: Block, + BE: Backend + 'static, + KBE: KeystoreBackend, + C: ClientWithApi, + N: Network, + > AsyncProtocol for ZcashFrostRepairProtocol +where + >::Api: JobsApi, +{ + type AdditionalParams = ZcashFrostRepairExtraParams; + async fn generate_protocol_from( + &self, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + protocol_message_channel: UnboundedReceiver, + additional_params: Self::AdditionalParams, + ) -> Result { + let debug_logger_post = self.logger.clone(); + let logger = debug_logger_post.clone(); + let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); + let protocol_output_clone = protocol_output.clone(); + let client = self.client.clone(); + let id = self.account_id; + let network = self.network.clone(); + + let (i, helpers, t, participant, keyshare, role_type, mapping) = ( + additional_params.i, + additional_params.helpers, + additional_params.t, + additional_params.participant, + additional_params.keyshare, + additional_params.role_type, + additional_params.user_id_to_account_id_mapping.clone(), + ); + + let role = match role_type { + RoleType::Tss(role) => role, + _ => { + return Err(JobError { + reason: "Invalid role type".to_string(), + }) + } + }; + + let keyshare2 = keyshare.clone(); + + Ok(JobBuilder::new() + .protocol(async move { + let mut rng = rand::rngs::StdRng::from_entropy(); + let protocol_message_channel = + super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + + logger.info(format!( + "Starting Signing Protocol with params: i={i}, t={t}" + )); + + let ( + signing_tx_to_outbound, + signing_rx_async_proto, + _broadcast_tx_to_outbound, + _broadcast_rx_from_gadget, + ) = super::util::create_job_manager_to_async_protocol_channel_split::<_, (), _>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + + let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); + let delivery = (signing_rx_async_proto, signing_tx_to_outbound); + let party = MpcParty::connected(delivery); + let signature = match role { + ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { + run_threshold_repair!( + Secp256K1Sha256, + keyshare, + &mut tracer, + i, + helpers, + participant, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostEd25519 => { + run_threshold_repair!( + Ed25519Sha512, + keyshare, + &mut tracer, + i, + helpers, + participant, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostP256 => { + run_threshold_repair!( + P256Sha256, + keyshare, + &mut tracer, + i, + helpers, + participant, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostRistretto255 => { + run_threshold_repair!( + Ristretto255Sha512, + keyshare, + &mut tracer, + i, + helpers, + participant, + role, + &mut rng, + party + ) + } + _ => { + return Err(JobError { + reason: "Invalid role type".to_string(), + }) + } + }; + let perf_report = tracer.get_report().map_err(|err| JobError { + reason: format!("Signing protocol error: {err:?}"), + })?; + logger.trace(format!("Signing protocol report: {perf_report}")); + logger.debug("Finished AsyncProtocol - Signing"); + *protocol_output.lock().await = Some(signature); + Ok(()) + }) + .post(async move { + // Submit the protocol output to the blockchain + if let Some(signature) = protocol_output_clone.lock().await.take() { + // TODO: Submit some job result to the blockchain. + } + + Ok(()) + }) + .build()) + } +} diff --git a/protocols/zcash-frost/src/rounds/repair.rs b/protocols/zcash-frost/src/rounds/repair.rs index d5c9a4a63..953759851 100644 --- a/protocols/zcash-frost/src/rounds/repair.rs +++ b/protocols/zcash-frost/src/rounds/repair.rs @@ -59,7 +59,7 @@ pub async fn run_threshold_repair( role: ThresholdSignatureRoleType, rng: &mut R, party: M, -) -> Result>, RepairError> +) -> Result>, RepairError> where R: RngCore + CryptoRng, M: Mpc, @@ -175,15 +175,16 @@ where .collect(); tracer.msgs_received(); tracer.stage("Repair secret share w/ sigmas from helpers"); - let mut secret_share: Option> = None; + let mut secret_share: Option> = None; if i == participant { let commitment = commitment.unwrap(); - secret_share = Some(repair_round3( + let secret_share_val = repair_round3( role, &sigmas, lost_share_participant_identifier, &commitment, - )); + ); + secret_share = Some(secret_share_val.serialize().unwrap_or_default()); } tracer.protocol_ends(); From 9a9af60b4e995157f4cd1b5b1d4fa0d95776a524 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 1 Feb 2024 19:35:08 +0200 Subject: [PATCH 09/66] delete: repair logic --- protocols/zcash-frost/src/protocols/mod.rs | 1 - protocols/zcash-frost/src/protocols/repair.rs | 401 ------------------ protocols/zcash-frost/src/rounds/mod.rs | 17 - protocols/zcash-frost/src/rounds/repair.rs | 268 ------------ 4 files changed, 687 deletions(-) delete mode 100644 protocols/zcash-frost/src/protocols/repair.rs delete mode 100644 protocols/zcash-frost/src/rounds/repair.rs diff --git a/protocols/zcash-frost/src/protocols/mod.rs b/protocols/zcash-frost/src/protocols/mod.rs index 36a8a722d..16b9199e9 100644 --- a/protocols/zcash-frost/src/protocols/mod.rs +++ b/protocols/zcash-frost/src/protocols/mod.rs @@ -1,4 +1,3 @@ pub mod keygen; -pub mod repair; pub mod sign; pub mod util; diff --git a/protocols/zcash-frost/src/protocols/repair.rs b/protocols/zcash-frost/src/protocols/repair.rs deleted file mode 100644 index 43684f5a1..000000000 --- a/protocols/zcash-frost/src/protocols/repair.rs +++ /dev/null @@ -1,401 +0,0 @@ -use async_trait::async_trait; -use frost_core::keys::{KeyPackage, PublicKeyPackage}; -use frost_ed25519::Ed25519Sha512; -use frost_p256::P256Sha256; -use frost_ristretto255::Ristretto255Sha512; -use frost_secp256k1::Secp256K1Sha256; -use gadget_common::client::{AccountId, ClientWithApi, JobsClient}; -use gadget_common::debug_logger::DebugLogger; -use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; -use gadget_common::gadget::network::Network; -use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::gadget::{GadgetProtocol, JobInitMetadata, WorkManagerConfig}; -use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; -use gadget_common::protocol::AsyncProtocol; -use gadget_common::{Block, BlockImportNotification}; -use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; -use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; -use pallet_jobs_rpc_runtime_api::JobsApi; -use rand::SeedableRng; -use round_based::MpcParty; -use sc_client_api::Backend; -use sp_api::ProvideRuntimeApi; -use sp_core::keccak_256; -use std::collections::HashMap; -use std::sync::Arc; -use tangle_primitives::jobs::{ - DKGTSSSignatureResult, DigitalSignatureType, JobId, JobResult, JobType, -}; -use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; -use tokio::sync::mpsc::UnboundedReceiver; - -use crate::rounds; -use crate::rounds::keygen::FrostKeyShare; - -pub struct ZcashFrostRepairProtocol { - client: JobsClient, - key_store: ECDSAKeyStore, - network: N, - logger: DebugLogger, - account_id: AccountId, -} - -pub async fn create_protocol( - account_id: AccountId, - client: JobsClient, - network: N, - logger: DebugLogger, - key_store: ECDSAKeyStore, -) -> ZcashFrostRepairProtocol -where - B: Block, - BE: Backend, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - >::Api: JobsApi, -{ - ZcashFrostRepairProtocol { - client, - network, - key_store, - logger, - account_id, - } -} - -#[async_trait] -impl< - B: Block, - BE: Backend + 'static, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - > GadgetProtocol for ZcashFrostRepairProtocol -where - >::Api: JobsApi, -{ - fn name(&self) -> String { - "zcash-frost-repair".to_string() - } - - async fn create_next_job( - &self, - job: JobInitMetadata, - ) -> Result<::AdditionalParams, gadget_common::Error> { - let job_id = job.job_id; - - let JobType::DKGTSSPhaseThree(p3_job) = job.job_type else { - panic!("Should be valid type") - }; - let previous_job_id = p3_job.phase_one_id; - - let phase1_job = job.phase1_job.expect("Should exist for a phase 2 job"); - let participants = phase1_job.clone().get_participants().expect("Should exist"); - let t = phase1_job.get_threshold().expect("Should exist") as u16; - - let seed = - keccak_256(&[&job_id.to_be_bytes()[..], &job.retry_id.to_be_bytes()[..]].concat()); - let mut rng = rand_chacha::ChaChaRng::from_seed(seed); - - let key = self - .key_store - .get_job_result(previous_job_id) - .await - .map_err(|err| gadget_common::Error::ClientError { - err: err.to_string(), - })? - .ok_or_else(|| gadget_common::Error::ClientError { - err: format!("No key found for job ID: {job_id:?}"), - })?; - - let user_id_to_account_id_mapping = Arc::new( - participants - .clone() - .into_iter() - .enumerate() - .map(|r| (r.0 as UserID, r.1)) - .collect(), - ); - - let params = ZcashFrostRepairExtraParams { - i: participants - .iter() - .position(|p| p == &self.account_id) - .expect("Should exist") as u16, - t, - helpers: participants - .into_iter() - .enumerate() - .map(|r| r.0 as u16) - .collect(), - job_id, - // TODO: Update to use the correct participant once the job type is updated. - participant: 1u16, - role_type: job.role_type, - keyshare: key, - user_id_to_account_id_mapping, - }; - Ok(params) - } - - async fn process_block_import_notification( - &self, - _notification: BlockImportNotification, - _job_manager: &ProtocolWorkManager, - ) -> Result<(), gadget_common::Error> { - Ok(()) - } - - async fn process_error( - &self, - error: gadget_common::Error, - _job_manager: &ProtocolWorkManager, - ) { - log::error!(target: "gadget", "Error: {error:?}"); - } - - fn account_id(&self) -> &AccountId { - &self.account_id - } - - fn role_filter(&self, role: RoleType) -> bool { - matches!( - role, - RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) - ) - } - - fn phase_filter(&self, job: JobType) -> bool { - matches!(job, JobType::DKGTSSPhaseTwo(_)) - } - - fn client(&self) -> &JobsClient { - &self.client - } - - fn logger(&self) -> &DebugLogger { - &self.logger - } - - fn get_work_manager_config(&self) -> WorkManagerConfig { - WorkManagerConfig { - interval: Some(crate::constants::signing_worker::JOB_POLL_INTERVAL), - max_active_tasks: crate::constants::signing_worker::MAX_RUNNING_TASKS, - max_pending_tasks: crate::constants::signing_worker::MAX_ENQUEUED_TASKS, - } - } -} - -macro_rules! run_threshold_repair { - ($impl_type:ty, $keyshare:expr, $tracer:expr, $i:expr, $helpers:expr, $participant:expr, $role:expr, $rng:expr, $party:expr) => {{ - let key_package = - KeyPackage::<$impl_type>::deserialize(&$keyshare.key_package).map_err(|err| { - JobError { - reason: format!("Failed to deserialize key share: {err:?}"), - } - })?; - - let public_key_package = PublicKeyPackage::<$impl_type>::deserialize( - &$keyshare.pubkey_package, - ) - .map_err(|err| JobError { - reason: format!("Failed to deserialize public key package: {err:?}"), - })?; - - let secret_share = SecretShare::<$impl_type> { - header: Header::default(), - identifier: round2_secret_package.identifier, - signing_share: key_package.signing_share, - commitment: commitment.clone(), - }; - - rounds::repair::run_threshold_repair::<$impl_type, _, _>( - Some($tracer), - $i, - $helpers, - $key_package.secret_share, - $commitment, - $participant, - $role, - $rng, - $party, - ) - .await - .map_err(|err| JobError { - reason: format!("Failed to run threshold repair: {err:?}"), - })? - }}; -} - -pub struct ZcashFrostRepairExtraParams { - i: u16, - t: u16, - helpers: Vec, - participant: u16, - job_id: JobId, - role_type: RoleType, - keyshare: FrostKeyShare, - user_id_to_account_id_mapping: Arc>, -} - -#[async_trait] -impl< - B: Block, - BE: Backend + 'static, - KBE: KeystoreBackend, - C: ClientWithApi, - N: Network, - > AsyncProtocol for ZcashFrostRepairProtocol -where - >::Api: JobsApi, -{ - type AdditionalParams = ZcashFrostRepairExtraParams; - async fn generate_protocol_from( - &self, - associated_block_id: ::Clock, - associated_retry_id: ::RetryID, - associated_session_id: ::SessionID, - associated_task_id: ::TaskID, - protocol_message_channel: UnboundedReceiver, - additional_params: Self::AdditionalParams, - ) -> Result { - let debug_logger_post = self.logger.clone(); - let logger = debug_logger_post.clone(); - let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); - let protocol_output_clone = protocol_output.clone(); - let client = self.client.clone(); - let id = self.account_id; - let network = self.network.clone(); - - let (i, helpers, t, participant, keyshare, role_type, mapping) = ( - additional_params.i, - additional_params.helpers, - additional_params.t, - additional_params.participant, - additional_params.keyshare, - additional_params.role_type, - additional_params.user_id_to_account_id_mapping.clone(), - ); - - let role = match role_type { - RoleType::Tss(role) => role, - _ => { - return Err(JobError { - reason: "Invalid role type".to_string(), - }) - } - }; - - let keyshare2 = keyshare.clone(); - - Ok(JobBuilder::new() - .protocol(async move { - let mut rng = rand::rngs::StdRng::from_entropy(); - let protocol_message_channel = - super::util::CloneableUnboundedReceiver::from(protocol_message_channel); - - logger.info(format!( - "Starting Signing Protocol with params: i={i}, t={t}" - )); - - let ( - signing_tx_to_outbound, - signing_rx_async_proto, - _broadcast_tx_to_outbound, - _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split::<_, (), _>( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - id, - network.clone(), - ); - - let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - let delivery = (signing_rx_async_proto, signing_tx_to_outbound); - let party = MpcParty::connected(delivery); - let signature = match role { - ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { - run_threshold_repair!( - Secp256K1Sha256, - keyshare, - &mut tracer, - i, - helpers, - participant, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostEd25519 => { - run_threshold_repair!( - Ed25519Sha512, - keyshare, - &mut tracer, - i, - helpers, - participant, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostP256 => { - run_threshold_repair!( - P256Sha256, - keyshare, - &mut tracer, - i, - helpers, - participant, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostRistretto255 => { - run_threshold_repair!( - Ristretto255Sha512, - keyshare, - &mut tracer, - i, - helpers, - participant, - role, - &mut rng, - party - ) - } - _ => { - return Err(JobError { - reason: "Invalid role type".to_string(), - }) - } - }; - let perf_report = tracer.get_report().map_err(|err| JobError { - reason: format!("Signing protocol error: {err:?}"), - })?; - logger.trace(format!("Signing protocol report: {perf_report}")); - logger.debug("Finished AsyncProtocol - Signing"); - *protocol_output.lock().await = Some(signature); - Ok(()) - }) - .post(async move { - // Submit the protocol output to the blockchain - if let Some(signature) = protocol_output_clone.lock().await.take() { - // TODO: Submit some job result to the blockchain. - } - - Ok(()) - }) - .build()) - } -} diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index 644549e23..c5ecf8ee5 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -13,7 +13,6 @@ use self::errors::IoError; pub mod errors; pub mod keygen; -pub mod repair; pub mod sign; /// Keygen protocol error @@ -115,12 +114,6 @@ enum Reason { #[from] SignAborted, ), - #[error("repair protocol was aborted by malicious party")] - RepairFailure( - #[source] - #[from] - RepairAborted, - ), #[error("i/o error")] IoError(#[source] IoError), #[error("unknown error")] @@ -146,13 +139,3 @@ enum SignAborted { error: frost_core::Error, }, } - -/// Repair protocol error -#[derive(Debug, Error)] -enum RepairAborted { - #[error("Frost repair error")] - FrostError { - parties: Vec, - error: frost_core::Error, - }, -} diff --git a/protocols/zcash-frost/src/rounds/repair.rs b/protocols/zcash-frost/src/rounds/repair.rs deleted file mode 100644 index 953759851..000000000 --- a/protocols/zcash-frost/src/rounds/repair.rs +++ /dev/null @@ -1,268 +0,0 @@ -use dfns_cggmp21::progress::Tracer; -use dfns_cggmp21::round_based::ProtocolMessage; -use frost_core::keys::repairable::{repair_share_step_1, repair_share_step_2, repair_share_step_3}; -use frost_core::keys::{SecretShare, VerifiableSecretSharingCommitment}; - -use frost_core::{Ciphersuite, Field, Group, Identifier, Scalar}; -use futures::SinkExt; -use rand_core::{CryptoRng, RngCore}; -use round_based::rounds_router::simple_store::RoundInput; -use round_based::rounds_router::RoundsRouter; -use round_based::{Delivery, Mpc, MpcParty, Outgoing}; -use serde::{Deserialize, Serialize}; -use std::collections::BTreeMap; -use tangle_primitives::roles::ThresholdSignatureRoleType; - -use super::errors::IoError; -use super::{Reason, RepairAborted, RepairError}; - -/// Message of key generation protocol -#[derive(ProtocolMessage, Clone, Serialize, Deserialize)] -#[serde(bound = "")] -pub enum Msg { - /// Round 1 message - Round1(MsgRound1), - /// Round 2 message - Round2(MsgRound2), -} - -/// Message from round 1 -#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] -#[serde(bound = "")] -#[udigest(bound = "")] -#[udigest(tag = "zcash.frost.sign.threshold.round1")] -pub struct MsgRound1 { - pub msg: Vec, -} -/// Message from round 2 -#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] -#[serde(bound = "")] -#[udigest(bound = "")] -#[udigest(tag = "zcash.frost.sign.threshold.round2")] -pub struct MsgRound2 { - pub msg: Vec, -} - -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct FrostSignature { - pub group_signature: Vec, -} - -#[allow(clippy::too_many_arguments)] -pub async fn run_threshold_repair( - mut tracer: Option<&mut dyn Tracer>, - i: u16, - helpers: Vec, - share_i: &SecretShare, - commitment: Option>, - participant: u16, - role: ThresholdSignatureRoleType, - rng: &mut R, - party: M, -) -> Result>, RepairError> -where - R: RngCore + CryptoRng, - M: Mpc, - C: Ciphersuite, -{ - tracer.protocol_begins(); - - tracer.stage("Setup networking"); - let MpcParty { delivery, .. } = party.into_party(); - let (incomings, mut outgoings) = delivery.split(); - - let mut rounds = RoundsRouter::::builder(); - let round1 = rounds.add_round(RoundInput::::p2p(i, helpers.len() as u16)); - let round2 = rounds.add_round(RoundInput::::broadcast(i, helpers.len() as u16)); - let mut rounds = rounds.listen(incomings); - - // Round 1 - tracer.round_begins(); - let helpers: Vec> = helpers - .iter() - .map(|i| Identifier::try_from(*i).expect("should be nonzero")) - .collect(); - let lost_share_participant_identifier = - Identifier::::try_from(participant).expect("should be nonzero"); - let _my_identifier = Identifier::::try_from(i).expect("should be nonzero"); - - tracer.send_msg(); - tracer.stage("Repair share step 1"); - // Calculate the messages to be sent to each party - let round1_msg_map: BTreeMap, Scalar> = helper_round1( - role, - &helpers, - share_i, - lost_share_participant_identifier, - rng, - )?; - for (identifier, msg) in round1_msg_map { - let receiver_index_be_bytes: [u8; 2] = identifier - .serialize() - .as_ref() - .try_into() - .expect("should be 2 bytes"); - let receiver_index = u16::from_be_bytes(receiver_index_be_bytes); - outgoings - .send(Outgoing::p2p( - receiver_index, - Msg::Round1(MsgRound1 { - msg: ::Field::serialize(&msg) - .as_ref() - .to_vec(), - }), - )) - .await - .map_err(|e| RepairError(Reason::IoError(IoError::send_message(e))))?; - } - tracer.msg_sent(); - - // Round 2 - tracer.round_begins(); - - tracer.receive_msgs(); - let delta_js: Vec> = rounds - .complete(round1) - .await - .map_err(|e| RepairError(Reason::IoError(IoError::receive_message(e))))? - .into_vec_without_me() - .into_iter() - .map(|msg| { - let ser = <::Field as Field>::Serialization::try_from(msg.msg) - .map_err(|_e| RepairError(Reason::::SerializationError)) - .expect("Failed to deserialize round 1 scalar"); - ::Field::deserialize(&ser) - .unwrap_or(::Field::zero()) - }) - .collect(); - tracer.msgs_received(); - - tracer.send_msg(); - tracer.stage("Repair share step 2"); - let round2_msg: Scalar = helper_round2::(role, delta_js.as_ref()); - outgoings - .send(Outgoing::p2p( - participant, - Msg::Round2(MsgRound2 { - msg: ::Field::serialize(&round2_msg) - .as_ref() - .to_vec(), - }), - )) - .await - .map_err(|e| RepairError(Reason::IoError(IoError::send_message(e))))?; - tracer.msg_sent(); - - // TODO: Figure out how to properly represent the participant requesting the - // TODO: share repairing. They do not run `helper_round1` or `helper_round2`. - // TODO: Instead they just run reconstruct. - tracer.round_begins(); - tracer.stage("Repair step 3 (run by participant requesting repairing)"); - tracer.receive_msgs(); - let sigmas: Vec> = rounds - .complete(round2) - .await - .map_err(|e| RepairError(Reason::IoError(IoError::receive_message(e))))? - .into_vec_without_me() - .into_iter() - .map(|msg| { - let ser = <::Field as Field>::Serialization::try_from(msg.msg) - .map_err(|_e| RepairError(Reason::::SerializationError)) - .expect("Failed to deserialize round 1 scalar"); - ::Field::deserialize(&ser) - .unwrap_or(::Field::zero()) - }) - .collect(); - tracer.msgs_received(); - tracer.stage("Repair secret share w/ sigmas from helpers"); - let mut secret_share: Option> = None; - if i == participant { - let commitment = commitment.unwrap(); - let secret_share_val = repair_round3( - role, - &sigmas, - lost_share_participant_identifier, - &commitment, - ); - secret_share = Some(secret_share_val.serialize().unwrap_or_default()); - } - tracer.protocol_ends(); - - Ok(secret_share) -} - -/// Step 1 of RTS. -/// -/// Generates the "delta" values from `helper_i` to help `participant` recover their share -/// where `helpers` contains the identifiers of all the helpers (including `helper_i`), and `share_i` -/// is the share of `helper_i`. -/// -/// Returns a BTreeMap mapping which value should be sent to which participant. -/// Taken from https://github.com/LIT-Protocol/frost/blob/main/frost-ed25519/src/keys/repairable.rs -fn helper_round1( - role: ThresholdSignatureRoleType, - helpers: &[Identifier], - share_i: &SecretShare, - participant: Identifier, - rng: &mut R, -) -> Result, Scalar>, RepairError> { - match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 - | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), - }; - - repair_share_step_1(helpers, share_i, rng, participant).map_err(|e| { - RepairError(Reason::RepairFailure(RepairAborted::FrostError { - parties: vec![], - error: e, - })) - }) -} - -/// Step 2 of RTS. -/// -/// Generates the `sigma` values from all `deltas` received from `helpers` -/// to help `participant` recover their share. -/// `sigma` is the sum of all received `delta` and the `delta_i` generated for `helper_i`. -/// -/// Returns a scalar -/// Taken from https://github.com/LIT-Protocol/frost/blob/main/frost-ed25519/src/keys/repairable.rs -fn helper_round2( - role: ThresholdSignatureRoleType, - deltas_j: &[Scalar], -) -> Scalar { - match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 - | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), - }; - - repair_share_step_2::(deltas_j) -} - -/// Step 3 of RTS -/// -/// The `participant` sums all `sigma_j` received to compute the `share`. The `SecretShare` -/// is made up of the `identifier`and `commitment` of the `participant` as well as the -/// `value` which is the `SigningShare`. -pub fn repair_round3( - role: ThresholdSignatureRoleType, - sigmas: &[Scalar], - identifier: Identifier, - commitment: &VerifiableSecretSharingCommitment, -) -> SecretShare { - match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 - | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), - }; - - repair_share_step_3(sigmas, identifier, commitment) -} From 170450a75359b889a531d0aad5446d5a7d60cd81 Mon Sep 17 00:00:00 2001 From: drewstone Date: Fri, 2 Feb 2024 18:21:26 +0200 Subject: [PATCH 10/66] Update protocols/zcash-frost/src/protocols/keygen.rs Co-authored-by: shekohex --- protocols/zcash-frost/src/protocols/keygen.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index ba20a08d0..b6e1f0add 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -143,7 +143,11 @@ where fn role_filter(&self, role: RoleType) -> bool { matches!( role, - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) + RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSr25519) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) ) } From c5bf2aed2721eb3e25faf43bd03961f8056fcb61 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Fri, 2 Feb 2024 18:22:28 +0200 Subject: [PATCH 11/66] fmt --- protocols/zcash-frost/src/protocols/keygen.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index b6e1f0add..05c66fb4f 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -144,10 +144,10 @@ where matches!( role, RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSr25519) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) ) } From e3b25f4c6388c6d23dae70f1ca07947ad0540300 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Tue, 6 Feb 2024 12:42:09 +0200 Subject: [PATCH 12/66] fix: keygen to completion, failing at tangle runtime --- Cargo.lock | 199 ++++++++++----------- Cargo.toml | 1 - protocols/zcash-frost/Cargo.toml | 1 - protocols/zcash-frost/src/rounds/keygen.rs | 36 ++-- protocols/zcash-frost/src/rounds/mod.rs | 12 +- 5 files changed, 122 insertions(+), 127 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70029f370..c25ae2710 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -627,8 +627,8 @@ dependencies = [ "futures-io", "futures-lite 2.2.0", "parking", - "polling 3.3.2", - "rustix 0.38.30", + "polling 3.4.0", + "rustix 0.38.31", "slab", "tracing", "windows-sys 0.52.0", @@ -678,7 +678,7 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.30", + "rustix 0.38.31", "windows-sys 0.48.0", ] @@ -694,7 +694,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 0.38.30", + "rustix 0.38.31", "signal-hook-registry", "slab", "windows-sys 0.48.0", @@ -1172,9 +1172,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytecheck" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" dependencies = [ "bytecheck_derive", "ptr_meta", @@ -1183,9 +1183,9 @@ dependencies = [ [[package]] name = "bytecheck_derive" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ "proc-macro2", "quote", @@ -2005,12 +2005,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.4" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da01daa5f6d41c91358398e8db4dde38e292378da1f28300b59ef4732b879454" +checksum = "fc5d6b04b3fd0ba9926f945895de7d806260a2d7431ba82e7edaecb043c4c6b8" dependencies = [ - "darling_core 0.20.4", - "darling_macro 0.20.4", + "darling_core 0.20.5", + "darling_macro 0.20.5", ] [[package]] @@ -2029,9 +2029,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.4" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f44f6238b948a3c6c3073cdf53bb0c2d5e024ee27e0f35bfe9d556a12395808a" +checksum = "04e48a959bcd5c761246f5d090ebc2fbf7b9cd527a492b07a67510c108f1e7e3" dependencies = [ "fnv", "ident_case", @@ -2054,11 +2054,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.4" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d2d88bd93979b1feb760a6b5c531ac5ba06bd63e74894c377af02faee07b9cd" +checksum = "1d1545d67a2149e1d93b7e5c7752dce5a7426eb5d1357ddcfd89336b94444f77" dependencies = [ - "darling_core 0.20.4", + "darling_core 0.20.5", "quote", "syn 2.0.48", ] @@ -2628,7 +2628,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ - "darling 0.20.4", + "darling 0.20.5", "proc-macro2", "quote", "syn 2.0.48", @@ -2769,9 +2769,9 @@ dependencies = [ [[package]] name = "ethers-core" -version = "2.0.12" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "918b1a9ba585ea61022647def2f27c29ba19f6d2a4a4c8f68a9ae97fd5769737" +checksum = "aab3cef6cc1c9fd7f787043c81ad3052eff2b96a3878ef1526aa446311bdbfc9" dependencies = [ "arrayvec 0.7.4", "bytes", @@ -2847,9 +2847,9 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6267a1fa6f59179ea4afc8e50fd8612a3cc60bc858f786ff877a4a8cb042799" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" dependencies = [ "indenter", "once_cell", @@ -2975,9 +2975,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" +checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" [[package]] name = "file-per-thread-logger" @@ -3357,20 +3357,6 @@ dependencies = [ "sha2 0.10.8", ] -[[package]] -name = "frost-taproot" -version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" -dependencies = [ - "document-features", - "frost-core", - "frost-rerandomized", - "k256", - "rand_core 0.6.4", - "sha2 0.10.8", - "signature 2.2.0", -] - [[package]] name = "fs-err" version = "2.11.0" @@ -3609,9 +3595,9 @@ dependencies = [ [[package]] name = "generic-ec" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81960ce6c780f5a63f6ab4e94b3b34212f839ce7e7768b953413e4ee3c4d1438" +checksum = "e61335b136fd9559af4284e642c081c2845e1f92650909eeec1fb47a8945a3f7" dependencies = [ "generic-ec-core", "generic-ec-curves", @@ -3641,9 +3627,9 @@ dependencies = [ [[package]] name = "generic-ec-curves" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d2e666dc9d9ac12f101e119490ff6f6577a25c3a3e43ba901e51b18203d128" +checksum = "a01b7dc4d4f06522f1c2bd8170c978f555a317c0e6c6f141b8b4f3db63c8c302" dependencies = [ "crypto-bigint 0.5.5", "elliptic-curve 0.13.8", @@ -3812,7 +3798,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.2.1", + "indexmap 2.2.2", "slab", "tokio", "tokio-util", @@ -3927,9 +3913,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -4097,9 +4083,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -4259,9 +4245,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -4307,7 +4293,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.4", + "hermit-abi 0.3.5", "libc", "windows-sys 0.48.0", ] @@ -4342,8 +4328,8 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" dependencies = [ - "hermit-abi 0.3.4", - "rustix 0.38.30", + "hermit-abi 0.3.5", + "rustix 0.38.31", "windows-sys 0.52.0", ] @@ -4498,13 +4484,14 @@ dependencies = [ [[package]] name = "jubjub" version = "0.10.4" -source = "git+https://github.com/LIT-Protocol/jubjub.git#b4aa27ecd61558dc50656d5810d62457dc31ce8c" +source = "git+https://github.com/LIT-Protocol/jubjub.git#3924292eb6b3ef5489744998c18de7c5144df499" dependencies = [ "bitvec 1.0.1", "bls12_381_plus", "elliptic-curve 0.13.8", "ff 0.13.0", "group 0.13.0", + "hex", "rand_chacha 0.3.1", "rand_core 0.6.4", "serde", @@ -4568,9 +4555,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" @@ -5263,7 +5250,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.30", + "rustix 0.38.31", ] [[package]] @@ -5343,9 +5330,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] @@ -5466,7 +5453,7 @@ dependencies = [ "round-based 0.1.7", "serde", "serde_repr", - "serde_with 3.5.1", + "serde_with 3.6.0", "sha2 0.9.9", "subtle", "thiserror", @@ -5754,6 +5741,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-format" version = "0.4.4" @@ -5813,7 +5806,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.4", + "hermit-abi 0.3.5", "libc", ] @@ -5993,7 +5986,7 @@ dependencies = [ "rand_core 0.6.4", "rug", "serde", - "serde_with 3.5.1", + "serde_with 3.6.0", "thiserror", ] @@ -6030,7 +6023,7 @@ dependencies = [ [[package]] name = "pallet-dkg" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" +source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" dependencies = [ "frame-support", "frame-system", @@ -6048,7 +6041,7 @@ dependencies = [ [[package]] name = "pallet-jobs" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" +source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" dependencies = [ "frame-benchmarking", "frame-support", @@ -6065,7 +6058,7 @@ dependencies = [ [[package]] name = "pallet-jobs-rpc-runtime-api" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" +source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", @@ -6096,7 +6089,7 @@ dependencies = [ [[package]] name = "pallet-zksaas" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" +source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" dependencies = [ "frame-benchmarking", "frame-support", @@ -6305,7 +6298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.2.1", + "indexmap 2.2.2", ] [[package]] @@ -6453,14 +6446,14 @@ dependencies = [ [[package]] name = "polling" -version = "3.3.2" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" +checksum = "30054e72317ab98eddd8561db0f6524df3367636884b7b21b703e4b280a84a14" dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite 0.2.13", - "rustix 0.38.30", + "rustix 0.38.31", "tracing", "windows-sys 0.52.0", ] @@ -7290,9 +7283,9 @@ dependencies = [ [[package]] name = "rend" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" dependencies = [ "bytecheck", ] @@ -7374,9 +7367,9 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.43" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527a97cdfef66f65998b5f3b637c26f5a5ec09cc52a3f9932313ac645f4190f5" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" dependencies = [ "bitvec 1.0.1", "bytecheck", @@ -7392,9 +7385,9 @@ dependencies = [ [[package]] name = "rkyv_derive" -version = "0.7.43" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5c462a1328c8e67e4d6dbad1eb0355dd43e8ab432c6e227a43657f16ade5033" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" dependencies = [ "proc-macro2", "quote", @@ -7576,9 +7569,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.2", "errno", @@ -8325,18 +8318,18 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.5.1" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5c9fdb6b00a489875b22efd4b78fe2b363b72265cc5f6eb2e2b9ee270e6140c" +checksum = "1b0ed1662c5a68664f45b76d18deb0e234aff37207086803165c961eb695e981" dependencies = [ "base64 0.21.7", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.1", + "indexmap 2.2.2", "serde", "serde_json", - "serde_with_macros 3.5.1", + "serde_with_macros 3.6.0", "time", ] @@ -8346,7 +8339,7 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" dependencies = [ - "darling 0.20.4", + "darling 0.20.5", "proc-macro2", "quote", "syn 2.0.48", @@ -8354,11 +8347,11 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.5.1" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbff351eb4b33600a2e138dfa0b10b65a238ea8ff8fb2387c422c5022a3e8298" +checksum = "568577ff0ef47b879f736cd66740e022f3672788cdf002a05a4e609ea5a6fb15" dependencies = [ - "darling 0.20.4", + "darling 0.20.5", "proc-macro2", "quote", "syn 2.0.48", @@ -9840,7 +9833,7 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5086ce2a90e723083ff19b77f06805d00e732eac3e19c86f6cd643d4255d334" dependencies = [ - "darling 0.20.4", + "darling 0.20.5", "parity-scale-codec 3.6.9", "proc-macro-error", "subxt-codegen", @@ -9918,7 +9911,7 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" +source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -9928,7 +9921,7 @@ dependencies = [ [[package]] name = "tangle-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#60990ee481a68fc6db0d9b8f5c7763531450fb17" +source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" dependencies = [ "ark-bn254", "ark-crypto-primitives", @@ -9966,14 +9959,13 @@ checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall 0.4.1", - "rustix 0.38.30", + "rustix 0.38.31", "windows-sys 0.52.0", ] @@ -10094,12 +10086,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -10114,10 +10107,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] @@ -10176,9 +10170,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -10275,7 +10269,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap 2.2.1", + "indexmap 2.2.2", "serde", "serde_spanned", "toml_datetime", @@ -11407,7 +11401,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.30", + "rustix 0.38.31", ] [[package]] @@ -11728,9 +11722,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.35" +version = "0.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" +checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" dependencies = [ "memchr", ] @@ -11849,7 +11843,6 @@ dependencies = [ "frost-rerandomized", "frost-ristretto255", "frost-secp256k1", - "frost-taproot", "futures", "gadget-common", "gadget-core", diff --git a/Cargo.toml b/Cargo.toml index 51c6b3f8b..d82b36ebb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,6 @@ frost-redjubjub = { git = "https://github.com/LIT-Protocol/frost.git" } frost-ristretto255 = { git = "https://github.com/LIT-Protocol/frost.git" } frost-secp256k1 = { git = "https://github.com/LIT-Protocol/frost.git" } frost-rerandomized = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-taproot = { git = "https://github.com/LIT-Protocol/frost.git" } sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml index d26661ea6..58df5c15d 100644 --- a/protocols/zcash-frost/Cargo.toml +++ b/protocols/zcash-frost/Cargo.toml @@ -32,7 +32,6 @@ frost-redjubjub = { workspace = true } frost-ristretto255 = { workspace = true } frost-secp256k1 = { workspace = true } frost-rerandomized = { workspace = true } -frost-taproot = { workspace = true } pallet-jobs-rpc-runtime-api = { workspace = true, features = ["std"] } pallet-jobs = { workspace = true, features = ["std"] } diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 59ecb8205..1372de47b 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -90,12 +90,13 @@ where tracer.round_begins(); tracer.stage("Compute round 1 dkg secret package"); - let (round1_secret_package, round1_package) = dkg_part1(i, n, t, role, rng).map_err(|e| { - KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { - parties: vec![], - error: e, - })) - })?; + let (round1_secret_package, round1_package) = + dkg_part1(i + 1, t, n, role, rng).map_err(|e| { + KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { + parties: vec![], + error: e, + })) + })?; tracer.send_msg(); let my_round1_msg = MsgRound1 { @@ -134,7 +135,9 @@ where p.clone(), ) }) + .filter(|(inx, _)| *inx != Identifier::try_from(i + 1).unwrap()) .collect(); + let (round2_secret_package, round2_packages_map) = dkg_part2(role, round1_secret_package, &round1_packages_map).map_err(|e| { KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { @@ -145,15 +148,16 @@ where tracer.send_msg(); for (receiver_identifier, round2_package) in round2_packages_map { - let receiver_index_be_bytes: [u8; 2] = receiver_identifier - .serialize() - .as_ref() - .try_into() - .expect("should be 2 bytes"); - let receiver_index = u16::from_be_bytes(receiver_index_be_bytes); + let receiver_index_bytes: Vec = receiver_identifier.serialize().as_ref().to_vec(); + let receiver_index = u16::from_le_bytes([receiver_index_bytes[0], receiver_index_bytes[1]]); + println!( + "Party i: {:?} | Sending round 2 to {:?}", + i, + receiver_index - 1 + ); outgoings .send(Outgoing::p2p( - receiver_index, + receiver_index - 1, Msg::Round2(MsgRound2 { msg: round2_package.serialize().unwrap_or_default(), }), @@ -222,8 +226,12 @@ where | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} _ => panic!("Invalid role"), }; + println!( + "Party i: {:?}, Total parties n: {:?}, Threshold t: {:?}", + i, n, t + ); let participant_identifier = i.try_into().expect("should be nonzero"); - frost_core::keys::dkg::part1::(participant_identifier, t, n, rng) + frost_core::keys::dkg::part1::(participant_identifier, n, t, rng) } #[allow(clippy::type_complexity)] diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index c5ecf8ee5..96a015309 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -3,10 +3,9 @@ use frost_ed25519::Ed25519Sha512; use frost_ed448::Ed448Shake256; use frost_p256::P256Sha256; use frost_p384::P384Sha384; -use frost_redjubjub::JubjubBlake2b512; +// use frost_redjubjub::JubjubBlake2b512; use frost_ristretto255::Ristretto255Sha512; use frost_secp256k1::Secp256K1Sha256; -use frost_taproot::Secp256K1Taproot; use thiserror::Error; use self::errors::IoError; @@ -42,8 +41,7 @@ impl_keygen_error_from!(P384Sha384); impl_keygen_error_from!(Ristretto255Sha512); impl_keygen_error_from!(Secp256K1Sha256); impl_keygen_error_from!(Ed448Shake256); -impl_keygen_error_from!(JubjubBlake2b512); -impl_keygen_error_from!(Secp256K1Taproot); +// impl_keygen_error_from!(JubjubBlake2b512); /// Sign protocol error #[derive(Debug, Error)] @@ -72,8 +70,7 @@ impl_sign_error_from!(P384Sha384); impl_sign_error_from!(Ristretto255Sha512); impl_sign_error_from!(Secp256K1Sha256); impl_sign_error_from!(Ed448Shake256); -impl_sign_error_from!(JubjubBlake2b512); -impl_sign_error_from!(Secp256K1Taproot); +// impl_sign_error_from!(JubjubBlake2b512); /// Repair protocol error #[derive(Debug, Error)] @@ -96,8 +93,7 @@ impl_repair_error_from!(P384Sha384); impl_repair_error_from!(Ristretto255Sha512); impl_repair_error_from!(Secp256K1Sha256); impl_repair_error_from!(Ed448Shake256); -impl_repair_error_from!(JubjubBlake2b512); -impl_repair_error_from!(Secp256K1Taproot); +// impl_repair_error_from!(JubjubBlake2b512); #[derive(Debug, Error)] enum Reason { From 85d8c03ae6105d5f3b42872f9424ec15ab31b65e Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Tue, 6 Feb 2024 12:42:52 +0200 Subject: [PATCH 13/66] cleanup: remove printlns --- protocols/zcash-frost/src/rounds/keygen.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 1372de47b..42a50a000 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -150,11 +150,6 @@ where for (receiver_identifier, round2_package) in round2_packages_map { let receiver_index_bytes: Vec = receiver_identifier.serialize().as_ref().to_vec(); let receiver_index = u16::from_le_bytes([receiver_index_bytes[0], receiver_index_bytes[1]]); - println!( - "Party i: {:?} | Sending round 2 to {:?}", - i, - receiver_index - 1 - ); outgoings .send(Outgoing::p2p( receiver_index - 1, @@ -226,10 +221,7 @@ where | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} _ => panic!("Invalid role"), }; - println!( - "Party i: {:?}, Total parties n: {:?}, Threshold t: {:?}", - i, n, t - ); + let participant_identifier = i.try_into().expect("should be nonzero"); frost_core::keys::dkg::part1::(participant_identifier, n, t, rng) } From 5c9a4bc0c0230e0d8545fdafef6e087481bb6c82 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 7 Feb 2024 16:52:53 +0200 Subject: [PATCH 14/66] Update against main tangle --- Cargo.lock | 6123 +++++++++++++++-- Cargo.toml | 5 +- gadget-common/Cargo.toml | 31 +- gadget-common/src/client.rs | 110 +- gadget-common/src/config.rs | 22 +- gadget-common/src/gadget/mod.rs | 42 +- gadget-common/src/lib.rs | 46 +- protocols/dfns-cggmp21/src/lib.rs | 15 +- .../dfns-cggmp21/src/protocols/key_refresh.rs | 39 +- .../dfns-cggmp21/src/protocols/key_rotate.rs | 39 +- .../dfns-cggmp21/src/protocols/keygen.rs | 41 +- protocols/dfns-cggmp21/src/protocols/sign.rs | 39 +- protocols/mp-ecdsa/src/lib.rs | 55 +- protocols/mp-ecdsa/src/protocols/keygen.rs | 43 +- protocols/mp-ecdsa/src/protocols/sign.rs | 39 +- protocols/stub/README.md | 4 +- protocols/stub/src/lib.rs | 33 +- protocols/stub/src/protocol.rs | 38 +- protocols/zcash-frost/Cargo.toml | 1 - protocols/zcash-frost/src/lib.rs | 15 +- protocols/zcash-frost/src/protocol.rs | 6 +- protocols/zcash-frost/src/protocols/keygen.rs | 47 +- protocols/zcash-frost/src/protocols/sign.rs | 48 +- protocols/zcash-frost/src/rounds/mod.rs | 4 - protocols/zk-saas/src/lib.rs | 33 +- protocols/zk-saas/src/protocol/mod.rs | 24 +- rust-toolchain.toml | 2 +- test-utils/src/lib.rs | 12 +- test-utils/src/mock.rs | 3 +- 29 files changed, 6132 insertions(+), 827 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c25ae2710..740506f4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,6 +82,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "affix" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e7ea84d3fa2009f355f8429a0b418a96849135a4188fadf384f59127d5d4bc" +dependencies = [ + "convert_case 0.5.0", +] + [[package]] name = "ahash" version = "0.7.7" @@ -121,6 +130,15 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "amcl" +version = "0.3.0" +source = "git+https://github.com/Snowfork/milagro_bls?rev=a6d66e4eb89015e352fb1c9f7b661ecdbb5b2176#a6d66e4eb89015e352fb1c9f7b661ecdbb5b2176" +dependencies = [ + "parity-scale-codec 3.6.9", + "scale-info", +] + [[package]] name = "android-tzdata" version = "0.1.1" @@ -145,6 +163,54 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.79" @@ -174,6 +240,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "ark-bls12-377" version = "0.4.0" @@ -302,7 +377,7 @@ dependencies = [ "num-traits", "paste", "rayon", - "rustc_version", + "rustc_version 0.4.0", "zeroize", ] @@ -473,6 +548,12 @@ dependencies = [ "sha3 0.10.8", ] +[[package]] +name = "array-bytes" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" + [[package]] name = "array-bytes" version = "6.2.2" @@ -506,6 +587,15 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + [[package]] name = "asn1-rs" version = "0.5.2" @@ -739,6 +829,17 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "async_io_stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" +dependencies = [ + "futures", + "pharos", + "rustc_version 0.4.0", +] + [[package]] name = "async_smux" version = "0.3.0" @@ -834,6 +935,20 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" +[[package]] +name = "backoff" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" +dependencies = [ + "futures-core", + "getrandom 0.2.12", + "instant", + "pin-project-lite 0.2.13", + "rand 0.8.5", + "tokio", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -913,6 +1028,12 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + [[package]] name = "beef" version = "0.5.2" @@ -948,12 +1069,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" dependencies = [ "bitcoin_hashes", - "rand 0.8.5", - "rand_core 0.6.4", + "rand 0.6.5", + "rand_core 0.4.2", "serde", "unicode-normalization", ] +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + [[package]] name = "bit-vec" version = "0.6.3" @@ -1095,19 +1225,33 @@ dependencies = [ ] [[package]] -name = "bls12_381_plus" -version = "0.8.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7533858fe2da020c4fba936036e702de0f73144fe13f9c71113f6f804cde3466" +name = "bls" +version = "0.2.0" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" dependencies = [ - "arrayref", - "elliptic-curve 0.13.8", - "ff 0.13.0", - "group 0.13.0", + "arbitrary", + "blst", + "ethereum-types 0.14.1", + "ethereum_hashing", + "ethereum_serde_utils", + "ethereum_ssz", "hex", - "rand_core 0.6.4", + "rand 0.7.3", "serde", - "subtle", + "serde_derive", + "tree_hash", + "zeroize", +] + +[[package]] +name = "blst" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" +dependencies = [ + "cc", + "glob", + "threadpool", "zeroize", ] @@ -1135,9 +1279,19 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" dependencies = [ + "sha2 0.10.8", "tinyvec", ] +[[package]] +name = "build-helper" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdce191bf3fa4995ce948c8c83b4640a1745457a149e73c6db75b4ffe36aad5f" +dependencies = [ + "semver 0.6.0", +] + [[package]] name = "bulletproof-kzen" version = "1.2.1" @@ -1194,9 +1348,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.14.1" +version = "1.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" +checksum = "ea31d69bda4949c1c1562c1e6f042a1caefac98cdc8a298260a2ff41c1e2d42b" dependencies = [ "bytemuck_derive", ] @@ -1227,6 +1381,72 @@ dependencies = [ "serde", ] +[[package]] +name = "cached_tree_hash" +version = "0.1.0" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" +dependencies = [ + "ethereum-types 0.14.1", + "ethereum_hashing", + "ethereum_ssz", + "ethereum_ssz_derive", + "smallvec", + "ssz_types", + "tree_hash", +] + +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.21", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.21", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "case" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" + [[package]] name = "cast" version = "0.3.0" @@ -1358,6 +1578,46 @@ dependencies = [ "vec_map", ] +[[package]] +name = "clap" +version = "4.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim 0.10.0", +] + +[[package]] +name = "clap_derive" +version = "4.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "clap_lex" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" + [[package]] name = "cloudabi" version = "0.0.3" @@ -1373,6 +1633,68 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "coins-bip32" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b6be4a5df2098cd811f3194f64ddb96c267606bffd9689ac7b0160097b01ad3" +dependencies = [ + "bs58 0.5.0", + "coins-core", + "digest 0.10.7", + "hmac 0.12.1", + "k256", + "serde", + "sha2 0.10.8", + "thiserror", +] + +[[package]] +name = "coins-bip39" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" +dependencies = [ + "bitvec 1.0.1", + "coins-bip32", + "hmac 0.12.1", + "once_cell", + "pbkdf2 0.12.2", + "rand 0.8.5", + "sha2 0.10.8", + "thiserror", +] + +[[package]] +name = "coins-core" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" +dependencies = [ + "base64 0.21.7", + "bech32", + "bs58 0.5.0", + "digest 0.10.7", + "generic-array 0.14.7", + "hex", + "ripemd", + "serde", + "serde_derive", + "sha2 0.10.8", + "sha3 0.10.8", + "thiserror", +] + [[package]] name = "color-eyre" version = "0.6.2" @@ -1400,6 +1722,12 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "colored" version = "2.1.0" @@ -1430,6 +1758,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" +[[package]] +name = "compare_fields" +version = "0.2.0" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" + +[[package]] +name = "compare_fields_derive" +version = "0.2.0" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "concurrent-queue" version = "2.4.0" @@ -1447,9 +1789,9 @@ checksum = "68d13f542d70e5b339bf46f6f74704ac052cfd526c58cd87996bd1ef4615b9a0" [[package]] name = "const-hex" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5104de16b218eddf8e34ffe2f86f74bfa4e61e95a1b89732fccf6325efd0557" +checksum = "18d59688ad0945eaf6b84cb44fedbe93484c81b48970e98f09db8a22832d7961" dependencies = [ "cfg-if", "cpufeatures", @@ -1508,6 +1850,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "convert_case" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" + [[package]] name = "core-foundation" version = "0.9.4" @@ -1738,7 +2086,7 @@ checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" dependencies = [ "atty", "cast", - "clap", + "clap 2.34.0", "criterion-plot", "csv", "itertools 0.10.5", @@ -1976,7 +2324,7 @@ dependencies = [ "fiat-crypto", "platforms", "rand_core 0.6.4", - "rustc_version", + "rustc_version 0.4.0", "serde", "subtle", "zeroize", @@ -1994,12 +2342,66 @@ dependencies = [ ] [[package]] -name = "darling" -version = "0.14.4" +name = "cxx" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +checksum = "8de00f15a6fa069c99b88c5c78c4541d0e7899a33b86f7480e23df2431fce0bc" dependencies = [ - "darling_core 0.14.4", + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a71e1e631fa2f2f5f92e8b0d860a00c198c6771623a6cefcc863e3554f0d8d6" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn 2.0.48", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f3fed61d56ba497c4efef9144dfdbaa25aa58f2f6b3a7cf441d4591c583745c" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8908e380a8efd42150c017b0cfa31509fc49b6d47f7cb6b33e93ffb8f4e3661e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core 0.13.4", + "darling_macro 0.13.4", +] + +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core 0.14.4", "darling_macro 0.14.4", ] @@ -2013,6 +2415,20 @@ dependencies = [ "darling_macro 0.20.5", ] +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn 1.0.109", +] + [[package]] name = "darling_core" version = "0.14.4" @@ -2041,6 +2457,17 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core 0.13.4", + "quote", + "syn 1.0.109", +] + [[package]] name = "darling_macro" version = "0.14.4" @@ -2173,16 +2600,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "derive_more" version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ - "convert_case", + "convert_case 0.4.0", "proc-macro2", "quote", - "rustc_version", + "rustc_version 0.4.0", "syn 1.0.109", ] @@ -2201,8 +2639,8 @@ dependencies = [ "hex", "itertools 0.12.1", "log", - "pallet-jobs", - "pallet-jobs-rpc-runtime-api", + "pallet-jobs 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", "parity-scale-codec 3.6.9", "protocol-macros", "rand 0.8.5", @@ -2210,15 +2648,21 @@ dependencies = [ "sc-client-api", "serde", "sp-api", - "sp-application-crypto 23.0.0", - "sp-core 21.0.0", - "sp-io 23.0.0", - "sp-runtime 24.0.0", - "tangle-primitives", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", "test-utils", "tokio", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "difflib" version = "0.4.0" @@ -2265,6 +2709,37 @@ dependencies = [ "dirs-sys-next", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -2363,6 +2838,18 @@ dependencies = [ "litrs", ] +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + [[package]] name = "downcast" version = "0.11.0" @@ -2381,6 +2868,12 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + [[package]] name = "dyn-clonable" version = "0.9.0" @@ -2434,6 +2927,15 @@ dependencies = [ "spki 0.7.3", ] +[[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.3" @@ -2446,12 +2948,24 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.1.0" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek 3.2.0", + "ed25519 1.5.3", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-dalek" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek 4.1.1", - "ed25519", + "ed25519 2.2.3", "rand_core 0.6.4", "serde", "sha2 0.10.8", @@ -2480,7 +2994,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ "curve25519-dalek 4.1.1", - "ed25519", + "ed25519 2.2.3", "hashbrown 0.14.3", "hex", "rand_core 0.6.4", @@ -2503,6 +3017,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ed448-goldilocks-plus" +version = "0.11.1" +source = "git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize#e5200a473655d2b8abb61263f62fdbe6a6c4d16c" +dependencies = [ + "elliptic-curve 0.13.8", + "rand_core 0.6.4", + "sha3 0.10.8", + "subtle", +] + [[package]] name = "educe" version = "0.4.23" @@ -2568,6 +3093,42 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" +[[package]] +name = "ena" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1" +dependencies = [ + "log", +] + +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enr" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" +dependencies = [ + "base64 0.21.7", + "bytes", + "hex", + "k256", + "log", + "rand 0.8.5", + "rlp", + "serde", + "sha3 0.10.8", + "zeroize", +] + [[package]] name = "enum-as-inner" version = "0.5.1" @@ -2613,6 +3174,26 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "enumflags2" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" +dependencies = [ + "enumflags2_derive", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "enumset" version = "1.1.3" @@ -2682,6 +3263,63 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "eth-keystore" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab" +dependencies = [ + "aes", + "ctr", + "digest 0.10.7", + "hex", + "hmac 0.12.1", + "pbkdf2 0.11.0", + "rand 0.8.5", + "scrypt", + "serde", + "serde_json", + "sha2 0.10.8", + "sha3 0.10.8", + "thiserror", + "uuid 0.8.2", +] + +[[package]] +name = "eth-types" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "derive_more", + "ethereum-types 0.14.1", + "hex", + "parity-scale-codec 3.6.9", + "rlp", + "rlp-derive", + "scale-info", + "serde", + "tiny-keccak", + "webb-eth2-serde-utils", + "webb-eth2-ssz", + "webb-tree-hash", + "webb-tree-hash-derive", +] + +[[package]] +name = "eth2_interop_keypairs" +version = "0.2.0" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" +dependencies = [ + "bls", + "ethereum_hashing", + "hex", + "lazy_static", + "num-bigint 0.4.4", + "serde", + "serde_derive", + "serde_yaml", +] + [[package]] name = "ethabi" version = "15.0.0" @@ -2739,6 +3377,24 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "ethereum" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a89fb87a9e103f71b903b80b670200b54cc67a07578f070681f1fffb7396fb7" +dependencies = [ + "bytes", + "ethereum-types 0.14.1", + "hash-db 0.15.2", + "hash256-std-hasher", + "parity-scale-codec 3.6.9", + "rlp", + "scale-info", + "serde", + "sha3 0.10.8", + "triehash", +] + [[package]] name = "ethereum-types" version = "0.12.1" @@ -2768,215 +3424,579 @@ dependencies = [ ] [[package]] -name = "ethers-core" -version = "2.0.13" +name = "ethereum_hashing" +version = "1.0.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aab3cef6cc1c9fd7f787043c81ad3052eff2b96a3878ef1526aa446311bdbfc9" +checksum = "233dc6f434ce680dbabf4451ee3380cec46cb3c45d66660445a435619710dd35" dependencies = [ - "arrayvec 0.7.4", - "bytes", - "chrono", - "const-hex", - "elliptic-curve 0.13.8", - "ethabi 18.0.0", - "generic-array 0.14.7", - "k256", - "num_enum", - "open-fastrlp", - "rand 0.8.5", - "rlp", - "serde", - "serde_json", - "strum", - "tempfile", - "thiserror", - "tiny-keccak", - "unicode-xid", + "cpufeatures", + "lazy_static", + "ring 0.16.20", + "sha2 0.10.8", ] [[package]] -name = "event-listener" -version = "2.5.3" +name = "ethereum_serde_utils" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "de4d5951468846963c24e8744c133d44f39dff2cd3a233f6be22b370d08a524f" +dependencies = [ + "ethereum-types 0.14.1", + "hex", + "serde", + "serde_derive", + "serde_json", +] [[package]] -name = "event-listener" -version = "3.1.0" +name = "ethereum_ssz" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +checksum = "e61ffea29f26e8249d35128a82ec8d3bd4fbc80179ea5f5e5e3daafef6a80fcb" dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite 0.2.13", + "ethereum-types 0.14.1", + "itertools 0.10.5", + "smallvec", ] [[package]] -name = "event-listener" -version = "4.0.3" +name = "ethereum_ssz_derive" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" +checksum = "6085d7fd3cf84bd2b8fec150d54c8467fb491d8db9c460607c5534f653a0ee38" dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite 0.2.13", + "darling 0.13.4", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] -name = "event-listener-strategy" -version = "0.4.0" +name = "ethers" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +checksum = "6c7cd562832e2ff584fa844cd2f6e5d4f35bbe11b28c7c9b8df957b2e1d0c701" dependencies = [ - "event-listener 4.0.3", - "pin-project-lite 0.2.13", + "ethers-addressbook", + "ethers-contract", + "ethers-core", + "ethers-etherscan", + "ethers-middleware", + "ethers-providers", + "ethers-signers", + "ethers-solc", ] [[package]] -name = "expander" -version = "2.0.0" +name = "ethers-addressbook" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" +checksum = "35dc9a249c066d17e8947ff52a4116406163cf92c7f0763cb8c001760b26403f" dependencies = [ - "blake2", - "fs-err", - "proc-macro2", - "quote", - "syn 2.0.48", + "ethers-core", + "once_cell", + "serde", + "serde_json", ] [[package]] -name = "eyre" -version = "0.6.12" +name = "ethers-contract" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +checksum = "43304317c7f776876e47f2f637859f6d0701c1ec7930a150f169d5fbe7d76f5a" dependencies = [ - "indenter", + "const-hex", + "ethers-contract-abigen", + "ethers-contract-derive", + "ethers-core", + "ethers-providers", + "futures-util", "once_cell", + "pin-project", + "serde", + "serde_json", + "thiserror", ] [[package]] -name = "fake-simd" -version = "0.1.2" +name = "ethers-contract-abigen" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +checksum = "f9f96502317bf34f6d71a3e3d270defaa9485d754d789e15a8e04a84161c95eb" +dependencies = [ + "Inflector", + "const-hex", + "dunce", + "ethers-core", + "eyre", + "prettyplease 0.2.16", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "syn 2.0.48", + "toml 0.8.2", + "walkdir", +] [[package]] -name = "fallible-iterator" -version = "0.2.0" +name = "ethers-contract-derive" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +checksum = "452ff6b0a64507ce8d67ffd48b1da3b42f03680dcf5382244e9c93822cbbf5de" +dependencies = [ + "Inflector", + "const-hex", + "ethers-contract-abigen", + "ethers-core", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.48", +] [[package]] -name = "fast-paillier" -version = "0.1.0" +name = "ethers-core" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da6ffbfab3f6dc72b28f6f33dc76705c1a56b2c119680c936d239990beb5ae6" +checksum = "aab3cef6cc1c9fd7f787043c81ad3052eff2b96a3878ef1526aa446311bdbfc9" dependencies = [ - "bytemuck", - "rand_core 0.6.4", - "rug", + "arrayvec 0.7.4", + "bytes", + "cargo_metadata 0.18.1", + "chrono", + "const-hex", + "elliptic-curve 0.13.8", + "ethabi 18.0.0", + "generic-array 0.14.7", + "k256", + "num_enum 0.7.2", + "once_cell", + "open-fastrlp", + "rand 0.8.5", + "rlp", "serde", + "serde_json", + "strum 0.25.0", + "syn 2.0.48", + "tempfile", "thiserror", + "tiny-keccak", + "unicode-xid", ] [[package]] -name = "fastrand" -version = "1.9.0" +name = "ethers-etherscan" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +checksum = "16d45b981f5fa769e1d0343ebc2a44cfa88c9bc312eb681b676318b40cef6fb1" dependencies = [ - "instant", + "chrono", + "ethers-core", + "ethers-solc", + "reqwest", + "semver 1.0.21", + "serde", + "serde_json", + "thiserror", + "tracing", ] [[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - -[[package]] -name = "ff" -version = "0.12.1" +name = "ethers-middleware" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +checksum = "145211f34342487ef83a597c1e69f0d3e01512217a7c72cc8a25931854c7dca0" dependencies = [ - "rand_core 0.6.4", - "subtle", + "async-trait", + "auto_impl", + "ethers-contract", + "ethers-core", + "ethers-providers", + "ethers-signers", + "futures-channel", + "futures-locks", + "futures-util", + "instant", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "tracing-futures", + "url", ] [[package]] -name = "ff" -version = "0.13.0" +name = "ethers-providers" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +checksum = "fb6b15393996e3b8a78ef1332d6483c11d839042c17be58decc92fa8b1c3508a" dependencies = [ - "bitvec 1.0.1", - "byteorder", - "ff_derive", - "rand_core 0.6.4", - "subtle", + "async-trait", + "auto_impl", + "base64 0.21.7", + "bytes", + "const-hex", + "enr", + "ethers-core", + "futures-core", + "futures-timer", + "futures-util", + "hashers", + "http", + "instant", + "jsonwebtoken", + "once_cell", + "pin-project", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "tracing-futures", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "ws_stream_wasm", ] [[package]] -name = "ff-zeroize" -version = "0.6.3" +name = "ethers-signers" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02169a2e8515aa316ce516eaaf6318a76617839fbf904073284bc2576b029ee" +checksum = "b3b125a103b56aef008af5d5fb48191984aa326b50bfd2557d231dc499833de3" dependencies = [ - "byteorder", - "ff_derive-zeroize", - "rand_core 0.5.1", - "zeroize", + "async-trait", + "coins-bip32", + "coins-bip39", + "const-hex", + "elliptic-curve 0.13.8", + "eth-keystore", + "ethers-core", + "rand 0.8.5", + "sha2 0.10.8", + "thiserror", + "tracing", ] [[package]] -name = "ff_derive" -version = "0.13.0" +name = "ethers-solc" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f54704be45ed286151c5e11531316eaef5b8f5af7d597b806fdb8af108d84a" +checksum = "d21df08582e0a43005018a858cc9b465c5fff9cf4056651be64f844e57d1f55f" dependencies = [ - "addchain", "cfg-if", - "num-bigint 0.3.3", - "num-integer", - "num-traits", - "proc-macro2", - "quote", - "syn 1.0.109", + "const-hex", + "dirs", + "dunce", + "ethers-core", + "glob", + "home", + "md-5", + "num_cpus", + "once_cell", + "path-slash", + "rayon", + "regex", + "semver 1.0.21", + "serde", + "serde_json", + "solang-parser", + "thiserror", + "tiny-keccak", + "tokio", + "tracing", + "walkdir", + "yansi", ] [[package]] -name = "ff_derive-zeroize" -version = "0.6.2" +name = "event-listener" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b24d4059bc0d0a0bf26b740aa21af1f96a984f0ab7a21356d00b32475388b53a" -dependencies = [ - "num-bigint 0.2.6", - "num-integer", - "num-traits", - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] -name = "fflonk" -version = "0.1.0" -source = "git+https://github.com/w3f/fflonk#1e854f35e9a65d08b11a86291405cdc95baa0a35" +name = "event-listener" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" dependencies = [ - "ark-ec", - "ark-ff", - "ark-poly", - "ark-serialize", - "ark-std", - "merlin 3.0.0", + "concurrent-queue", + "parking", + "pin-project-lite 0.2.13", ] [[package]] -name = "fiat-crypto" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "event-listener" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite 0.2.13", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.3", + "pin-project-lite 0.2.13", +] + +[[package]] +name = "evm" +version = "0.39.1" +source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +dependencies = [ + "auto_impl", + "environmental", + "ethereum", + "evm-core", + "evm-gasometer", + "evm-runtime", + "log", + "parity-scale-codec 3.6.9", + "primitive-types 0.12.2", + "rlp", + "scale-info", + "serde", + "sha3 0.10.8", +] + +[[package]] +name = "evm-core" +version = "0.39.0" +source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +dependencies = [ + "parity-scale-codec 3.6.9", + "primitive-types 0.12.2", + "scale-info", + "serde", +] + +[[package]] +name = "evm-gasometer" +version = "0.39.0" +source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +dependencies = [ + "environmental", + "evm-core", + "evm-runtime", + "primitive-types 0.12.2", +] + +[[package]] +name = "evm-runtime" +version = "0.39.0" +source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +dependencies = [ + "auto_impl", + "environmental", + "evm-core", + "primitive-types 0.12.2", + "sha3 0.10.8", +] + +[[package]] +name = "evm-tracer" +version = "0.1.0" +dependencies = [ + "ethereum-types 0.14.1", + "evm", + "evm-gasometer", + "evm-runtime", + "evm-tracing-events", + "fp-evm", + "pallet-evm", + "parity-scale-codec 3.6.9", + "primitives-ext", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "evm-tracing-events" +version = "0.1.0" +dependencies = [ + "environmental", + "ethereum", + "ethereum-types 0.14.1", + "evm", + "evm-gasometer", + "evm-runtime", + "parity-scale-codec 3.6.9", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "expander" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" +dependencies = [ + "blake2", + "fs-err", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + +[[package]] +name = "fast-paillier" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da6ffbfab3f6dc72b28f6f33dc76705c1a56b2c119680c936d239990beb5ae6" +dependencies = [ + "bytemuck", + "rand_core 0.6.4", + "rug", + "serde", + "thiserror", +] + +[[package]] +name = "faster-hex" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51e2ce894d53b295cf97b05685aa077950ff3e8541af83217fc720a6437169f8" + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "bitvec 1.0.1", + "byteorder", + "ff_derive", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "ff-zeroize" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02169a2e8515aa316ce516eaaf6318a76617839fbf904073284bc2576b029ee" +dependencies = [ + "byteorder", + "ff_derive-zeroize", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "ff_derive" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f54704be45ed286151c5e11531316eaef5b8f5af7d597b806fdb8af108d84a" +dependencies = [ + "addchain", + "cfg-if", + "num-bigint 0.3.3", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ff_derive-zeroize" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b24d4059bc0d0a0bf26b740aa21af1f96a984f0ab7a21356d00b32475388b53a" +dependencies = [ + "num-bigint 0.2.6", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "fflonk" +version = "0.1.0" +source = "git+https://github.com/w3f/fflonk#1e854f35e9a65d08b11a86291405cdc95baa0a35" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "merlin 3.0.0", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" [[package]] @@ -2989,6 +4009,18 @@ dependencies = [ "log", ] +[[package]] +name = "filetime" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.4.1", + "windows-sys 0.52.0", +] + [[package]] name = "finality-grandpa" version = "0.16.2" @@ -3023,6 +4055,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ + "arbitrary", "byteorder", "rand 0.8.5", "rustc-hex", @@ -3061,6 +4094,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "fork-tree" version = "3.0.0" @@ -3079,18 +4127,126 @@ dependencies = [ ] [[package]] -name = "fragile" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" - -[[package]] -name = "frame-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +name = "fp-account" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ - "frame-support", - "frame-support-procedural", + "hex", + "impl-serde", + "libsecp256k1", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "fp-consensus" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "ethereum", + "parity-scale-codec 3.6.9", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "fp-dynamic-fee" +version = "1.0.0" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "async-trait", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-inherents", +] + +[[package]] +name = "fp-ethereum" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "ethereum", + "ethereum-types 0.14.1", + "fp-evm", + "frame-support", + "parity-scale-codec 3.6.9", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "fp-evm" +version = "3.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "evm", + "frame-support", + "num_enum 0.7.2", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "fp-rpc" +version = "3.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "ethereum", + "ethereum-types 0.14.1", + "fp-evm", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-api", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-state-machine 0.28.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "fp-self-contained" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "frame-support", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "fp-storage" +version = "2.0.0" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "parity-scale-codec 3.6.9", + "serde", +] + +[[package]] +name = "fragile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" + +[[package]] +name = "frame-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-support", + "frame-support-procedural", "frame-system", "linregress", "log", @@ -3099,16 +4255,62 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-application-crypto 23.0.0", - "sp-core 21.0.0", - "sp-io 23.0.0", - "sp-runtime 24.0.0", - "sp-runtime-interface 17.0.0", - "sp-std 8.0.0", - "sp-storage 13.0.0", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-storage 13.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "static_assertions", ] +[[package]] +name = "frame-election-provider-solution-type" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "frame-election-provider-support" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-election-provider-solution-type", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-npos-elections", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "frame-executive" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-support", + "frame-system", + "frame-try-runtime", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-tracing 10.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + [[package]] name = "frame-metadata" version = "15.1.0" @@ -3118,6 +4320,7 @@ dependencies = [ "cfg-if", "parity-scale-codec 3.6.9", "scale-info", + "serde", ] [[package]] @@ -3154,20 +4357,20 @@ dependencies = [ "serde_json", "smallvec", "sp-api", - "sp-arithmetic 16.0.0", - "sp-core 21.0.0", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-core-hashing-proc-macro", - "sp-debug-derive 8.0.0", + "sp-debug-derive 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-genesis-builder", "sp-inherents", - "sp-io 23.0.0", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-metadata-ir", - "sp-runtime 24.0.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-staking", - "sp-state-machine 0.28.0", - "sp-std 8.0.0", - "sp-tracing 10.0.0", - "sp-weights 20.0.0", + "sp-state-machine 0.28.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-tracing 10.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-weights 20.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "static_assertions", "tt-call", ] @@ -3223,12 +4426,77 @@ dependencies = [ "parity-scale-codec 3.6.9", "scale-info", "serde", - "sp-core 21.0.0", - "sp-io 23.0.0", - "sp-runtime 24.0.0", - "sp-std 8.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-version", - "sp-weights 20.0.0", + "sp-weights 20.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "frame-system-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "frame-system-rpc-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "parity-scale-codec 3.6.9", + "sp-api", +] + +[[package]] +name = "frame-try-runtime" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-support", + "parity-scale-codec 3.6.9", + "sp-api", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "frost-core" +version = "0.6.1" +dependencies = [ + "debugless-unwrap", + "hex", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "serde", + "serdect", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "subtle", +] + +[[package]] +name = "frost-core" +version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "debugless-unwrap", + "hex", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "serde", + "serdect", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "subtle", ] [[package]] @@ -3253,6 +4521,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "frost-ed25519" +version = "1.0.0-rc.0" +dependencies = [ + "curve25519-dalek 4.1.1", + "frost-core 0.6.1", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "sha2 0.10.8", + "subtle", +] + [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" @@ -3260,64 +4540,137 @@ source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b7 dependencies = [ "curve25519-dalek 4.1.1", "document-features", - "frost-core", + "frost-core 1.0.0-rc.0", "frost-rerandomized", "rand_core 0.6.4", "sha2 0.10.8", ] +[[package]] +name = "frost-ed25519" +version = "1.0.0-rc.0" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "curve25519-dalek 4.1.1", + "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "sha2 0.10.8", + "subtle", +] + +[[package]] +name = "frost-ed448" +version = "1.0.0-rc.0" +dependencies = [ + "ed448-goldilocks-plus 0.11.1 (git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize)", + "frost-core 0.6.1", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "sha3 0.10.8", + "subtle", +] + [[package]] name = "frost-ed448" version = "1.0.0-rc.0" source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" dependencies = [ "document-features", - "ed448-goldilocks-plus", - "frost-core", + "ed448-goldilocks-plus 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "frost-core 1.0.0-rc.0", "frost-rerandomized", "rand_core 0.6.4", "sha3 0.10.8", ] +[[package]] +name = "frost-ed448" +version = "1.0.0-rc.0" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "ed448-goldilocks-plus 0.11.1 (git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize)", + "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "sha3 0.10.8", + "subtle", +] + +[[package]] +name = "frost-p256" +version = "1.0.0-rc.0" +dependencies = [ + "frost-core 0.6.1", + "p256 0.13.2", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "sha2 0.10.8", + "subtle", +] + [[package]] name = "frost-p256" version = "1.0.0-rc.0" source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" dependencies = [ "document-features", - "frost-core", + "frost-core 1.0.0-rc.0", "frost-rerandomized", "p256 0.13.2", "rand_core 0.6.4", "sha2 0.10.8", ] +[[package]] +name = "frost-p256" +version = "1.0.0-rc.0" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", + "p256 0.13.2", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "sha2 0.10.8", + "subtle", +] + [[package]] name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" dependencies = [ - "document-features", - "frost-core", - "frost-rerandomized", + "frost-core 0.6.1", "p384", + "parity-scale-codec 3.6.9", "rand_core 0.6.4", "sha2 0.10.8", + "subtle", ] [[package]] -name = "frost-redjubjub" +name = "frost-p384" version = "1.0.0-rc.0" source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" dependencies = [ - "blake2b_simd", "document-features", - "frost-core", + "frost-core 1.0.0-rc.0", "frost-rerandomized", - "group 0.13.0", - "jubjub", + "p384", + "rand_core 0.6.4", + "sha2 0.10.8", +] + +[[package]] +name = "frost-p384" +version = "1.0.0-rc.0" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", + "p384", + "parity-scale-codec 3.6.9", "rand_core 0.6.4", "sha2 0.10.8", + "subtle", ] [[package]] @@ -3327,42 +4680,92 @@ source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b7 dependencies = [ "derive-getters", "document-features", - "frost-core", + "frost-core 1.0.0-rc.0", "rand_core 0.6.4", ] [[package]] name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" dependencies = [ "curve25519-dalek 4.1.1", - "document-features", - "frost-core", - "frost-rerandomized", + "frost-core 0.6.1", + "parity-scale-codec 3.6.9", "rand_core 0.6.4", "sha2 0.10.8", + "subtle", ] [[package]] -name = "frost-secp256k1" +name = "frost-ristretto255" version = "1.0.0-rc.0" source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" dependencies = [ + "curve25519-dalek 4.1.1", "document-features", - "frost-core", + "frost-core 1.0.0-rc.0", "frost-rerandomized", - "k256", "rand_core 0.6.4", "sha2 0.10.8", ] [[package]] -name = "fs-err" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" -dependencies = [ +name = "frost-ristretto255" +version = "1.0.0-rc.0" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "curve25519-dalek 4.1.1", + "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "sha2 0.10.8", + "subtle", +] + +[[package]] +name = "frost-secp256k1" +version = "1.0.0-rc.0" +dependencies = [ + "frost-core 0.6.1", + "k256", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "sha2 0.10.8", + "subtle", +] + +[[package]] +name = "frost-secp256k1" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#996e0bf2ffe46cd8bbe132b74f7495ac5ce8f607" +dependencies = [ + "document-features", + "frost-core 1.0.0-rc.0", + "frost-rerandomized", + "k256", + "rand_core 0.6.4", + "sha2 0.10.8", +] + +[[package]] +name = "frost-secp256k1" +version = "1.0.0-rc.0" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", + "k256", + "parity-scale-codec 3.6.9", + "rand_core 0.6.4", + "sha2 0.10.8", + "subtle", +] + +[[package]] +name = "fs-err" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ "autocfg 1.1.0", ] @@ -3461,6 +4864,16 @@ dependencies = [ "pin-project-lite 0.2.13", ] +[[package]] +name = "futures-locks" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" +dependencies = [ + "futures-channel", + "futures-task", +] + [[package]] name = "futures-macro" version = "0.3.30" @@ -3500,6 +4913,10 @@ name = "futures-timer" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +dependencies = [ + "gloo-timers", + "send_wrapper 0.4.0", +] [[package]] name = "futures-util" @@ -3542,7 +4959,7 @@ dependencies = [ "hex", "linked-hash-map", "log", - "pallet-jobs-rpc-runtime-api", + "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", "parking_lot 0.12.1", "sc-client-api", "sc-network", @@ -3550,10 +4967,12 @@ dependencies = [ "sc-network-sync", "serde", "sp-api", - "sp-core 21.0.0", - "sp-runtime 24.0.0", - "subxt", - "tangle-primitives", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "subxt 0.33.0", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-runtime", + "tangle-testnet-runtime", "tokio", ] @@ -3568,7 +4987,7 @@ dependencies = [ "log", "parking_lot 0.12.1", "sc-client-api", - "sp-runtime 24.0.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "tokio", ] @@ -3675,8 +5094,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -3726,6 +5147,24 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "gmp-mpfr-sys" version = "1.6.2" @@ -3811,6 +5250,12 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +[[package]] +name = "hash-db" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" + [[package]] name = "hash-db" version = "0.16.0" @@ -3873,6 +5318,24 @@ dependencies = [ "serde", ] +[[package]] +name = "hashers" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" +dependencies = [ + "fxhash", +] + +[[package]] +name = "hashlink" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" +dependencies = [ + "hashbrown 0.14.3", +] + [[package]] name = "heapless" version = "0.7.17" @@ -3881,7 +5344,7 @@ checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" dependencies = [ "atomic-polyfill", "hash32", - "rustc_version", + "rustc_version 0.4.0", "serde", "spin 0.9.8", "stable_deref_trait", @@ -3932,6 +5395,12 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + [[package]] name = "hkdf" version = "0.12.4" @@ -4058,7 +5527,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.13", - "socket2 0.5.5", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -4079,6 +5548,20 @@ dependencies = [ "rustls-native-certs", "tokio", "tokio-rustls", + "webpki-roots 0.25.4", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", ] [[package]] @@ -4092,7 +5575,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core 0.52.0", + "windows-core", ] [[package]] @@ -4278,6 +5761,14 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "int_to_bytes" +version = "0.2.0" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" +dependencies = [ + "bytes", +] + [[package]] name = "integer-sqrt" version = "0.1.5" @@ -4386,23 +5877,56 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonrpsee" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "367a292944c07385839818bb71c8d76611138e2dedb0677d035b8da21d29c78b" +dependencies = [ + "jsonrpsee-client-transport 0.16.3", + "jsonrpsee-core 0.16.3", + "jsonrpsee-http-client 0.16.3", + "jsonrpsee-types 0.16.3", +] + [[package]] name = "jsonrpsee" version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "affdc52f7596ccb2d7645231fc6163bb314630c989b64998f3699a28b4d5d4dc" dependencies = [ - "jsonrpsee-client-transport", - "jsonrpsee-core", - "jsonrpsee-http-client", - "jsonrpsee-types", + "jsonrpsee-client-transport 0.20.3", + "jsonrpsee-core 0.20.3", + "jsonrpsee-http-client 0.20.3", + "jsonrpsee-types 0.20.3", +] + +[[package]] +name = "jsonrpsee-client-transport" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8b3815d9f5d5de348e5f162b316dc9cdf4548305ebb15b4eb9328e66cf27d7a" +dependencies = [ + "futures-util", + "http", + "jsonrpsee-core 0.16.3", + "jsonrpsee-types 0.16.3", + "pin-project", + "rustls-native-certs", + "soketto", + "thiserror", + "tokio", + "tokio-rustls", + "tokio-util", + "tracing", + "webpki-roots 0.25.4", ] [[package]] @@ -4413,7 +5937,7 @@ checksum = "b5b005c793122d03217da09af68ba9383363caa950b90d3436106df8cabce935" dependencies = [ "futures-util", "http", - "jsonrpsee-core", + "jsonrpsee-core 0.20.3", "pin-project", "rustls-native-certs", "soketto", @@ -4425,6 +5949,29 @@ dependencies = [ "url", ] +[[package]] +name = "jsonrpsee-core" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" +dependencies = [ + "anyhow", + "async-lock 2.8.0", + "async-trait", + "beef", + "futures-channel", + "futures-timer", + "futures-util", + "hyper", + "jsonrpsee-types 0.16.3", + "rustc-hash", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "jsonrpsee-core" version = "0.20.3" @@ -4438,7 +5985,26 @@ dependencies = [ "futures-timer", "futures-util", "hyper", - "jsonrpsee-types", + "jsonrpsee-types 0.20.3", + "rustc-hash", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "jsonrpsee-http-client" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" +dependencies = [ + "async-trait", + "hyper", + "hyper-rustls", + "jsonrpsee-core 0.16.3", + "jsonrpsee-types 0.16.3", "rustc-hash", "serde", "serde_json", @@ -4456,8 +6022,8 @@ dependencies = [ "async-trait", "hyper", "hyper-rustls", - "jsonrpsee-core", - "jsonrpsee-types", + "jsonrpsee-core 0.20.3", + "jsonrpsee-types 0.20.3", "serde", "serde_json", "thiserror", @@ -4467,6 +6033,20 @@ dependencies = [ "url", ] +[[package]] +name = "jsonrpsee-types" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245ba8e5aa633dd1c1e4fae72bce06e71f42d34c14a2767c6b4d173b57bee5e5" +dependencies = [ + "anyhow", + "beef", + "serde", + "serde_json", + "thiserror", + "tracing", +] + [[package]] name = "jsonrpsee-types" version = "0.20.3" @@ -4482,20 +6062,17 @@ dependencies = [ ] [[package]] -name = "jubjub" -version = "0.10.4" -source = "git+https://github.com/LIT-Protocol/jubjub.git#3924292eb6b3ef5489744998c18de7c5144df499" +name = "jsonwebtoken" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "bitvec 1.0.1", - "bls12_381_plus", - "elliptic-curve 0.13.8", - "ff 0.13.0", - "group 0.13.0", - "hex", - "rand_chacha 0.3.1", - "rand_core 0.6.4", + "base64 0.21.7", + "pem 1.1.1", + "ring 0.16.20", "serde", - "subtle", + "serde_json", + "simple_asn1", ] [[package]] @@ -4541,11 +6118,42 @@ dependencies = [ "serde", ] +[[package]] +name = "lalrpop" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da4081d44f4611b66c6dd725e6de3169f9f63905421e8626fcb86b6a898998b8" +dependencies = [ + "ascii-canvas", + "bit-set", + "diff", + "ena", + "is-terminal", + "itertools 0.10.5", + "lalrpop-util", + "petgraph", + "regex", + "regex-syntax 0.7.5", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "lalrpop-util" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f35c735096c0293d313e8f2a641627472b83d01b937177fe76e5e2708d31e0d" + [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] [[package]] name = "leb128" @@ -4702,7 +6310,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ "bs58 0.4.0", - "ed25519-dalek", + "ed25519-dalek 2.1.1", "log", "multiaddr", "multihash", @@ -4937,7 +6545,7 @@ dependencies = [ "rw-stream-sink", "soketto", "url", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -5012,6 +6620,17 @@ dependencies = [ "libsecp256k1-core", ] +[[package]] +name = "libsqlite3-sys" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "libz-sys" version = "1.1.15" @@ -5023,6 +6642,15 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "link-cplusplus" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" +dependencies = [ + "cc", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -5086,6 +6714,9 @@ name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +dependencies = [ + "serde", +] [[package]] name = "loupe" @@ -5192,6 +6823,12 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "match_cfg" version = "0.1.0" @@ -5232,6 +6869,16 @@ dependencies = [ "rawpointer", ] +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest 0.10.7", +] + [[package]] name = "md5" version = "0.7.0" @@ -5286,7 +6933,7 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" dependencies = [ - "hash-db", + "hash-db 0.16.0", ] [[package]] @@ -5298,6 +6945,17 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "merkle_proof" +version = "0.2.0" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" +dependencies = [ + "ethereum-types 0.14.1", + "ethereum_hashing", + "lazy_static", + "safe_arith", +] + [[package]] name = "merlin" version = "2.0.1" @@ -5323,8 +6981,51 @@ dependencies = [ ] [[package]] -name = "minimal-lexical" -version = "0.2.1" +name = "metastruct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccfbb8826226b09b05bb62a0937cf6abb16f1f7d4b746eb95a83db14aec60f06" +dependencies = [ + "metastruct_macro", +] + +[[package]] +name = "metastruct_macro" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37cb4045d5677b7da537f8cb5d0730d5b6414e3cc81c61e4b50e1f0cbdc73909" +dependencies = [ + "darling 0.13.4", + "itertools 0.10.5", + "proc-macro2", + "quote", + "smallvec", + "syn 1.0.109", +] + +[[package]] +name = "milagro_bls" +version = "1.5.0" +source = "git+https://github.com/Snowfork/milagro_bls?rev=a6d66e4eb89015e352fb1c9f7b661ecdbb5b2176#a6d66e4eb89015e352fb1c9f7b661ecdbb5b2176" +dependencies = [ + "amcl", + "hex", + "lazy_static", + "parity-scale-codec 3.6.9", + "rand 0.8.5", + "scale-info", + "zeroize", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" @@ -5395,19 +7096,19 @@ dependencies = [ "itertools 0.12.1", "log", "multi-party-ecdsa", - "pallet-jobs", - "pallet-jobs-rpc-runtime-api", + "pallet-jobs 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", "parity-scale-codec 3.6.9", "protocol-macros", "round-based 0.1.7", "sc-client-api", "serde", "sp-api", - "sp-application-crypto 23.0.0", - "sp-core 21.0.0", - "sp-io 23.0.0", - "sp-runtime 24.0.0", - "tangle-primitives", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", "test-utils", "tokio", ] @@ -5432,7 +7133,7 @@ dependencies = [ "rustls 0.21.10", "rustls-pemfile", "serde", - "strum", + "strum 0.25.0", "tokio", "tokio-rustls", "tokio-util", @@ -5563,6 +7264,24 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "netlink-packet-core" version = "0.4.2" @@ -5629,6 +7348,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + [[package]] name = "nix" version = "0.24.3" @@ -5734,9 +7459,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] @@ -5810,13 +7535,33 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +dependencies = [ + "num_enum_derive 0.5.11", +] + [[package]] name = "num_enum" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" dependencies = [ - "num_enum_derive", + "num_enum_derive 0.7.2", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -5844,233 +7589,1349 @@ dependencies = [ ] [[package]] -name = "object" -version = "0.30.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" +name = "object" +version = "0.30.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" +dependencies = [ + "crc32fast", + "hashbrown 0.13.2", + "indexmap 1.9.3", + "memchr", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "oid-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" +dependencies = [ + "asn1-rs", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "open-fastrlp" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" +dependencies = [ + "arrayvec 0.7.4", + "auto_impl", + "bytes", + "ethereum-types 0.14.1", + "open-fastrlp-derive", +] + +[[package]] +name = "open-fastrlp-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" +dependencies = [ + "bytes", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "openssl" +version = "0.10.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +dependencies = [ + "bitflags 2.4.2", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "p256" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" +dependencies = [ + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", + "sha2 0.10.8", +] + +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa 0.16.9", + "elliptic-curve 0.13.8", + "primeorder 0.13.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.10.8", +] + +[[package]] +name = "p384" +version = "0.13.0" +source = "git+https://github.com/LIT-Protocol/elliptic-curves.git#67924afc93d236e1508afd5f55bbf738e1c41eaa" +dependencies = [ + "ecdsa 0.16.9", + "elliptic-curve 0.13.8", + "primeorder 0.13.6 (git+https://github.com/LIT-Protocol/elliptic-curves.git)", + "sha2 0.10.8", +] + +[[package]] +name = "paillier-zk" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4956496b1cb7ecf45e86844ae50a5c0ade430dd4d491de8d020adb95ca6f328" +dependencies = [ + "digest 0.10.7", + "fast-paillier", + "generic-ec", + "rand_core 0.6.4", + "rug", + "serde", + "serde_with 3.6.0", + "thiserror", +] + +[[package]] +name = "pairing-plus" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58cda4f22e8e6720f3c254049960c8cc4f93cb82b5ade43bddd2622b5f39ea62" +dependencies = [ + "byteorder", + "digest 0.8.1", + "ff-zeroize", + "rand 0.4.6", + "rand_core 0.5.1", + "rand_xorshift 0.2.0", + "zeroize", +] + +[[package]] +name = "pallet-airdrop-claims" +version = "0.6.1" +dependencies = [ + "frame-support", + "frame-system", + "libsecp256k1", + "log", + "pallet-balances", + "pallet-evm", + "pallet-vesting", + "parity-scale-codec 3.6.9", + "rustc-hex", + "scale-info", + "schnorrkel 0.9.1", + "serde", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-authorship" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-babe" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "pallet-timestamp", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-consensus-babe", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-session", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-bags-list" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "aquamarine", + "docify", + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-tracing 10.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-balances" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-base-fee" +version = "1.0.0" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "fp-evm", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-bounties" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-treasury", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-child-bounties" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-bounties", + "pallet-treasury", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-collective" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-democracy" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-dkg" +version = "0.6.1" +dependencies = [ + "elliptic-curve 0.13.8", + "frame-support", + "frame-system", + "frost-core 0.6.1", + "frost-ed25519 1.0.0-rc.0", + "frost-ed448 1.0.0-rc.0", + "frost-p256 1.0.0-rc.0", + "frost-p384 1.0.0-rc.0", + "frost-ristretto255 1.0.0-rc.0", + "frost-secp256k1 1.0.0-rc.0", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "serdect", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "subtle", + "tangle-crypto-primitives 0.6.1", + "tangle-primitives 0.6.1", +] + +[[package]] +name = "pallet-dkg" +version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "elliptic-curve 0.13.8", + "frame-support", + "frame-system", + "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", + "frost-ed25519 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle)", + "frost-ed448 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle)", + "frost-p256 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle)", + "frost-p384 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle)", + "frost-ristretto255 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle)", + "frost-secp256k1 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle)", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "serdect", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "subtle", + "tangle-crypto-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", +] + +[[package]] +name = "pallet-dynamic-fee" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "fp-dynamic-fee", + "fp-evm", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-inherents", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-election-provider-multi-phase" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-election-provider-support-benchmarking", + "parity-scale-codec 3.6.9", + "rand 0.8.5", + "scale-info", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-npos-elections", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "strum 0.24.1", +] + +[[package]] +name = "pallet-election-provider-support-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-system", + "parity-scale-codec 3.6.9", + "sp-npos-elections", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-elections-phragmen" +version = "5.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-npos-elections", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-eth2-light-client" +version = "0.1.0" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "anyhow", + "async-trait", + "bitvec 1.0.1", + "derive_more", + "eth-types", + "ethereum-types 0.14.1", + "frame-support", + "frame-system", + "hex", + "lazy_static", + "log", + "pallet-balances", + "parity-scale-codec 3.6.9", + "rlp", + "rlp-derive", + "scale-info", + "serde", + "serde_json", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tiny-keccak", + "webb-bls", + "webb-consensus-types", + "webb-eth2-pallet-init", + "webb-eth2-ssz", + "webb-light-client-primitives", + "webb-merkle-proof", + "webb-proposals", + "webb-tree-hash", + "webb-tree-hash-derive", +] + +[[package]] +name = "pallet-ethereum" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "ethereum", + "ethereum-types 0.14.1", + "evm", + "fp-consensus", + "fp-ethereum", + "fp-evm", + "fp-rpc", + "fp-storage", + "frame-support", + "frame-system", + "pallet-evm", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm" +version = "6.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "environmental", + "evm", + "fp-account", + "fp-evm", + "frame-benchmarking", + "frame-support", + "frame-system", + "hash-db 0.16.0", + "hex", + "hex-literal 0.4.1", + "impl-trait-for-tuples", + "log", + "parity-scale-codec 3.6.9", + "rlp", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm-chain-id" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm-precompile-batch" +version = "0.1.0" +dependencies = [ + "evm", + "evm-runtime", + "fp-evm", + "frame-support", + "frame-system", + "log", + "num_enum 0.5.11", + "pallet-evm", + "parity-scale-codec 3.6.9", + "paste", + "precompile-utils", + "slices", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm-precompile-blake2" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "fp-evm", +] + +[[package]] +name = "pallet-evm-precompile-bn128" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "fp-evm", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "substrate-bn", +] + +[[package]] +name = "pallet-evm-precompile-call-permit" +version = "0.1.0" +dependencies = [ + "evm", + "fp-evm", + "frame-support", + "frame-system", + "log", + "num_enum 0.5.11", + "pallet-evm", + "pallet-timestamp", + "parity-scale-codec 3.6.9", + "paste", + "precompile-utils", + "slices", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm-precompile-curve25519" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "curve25519-dalek 4.1.1", + "fp-evm", +] + +[[package]] +name = "pallet-evm-precompile-democracy" +version = "0.2.0" +dependencies = [ + "fp-evm", + "frame-support", + "frame-system", + "log", + "num_enum 0.5.11", + "pallet-democracy", + "pallet-evm", + "pallet-preimage", + "parity-scale-codec 3.6.9", + "precompile-utils", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm-precompile-dispatch" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "fp-evm", + "frame-support", + "pallet-evm", + "parity-scale-codec 3.6.9", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm-precompile-ed25519" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "ed25519-dalek 2.1.1", + "fp-evm", +] + +[[package]] +name = "pallet-evm-precompile-jobs" +version = "0.1.0" +dependencies = [ + "fp-evm", + "frame-support", + "frame-system", + "log", + "num_enum 0.5.11", + "pallet-evm", + "pallet-jobs 0.6.1", + "parity-scale-codec 3.6.9", + "precompile-utils", + "rustc-hex", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1", +] + +[[package]] +name = "pallet-evm-precompile-modexp" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "fp-evm", + "num", +] + +[[package]] +name = "pallet-evm-precompile-preimage" +version = "0.1.0" +dependencies = [ + "fp-evm", + "frame-support", + "frame-system", + "log", + "num_enum 0.5.11", + "pallet-evm", + "pallet-preimage", + "parity-scale-codec 3.6.9", + "precompile-utils", + "rustc-hex", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm-precompile-proxy" +version = "0.1.0" +dependencies = [ + "evm", + "fp-evm", + "frame-support", + "frame-system", + "log", + "num_enum 0.5.11", + "pallet-balances", + "pallet-evm", + "pallet-proxy", + "parity-scale-codec 3.6.9", + "precompile-utils", + "rustc-hex", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm-precompile-registry" +version = "0.1.0" +dependencies = [ + "fp-evm", + "frame-support", + "frame-system", + "log", + "pallet-evm", + "parity-scale-codec 3.6.9", + "precompile-utils", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm-precompile-sha3fips" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "fp-evm", + "tiny-keccak", +] + +[[package]] +name = "pallet-evm-precompile-simple" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "fp-evm", + "ripemd", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-evm-precompile-staking" +version = "1.0.0" +dependencies = [ + "fp-evm", + "frame-support", + "frame-system", + "log", + "num_enum 0.5.11", + "pallet-evm", + "pallet-staking", + "parity-scale-codec 3.6.9", + "precompile-utils", + "rustc-hex", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1", +] + +[[package]] +name = "pallet-evm-precompile-vesting" +version = "0.1.0" +dependencies = [ + "evm", + "fp-evm", + "frame-support", + "frame-system", + "log", + "num_enum 0.5.11", + "pallet-balances", + "pallet-evm", + "pallet-vesting", + "parity-scale-codec 3.6.9", + "precompile-utils", + "rustc-hex", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1", +] + +[[package]] +name = "pallet-grandpa" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-consensus-grandpa", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-session", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-hotfix-sufficients" +version = "1.0.0" +source = "git+https://github.com/paritytech/frontier.git?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-evm", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-identity" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "enumflags2", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-im-online" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-indices" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-keyring 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-insecure-randomness-collective-flip" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "safe-mix", + "scale-info", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-jobs" +version = "0.6.1" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-crypto-primitives 0.6.1", + "tangle-primitives 0.6.1", +] + +[[package]] +name = "pallet-jobs" +version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-crypto-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", +] + +[[package]] +name = "pallet-jobs-rpc-runtime-api" +version = "0.6.1" +dependencies = [ + "parity-scale-codec 3.6.9", + "sp-api", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1", +] + +[[package]] +name = "pallet-jobs-rpc-runtime-api" +version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "parity-scale-codec 3.6.9", + "sp-api", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", +] + +[[package]] +name = "pallet-multisig" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-nomination-pools" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-tracing 10.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "pallet-offences" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "crc32fast", - "hashbrown 0.13.2", - "indexmap 1.9.3", - "memchr", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +name = "pallet-preimage" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "memchr", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "oid-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" +name = "pallet-proxy" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "asn1-rs", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +name = "pallet-roles" +version = "0.6.1" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-session", + "pallet-staking", + "pallet-timestamp", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-crypto-primitives 0.6.1", + "tangle-primitives 0.6.1", +] [[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +name = "pallet-scheduler" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "docify", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-weights 20.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] [[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +name = "pallet-session" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-timestamp", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-session", + "sp-staking", + "sp-state-machine 0.28.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-trie 22.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] [[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" +name = "pallet-staking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "arrayvec 0.7.4", - "auto_impl", - "bytes", - "ethereum-types 0.14.1", - "open-fastrlp-derive", + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" +name = "pallet-staking-reward-curve" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "bytes", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "owo-colors" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" - -[[package]] -name = "p256" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" +name = "pallet-sudo" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2 0.10.8", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "p256" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +name = "pallet-timestamp" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "ecdsa 0.16.9", - "elliptic-curve 0.13.8", - "primeorder 0.13.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.10.8", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-inherents", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-storage 13.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-timestamp", ] [[package]] -name = "p384" -version = "0.13.0" -source = "git+https://github.com/LIT-Protocol/elliptic-curves.git#67924afc93d236e1508afd5f55bbf738e1c41eaa" +name = "pallet-transaction-pause" +version = "0.6.1" dependencies = [ - "ecdsa 0.16.9", - "elliptic-curve 0.13.8", - "primeorder 0.13.6 (git+https://github.com/LIT-Protocol/elliptic-curves.git)", - "sha2 0.10.8", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "paillier-zk" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4956496b1cb7ecf45e86844ae50a5c0ade430dd4d491de8d020adb95ca6f328" +name = "pallet-transaction-payment" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "digest 0.10.7", - "fast-paillier", - "generic-ec", - "rand_core 0.6.4", - "rug", + "frame-support", + "frame-system", + "parity-scale-codec 3.6.9", + "scale-info", "serde", - "serde_with 3.6.0", - "thiserror", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "pairing-plus" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cda4f22e8e6720f3c254049960c8cc4f93cb82b5ade43bddd2622b5f39ea62" +name = "pallet-transaction-payment-rpc-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "byteorder", - "digest 0.8.1", - "ff-zeroize", - "rand 0.4.6", - "rand_core 0.5.1", - "rand_xorshift 0.2.0", - "zeroize", + "pallet-transaction-payment", + "parity-scale-codec 3.6.9", + "sp-api", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-weights 20.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "pallet-balances" +name = "pallet-treasury" version = "4.0.0-dev" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "log", + "impl-trait-for-tuples", + "pallet-balances", "parity-scale-codec 3.6.9", "scale-info", - "sp-runtime 24.0.0", - "sp-std 8.0.0", + "serde", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "pallet-dkg" -version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" +name = "pallet-utility" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec 3.6.9", "scale-info", - "serde", - "sp-core 21.0.0", - "sp-io 23.0.0", - "sp-runtime 24.0.0", - "sp-std 8.0.0", - "tangle-crypto-primitives", - "tangle-primitives", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "pallet-jobs" -version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" +name = "pallet-vesting" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec 3.6.9", "scale-info", - "sp-core 21.0.0", - "sp-runtime 24.0.0", - "sp-std 8.0.0", - "tangle-crypto-primitives", - "tangle-primitives", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] -name = "pallet-jobs-rpc-runtime-api" +name = "pallet-zksaas" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" -dependencies = [ - "parity-scale-codec 3.6.9", - "sp-api", - "sp-runtime 24.0.0", - "sp-std 8.0.0", - "tangle-primitives", -] - -[[package]] -name = "pallet-timestamp" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6078,18 +8939,18 @@ dependencies = [ "log", "parity-scale-codec 3.6.9", "scale-info", - "sp-inherents", - "sp-io 23.0.0", - "sp-runtime 24.0.0", - "sp-std 8.0.0", - "sp-storage 13.0.0", - "sp-timestamp", + "serde", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1", ] [[package]] name = "pallet-zksaas" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" dependencies = [ "frame-benchmarking", "frame-support", @@ -6098,11 +8959,11 @@ dependencies = [ "parity-scale-codec 3.6.9", "scale-info", "serde", - "sp-core 21.0.0", - "sp-io 23.0.0", - "sp-runtime 24.0.0", - "sp-std 8.0.0", - "tangle-primitives", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", ] [[package]] @@ -6230,6 +9091,12 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "path-slash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" + [[package]] name = "pbkdf2" version = "0.8.0" @@ -6255,6 +9122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" dependencies = [ "digest 0.10.7", + "hmac 0.12.1", ] [[package]] @@ -6319,6 +9187,67 @@ dependencies = [ "educe", ] +[[package]] +name = "pharos" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" +dependencies = [ + "futures", + "rustc_version 0.4.0", +] + +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_macros", + "phf_shared 0.11.2", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared 0.11.2", + "rand 0.8.5", +] + +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator", + "phf_shared 0.11.2", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher 0.3.11", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher 0.3.11", +] + [[package]] name = "pin-project" version = "1.1.4" @@ -6505,6 +9434,50 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "precompile-utils" +version = "0.1.0" +dependencies = [ + "affix", + "environmental", + "evm", + "fp-evm", + "frame-support", + "frame-system", + "hex", + "impl-trait-for-tuples", + "log", + "num_enum 0.5.11", + "pallet-evm", + "parity-scale-codec 3.6.9", + "paste", + "precompile-utils-macro", + "sha3 0.10.8", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "precompile-utils-macro" +version = "0.1.0" +dependencies = [ + "case", + "num_enum 0.5.11", + "prettyplease 0.1.25", + "proc-macro2", + "quote", + "sha3 0.10.8", + "syn 1.0.109", +] + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + [[package]] name = "predicates" version = "2.1.5" @@ -6545,6 +9518,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prettyplease" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +dependencies = [ + "proc-macro2", + "syn 2.0.48", +] + [[package]] name = "primeorder" version = "0.13.6" @@ -6587,6 +9570,18 @@ dependencies = [ "uint", ] +[[package]] +name = "primitives-ext" +version = "0.1.0" +dependencies = [ + "ethereum-types 0.14.1", + "evm-tracing-events", + "parity-scale-codec 3.6.9", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + [[package]] name = "proc-macro-crate" version = "1.1.3" @@ -6604,7 +9599,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" dependencies = [ "toml_datetime", - "toml_edit", + "toml_edit 0.20.2", ] [[package]] @@ -6727,7 +9722,7 @@ dependencies = [ "log", "multimap", "petgraph", - "prettyplease", + "prettyplease 0.1.25", "prost", "prost-types", "regex", @@ -7263,6 +10258,12 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + [[package]] name = "regex-syntax" version = "0.8.2" @@ -7290,6 +10291,46 @@ dependencies = [ "bytecheck", ] +[[package]] +name = "reqwest" +version = "0.11.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite 0.2.13", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "resolv-conf" version = "0.7.0" @@ -7365,6 +10406,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "rkyv" version = "0.7.44" @@ -7380,7 +10430,7 @@ dependencies = [ "rkyv_derive", "seahash", "tinyvec", - "uuid", + "uuid 1.7.0", ] [[package]] @@ -7464,6 +10514,36 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "rpc-primitives-debug" +version = "0.1.0" +dependencies = [ + "environmental", + "ethereum", + "ethereum-types 0.14.1", + "hex", + "parity-scale-codec 3.6.9", + "serde", + "sp-api", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "rpc-primitives-txpool" +version = "0.6.0" +dependencies = [ + "ethereum", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-api", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + [[package]] name = "rtnetlink" version = "0.10.1" @@ -7492,6 +10572,20 @@ dependencies = [ "serde", ] +[[package]] +name = "rusqlite" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "549b9d036d571d42e6e85d1c1425e2ac83491075078ca9a15be021c56b1641f2" +dependencies = [ + "bitflags 2.4.2", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + [[package]] name = "rust-gmp-kzen" version = "0.5.1" @@ -7521,13 +10615,22 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.21", ] [[package]] @@ -7669,6 +10772,15 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +[[package]] +name = "safe-mix" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" +dependencies = [ + "rustc_version 0.2.3", +] + [[package]] name = "safe_arch" version = "0.7.1" @@ -7678,6 +10790,20 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "safe_arith" +version = "0.1.0" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" + +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + [[package]] name = "same-file" version = "1.0.6" @@ -7693,8 +10819,8 @@ version = "4.1.0-dev" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "log", - "sp-core 21.0.0", - "sp-wasm-interface 14.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-wasm-interface 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", ] @@ -7714,13 +10840,13 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-consensus", - "sp-core 21.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-database", - "sp-externalities 0.19.0", - "sp-runtime 24.0.0", - "sp-state-machine 0.28.0", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-state-machine 0.28.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-statement-store", - "sp-storage 13.0.0", + "sp-storage 13.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "substrate-prometheus-endpoint", ] @@ -7742,9 +10868,9 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-consensus", - "sp-core 21.0.0", - "sp-runtime 24.0.0", - "sp-state-machine 0.28.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-state-machine 0.28.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "substrate-prometheus-endpoint", "thiserror", ] @@ -7760,14 +10886,14 @@ dependencies = [ "sc-executor-wasmtime", "schnellru", "sp-api", - "sp-core 21.0.0", - "sp-externalities 0.19.0", - "sp-io 23.0.0", - "sp-panic-handler 8.0.0", - "sp-runtime-interface 17.0.0", - "sp-trie 22.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-panic-handler 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-trie 22.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-version", - "sp-wasm-interface 14.0.0", + "sp-wasm-interface 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "tracing", ] @@ -7778,7 +10904,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", - "sp-wasm-interface 14.0.0", + "sp-wasm-interface 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", "wasm-instrument", ] @@ -7795,8 +10921,8 @@ dependencies = [ "rustix 0.36.17", "sc-allocator", "sc-executor-common", - "sp-runtime-interface 17.0.0", - "sp-wasm-interface 14.0.0", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-wasm-interface 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "wasmtime", ] @@ -7805,7 +10931,7 @@ name = "sc-network" version = "0.10.0-dev" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.2", "async-channel 1.9.0", "async-trait", "asynchronous-codec", @@ -7830,10 +10956,10 @@ dependencies = [ "serde", "serde_json", "smallvec", - "sp-arithmetic 16.0.0", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-blockchain", - "sp-core 21.0.0", - "sp-runtime 24.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "substrate-prometheus-endpoint", "thiserror", "unsigned-varint", @@ -7855,7 +10981,7 @@ dependencies = [ "sc-consensus", "sp-consensus", "sp-consensus-grandpa", - "sp-runtime 24.0.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] @@ -7863,7 +10989,7 @@ name = "sc-network-sync" version = "0.10.0-dev" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.2", "async-channel 1.9.0", "async-trait", "fork-tree", @@ -7882,12 +11008,12 @@ dependencies = [ "sc-utils", "schnellru", "smallvec", - "sp-arithmetic 16.0.0", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-blockchain", "sp-consensus", "sp-consensus-grandpa", - "sp-core 21.0.0", - "sp-runtime 24.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "substrate-prometheus-endpoint", "thiserror", ] @@ -7903,8 +11029,8 @@ dependencies = [ "parity-scale-codec 3.6.9", "serde", "sp-blockchain", - "sp-core 21.0.0", - "sp-runtime 24.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", ] @@ -7920,7 +11046,18 @@ dependencies = [ "log", "parking_lot 0.12.1", "prometheus", - "sp-arithmetic 16.0.0", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "scale-bits" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd7aca73785181cc41f0bbe017263e682b585ca660540ba569133901d013ecf" +dependencies = [ + "parity-scale-codec 3.6.9", + "scale-info", + "serde", ] [[package]] @@ -7934,6 +11071,21 @@ dependencies = [ "serde", ] +[[package]] +name = "scale-decode" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0459d00b0dbd2e765009924a78ef36b2ff7ba116292d732f00eb0ed8e465d15" +dependencies = [ + "parity-scale-codec 3.6.9", + "primitive-types 0.12.2", + "scale-bits 0.3.0", + "scale-decode-derive 0.7.0", + "scale-info", + "smallvec", + "thiserror", +] + [[package]] name = "scale-decode" version = "0.10.0" @@ -7943,12 +11095,25 @@ dependencies = [ "derive_more", "parity-scale-codec 3.6.9", "primitive-types 0.12.2", - "scale-bits", - "scale-decode-derive", + "scale-bits 0.4.0", + "scale-decode-derive 0.10.0", "scale-info", "smallvec", ] +[[package]] +name = "scale-decode-derive" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4391f0dfbb6690f035f6d2a15d6a12f88cc5395c36bcc056db07ffa2a90870ec" +dependencies = [ + "darling 0.14.4", + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "scale-decode-derive" version = "0.10.0" @@ -7962,6 +11127,21 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scale-encode" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0401b7cdae8b8aa33725f3611a051358d5b32887ecaa0fda5953a775b2d4d76" +dependencies = [ + "parity-scale-codec 3.6.9", + "primitive-types 0.12.2", + "scale-bits 0.3.0", + "scale-encode-derive 0.3.0", + "scale-info", + "smallvec", + "thiserror", +] + [[package]] name = "scale-encode" version = "0.5.0" @@ -7971,12 +11151,25 @@ dependencies = [ "derive_more", "parity-scale-codec 3.6.9", "primitive-types 0.12.2", - "scale-bits", - "scale-encode-derive", + "scale-bits 0.4.0", + "scale-encode-derive 0.5.0", "scale-info", "smallvec", ] +[[package]] +name = "scale-encode-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "316e0fb10ec0fee266822bd641bab5e332a4ab80ef8c5b5ff35e5401a394f5a6" +dependencies = [ + "darling 0.14.4", + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "scale-encode-derive" version = "0.5.0" @@ -8016,6 +11209,26 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scale-value" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2096d36e94ce9bf87d8addb752423b6b19730dc88edd7cc452bb2b90573f7a7" +dependencies = [ + "base58", + "blake2", + "either", + "frame-metadata 15.1.0", + "parity-scale-codec 3.6.9", + "scale-bits 0.3.0", + "scale-decode 0.7.0", + "scale-encode 0.3.0", + "scale-info", + "serde", + "thiserror", + "yap 0.10.0", +] + [[package]] name = "scale-value" version = "0.13.0" @@ -8028,12 +11241,12 @@ dependencies = [ "either", "frame-metadata 15.1.0", "parity-scale-codec 3.6.9", - "scale-bits", - "scale-decode", - "scale-encode", + "scale-bits 0.4.0", + "scale-decode 0.10.0", + "scale-encode 0.5.0", "scale-info", "serde", - "yap", + "yap 0.11.0", ] [[package]] @@ -8097,7 +11310,25 @@ dependencies = [ name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "scratch" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" + +[[package]] +name = "scrypt" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" +dependencies = [ + "hmac 0.12.1", + "pbkdf2 0.11.0", + "salsa20", + "sha2 0.10.8", +] [[package]] name = "sct" @@ -8224,11 +11455,50 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +dependencies = [ + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "send_wrapper" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" @@ -8300,6 +11570,28 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" +dependencies = [ + "serde", + "serde_with_macros 1.5.2", +] + [[package]] name = "serde_with" version = "2.3.3" @@ -8333,6 +11625,18 @@ dependencies = [ "time", ] +[[package]] +name = "serde_with_macros" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" +dependencies = [ + "darling 0.13.4", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "serde_with_macros" version = "2.3.3" @@ -8357,6 +11661,18 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "serde_yaml" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +dependencies = [ + "indexmap 1.9.3", + "ryu", + "serde", + "yaml-rust", +] + [[package]] name = "serdect" version = "0.2.0" @@ -8495,6 +11811,24 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint 0.4.4", + "num-traits", + "thiserror", + "time", +] + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "siphasher" version = "1.0.0" @@ -8516,6 +11850,24 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" +[[package]] +name = "slices" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2086e458a369cdca838e9f6ed04b4cc2e3ce636d99abb80c9e2eada107749cf" +dependencies = [ + "faster-hex", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "slog" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" + [[package]] name = "smallvec" version = "1.13.1" @@ -8584,13 +11936,13 @@ dependencies = [ "serde_json", "sha2 0.10.8", "sha3 0.10.8", - "siphasher", + "siphasher 1.0.0", "slab", "smallvec", "soketto", "twox-hash", "wasmi", - "x25519-dalek 2.0.0", + "x25519-dalek 2.0.1", "zeroize", ] @@ -8623,7 +11975,7 @@ dependencies = [ "rand_chacha 0.3.1", "serde", "serde_json", - "siphasher", + "siphasher 1.0.0", "slab", "smol", "smoldot", @@ -8642,7 +11994,7 @@ dependencies = [ "curve25519-dalek 4.1.1", "rand_core 0.6.4", "ring 0.17.7", - "rustc_version", + "rustc_version 0.4.0", "sha2 0.10.8", "subtle", ] @@ -8683,23 +12035,37 @@ dependencies = [ "sha-1", ] +[[package]] +name = "solang-parser" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" +dependencies = [ + "itertools 0.11.0", + "lalrpop", + "lalrpop-util", + "phf", + "thiserror", + "unicode-xid", +] + [[package]] name = "sp-api" version = "4.0.0-dev" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "hash-db", + "hash-db 0.16.0", "log", "parity-scale-codec 3.6.9", "scale-info", "sp-api-proc-macro", - "sp-core 21.0.0", - "sp-externalities 0.19.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-metadata-ir", - "sp-runtime 24.0.0", - "sp-state-machine 0.28.0", - "sp-std 8.0.0", - "sp-trie 22.0.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-state-machine 0.28.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-trie 22.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-version", "thiserror", ] @@ -8718,6 +12084,20 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "sp-application-crypto" +version = "23.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899492ea547816d5dfe9a5a2ecc32f65a7110805af6da3380aa4902371b31dc2" +dependencies = [ + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "sp-core 21.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-io 23.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-application-crypto" version = "23.0.0" @@ -8726,9 +12106,9 @@ dependencies = [ "parity-scale-codec 3.6.9", "scale-info", "serde", - "sp-core 21.0.0", - "sp-io 23.0.0", - "sp-std 8.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] @@ -8745,6 +12125,21 @@ dependencies = [ "sp-std 12.0.0", ] +[[package]] +name = "sp-arithmetic" +version = "16.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6020576e544c6824a51d651bc8df8e6ab67cd59f1c9ac09868bb81a5199ded" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "static_assertions", +] + [[package]] name = "sp-arithmetic" version = "16.0.0" @@ -8755,7 +12150,7 @@ dependencies = [ "parity-scale-codec 3.6.9", "scale-info", "serde", - "sp-std 8.0.0", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "static_assertions", ] @@ -8774,6 +12169,17 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "sp-block-builder" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "sp-api", + "sp-inherents", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + [[package]] name = "sp-blockchain" version = "4.0.0-dev" @@ -8787,8 +12193,8 @@ dependencies = [ "sp-api", "sp-consensus", "sp-database", - "sp-runtime 24.0.0", - "sp-state-machine 0.28.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-state-machine 0.28.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", ] @@ -8800,10 +12206,10 @@ dependencies = [ "async-trait", "futures", "log", - "sp-core 21.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-inherents", - "sp-runtime 24.0.0", - "sp-state-machine 0.28.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-state-machine 0.28.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", ] @@ -8817,12 +12223,12 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-application-crypto 23.0.0", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-consensus-slots", - "sp-core 21.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-inherents", - "sp-runtime 24.0.0", - "sp-std 8.0.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-timestamp", ] @@ -8837,11 +12243,11 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-application-crypto 23.0.0", - "sp-core 21.0.0", - "sp-keystore 0.27.0", - "sp-runtime 24.0.0", - "sp-std 8.0.0", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-keystore 0.27.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] @@ -8852,16 +12258,61 @@ dependencies = [ "parity-scale-codec 3.6.9", "scale-info", "serde", - "sp-std 8.0.0", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-timestamp", ] +[[package]] +name = "sp-core" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f18d9e2f67d8661f9729f35347069ac29d92758b59135176799db966947a7336" +dependencies = [ + "array-bytes 4.2.0", + "bitflags 1.3.2", + "blake2", + "bounded-collections", + "bs58 0.4.0", + "dyn-clonable", + "ed25519-zebra 3.1.0", + "futures", + "hash-db 0.16.0", + "hash256-std-hasher", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "merlin 2.0.1", + "parity-scale-codec 3.6.9", + "parking_lot 0.12.1", + "paste", + "primitive-types 0.12.2", + "rand 0.8.5", + "regex", + "scale-info", + "schnorrkel 0.9.1", + "secp256k1 0.24.3", + "secrecy", + "serde", + "sp-core-hashing 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-debug-derive 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-externalities 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime-interface 17.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-storage 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ss58-registry", + "substrate-bip39", + "thiserror", + "tiny-bip39", + "zeroize", +] + [[package]] name = "sp-core" version = "21.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.2", "arrayvec 0.7.4", "bandersnatch_vrfs", "bitflags 1.3.2", @@ -8871,7 +12322,7 @@ dependencies = [ "dyn-clonable", "ed25519-zebra 3.1.0", "futures", - "hash-db", + "hash-db 0.16.0", "hash256-std-hasher", "impl-serde", "lazy_static", @@ -8889,12 +12340,12 @@ dependencies = [ "secp256k1 0.24.3", "secrecy", "serde", - "sp-core-hashing 9.0.0", - "sp-debug-derive 8.0.0", - "sp-externalities 0.19.0", - "sp-runtime-interface 17.0.0", - "sp-std 8.0.0", - "sp-storage 13.0.0", + "sp-core-hashing 9.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-debug-derive 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-storage 13.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "ss58-registry", "substrate-bip39", "thiserror", @@ -8909,7 +12360,7 @@ version = "26.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0db34a19be2efa0398a9506a365392d93a85220856d55e0eb78165ad2e1bedc" dependencies = [ - "array-bytes", + "array-bytes 6.2.2", "bip39", "bitflags 1.3.2", "blake2", @@ -8918,7 +12369,7 @@ dependencies = [ "dyn-clonable", "ed25519-zebra 3.1.0", "futures", - "hash-db", + "hash-db 0.16.0", "hash256-std-hasher", "impl-serde", "itertools 0.10.5", @@ -8951,6 +12402,21 @@ dependencies = [ "zeroize", ] +[[package]] +name = "sp-core-hashing" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ee599a8399448e65197f9a6cee338ad192e9023e35e31f22382964c3c174c68" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest 0.10.7", + "sha2 0.10.8", + "sha3 0.10.8", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "twox-hash", +] + [[package]] name = "sp-core-hashing" version = "9.0.0" @@ -8984,7 +12450,7 @@ version = "9.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "quote", - "sp-core-hashing 9.0.0", + "sp-core-hashing 9.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "syn 2.0.48", ] @@ -8997,6 +12463,17 @@ dependencies = [ "parking_lot 0.12.1", ] +[[package]] +name = "sp-debug-derive" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f531814d2f16995144c74428830ccf7d94ff4a7749632b83ad8199b181140c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "sp-debug-derive" version = "8.0.0" @@ -9018,6 +12495,18 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "sp-externalities" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0f71c671e01a8ca60da925d43a1b351b69626e268b8837f8371e320cf1dd100" +dependencies = [ + "environmental", + "parity-scale-codec 3.6.9", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-storage 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-externalities" version = "0.19.0" @@ -9025,8 +12514,8 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "environmental", "parity-scale-codec 3.6.9", - "sp-std 8.0.0", - "sp-storage 13.0.0", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-storage 13.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] @@ -9048,8 +12537,8 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "serde_json", "sp-api", - "sp-runtime 24.0.0", - "sp-std 8.0.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] @@ -9061,31 +12550,58 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec 3.6.9", "scale-info", - "sp-runtime 24.0.0", - "sp-std 8.0.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", ] +[[package]] +name = "sp-io" +version = "23.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d597e35a9628fe7454b08965b2442e3ec0f264b0a90d41328e87422cec02e99" +dependencies = [ + "bytes", + "ed25519 1.5.3", + "ed25519-dalek 1.0.1", + "futures", + "libsecp256k1", + "log", + "parity-scale-codec 3.6.9", + "rustversion", + "secp256k1 0.24.3", + "sp-core 21.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-externalities 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-keystore 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime-interface 17.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-state-machine 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-tracing 10.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-trie 22.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing", + "tracing-core", +] + [[package]] name = "sp-io" version = "23.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "bytes", - "ed25519-dalek", + "ed25519-dalek 2.1.1", "libsecp256k1", "log", "parity-scale-codec 3.6.9", "rustversion", "secp256k1 0.24.3", - "sp-core 21.0.0", - "sp-externalities 0.19.0", - "sp-keystore 0.27.0", - "sp-runtime-interface 17.0.0", - "sp-state-machine 0.28.0", - "sp-std 8.0.0", - "sp-tracing 10.0.0", - "sp-trie 22.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-keystore 0.27.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-state-machine 0.28.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-tracing 10.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-trie 22.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "tracing", "tracing-core", ] @@ -9097,22 +12613,59 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "301c0ce94f80b324465a6f6173183aa07b26bd71d67f94a44de1fd11dea4a7cb" dependencies = [ "bytes", - "ed25519-dalek", + "ed25519-dalek 2.1.1", "libsecp256k1", "log", "parity-scale-codec 3.6.9", - "rustversion", - "secp256k1 0.24.3", - "sp-core 26.0.0", - "sp-externalities 0.23.0", - "sp-keystore 0.32.0", - "sp-runtime-interface 22.0.0", - "sp-state-machine 0.33.0", - "sp-std 12.0.0", - "sp-tracing 14.0.0", - "sp-trie 27.0.0", - "tracing", - "tracing-core", + "rustversion", + "secp256k1 0.24.3", + "sp-core 26.0.0", + "sp-externalities 0.23.0", + "sp-keystore 0.32.0", + "sp-runtime-interface 22.0.0", + "sp-state-machine 0.33.0", + "sp-std 12.0.0", + "sp-tracing 14.0.0", + "sp-trie 27.0.0", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-keyring" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4673405248580504a8bc4e09615ab25ccb182dfaccd27e000fda9dcb2ca1dab1" +dependencies = [ + "lazy_static", + "sp-core 21.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime 24.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "strum 0.24.1", +] + +[[package]] +name = "sp-keyring" +version = "24.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "lazy_static", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "strum 0.24.1", +] + +[[package]] +name = "sp-keystore" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9be3cdd67cc1d9c1db17c5cbc4ec4924054a8437009d167f21f6590797e4aa45" +dependencies = [ + "futures", + "parity-scale-codec 3.6.9", + "parking_lot 0.12.1", + "sp-core 21.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-externalities 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror", ] [[package]] @@ -9122,8 +12675,8 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "parity-scale-codec 3.6.9", "parking_lot 0.12.1", - "sp-core 21.0.0", - "sp-externalities 0.19.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", ] @@ -9157,7 +12710,42 @@ dependencies = [ "frame-metadata 16.0.0", "parity-scale-codec 3.6.9", "scale-info", - "sp-std 8.0.0", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "sp-npos-elections" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "sp-offchain" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "sp-api", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "sp-panic-handler" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd2de46003fa8212426838ca71cd42ee36a26480ba9ffea983506ce03131033" +dependencies = [ + "backtrace", + "lazy_static", + "regex", ] [[package]] @@ -9181,6 +12769,29 @@ dependencies = [ "regex", ] +[[package]] +name = "sp-runtime" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21c5bfc764a1a8259d7e8f7cfd22c84006275a512c958d3ff966c92151e134d5" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec 3.6.9", + "paste", + "rand 0.8.5", + "scale-info", + "serde", + "sp-application-crypto 23.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-arithmetic 16.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 21.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-io 23.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-weights 20.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-runtime" version = "24.0.0" @@ -9195,12 +12806,12 @@ dependencies = [ "rand 0.8.5", "scale-info", "serde", - "sp-application-crypto 23.0.0", - "sp-arithmetic 16.0.0", - "sp-core 21.0.0", - "sp-io 23.0.0", - "sp-std 8.0.0", - "sp-weights 20.0.0", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-weights 20.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] @@ -9226,6 +12837,25 @@ dependencies = [ "sp-weights 25.0.0", ] +[[package]] +name = "sp-runtime-interface" +version = "17.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e676128182f90015e916f806cba635c8141e341e7abbc45d25525472e1bbce8" +dependencies = [ + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec 3.6.9", + "primitive-types 0.12.2", + "sp-externalities 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime-interface-proc-macro 11.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-storage 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-tracing 10.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-wasm-interface 14.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "static_assertions", +] + [[package]] name = "sp-runtime-interface" version = "17.0.0" @@ -9235,12 +12865,12 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec 3.6.9", "primitive-types 0.12.2", - "sp-externalities 0.19.0", - "sp-runtime-interface-proc-macro 11.0.0", - "sp-std 8.0.0", - "sp-storage 13.0.0", - "sp-tracing 10.0.0", - "sp-wasm-interface 14.0.0", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime-interface-proc-macro 11.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-storage 13.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-tracing 10.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-wasm-interface 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "static_assertions", ] @@ -9263,6 +12893,19 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "11.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d5bd5566fe5633ec48dfa35ab152fd29f8a577c21971e1c6db9f28afb9bbb9" +dependencies = [ + "Inflector", + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" @@ -9288,6 +12931,21 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "sp-session" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "parity-scale-codec 3.6.9", + "scale-info", + "sp-api", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-keystore 0.27.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + [[package]] name = "sp-staking" version = "4.0.0-dev" @@ -9297,9 +12955,30 @@ dependencies = [ "parity-scale-codec 3.6.9", "scale-info", "serde", - "sp-core 21.0.0", - "sp-runtime 24.0.0", - "sp-std 8.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "sp-state-machine" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef45d31f9e7ac648f8899a0cd038a3608f8499028bff55b6c799702592325b6" +dependencies = [ + "hash-db 0.16.0", + "log", + "parity-scale-codec 3.6.9", + "parking_lot 0.12.1", + "rand 0.8.5", + "smallvec", + "sp-core 21.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-externalities 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-panic-handler 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-trie 22.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror", + "tracing", ] [[package]] @@ -9307,17 +12986,17 @@ name = "sp-state-machine" version = "0.28.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "hash-db", + "hash-db 0.16.0", "log", "parity-scale-codec 3.6.9", "parking_lot 0.12.1", "rand 0.8.5", "smallvec", - "sp-core 21.0.0", - "sp-externalities 0.19.0", - "sp-panic-handler 8.0.0", - "sp-std 8.0.0", - "sp-trie 22.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-panic-handler 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-trie 22.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", "tracing", "trie-db 0.27.1", @@ -9329,7 +13008,7 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df7c6680d9342c22c10d8272ebf9f0339b0e439b3e67b68f5627f9dfc6926a07" dependencies = [ - "hash-db", + "hash-db 0.16.0", "log", "parity-scale-codec 3.6.9", "parking_lot 0.12.1", @@ -9352,23 +13031,29 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "aes-gcm", "curve25519-dalek 4.1.1", - "ed25519-dalek", + "ed25519-dalek 2.1.1", "hkdf", "parity-scale-codec 3.6.9", "rand 0.8.5", "scale-info", "sha2 0.10.8", "sp-api", - "sp-application-crypto 23.0.0", - "sp-core 21.0.0", - "sp-externalities 0.19.0", - "sp-runtime 24.0.0", - "sp-runtime-interface 17.0.0", - "sp-std 8.0.0", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime-interface 17.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", - "x25519-dalek 2.0.0", + "x25519-dalek 2.0.1", ] +[[package]] +name = "sp-std" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53458e3c57df53698b3401ec0934bea8e8cfce034816873c0b0abbd83d7bac0d" + [[package]] name = "sp-std" version = "8.0.0" @@ -9380,6 +13065,20 @@ version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54c78c5a66682568cc7b153603c5d01a2cc8f5c221c7b1e921517a0eef18ae05" +[[package]] +name = "sp-storage" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94294be83f11d4958cfea89ed5798f0b6605f5defc3a996948848458abbcc18e" +dependencies = [ + "impl-serde", + "parity-scale-codec 3.6.9", + "ref-cast", + "serde", + "sp-debug-derive 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-storage" version = "13.0.0" @@ -9389,8 +13088,8 @@ dependencies = [ "parity-scale-codec 3.6.9", "ref-cast", "serde", - "sp-debug-derive 8.0.0", - "sp-std 8.0.0", + "sp-debug-derive 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] @@ -9415,18 +13114,31 @@ dependencies = [ "async-trait", "parity-scale-codec 3.6.9", "sp-inherents", - "sp-runtime 24.0.0", - "sp-std 8.0.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", ] +[[package]] +name = "sp-tracing" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357f7591980dd58305956d32f8f6646d0a8ea9ea0e7e868e46f53b68ddf00cec" +dependencies = [ + "parity-scale-codec 3.6.9", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing", + "tracing-core", + "tracing-subscriber 0.2.25", +] + [[package]] name = "sp-tracing" version = "10.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec 3.6.9", - "sp-std 8.0.0", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "tracing", "tracing-core", "tracing-subscriber 0.2.25", @@ -9445,13 +13157,46 @@ dependencies = [ "tracing-subscriber 0.2.25", ] +[[package]] +name = "sp-transaction-pool" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "sp-api", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "sp-trie" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4eeb7ef23f79eba8609db79ef9cef242f994f1f87a3c0387b4b5f177fda74" +dependencies = [ + "ahash 0.8.7", + "hash-db 0.16.0", + "hashbrown 0.13.2", + "lazy_static", + "memory-db", + "nohash-hasher", + "parity-scale-codec 3.6.9", + "parking_lot 0.12.1", + "scale-info", + "schnellru", + "sp-core 21.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror", + "tracing", + "trie-db 0.27.1", + "trie-root", +] + [[package]] name = "sp-trie" version = "22.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "ahash 0.8.7", - "hash-db", + "hash-db 0.16.0", "hashbrown 0.13.2", "lazy_static", "memory-db", @@ -9460,8 +13205,8 @@ dependencies = [ "parking_lot 0.12.1", "scale-info", "schnellru", - "sp-core 21.0.0", - "sp-std 8.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "thiserror", "tracing", "trie-db 0.27.1", @@ -9475,7 +13220,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9c4bf89a5bd74f696cd1f23d83bb6abe6bd0abad1f3c70d4b0d7ebec4098cfe" dependencies = [ "ahash 0.8.7", - "hash-db", + "hash-db 0.16.0", "hashbrown 0.13.2", "lazy_static", "memory-db", @@ -9504,8 +13249,8 @@ dependencies = [ "scale-info", "serde", "sp-core-hashing-proc-macro", - "sp-runtime 24.0.0", - "sp-std 8.0.0", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-version-proc-macro", "thiserror", ] @@ -9521,6 +13266,20 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "sp-wasm-interface" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19c122609ca5d8246be6386888596320d03c7bc880959eaa2c36bcd5acd6846" +dependencies = [ + "anyhow", + "impl-trait-for-tuples", + "log", + "parity-scale-codec 3.6.9", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmtime", +] + [[package]] name = "sp-wasm-interface" version = "14.0.0" @@ -9530,7 +13289,7 @@ dependencies = [ "impl-trait-for-tuples", "log", "parity-scale-codec 3.6.9", - "sp-std 8.0.0", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "wasmtime", ] @@ -9548,6 +13307,22 @@ dependencies = [ "wasmtime", ] +[[package]] +name = "sp-weights" +version = "20.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45d084c735544f70625b821c3acdbc7a2fc1893ca98b85f1942631284692c75b" +dependencies = [ + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic 16.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 21.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-debug-derive 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-weights" version = "20.0.0" @@ -9557,10 +13332,10 @@ dependencies = [ "scale-info", "serde", "smallvec", - "sp-arithmetic 16.0.0", - "sp-core 21.0.0", - "sp-debug-derive 8.0.0", - "sp-std 8.0.0", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-debug-derive 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] @@ -9629,6 +13404,24 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "ssz_types" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382939886cb24ee8ac885d09116a60f6262d827c7a9e36012b4f6d3d0116d0b3" +dependencies = [ + "arbitrary", + "derivative", + "ethereum_serde_utils", + "ethereum_ssz", + "itertools 0.10.5", + "serde", + "serde_derive", + "smallvec", + "tree_hash", + "typenum", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -9642,7 +13435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f357220731130667173ede5f8f9763eba482bdec60cd91a535156537635cdbcc" dependencies = [ "ff 0.13.0", - "hex-literal", + "hex-literal 0.3.4", "primeorder 0.13.6 (registry+https://github.com/rust-lang/crates.io-index)", "subtle", "zeroize", @@ -9654,6 +13447,19 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "string_cache" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot 0.12.1", + "phf_shared 0.10.0", + "precomputed-hash", +] + [[package]] name = "strsim" version = "0.8.0" @@ -9672,7 +13478,7 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ - "clap", + "clap 2.34.0", "lazy_static", "structopt-derive", ] @@ -9690,13 +13496,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros 0.24.3", +] + [[package]] name = "strum" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" dependencies = [ - "strum_macros", + "strum_macros 0.25.3", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", ] [[package]] @@ -9720,7 +13548,7 @@ dependencies = [ "futures", "gadget-common", "protocol-macros", - "tangle-primitives", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", "tokio", ] @@ -9737,6 +13565,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "substrate-bn" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b5bbfa79abbae15dd642ea8176a21a635ff3c00059961d1ea27ad04e5b441c" +dependencies = [ + "byteorder", + "crunchy", + "lazy_static", + "rand 0.8.5", + "rustc-hex", +] + [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" @@ -9746,15 +13587,67 @@ dependencies = [ "log", "prometheus", "thiserror", - "tokio", + "tokio", +] + +[[package]] +name = "substrate-wasm-builder" +version = "5.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "ansi_term", + "build-helper", + "cargo_metadata 0.15.4", + "filetime", + "parity-wasm", + "sp-maybe-compressed-blob", + "strum 0.24.1", + "tempfile", + "toml 0.7.8", + "walkdir", + "wasm-opt", +] + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "subxt" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31a734d66fa935fbda56ba6a71d7e969f424c8c5608d416ba8499d71d8cbfc1f" +dependencies = [ + "base58", + "blake2", + "derivative", + "either", + "frame-metadata 15.1.0", + "futures", + "getrandom 0.2.12", + "hex", + "impl-serde", + "jsonrpsee 0.16.3", + "parity-scale-codec 3.6.9", + "primitive-types 0.12.2", + "scale-bits 0.3.0", + "scale-decode 0.7.0", + "scale-encode 0.3.0", + "scale-info", + "scale-value 0.10.0", + "serde", + "serde_json", + "sp-core 21.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core-hashing 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime 24.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subxt-macro 0.29.0", + "subxt-metadata 0.29.0", + "thiserror", + "tracing", ] -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "subxt" version = "0.33.0" @@ -9770,26 +13663,46 @@ dependencies = [ "futures", "hex", "impl-serde", - "jsonrpsee", + "jsonrpsee 0.20.3", "parity-scale-codec 3.6.9", "primitive-types 0.12.2", - "scale-bits", - "scale-decode", - "scale-encode", + "scale-bits 0.4.0", + "scale-decode 0.10.0", + "scale-encode 0.5.0", "scale-info", - "scale-value", + "scale-value 0.13.0", "serde", "serde_json", "sp-core 26.0.0", "sp-core-hashing 13.0.0", "sp-runtime 29.0.0", "subxt-lightclient", - "subxt-macro", - "subxt-metadata", + "subxt-macro 0.33.0", + "subxt-metadata 0.33.0", "thiserror", "tracing", ] +[[package]] +name = "subxt-codegen" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e2f231d97c145c564bd544212c0cc0c29c09ff516af199f4ce00c8e055f8138" +dependencies = [ + "frame-metadata 15.1.0", + "heck 0.4.1", + "hex", + "jsonrpsee 0.16.3", + "parity-scale-codec 3.6.9", + "proc-macro2", + "quote", + "scale-info", + "subxt-metadata 0.29.0", + "syn 2.0.48", + "thiserror", + "tokio", +] + [[package]] name = "subxt-codegen" version = "0.33.0" @@ -9799,12 +13712,12 @@ dependencies = [ "frame-metadata 16.0.0", "heck 0.4.1", "hex", - "jsonrpsee", + "jsonrpsee 0.20.3", "parity-scale-codec 3.6.9", "proc-macro2", "quote", "scale-info", - "subxt-metadata", + "subxt-metadata 0.33.0", "syn 2.0.48", "thiserror", "tokio", @@ -9827,6 +13740,18 @@ dependencies = [ "tracing", ] +[[package]] +name = "subxt-macro" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e544e41e1c84b616632cd2f86862342868f62e11e4cd9062a9e3dbf5fc871f64" +dependencies = [ + "darling 0.20.5", + "proc-macro-error", + "subxt-codegen 0.29.0", + "syn 2.0.48", +] + [[package]] name = "subxt-macro" version = "0.33.0" @@ -9836,10 +13761,23 @@ dependencies = [ "darling 0.20.5", "parity-scale-codec 3.6.9", "proc-macro-error", - "subxt-codegen", + "subxt-codegen 0.33.0", "syn 2.0.48", ] +[[package]] +name = "subxt-metadata" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01ce5044c81db3404d38c56f1e69d72eff72c54e5913c9bba4c0b58d376031f" +dependencies = [ + "frame-metadata 15.1.0", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-core-hashing 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror", +] + [[package]] name = "subxt-metadata" version = "0.33.0" @@ -9853,6 +13791,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "superstruct" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b9e5728aa1a87141cefd4e7509903fc01fa0dcb108022b1e841a67c5159fc5" +dependencies = [ + "darling 0.13.4", + "itertools 0.10.5", + "proc-macro2", + "quote", + "smallvec", + "syn 1.0.109", +] + +[[package]] +name = "swap_or_not_shuffle" +version = "0.2.0" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" +dependencies = [ + "ethereum-types 0.14.1", + "ethereum_hashing", +] + [[package]] name = "syn" version = "1.0.109" @@ -9875,6 +13836,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "synstructure" version = "0.12.6" @@ -9911,17 +13878,52 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", - "sp-application-crypto 23.0.0", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "tangle-crypto-primitives" +version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +dependencies = [ + "parity-scale-codec 3.6.9", + "scale-info", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "tangle-primitives" +version = "0.6.1" +dependencies = [ + "ark-bn254", + "ark-crypto-primitives", + "ark-ec", + "ark-ff", + "ark-groth16", + "ark-serialize", + "ark-std", + "ethabi 15.0.0", + "frame-support", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-consensus-babe", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", ] [[package]] name = "tangle-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#97a25c34d1bd6b64799a9566cf82e6c6bde6148a" +source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" dependencies = [ "ark-bn254", "ark-crypto-primitives", @@ -9937,12 +13939,218 @@ dependencies = [ "scale-info", "serde", "smallvec", - "sp-arithmetic 16.0.0", + "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-consensus-babe", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", +] + +[[package]] +name = "tangle-runtime" +version = "0.6.1" +dependencies = [ + "evm-tracer", + "fp-account", + "fp-evm", + "fp-rpc", + "fp-self-contained", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "log", + "num_enum 0.5.11", + "pallet-airdrop-claims", + "pallet-authorship", + "pallet-babe", + "pallet-bags-list", + "pallet-balances", + "pallet-base-fee", + "pallet-bounties", + "pallet-child-bounties", + "pallet-collective", + "pallet-democracy", + "pallet-dynamic-fee", + "pallet-election-provider-multi-phase", + "pallet-elections-phragmen", + "pallet-eth2-light-client", + "pallet-ethereum", + "pallet-evm", + "pallet-evm-chain-id", + "pallet-evm-precompile-batch", + "pallet-evm-precompile-blake2", + "pallet-evm-precompile-bn128", + "pallet-evm-precompile-call-permit", + "pallet-evm-precompile-curve25519", + "pallet-evm-precompile-democracy", + "pallet-evm-precompile-dispatch", + "pallet-evm-precompile-ed25519", + "pallet-evm-precompile-modexp", + "pallet-evm-precompile-preimage", + "pallet-evm-precompile-proxy", + "pallet-evm-precompile-registry", + "pallet-evm-precompile-sha3fips", + "pallet-evm-precompile-simple", + "pallet-evm-precompile-staking", + "pallet-evm-precompile-vesting", + "pallet-grandpa", + "pallet-hotfix-sufficients", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-insecure-randomness-collective-flip", + "pallet-jobs 0.6.1", + "pallet-multisig", + "pallet-nomination-pools", + "pallet-offences", + "pallet-preimage", + "pallet-proxy", + "pallet-roles", + "pallet-scheduler", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-pause", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "parity-scale-codec 3.6.9", + "precompile-utils", + "rpc-primitives-debug", + "rpc-primitives-txpool", + "scale-info", + "serde", + "sp-api", + "sp-block-builder", + "sp-consensus-babe", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-inherents", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-offchain", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-session", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-storage 13.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-transaction-pool", + "sp-version", + "static_assertions", + "substrate-wasm-builder", + "tangle-crypto-primitives 0.6.1", + "tangle-primitives 0.6.1", +] + +[[package]] +name = "tangle-testnet-runtime" +version = "0.6.1" +dependencies = [ + "evm-tracer", + "fp-account", + "fp-evm", + "fp-rpc", + "fp-self-contained", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "log", + "num_enum 0.5.11", + "pallet-airdrop-claims", + "pallet-authorship", + "pallet-babe", + "pallet-bags-list", + "pallet-balances", + "pallet-base-fee", + "pallet-bounties", + "pallet-child-bounties", + "pallet-collective", + "pallet-democracy", + "pallet-dkg 0.6.1", + "pallet-dynamic-fee", + "pallet-election-provider-multi-phase", + "pallet-elections-phragmen", + "pallet-eth2-light-client", + "pallet-ethereum", + "pallet-evm", + "pallet-evm-chain-id", + "pallet-evm-precompile-batch", + "pallet-evm-precompile-blake2", + "pallet-evm-precompile-bn128", + "pallet-evm-precompile-call-permit", + "pallet-evm-precompile-curve25519", + "pallet-evm-precompile-democracy", + "pallet-evm-precompile-dispatch", + "pallet-evm-precompile-ed25519", + "pallet-evm-precompile-jobs", + "pallet-evm-precompile-modexp", + "pallet-evm-precompile-preimage", + "pallet-evm-precompile-proxy", + "pallet-evm-precompile-registry", + "pallet-evm-precompile-sha3fips", + "pallet-evm-precompile-simple", + "pallet-evm-precompile-staking", + "pallet-evm-precompile-vesting", + "pallet-grandpa", + "pallet-hotfix-sufficients", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-insecure-randomness-collective-flip", + "pallet-jobs 0.6.1", + "pallet-jobs-rpc-runtime-api 0.6.1", + "pallet-multisig", + "pallet-nomination-pools", + "pallet-offences", + "pallet-preimage", + "pallet-proxy", + "pallet-roles", + "pallet-scheduler", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-pause", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-zksaas 0.6.1", + "parity-scale-codec 3.6.9", + "precompile-utils", + "rpc-primitives-debug", + "rpc-primitives-txpool", + "scale-info", + "serde", + "sp-api", + "sp-block-builder", "sp-consensus-babe", - "sp-core 21.0.0", - "sp-runtime 24.0.0", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-inherents", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-offchain", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-session", "sp-staking", - "sp-std 8.0.0", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-storage 13.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-transaction-pool", + "sp-version", + "static_assertions", + "substrate-wasm-builder", + "tangle-crypto-primitives 0.6.1", + "tangle-primitives 0.6.1", ] [[package]] @@ -9969,6 +14177,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + [[package]] name = "termcolor" version = "1.4.1" @@ -10022,29 +14241,38 @@ dependencies = [ "gadget-core", "log", "pallet-balances", - "pallet-dkg", - "pallet-jobs", - "pallet-jobs-rpc-runtime-api", + "pallet-dkg 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-jobs 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", "pallet-timestamp", - "pallet-zksaas", + "pallet-zksaas 0.6.1 (git+https://github.com/webb-tools/tangle)", "parity-scale-codec 3.6.9", "parking_lot 0.12.1", "sc-client-api", "sc-utils", "scale-info", "sp-api", - "sp-application-crypto 23.0.0", - "sp-core 21.0.0", - "sp-externalities 0.19.0", - "sp-io 23.0.0", - "sp-keystore 0.27.0", - "sp-runtime 24.0.0", - "sp-std 8.0.0", - "tangle-primitives", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-externalities 0.19.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-keystore 0.27.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", "tokio", "tracing-subscriber 0.3.18", ] +[[package]] +name = "test_random_derive" +version = "0.2.0" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -10084,6 +14312,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "time" version = "0.3.34" @@ -10181,6 +14418,7 @@ dependencies = [ "num_cpus", "parking_lot 0.12.1", "pin-project-lite 0.2.13", + "signal-hook-registry", "socket2 0.5.5", "tokio-macros", "windows-sys 0.48.0", @@ -10197,6 +14435,16 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.24.1" @@ -10242,6 +14490,18 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.19.15", +] + [[package]] name = "toml" version = "0.8.2" @@ -10251,7 +14511,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.20.2", ] [[package]] @@ -10263,6 +14523,19 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.2.2", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "toml_edit" version = "0.20.2" @@ -10346,6 +14619,16 @@ dependencies = [ "tracing-subscriber 0.3.18", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + [[package]] name = "tracing-log" version = "0.1.4" @@ -10418,13 +14701,35 @@ dependencies = [ "tracing-log 0.2.0", ] +[[package]] +name = "tree_hash" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c998ac5fe2b07c025444bdd522e6258110b63861c6698eedc610c071980238d" +dependencies = [ + "ethereum-types 0.14.1", + "ethereum_hashing", + "smallvec", +] + +[[package]] +name = "tree_hash_derive" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84303a9c7cda5f085a3ed9cd241d1e95e04d88aab1d679b02f212e653537ba86" +dependencies = [ + "darling 0.13.4", + "quote", + "syn 1.0.109", +] + [[package]] name = "trie-db" version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" dependencies = [ - "hash-db", + "hash-db 0.16.0", "hashbrown 0.13.2", "log", "rustc-hex", @@ -10437,7 +14742,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff28e0f815c2fea41ebddf148e008b077d2faddb026c9555b29696114d602642" dependencies = [ - "hash-db", + "hash-db 0.16.0", "hashbrown 0.13.2", "log", "rustc-hex", @@ -10450,7 +14755,17 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" dependencies = [ - "hash-db", + "hash-db 0.16.0", +] + +[[package]] +name = "triehash" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1631b201eb031b563d2e85ca18ec8092508e262a3196ce9bd10a67ec87b9f5c" +dependencies = [ + "hash-db 0.15.2", + "rlp", ] [[package]] @@ -10515,12 +14830,52 @@ checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" name = "twox-hash" version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "digest 0.10.7", + "rand 0.4.6", + "static_assertions", +] + +[[package]] +name = "typed-builder" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34085c17941e36627a879208083e25d357243812c30e7d7387c3b954f30ade16" +dependencies = [ + "typed-builder-macro 0.16.2", +] + +[[package]] +name = "typed-builder" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "444d8748011b93cb168770e8092458cb0f8854f931ff82fdf6ddfbd72a9c933e" +dependencies = [ + "typed-builder-macro 0.18.1", +] + +[[package]] +name = "typed-builder-macro" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f03ca4cb38206e2bef0700092660bb74d696f808514dae47fa1467cbfe26e96e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "typed-builder-macro" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "563b3b88238ec95680aef36bdece66896eaa7ce3c0f1b4f39d38fb2435261352" dependencies = [ - "cfg-if", - "digest 0.10.7", - "rand 0.8.5", - "static_assertions", + "proc-macro2", + "quote", + "syn 2.0.48", ] [[package]] @@ -10529,6 +14884,55 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "types" +version = "0.2.1" +source = "git+https://github.com/webb-tools/lighthouse.git?rev=ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8#ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" +dependencies = [ + "arbitrary", + "bls", + "cached_tree_hash", + "compare_fields", + "compare_fields_derive", + "derivative", + "eth2_interop_keypairs", + "ethereum-types 0.14.1", + "ethereum_hashing", + "ethereum_serde_utils", + "ethereum_ssz", + "ethereum_ssz_derive", + "hex", + "int_to_bytes", + "itertools 0.10.5", + "lazy_static", + "log", + "maplit", + "merkle_proof", + "metastruct", + "parking_lot 0.12.1", + "rand 0.8.5", + "rand_xorshift 0.3.0", + "rayon", + "regex", + "rusqlite", + "safe_arith", + "serde", + "serde_derive", + "serde_json", + "serde_with 1.14.0", + "serde_yaml", + "slog", + "smallvec", + "ssz_types", + "strum 0.24.1", + "superstruct", + "swap_or_not_shuffle", + "tempfile", + "test_random_derive", + "tree_hash", + "tree_hash_derive", +] + [[package]] name = "udigest" version = "0.1.0" @@ -10556,6 +14960,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ + "arbitrary", "byteorder", "crunchy", "hex", @@ -10591,9 +14996,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -10652,6 +15057,22 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom 0.2.12", + "serde", +] + [[package]] name = "uuid" version = "1.7.0" @@ -10762,9 +15183,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -10772,9 +15193,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -10787,9 +15208,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -10799,9 +15220,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -10809,9 +15230,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -10822,9 +15243,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-encoder" @@ -10844,6 +15265,46 @@ dependencies = [ "parity-wasm", ] +[[package]] +name = "wasm-opt" +version = "0.114.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "effbef3bd1dde18acb401f73e740a6f3d4a1bc651e9773bddc512fe4d8d68f67" +dependencies = [ + "anyhow", + "libc", + "strum 0.24.1", + "strum_macros 0.24.3", + "tempfile", + "thiserror", + "wasm-opt-cxx-sys", + "wasm-opt-sys", +] + +[[package]] +name = "wasm-opt-cxx-sys" +version = "0.114.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c09e24eb283919ace2ed5733bda4842a59ce4c8de110ef5c6d98859513d17047" +dependencies = [ + "anyhow", + "cxx", + "cxx-build", + "wasm-opt-sys", +] + +[[package]] +name = "wasm-opt-sys" +version = "0.114.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f2f817bed2e8d65eb779fa37317e74de15585751f903c9118342d1970703a4" +dependencies = [ + "anyhow", + "cc", + "cxx", + "cxx-build", +] + [[package]] name = "wasm-timer" version = "0.2.5" @@ -11365,14 +15826,256 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", ] +[[package]] +name = "webb" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f7957a32acb6a6415a8b8123418d57ab7d2be3379265f9ea8a407165101863a" +dependencies = [ + "async-trait", + "ethers", + "hex", + "parity-scale-codec 3.6.9", + "prettyplease 0.2.16", + "rand 0.8.5", + "scale-info", + "serde", + "serde_json", + "subxt 0.29.0", + "tempfile", + "thiserror", +] + +[[package]] +name = "webb-bls" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "ethereum-types 0.14.1", + "hex", + "log", + "milagro_bls", + "rand 0.7.3", + "rand_chacha 0.3.1", + "serde", + "webb-eth2-hashing", + "webb-eth2-serde-utils", + "webb-eth2-ssz", + "webb-tree-hash", + "zeroize", +] + +[[package]] +name = "webb-consensus-types" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "bitvec 1.0.1", + "derive_more", + "eth-types", + "ethereum-types 0.14.1", + "hex", + "parity-scale-codec 3.6.9", + "rlp", + "rlp-derive", + "scale-info", + "serde", + "tiny-keccak", + "webb-eth2-serde-utils", + "webb-eth2-ssz", + "webb-merkle-proof", + "webb-tree-hash", + "webb-tree-hash-derive", +] + +[[package]] +name = "webb-eth-rpc-client" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "anyhow", + "bitvec 1.0.1", + "dotenv", + "eth-types", + "ethereum-types 0.14.1", + "ethereum_hashing", + "ethereum_ssz", + "funty 2.0.0", + "hex", + "lazy_static", + "log", + "merkle_proof", + "reqwest", + "serde", + "serde_json", + "tokio", + "toml 0.5.11", + "tree_hash", + "types", + "webb-lc-relay-types", +] + +[[package]] +name = "webb-eth2-hashing" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "lazy_static", + "ring 0.16.20", + "sha2 0.10.8", +] + +[[package]] +name = "webb-eth2-pallet-init" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "anyhow", + "async-trait", + "clap 4.4.18", + "dotenvy", + "eth-types", + "log", + "reqwest", + "scale-info", + "serde", + "serde_json", + "sp-keyring 24.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subxt 0.29.0", + "tokio", + "toml 0.5.11", + "types", + "webb", + "webb-consensus-types", + "webb-eth-rpc-client", + "webb-merkle-proof", + "webb-proposals", + "webb-tree-hash", +] + +[[package]] +name = "webb-eth2-serde-utils" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "ethereum-types 0.14.1", + "hex", + "serde", + "serde_json", +] + +[[package]] +name = "webb-eth2-ssz" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "ethereum-types 0.14.1", + "itertools 0.10.5", + "smallvec", +] + +[[package]] +name = "webb-lc-relay-types" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "anyhow", + "backoff", + "reqwest", + "serde", + "serde_json", + "tokio", + "tracing", + "typed-builder 0.16.2", + "webb", +] + +[[package]] +name = "webb-light-client-primitives" +version = "0.1.0" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "eth-types", + "ethereum-types 0.14.1", + "frame-support", + "log", + "parity-scale-codec 3.6.9", + "scale-info", + "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "webb-proposals", +] + +[[package]] +name = "webb-merkle-proof" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "ethereum-types 0.14.1", + "lazy_static", + "webb-eth2-hashing", + "webb-safe-arith", +] + +[[package]] +name = "webb-proposal-derive" +version = "0.1.0" +source = "git+https://github.com/webb-tools/webb-rs.git#1f0d2635971b2d9c36af4bc0bd1501d0b2a1e675" +dependencies = [ + "ethers-core", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "webb-proposals" +version = "0.8.0" +source = "git+https://github.com/webb-tools/webb-rs.git#1f0d2635971b2d9c36af4bc0bd1501d0b2a1e675" +dependencies = [ + "frame-support", + "hex", + "num-traits", + "parity-scale-codec 3.6.9", + "scale-info", + "serde", + "thiserror", + "tiny-keccak", + "typed-builder 0.18.1", + "webb-proposal-derive", +] + +[[package]] +name = "webb-safe-arith" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" + +[[package]] +name = "webb-tree-hash" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "ethereum-types 0.14.1", + "smallvec", + "webb-eth2-hashing", +] + +[[package]] +name = "webb-tree-hash-derive" +version = "0.2.0-dev" +source = "git+https://github.com/webb-tools/pallet-eth2-light-client?tag=v0.5.0#0ac997902435ed0bebfd03fbb0dccc0473b8d621" +dependencies = [ + "darling 0.13.4", + "quote", + "syn 1.0.109", +] + [[package]] name = "webpki" version = "0.22.4" @@ -11392,6 +16095,12 @@ dependencies = [ "webpki", ] +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + [[package]] name = "which" version = "4.4.2" @@ -11457,7 +16166,7 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows-core 0.51.1", + "windows-core", "windows-targets 0.48.5", ] @@ -11470,15 +16179,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.0", -] - [[package]] name = "windows-sys" version = "0.33.0" @@ -11722,9 +16422,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.37" +version = "0.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" +checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" dependencies = [ "memchr", ] @@ -11739,6 +16439,25 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "ws_stream_wasm" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" +dependencies = [ + "async_io_stream", + "futures", + "js-sys", + "log", + "pharos", + "rustc_version 0.4.0", + "send_wrapper 0.6.0", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wyz" version = "0.2.0" @@ -11767,9 +16486,9 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ "curve25519-dalek 4.1.1", "rand_core 0.6.4", @@ -11795,6 +16514,15 @@ dependencies = [ "time", ] +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "yamux" version = "0.10.2" @@ -11809,6 +16537,18 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "yap" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2a7eb6d82a11e4d0b8e6bda8347169aff4ccd8235d039bba7c47482d977dcf7" + [[package]] name = "yap" version = "0.11.0" @@ -11834,23 +16574,22 @@ dependencies = [ "curv-kzen", "digest 0.10.7", "frame-support", - "frost-core", - "frost-ed25519", - "frost-ed448", - "frost-p256", - "frost-p384", - "frost-redjubjub", + "frost-core 1.0.0-rc.0", + "frost-ed25519 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-ed448 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-p256 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-p384 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", "frost-rerandomized", - "frost-ristretto255", - "frost-secp256k1", + "frost-ristretto255 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-secp256k1 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", "futures", "gadget-common", "gadget-core", "hex", "itertools 0.12.1", "log", - "pallet-jobs", - "pallet-jobs-rpc-runtime-api", + "pallet-jobs 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", "parity-scale-codec 3.6.9", "protocol-macros", "rand 0.8.5", @@ -11861,11 +16600,11 @@ dependencies = [ "serde", "sha2 0.10.8", "sp-api", - "sp-application-crypto 23.0.0", - "sp-core 21.0.0", - "sp-io 23.0.0", - "sp-runtime 24.0.0", - "tangle-primitives", + "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", "test-utils", "thiserror", "tokio", @@ -11955,7 +16694,7 @@ dependencies = [ "groth16", "log", "mpc-net", - "pallet-jobs-rpc-runtime-api", + "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", "parking_lot 0.12.1", "protocol-macros", "rayon", @@ -11965,9 +16704,9 @@ dependencies = [ "serde", "serde_bytes", "sp-api", - "sp-core 21.0.0", - "sp-runtime 24.0.0", - "tangle-primitives", + "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", + "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", "test-utils", "tokio", "tokio-rustls", diff --git a/Cargo.toml b/Cargo.toml index d82b36ebb..f252c9061 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,8 +29,8 @@ pallet-jobs = { git = "https://github.com/webb-tools/tangle" } pallet-dkg = { git = "https://github.com/webb-tools/tangle" } pallet-zksaas = { git = "https://github.com/webb-tools/tangle" } tangle-primitives = { git = "https://github.com/webb-tools/tangle" } -tangle-testnet-runtime = { git = "https://github.com/webb-tools/tangle" } -tangle-mainnet-runtime = { git = "https://github.com/webb-tools/tangle" } +tangle-testnet-runtime = { path = "../tangle/runtime/testnet" } +tangle-mainnet-runtime = { package = "tangle-runtime", path = "../tangle/runtime/mainnet" } multi-party-ecdsa = { git = "https://github.com/webb-tools/cggmp-threshold-ecdsa/" } round-based = { git = "https://github.com/webb-tools/round-based-protocol", features = [] } @@ -42,7 +42,6 @@ frost-ed25519 = { git = "https://github.com/LIT-Protocol/frost.git" } frost-ed448 = { git = "https://github.com/LIT-Protocol/frost.git" } frost-p256 = { git = "https://github.com/LIT-Protocol/frost.git" } frost-p384 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-redjubjub = { git = "https://github.com/LIT-Protocol/frost.git" } frost-ristretto255 = { git = "https://github.com/LIT-Protocol/frost.git" } frost-secp256k1 = { git = "https://github.com/LIT-Protocol/frost.git" } frost-rerandomized = { git = "https://github.com/LIT-Protocol/frost.git" } diff --git a/gadget-common/Cargo.toml b/gadget-common/Cargo.toml index 3374974c0..71a34f91e 100644 --- a/gadget-common/Cargo.toml +++ b/gadget-common/Cargo.toml @@ -3,19 +3,6 @@ name = "gadget-common" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[features] -default = [ - "std" -] - -std = [ - "sp-api/std", - "tangle-primitives/std", - "pallet-jobs-rpc-runtime-api/std" -] - [dependencies] gadget-core = { workspace = true, features = ["substrate"] } tokio = { workspace = true } @@ -42,4 +29,20 @@ sc-network-common = { workspace = true } sc-network-sync = { workspace = true } tangle-primitives = { workspace = true } -pallet-jobs-rpc-runtime-api = { workspace = true } \ No newline at end of file +pallet-jobs-rpc-runtime-api = { workspace = true } + +tangle-mainnet-runtime = { workspace = true, optional = true } +tangle-testnet-runtime = { workspace = true, optional = true } + +[features] +default = [ + "std", + "mainnet", +] +std = [ + "sp-api/std", + "tangle-primitives/std", + "pallet-jobs-rpc-runtime-api/std" +] +mainnet = ["tangle-mainnet-runtime"] +testnet = ["tangle-testnet-runtime"] \ No newline at end of file diff --git a/gadget-common/src/client.rs b/gadget-common/src/client.rs index 22ed2d188..ed1477e0a 100644 --- a/gadget-common/src/client.rs +++ b/gadget-common/src/client.rs @@ -1,4 +1,5 @@ use crate::debug_logger::DebugLogger; +use crate::jobs_api_config::*; use crate::keystore::{ECDSAKeyStore, KeystoreBackend}; use async_trait::async_trait; use auto_impl::auto_impl; @@ -44,7 +45,16 @@ pub async fn create_client, C: ClientWithApi>( pallet_tx: Arc, ) -> Result, crate::Error> where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { Ok(JobsClient { client, @@ -61,7 +71,16 @@ pub trait ClientWithApi: where B: Block, BE: Backend, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { } @@ -70,14 +89,32 @@ where B: Block, BE: Backend, T: BlockchainEvents + ProvideRuntimeApi + Send + Sync + Client + Clone + 'static, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { } impl, C: ClientWithApi> ProvideRuntimeApi for JobsClient where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type Api = C::Api; @@ -88,7 +125,16 @@ where impl, C: ClientWithApi> BlockchainEvents for JobsClient where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { fn import_notification_stream(&self) -> ImportNotifications { self.client.import_notification_stream() @@ -114,13 +160,25 @@ where impl, C: ClientWithApi> JobsClient where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { pub async fn query_jobs_by_validator( &self, at: ::Hash, validator: AccountId, - ) -> Result>>, crate::Error> { + ) -> Result< + Vec, MaxParticipants, MaxSubmissionLen>>, + crate::Error, + > { exec_client_function(&self.client, move |client| { client.runtime_api().query_jobs_by_validator(at, validator) }) @@ -136,7 +194,10 @@ where at: ::Hash, role_type: RoleType, job_id: JobId, - ) -> Result>>, crate::Error> { + ) -> Result< + Option, MaxParticipants, MaxSubmissionLen>>, + crate::Error, + > { exec_client_function(&self.client, move |client| { client.runtime_api().query_job_by_id(at, role_type, job_id) }) @@ -151,7 +212,21 @@ where at: ::Hash, role_type: RoleType, job_id: JobId, - ) -> Result>>, crate::Error> { + ) -> Result< + Option< + PhaseResult< + AccountId, + BlockNumberOf, + MaxParticipants, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxSubmissionLen, + MaxProofLen, + >, + >, + crate::Error, + > { exec_client_function(&self.client, move |client| { client.runtime_api().query_job_result(at, role_type, job_id) }) @@ -165,7 +240,7 @@ where &self, role_type: RoleType, job_id: JobId, - result: JobResult, + result: JobResult, ) -> Result<(), crate::Error> { self.pallet_tx .submit_job_result(role_type, job_id, result) @@ -179,7 +254,16 @@ where B: Block, BE: Backend, C: ClientWithApi, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { async fn get_next_finality_notification(&self) -> Option> { self.client.get_next_finality_notification().await @@ -201,7 +285,7 @@ pub trait PalletSubmitter: Send + Sync + 'static { &self, role_type: RoleType, job_id: JobId, - result: JobResult, + result: JobResult, ) -> Result<(), crate::Error>; } @@ -216,7 +300,7 @@ impl PalletSubmitter for SubxtPalletSubmitter { &self, role_type: RoleType, job_id: JobId, - result: JobResult, + result: JobResult, ) -> Result<(), crate::Error> { let tx = tangle::tx().jobs().submit_job_result( Decode::decode(&mut role_type.encode().as_slice()).expect("Should decode"), diff --git a/gadget-common/src/config.rs b/gadget-common/src/config.rs index 3b10f5055..176148eaa 100644 --- a/gadget-common/src/config.rs +++ b/gadget-common/src/config.rs @@ -3,6 +3,9 @@ pub use crate::client::{AccountId, ClientWithApi}; pub use crate::debug_logger::DebugLogger; pub use crate::gadget::network::Network; pub use crate::gadget::GadgetProtocol; +use crate::jobs_api_config::{ + MaxDataLen, MaxKeyLen, MaxParticipants, MaxProofLen, MaxSignatureLen, MaxSubmissionLen, +}; use async_trait::async_trait; pub use pallet_jobs_rpc_runtime_api::JobsApi; pub use sc_client_api::Backend; @@ -13,7 +16,18 @@ use std::sync::Arc; #[async_trait] pub trait ProtocolConfig where - <::Client as ProvideRuntimeApi<::Block>>::Api: JobsApi<::Block, AccountId>, + <::Client as ProvideRuntimeApi< + ::Block + >>::Api: JobsApi< + ::Block, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, Self: Sized, { type Network: Network; @@ -71,6 +85,12 @@ where >>::Api: pallet_jobs_rpc_runtime_api::JobsApi< ::Block, sp_core::ecdsa::Public, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, >, { type Network; diff --git a/gadget-common/src/gadget/mod.rs b/gadget-common/src/gadget/mod.rs index 1e5461c26..25e712f42 100644 --- a/gadget-common/src/gadget/mod.rs +++ b/gadget-common/src/gadget/mod.rs @@ -2,6 +2,7 @@ use crate::client::{AccountId, ClientWithApi, JobsClient}; use crate::debug_logger::DebugLogger; use crate::gadget::message::GadgetProtocolMessage; use crate::gadget::work_manager::WorkManager; +use crate::jobs_api_config::*; use crate::protocol::{AsyncProtocol, AsyncProtocolRemote}; use crate::Error; use async_trait::async_trait; @@ -54,7 +55,16 @@ impl< BE: Backend, > Module where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { pub fn new(network: N, module: M, job_manager: ProtocolWorkManager) -> Self { let clock = job_manager.utility.clock.clone(); @@ -69,10 +79,10 @@ where } pub struct JobInitMetadata { - pub job_type: JobType, + pub job_type: JobType, pub role_type: RoleType, /// This value only exists if this is a stage2 job - pub phase1_job: Option>, + pub phase1_job: Option>, pub task_id: ::TaskID, pub retry_id: ::RetryID, pub job_id: JobId, @@ -89,7 +99,16 @@ impl< BE: Backend, > SubstrateGadgetModule for Module where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type Error = Error; type ProtocolMessage = GadgetProtocolMessage; @@ -266,7 +285,16 @@ pub type Job = (AsyncProtocolRemote, BuiltExecutableJobWrapper); pub trait GadgetProtocol, C: ClientWithApi>: AsyncProtocol + Send + Sync where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { /// Given an input of a valid and relevant job, return the parameters needed to start the async protocol /// Note: the parameters returned must be relevant to the `AsyncProtocol` implementation of this protocol @@ -305,11 +333,11 @@ where /// ## Example /// /// ```rust,ignore - /// fn phase_filter(&self, job: JobType) -> bool { + /// fn phase_filter(&self, job: JobType) -> bool { /// matches!(job, JobType::DKGTSSPhaseOne(_)) /// } /// ``` - fn phase_filter(&self, job: JobType) -> bool; + fn phase_filter(&self, job: JobType) -> bool; fn client(&self) -> &JobsClient; fn logger(&self) -> &DebugLogger; fn get_work_manager_config(&self) -> WorkManagerConfig { diff --git a/gadget-common/src/lib.rs b/gadget-common/src/lib.rs index 845b861bb..ef72575f2 100644 --- a/gadget-common/src/lib.rs +++ b/gadget-common/src/lib.rs @@ -29,6 +29,29 @@ pub mod locks; pub mod protocol; pub mod config; + +#[cfg(feature = "mainnet")] +pub mod jobs_api_config { + pub type MaxParticipants = tangle_mainnet_runtime::MaxParticipants; + pub type MaxSubmissionLen = tangle_mainnet_runtime::MaxSubmissionLen; + pub type MaxKeyLen = tangle_mainnet_runtime::MaxKeyLen; + pub type MaxDataLen = tangle_mainnet_runtime::MaxDataLen; + pub type MaxSignatureLen = tangle_mainnet_runtime::MaxSignatureLen; + pub type MaxProofLen = tangle_mainnet_runtime::MaxProofLen; +} + +#[cfg(feature = "testnet")] +pub mod jobs_api_config { + pub type MaxParticipants = tangle_testnet_runtime::MaxParticipants; + pub type MaxSubmissionLen = tangle_testnet_runtime::MaxSubmissionLen; + pub type MaxKeyLen = tangle_testnet_runtime::MaxKeyLen; + pub type MaxDataLen = tangle_testnet_runtime::MaxDataLen; + pub type MaxSignatureLen = tangle_testnet_runtime::MaxSignatureLen; + pub type MaxProofLen = tangle_testnet_runtime::MaxProofLen; +} + +use jobs_api_config::*; + #[derive(Debug)] pub enum Error { RegistryCreateError { err: String }, @@ -68,8 +91,16 @@ pub async fn run_protocol(mut protocol_config: T) -> Result<( where <::Client as ProvideRuntimeApi< ::Block, - >>::Api: - JobsApi<::Block, AccountId>, + >>::Api: JobsApi< + ::Block, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { let client = protocol_config.take_client(); let network = protocol_config.take_network(); @@ -113,7 +144,16 @@ pub async fn create_work_manager< protocol: &P, ) -> Result, Error> where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { let now: u64 = (*latest_finality_notification.header.number()).saturated_into(); diff --git a/protocols/dfns-cggmp21/src/lib.rs b/protocols/dfns-cggmp21/src/lib.rs index 0d1868c2e..50f650ce6 100644 --- a/protocols/dfns-cggmp21/src/lib.rs +++ b/protocols/dfns-cggmp21/src/lib.rs @@ -32,7 +32,7 @@ macro_rules! decl_porto { KBE: KeystoreBackend, C: ClientWithApi, > where - >::Api: JobsApi, + >::Api: JobsApi, { pub account_id: AccountId, pub network: N, @@ -47,7 +47,7 @@ macro_rules! decl_porto { impl, KBE: KeystoreBackend, C: ClientWithApi> NetworkAndProtocolSetup for $name where - >::Api: JobsApi, + >::Api: JobsApi, { type Network = N; type Protocol = $proto; @@ -116,7 +116,16 @@ where KBE: KeystoreBackend, N: Network, Tx: PalletSubmitter, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { let pallet_tx = Arc::new(pallet_tx) as Arc; let keygen_config = DfnsCGGMP21KeygenProtocolConfig { diff --git a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs index c3bc32c6f..7177e7fc2 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs @@ -20,7 +20,7 @@ use sp_application_crypto::sp_core::keccak_256; use std::collections::HashMap; use std::sync::Arc; use tangle_primitives::jobs::{ - DKGTSSKeyRefreshResult, DigitalSignatureType, JobId, JobResult, JobType, + DKGTSSKeyRefreshResult, DigitalSignatureScheme, JobId, JobResult, JobType, }; use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; @@ -46,7 +46,16 @@ where C: ClientWithApi, KBE: KeystoreBackend, N: Network, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { DfnsCGGMP21KeyRefreshProtocol { client, @@ -66,7 +75,16 @@ impl< N: Network, > GadgetProtocol for DfnsCGGMP21KeyRefreshProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { fn name(&self) -> String { "dfns-cggmp21-key-refresh".to_string() @@ -159,7 +177,7 @@ where ) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: JobType) -> bool { matches!(job, JobType::DKGTSSPhaseThree(_)) } @@ -198,7 +216,16 @@ impl< N: Network, > AsyncProtocol for DfnsCGGMP21KeyRefreshProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type AdditionalParams = DfnsCGGMP21KeyRefreshExtraParams; async fn generate_protocol_from( @@ -279,7 +306,7 @@ where logger.debug("Finished AsyncProtocol - KeyRefresh"); let job_result = JobResult::DKGPhaseThree(DKGTSSKeyRefreshResult { - signature_type: DigitalSignatureType::Ecdsa, + signature_scheme: DigitalSignatureScheme::Ecdsa, }); *protocol_output.lock().await = Some((key, job_result)); Ok(()) diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index e37539ede..54bf92ad7 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -20,7 +20,7 @@ use sp_core::keccak_256; use std::collections::HashMap; use std::sync::Arc; use tangle_primitives::jobs::{ - DKGTSSKeyRotationResult, DigitalSignatureType, JobId, JobResult, JobType, + DKGTSSKeyRotationResult, DigitalSignatureScheme, JobId, JobResult, JobType, }; use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; @@ -46,7 +46,16 @@ where C: ClientWithApi, KBE: KeystoreBackend, N: Network, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { DfnsCGGMP21KeyRotateProtocol { client, @@ -66,7 +75,16 @@ impl< N: Network, > GadgetProtocol for DfnsCGGMP21KeyRotateProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { fn name(&self) -> String { "dfns-cggmp21-key-rotate".to_string() @@ -167,7 +185,7 @@ where ) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: JobType) -> bool { matches!(job, JobType::DKGTSSPhaseFour(_)) } @@ -210,7 +228,16 @@ impl< N: Network, > AsyncProtocol for DfnsCGGMP21KeyRotateProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type AdditionalParams = DfnsCGGMP21KeyRotateExtraParams; async fn generate_protocol_from( @@ -335,7 +362,7 @@ where signature_bytes[64] = v + 27; let job_result = JobResult::DKGPhaseFour(DKGTSSKeyRotationResult { - signature_type: DigitalSignatureType::Ecdsa, + signature_scheme: DigitalSignatureScheme::Ecdsa, signature: signature_bytes.to_vec(), phase_one_id, new_phase_one_id, diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 40606531c..b7fd29bfd 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -23,7 +23,7 @@ use sp_core::{ecdsa, Pair}; use std::collections::{BTreeMap, HashMap}; use std::sync::Arc; use tangle_primitives::jobs::{ - DKGTSSKeySubmissionResult, DigitalSignatureType, JobId, JobResult, JobType, + DKGTSSKeySubmissionResult, DigitalSignatureScheme, JobId, JobResult, JobType, }; use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; @@ -51,7 +51,16 @@ where C: ClientWithApi, KBE: KeystoreBackend, N: Network, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { DfnsCGGMP21KeygenProtocol { client, @@ -71,7 +80,16 @@ impl< N: Network, > GadgetProtocol for DfnsCGGMP21KeygenProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { fn name(&self) -> String { "dfns-cggmp21-keygen".to_string() @@ -143,7 +161,7 @@ where ) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: JobType) -> bool { matches!(job, JobType::DKGTSSPhaseOne(_)) } @@ -182,7 +200,16 @@ impl< N: Network, > AsyncProtocol for DfnsCGGMP21KeygenProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type AdditionalParams = DfnsCGGMP21KeygenExtraParams; async fn generate_protocol_from( @@ -447,10 +474,10 @@ async fn handle_public_key_gossip( } let res = DKGTSSKeySubmissionResult { - signature_type: DigitalSignatureType::Ecdsa, + signature_scheme: DigitalSignatureScheme::Ecdsa, key: serialized_public_key, participants, - signatures, + signatures: signatures.try_into().unwrap(), threshold: t as _, }; verify_generated_dkg_key_ecdsa(res.clone(), logger); diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index 2fa2e771b..edc4628e2 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -20,7 +20,7 @@ use sp_core::keccak_256; use std::collections::HashMap; use std::sync::Arc; use tangle_primitives::jobs::{ - DKGTSSSignatureResult, DigitalSignatureType, JobId, JobResult, JobType, + DKGTSSSignatureResult, DigitalSignatureScheme, JobId, JobResult, JobType, }; use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; @@ -46,7 +46,16 @@ where C: ClientWithApi, KBE: KeystoreBackend, N: Network, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { DfnsCGGMP21SigningProtocol { client, @@ -66,7 +75,16 @@ impl< N: Network, > GadgetProtocol for DfnsCGGMP21SigningProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { fn name(&self) -> String { "dfns-cggmp21-signing".to_string() @@ -147,7 +165,7 @@ where ) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: JobType) -> bool { matches!(job, JobType::DKGTSSPhaseTwo(_)) } @@ -188,7 +206,16 @@ impl< N: Network, > AsyncProtocol for DfnsCGGMP21SigningProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type AdditionalParams = DfnsCGGMP21SigningExtraParams; async fn generate_protocol_from( @@ -316,7 +343,7 @@ where signature_bytes[64] = v + 27; let job_result = JobResult::DKGPhaseTwo(DKGTSSSignatureResult { - signature_type: DigitalSignatureType::Ecdsa, + signature_scheme: DigitalSignatureScheme::Ecdsa, data: additional_params.input_data_to_sign, signature: signature_bytes.to_vec(), signing_key: public_key_bytes, diff --git a/protocols/mp-ecdsa/src/lib.rs b/protocols/mp-ecdsa/src/lib.rs index 47d4fd297..4ca6e8e7f 100644 --- a/protocols/mp-ecdsa/src/lib.rs +++ b/protocols/mp-ecdsa/src/lib.rs @@ -26,7 +26,16 @@ pub struct MpEcdsaKeygenProtocolConfig< KBE: KeystoreBackend, C: ClientWithApi, > where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { pub account_id: AccountId, pub network: N, @@ -45,7 +54,16 @@ pub struct MpEcdsaSigningProtocolConfig< KBE: KeystoreBackend, C: ClientWithApi, > where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { pub account_id: AccountId, pub network: N, @@ -60,7 +78,16 @@ pub struct MpEcdsaSigningProtocolConfig< impl, KBE: KeystoreBackend, C: ClientWithApi> NetworkAndProtocolSetup for MpEcdsaKeygenProtocolConfig where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type Network = N; type Protocol = MpEcdsaKeygenProtocol; @@ -101,7 +128,16 @@ where impl, KBE: KeystoreBackend, C: ClientWithApi> NetworkAndProtocolSetup for MpEcdsaSigningProtocolConfig where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type Network = N; type Protocol = MpEcdsaSigningProtocol; @@ -156,7 +192,16 @@ where N: Network, N2: Network, Tx: PalletSubmitter, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { let pallet_tx = Arc::new(pallet_tx) as Arc; let keygen_config = MpEcdsaKeygenProtocolConfig { diff --git a/protocols/mp-ecdsa/src/protocols/keygen.rs b/protocols/mp-ecdsa/src/protocols/keygen.rs index 28a712f52..0c52a88bb 100644 --- a/protocols/mp-ecdsa/src/protocols/keygen.rs +++ b/protocols/mp-ecdsa/src/protocols/keygen.rs @@ -26,12 +26,14 @@ use sp_core::{ecdsa, Pair}; use std::collections::{BTreeMap, HashMap}; use std::sync::Arc; use tangle_primitives::jobs::{ - DKGTSSKeySubmissionResult, DigitalSignatureType, JobId, JobResult, JobType, + DKGTSSKeySubmissionResult, DigitalSignatureScheme, JobId, JobResult, JobType, }; use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; use tokio::sync::RwLock; +use super::sign; + pub struct MpEcdsaKeygenProtocol { client: JobsClient, key_store: ECDSAKeyStore, @@ -61,7 +63,16 @@ where C: ClientWithApi, KBE: KeystoreBackend, N: Network, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { MpEcdsaKeygenProtocol { client, @@ -82,7 +93,16 @@ impl< N: Network, > GadgetProtocol for MpEcdsaKeygenProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { fn name(&self) -> String { "mp-ecdsa-keygen".to_string() @@ -158,7 +178,7 @@ where ) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: JobType) -> bool { matches!(job, JobType::DKGTSSPhaseOne(_)) } @@ -197,7 +217,16 @@ impl< N: Network, > AsyncProtocol for MpEcdsaKeygenProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type AdditionalParams = MpEcdsaKeygenExtraParams; async fn generate_protocol_from( @@ -429,10 +458,10 @@ async fn handle_public_key_gossip( } let res = DKGTSSKeySubmissionResult { - signature_type: DigitalSignatureType::Ecdsa, + signature_scheme: DigitalSignatureScheme::Ecdsa, key: serialized_public_key, participants, - signatures, + signatures: signatures.try_into().unwrap(), threshold: t as _, }; verify_generated_dkg_key_ecdsa(res.clone(), logger); diff --git a/protocols/mp-ecdsa/src/protocols/sign.rs b/protocols/mp-ecdsa/src/protocols/sign.rs index b1287de43..2fc42195c 100644 --- a/protocols/mp-ecdsa/src/protocols/sign.rs +++ b/protocols/mp-ecdsa/src/protocols/sign.rs @@ -30,7 +30,7 @@ use sp_core::ecdsa::Signature; use std::collections::HashMap; use std::sync::Arc; use tangle_primitives::jobs::{ - DKGTSSSignatureResult, DigitalSignatureType, JobId, JobResult, JobType, + DKGTSSSignatureResult, DigitalSignatureScheme, JobId, JobResult, JobType, }; use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; @@ -65,7 +65,16 @@ where C: ClientWithApi, KBE: KeystoreBackend, N: Network, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { MpEcdsaSigningProtocol { client, @@ -86,7 +95,16 @@ impl< N: Network, > GadgetProtocol for MpEcdsaSigningProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { fn name(&self) -> String { "mp-ecdsa-signing".to_string() @@ -176,7 +194,7 @@ where ) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: JobType) -> bool { matches!(job, JobType::DKGTSSPhaseTwo(_)) } @@ -217,7 +235,16 @@ impl< N: Network, > AsyncProtocol for MpEcdsaSigningProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type AdditionalParams = MpEcdsaSigningExtraParams; async fn generate_protocol_from( @@ -339,7 +366,7 @@ where let signature: Vec = signature.0.to_vec(); let job_result = JobResult::DKGPhaseTwo(DKGTSSSignatureResult { - signature_type: DigitalSignatureType::Ecdsa, + signature_scheme: DigitalSignatureScheme::Ecdsa, data: additional_params.input_data_to_sign, signature, signing_key: public_key_bytes, diff --git a/protocols/stub/README.md b/protocols/stub/README.md index eef9cb539..246f9ad26 100644 --- a/protocols/stub/README.md +++ b/protocols/stub/README.md @@ -14,7 +14,7 @@ protocol-macros = { workspace = true } #[protocol] pub struct StubConfig, C: ClientWithApi> where - >::Api: JobsApi, + >::Api: JobsApi, { pallet_tx: Arc, logger: DebugLogger, @@ -38,7 +38,7 @@ pub async fn run + 'static, C: ClientWithApi>( logger: DebugLogger, ) -> Result<(), Error> where - >::Api: JobsApi, + >::Api: JobsApi, { let config = StubConfig { pallet_tx, diff --git a/protocols/stub/src/lib.rs b/protocols/stub/src/lib.rs index 534d1d60a..c235da7cc 100644 --- a/protocols/stub/src/lib.rs +++ b/protocols/stub/src/lib.rs @@ -13,7 +13,16 @@ pub mod protocol; #[protocol] pub struct StubConfig, C: ClientWithApi> where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { pallet_tx: Arc, logger: DebugLogger, @@ -25,7 +34,16 @@ where impl, C: ClientWithApi> NetworkAndProtocolSetup for StubConfig where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type Network = StubNetworkService; type Protocol = StubProtocol; @@ -65,7 +83,16 @@ pub async fn run + 'static, C: ClientWithApi>( logger: DebugLogger, ) -> Result<(), Error> where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { let config = StubConfig { pallet_tx, diff --git a/protocols/stub/src/protocol.rs b/protocols/stub/src/protocol.rs index 7766ef1af..bf4172d3a 100644 --- a/protocols/stub/src/protocol.rs +++ b/protocols/stub/src/protocol.rs @@ -13,7 +13,16 @@ use tangle_primitives::roles::RoleType; pub struct StubProtocol, C: ClientWithApi> where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { pub jobs_client: JobsClient, pub account_id: AccountId, @@ -24,7 +33,16 @@ where impl, C: ClientWithApi> GadgetProtocol for StubProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { fn name(&self) -> String { "stub".to_string() @@ -55,7 +73,10 @@ where false } - fn phase_filter(&self, _job: tangle_primitives::jobs::JobType) -> bool { + fn phase_filter( + &self, + _job: tangle_primitives::jobs::JobType, + ) -> bool { false } @@ -71,7 +92,16 @@ where #[async_trait] impl, C: ClientWithApi> AsyncProtocol for StubProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type AdditionalParams = (); diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml index 58df5c15d..abbeb928f 100644 --- a/protocols/zcash-frost/Cargo.toml +++ b/protocols/zcash-frost/Cargo.toml @@ -28,7 +28,6 @@ frost-ed25519 = { workspace = true } frost-ed448 = { workspace = true } frost-p256 = { workspace = true } frost-p384 = { workspace = true } -frost-redjubjub = { workspace = true } frost-ristretto255 = { workspace = true } frost-secp256k1 = { workspace = true } frost-rerandomized = { workspace = true } diff --git a/protocols/zcash-frost/src/lib.rs b/protocols/zcash-frost/src/lib.rs index 58693e891..cf00c2449 100644 --- a/protocols/zcash-frost/src/lib.rs +++ b/protocols/zcash-frost/src/lib.rs @@ -25,7 +25,7 @@ macro_rules! decl_porto { KBE: KeystoreBackend, C: ClientWithApi, > where - >::Api: JobsApi, + >::Api: JobsApi, { pub account_id: AccountId, pub network: N, @@ -40,7 +40,7 @@ macro_rules! decl_porto { impl, KBE: KeystoreBackend, C: ClientWithApi> NetworkAndProtocolSetup for $name where - >::Api: JobsApi, + >::Api: JobsApi, { type Network = N; type Protocol = $proto; @@ -107,7 +107,16 @@ where KBE: KeystoreBackend, N: Network, Tx: PalletSubmitter, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { let pallet_tx = Arc::new(pallet_tx) as Arc; let keygen_config = ZcashFrostKeygenConfig { diff --git a/protocols/zcash-frost/src/protocol.rs b/protocols/zcash-frost/src/protocol.rs index ecf09b5a0..dcd3a7408 100644 --- a/protocols/zcash-frost/src/protocol.rs +++ b/protocols/zcash-frost/src/protocol.rs @@ -18,7 +18,7 @@ use tangle_primitives::roles::RoleType; pub struct ZcashFrostProtocol, C: ClientWithApi> where - >::Api: JobsApi, + >::Api: JobsApi, { pub jobs_client: JobsClient, pub account_id: AccountId, @@ -40,7 +40,7 @@ pub struct ZcashFrostKeygenExtraParams { impl, C: ClientWithApi> GadgetProtocol for ZcashFrostProtocol where - >::Api: JobsApi, + >::Api: JobsApi, { async fn create_next_job( &self, @@ -120,7 +120,7 @@ where #[async_trait] impl, C: ClientWithApi> AsyncProtocol for ZcashFrostProtocol where - >::Api: JobsApi, + >::Api: JobsApi, { type AdditionalParams = ZcashFrostKeygenExtraParams; diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index 05c66fb4f..e063ab4e2 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -25,7 +25,7 @@ use sp_core::{ecdsa, Pair}; use std::collections::{BTreeMap, HashMap}; use std::sync::Arc; use tangle_primitives::jobs::{ - DKGTSSKeySubmissionResult, DigitalSignatureType, JobId, JobResult, JobType, + DKGTSSKeySubmissionResult, DigitalSignatureScheme, JobId, JobResult, JobType, }; use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; @@ -55,7 +55,16 @@ where C: ClientWithApi, KBE: KeystoreBackend, N: Network, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { ZcashFrostKeygenProtocol { client, @@ -75,7 +84,16 @@ impl< N: Network, > GadgetProtocol for ZcashFrostKeygenProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { fn name(&self) -> String { "zcash-frost-keygen".to_string() @@ -151,7 +169,7 @@ where ) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: JobType) -> bool { matches!(job, JobType::DKGTSSPhaseOne(_)) } @@ -208,7 +226,16 @@ impl< N: Network, > AsyncProtocol for ZcashFrostKeygenProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type AdditionalParams = ZcashFrostKeygenExtraParams; async fn generate_protocol_from( @@ -470,14 +497,14 @@ async fn handle_public_key_gossip( } let res = DKGTSSKeySubmissionResult { - signature_type: match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 => DigitalSignatureType::SchnorrEd25519, - ThresholdSignatureRoleType::ZcashFrostP256 => DigitalSignatureType::SchnorrP256, + signature_scheme: match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 => DigitalSignatureScheme::SchnorrEd25519, + ThresholdSignatureRoleType::ZcashFrostP256 => DigitalSignatureScheme::SchnorrP256, ThresholdSignatureRoleType::ZcashFrostRistretto255 => { - DigitalSignatureType::SchnorrSr25519 + DigitalSignatureScheme::SchnorrSr25519 } ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { - DigitalSignatureType::SchnorrSecp256k1 + DigitalSignatureScheme::SchnorrSecp256k1 } _ => unreachable!("Invalid role"), }, diff --git a/protocols/zcash-frost/src/protocols/sign.rs b/protocols/zcash-frost/src/protocols/sign.rs index 346a449e3..b2d5d1c59 100644 --- a/protocols/zcash-frost/src/protocols/sign.rs +++ b/protocols/zcash-frost/src/protocols/sign.rs @@ -24,7 +24,7 @@ use sp_core::keccak_256; use std::collections::HashMap; use std::sync::Arc; use tangle_primitives::jobs::{ - DKGTSSSignatureResult, DigitalSignatureType, JobId, JobResult, JobType, + DKGTSSSignatureResult, DigitalSignatureScheme, JobId, JobResult, JobType, }; use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; @@ -53,7 +53,16 @@ where C: ClientWithApi, KBE: KeystoreBackend, N: Network, - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { ZcashFrostSigningProtocol { client, @@ -73,7 +82,16 @@ impl< N: Network, > GadgetProtocol for ZcashFrostSigningProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { fn name(&self) -> String { "zcash-frost-signing".to_string() @@ -157,7 +175,7 @@ where ) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: JobType) -> bool { matches!(job, JobType::DKGTSSPhaseTwo(_)) } @@ -230,7 +248,16 @@ impl< N: Network, > AsyncProtocol for ZcashFrostSigningProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type AdditionalParams = ZcashFrostSigningExtraParams; async fn generate_protocol_from( @@ -379,7 +406,7 @@ where signature_bytes.copy_from_slice(&signature.group_signature); ( signature_bytes.to_vec(), - DigitalSignatureType::SchnorrSecp256k1, + DigitalSignatureScheme::SchnorrSecp256k1, ) } ThresholdSignatureRoleType::ZcashFrostEd25519 => { @@ -387,20 +414,23 @@ where signature_bytes.copy_from_slice(&signature.group_signature); ( signature_bytes.to_vec(), - DigitalSignatureType::SchnorrEd25519, + DigitalSignatureScheme::SchnorrEd25519, ) } ThresholdSignatureRoleType::ZcashFrostP256 => { let mut signature_bytes = [0u8; 64]; signature_bytes.copy_from_slice(&signature.group_signature); - (signature_bytes.to_vec(), DigitalSignatureType::SchnorrP256) + ( + signature_bytes.to_vec(), + DigitalSignatureScheme::SchnorrP256, + ) } ThresholdSignatureRoleType::ZcashFrostRistretto255 => { let mut signature_bytes = [0u8; 64]; signature_bytes.copy_from_slice(&signature.group_signature); ( signature_bytes.to_vec(), - DigitalSignatureType::SchnorrSr25519, + DigitalSignatureScheme::SchnorrSr25519, ) } _ => { diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index 96a015309..3be817228 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -3,7 +3,6 @@ use frost_ed25519::Ed25519Sha512; use frost_ed448::Ed448Shake256; use frost_p256::P256Sha256; use frost_p384::P384Sha384; -// use frost_redjubjub::JubjubBlake2b512; use frost_ristretto255::Ristretto255Sha512; use frost_secp256k1::Secp256K1Sha256; use thiserror::Error; @@ -41,7 +40,6 @@ impl_keygen_error_from!(P384Sha384); impl_keygen_error_from!(Ristretto255Sha512); impl_keygen_error_from!(Secp256K1Sha256); impl_keygen_error_from!(Ed448Shake256); -// impl_keygen_error_from!(JubjubBlake2b512); /// Sign protocol error #[derive(Debug, Error)] @@ -70,7 +68,6 @@ impl_sign_error_from!(P384Sha384); impl_sign_error_from!(Ristretto255Sha512); impl_sign_error_from!(Secp256K1Sha256); impl_sign_error_from!(Ed448Shake256); -// impl_sign_error_from!(JubjubBlake2b512); /// Repair protocol error #[derive(Debug, Error)] @@ -93,7 +90,6 @@ impl_repair_error_from!(P384Sha384); impl_repair_error_from!(Ristretto255Sha512); impl_repair_error_from!(Secp256K1Sha256); impl_repair_error_from!(Ed448Shake256); -// impl_repair_error_from!(JubjubBlake2b512); #[derive(Debug, Error)] enum Reason { diff --git a/protocols/zk-saas/src/lib.rs b/protocols/zk-saas/src/lib.rs index 612ffd9d2..659e76f40 100644 --- a/protocols/zk-saas/src/lib.rs +++ b/protocols/zk-saas/src/lib.rs @@ -21,7 +21,16 @@ pub mod protocol; #[protocol] pub struct ZkGadgetConfig, BE: Backend> where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { pub king_bind_addr: Option, pub client_only_king_addr: Option, @@ -39,7 +48,16 @@ where impl, BE: Backend> NetworkAndProtocolSetup for ZkGadgetConfig where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type Network = ZkNetworkService; type Protocol = ZkProtocol; @@ -79,7 +97,16 @@ pub async fn create_zk_network, BE: Backend config: &ZkGadgetConfig, ) -> Result where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { let our_identity = RustlsCertificate { cert: Certificate(config.public_identity_der.clone()), diff --git a/protocols/zk-saas/src/protocol/mod.rs b/protocols/zk-saas/src/protocol/mod.rs index de0c4f7f5..3a10fc3c2 100644 --- a/protocols/zk-saas/src/protocol/mod.rs +++ b/protocols/zk-saas/src/protocol/mod.rs @@ -56,7 +56,16 @@ pub trait AdditionalProtocolParams: Send + Sync + Clone + 'static { #[async_trait] impl GadgetProtocol for ZkProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, B: Block, C: ClientWithApi + 'static, BE: Backend + 'static, @@ -119,7 +128,7 @@ where matches!(role, RoleType::ZkSaaS(ZeroKnowledgeRoleType::ZkSaaSGroth16)) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: JobType) -> bool { matches!(job, JobType::ZkSaaSPhaseTwo(_)) } @@ -164,7 +173,16 @@ impl AdditionalProtocolParams for ZkJobAdditionalParams { impl + 'static, BE: Backend + 'static> AsyncProtocol for ZkProtocol where - >::Api: JobsApi, + >::Api: JobsApi< + B, + AccountId, + MaxParticipants, + MaxSubmissionLen, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxProofLen, + >, { type AdditionalParams = ZkJobAdditionalParams; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 24f0d828a..516c9f1d5 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "stable" +channel = "nightly" components = ["rustfmt", "clippy", "rust-src"] targets = [] diff --git a/test-utils/src/lib.rs b/test-utils/src/lib.rs index 48929ac18..6080c329b 100644 --- a/test-utils/src/lib.rs +++ b/test-utils/src/lib.rs @@ -1,6 +1,7 @@ use crate::mock::{Jobs, Runtime}; use crate::sync::substrate_test_channel::MultiThreadedTestExternalities; use gadget_common::client::AccountId; +use gadget_common::jobs_api_config::*; use pallet_jobs::{SubmittedJobs, SubmittedJobsRole}; use std::time::Duration; use tangle_primitives::jobs::{JobId, PhaseResult}; @@ -29,7 +30,16 @@ pub async fn wait_for_job_completion( ext: &MultiThreadedTestExternalities, role_type: RoleType, job_id: JobId, -) -> PhaseResult { +) -> PhaseResult< + AccountId, + u64, + MaxParticipants, + MaxKeyLen, + MaxDataLen, + MaxSignatureLen, + MaxSubmissionLen, + MaxProofLen, +> { loop { tokio::time::sleep(Duration::from_millis(100)).await; if let Some(ret) = ext diff --git a/test-utils/src/mock.rs b/test-utils/src/mock.rs index 692bdf2f8..033c36911 100644 --- a/test-utils/src/mock.rs +++ b/test-utils/src/mock.rs @@ -23,6 +23,7 @@ use frame_support::{ }; use frame_system::EnsureSigned; use gadget_common::client::AccountId; +use gadget_common::jobs_api_config::*; use pallet_jobs_rpc_runtime_api::BlockNumberOf; use sc_client_api::{FinalityNotification, FinalizeSummary}; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender}; @@ -235,7 +236,7 @@ sp_api::mock_impl_runtime_apis! { &self, role_type: RoleType, job_id: JobId, - ) -> Option>> { + ) -> Option, MaxParticipants, MaxKeyLen, MaxDataLen, MaxSignatureLen, MaxSubmissionLen, MaxProofLen>> { TEST_EXTERNALITIES.lock().as_ref().unwrap().execute_with(move || { Jobs::query_job_result(role_type, job_id) }) From cf1b7fc83c9f0da1c87a3cc0c2d25914642356f7 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 8 Feb 2024 00:31:27 +0200 Subject: [PATCH 15/66] fix: git link --- Cargo.lock | 334 +++++++++++++---------------------------------------- Cargo.toml | 4 +- 2 files changed, 83 insertions(+), 255 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 740506f4d..fc7f2cfdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1070,7 +1070,7 @@ checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" dependencies = [ "bitcoin_hashes", "rand 0.6.5", - "rand_core 0.4.2", + "rand_core 0.6.4", "serde", "unicode-normalization", ] @@ -2639,8 +2639,8 @@ dependencies = [ "hex", "itertools 0.12.1", "log", - "pallet-jobs 0.6.1 (git+https://github.com/webb-tools/tangle)", - "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-jobs", + "pallet-jobs-rpc-runtime-api", "parity-scale-codec 3.6.9", "protocol-macros", "rand 0.8.5", @@ -2652,7 +2652,7 @@ dependencies = [ "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives", "test-utils", "tokio", ] @@ -3810,6 +3810,7 @@ dependencies = [ [[package]] name = "evm-tracer" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "ethereum-types 0.14.1", "evm", @@ -3829,6 +3830,7 @@ dependencies = [ [[package]] name = "evm-tracing-events" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "environmental", "ethereum", @@ -4473,21 +4475,7 @@ dependencies = [ [[package]] name = "frost-core" version = "0.6.1" -dependencies = [ - "debugless-unwrap", - "hex", - "parity-scale-codec 3.6.9", - "rand_core 0.6.4", - "serde", - "serdect", - "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "subtle", -] - -[[package]] -name = "frost-core" -version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "debugless-unwrap", "hex", @@ -4521,18 +4509,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "frost-ed25519" -version = "1.0.0-rc.0" -dependencies = [ - "curve25519-dalek 4.1.1", - "frost-core 0.6.1", - "parity-scale-codec 3.6.9", - "rand_core 0.6.4", - "sha2 0.10.8", - "subtle", -] - [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" @@ -4549,25 +4525,13 @@ dependencies = [ [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "curve25519-dalek 4.1.1", - "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", - "parity-scale-codec 3.6.9", - "rand_core 0.6.4", - "sha2 0.10.8", - "subtle", -] - -[[package]] -name = "frost-ed448" -version = "1.0.0-rc.0" -dependencies = [ - "ed448-goldilocks-plus 0.11.1 (git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize)", "frost-core 0.6.1", "parity-scale-codec 3.6.9", "rand_core 0.6.4", - "sha3 0.10.8", + "sha2 0.10.8", "subtle", ] @@ -4587,25 +4551,13 @@ dependencies = [ [[package]] name = "frost-ed448" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "ed448-goldilocks-plus 0.11.1 (git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize)", - "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", - "parity-scale-codec 3.6.9", - "rand_core 0.6.4", - "sha3 0.10.8", - "subtle", -] - -[[package]] -name = "frost-p256" -version = "1.0.0-rc.0" -dependencies = [ "frost-core 0.6.1", - "p256 0.13.2", "parity-scale-codec 3.6.9", "rand_core 0.6.4", - "sha2 0.10.8", + "sha3 0.10.8", "subtle", ] @@ -4625,22 +4577,10 @@ dependencies = [ [[package]] name = "frost-p256" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" -dependencies = [ - "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", - "p256 0.13.2", - "parity-scale-codec 3.6.9", - "rand_core 0.6.4", - "sha2 0.10.8", - "subtle", -] - -[[package]] -name = "frost-p384" -version = "1.0.0-rc.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "frost-core 0.6.1", - "p384", + "p256 0.13.2", "parity-scale-codec 3.6.9", "rand_core 0.6.4", "sha2 0.10.8", @@ -4663,9 +4603,9 @@ dependencies = [ [[package]] name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ - "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", + "frost-core 0.6.1", "p384", "parity-scale-codec 3.6.9", "rand_core 0.6.4", @@ -4684,18 +4624,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "frost-ristretto255" -version = "1.0.0-rc.0" -dependencies = [ - "curve25519-dalek 4.1.1", - "frost-core 0.6.1", - "parity-scale-codec 3.6.9", - "rand_core 0.6.4", - "sha2 0.10.8", - "subtle", -] - [[package]] name = "frost-ristretto255" version = "1.0.0-rc.0" @@ -4712,22 +4640,10 @@ dependencies = [ [[package]] name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "curve25519-dalek 4.1.1", - "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", - "parity-scale-codec 3.6.9", - "rand_core 0.6.4", - "sha2 0.10.8", - "subtle", -] - -[[package]] -name = "frost-secp256k1" -version = "1.0.0-rc.0" -dependencies = [ "frost-core 0.6.1", - "k256", "parity-scale-codec 3.6.9", "rand_core 0.6.4", "sha2 0.10.8", @@ -4750,9 +4666,9 @@ dependencies = [ [[package]] name = "frost-secp256k1" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ - "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", + "frost-core 0.6.1", "k256", "parity-scale-codec 3.6.9", "rand_core 0.6.4", @@ -4959,7 +4875,7 @@ dependencies = [ "hex", "linked-hash-map", "log", - "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-jobs-rpc-runtime-api", "parking_lot 0.12.1", "sc-client-api", "sc-network", @@ -4970,7 +4886,7 @@ dependencies = [ "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "subxt 0.33.0", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives", "tangle-runtime", "tangle-testnet-runtime", "tokio", @@ -7096,8 +7012,8 @@ dependencies = [ "itertools 0.12.1", "log", "multi-party-ecdsa", - "pallet-jobs 0.6.1 (git+https://github.com/webb-tools/tangle)", - "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-jobs", + "pallet-jobs-rpc-runtime-api", "parity-scale-codec 3.6.9", "protocol-macros", "round-based 0.1.7", @@ -7108,7 +7024,7 @@ dependencies = [ "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives", "test-utils", "tokio", ] @@ -7797,6 +7713,7 @@ dependencies = [ [[package]] name = "pallet-airdrop-claims" version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "frame-support", "frame-system", @@ -7980,39 +7897,12 @@ dependencies = [ [[package]] name = "pallet-dkg" version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "elliptic-curve 0.13.8", "frame-support", "frame-system", "frost-core 0.6.1", - "frost-ed25519 1.0.0-rc.0", - "frost-ed448 1.0.0-rc.0", - "frost-p256 1.0.0-rc.0", - "frost-p384 1.0.0-rc.0", - "frost-ristretto255 1.0.0-rc.0", - "frost-secp256k1 1.0.0-rc.0", - "parity-scale-codec 3.6.9", - "scale-info", - "serde", - "serdect", - "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "subtle", - "tangle-crypto-primitives 0.6.1", - "tangle-primitives 0.6.1", -] - -[[package]] -name = "pallet-dkg" -version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" -dependencies = [ - "elliptic-curve 0.13.8", - "frame-support", - "frame-system", - "frost-core 0.6.1 (git+https://github.com/webb-tools/tangle)", "frost-ed25519 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle)", "frost-ed448 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle)", "frost-p256 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle)", @@ -8028,8 +7918,8 @@ dependencies = [ "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "subtle", - "tangle-crypto-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-crypto-primitives", + "tangle-primitives", ] [[package]] @@ -8208,6 +8098,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-batch" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "evm", "evm-runtime", @@ -8247,6 +8138,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-call-permit" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "evm", "fp-evm", @@ -8277,6 +8169,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-democracy" version = "0.2.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "fp-evm", "frame-support", @@ -8318,6 +8211,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-jobs" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "fp-evm", "frame-support", @@ -8325,14 +8219,14 @@ dependencies = [ "log", "num_enum 0.5.11", "pallet-evm", - "pallet-jobs 0.6.1", + "pallet-jobs", "parity-scale-codec 3.6.9", "precompile-utils", "rustc-hex", "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1", + "tangle-primitives", ] [[package]] @@ -8347,6 +8241,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-preimage" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "fp-evm", "frame-support", @@ -8366,6 +8261,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-proxy" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "evm", "fp-evm", @@ -8387,6 +8283,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-registry" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "fp-evm", "frame-support", @@ -8422,6 +8319,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-staking" version = "1.0.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "fp-evm", "frame-support", @@ -8437,12 +8335,13 @@ dependencies = [ "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1", + "tangle-primitives", ] [[package]] name = "pallet-evm-precompile-vesting" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "evm", "fp-evm", @@ -8459,7 +8358,7 @@ dependencies = [ "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1", + "tangle-primitives", ] [[package]] @@ -8571,6 +8470,7 @@ dependencies = [ [[package]] name = "pallet-jobs" version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "frame-benchmarking", "frame-support", @@ -8580,48 +8480,20 @@ dependencies = [ "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-crypto-primitives 0.6.1", - "tangle-primitives 0.6.1", -] - -[[package]] -name = "pallet-jobs" -version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec 3.6.9", - "scale-info", - "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-crypto-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-crypto-primitives", + "tangle-primitives", ] [[package]] name = "pallet-jobs-rpc-runtime-api" version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1", -] - -[[package]] -name = "pallet-jobs-rpc-runtime-api" -version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" -dependencies = [ - "parity-scale-codec 3.6.9", - "sp-api", - "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives", ] [[package]] @@ -8711,6 +8583,7 @@ dependencies = [ [[package]] name = "pallet-roles" version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8729,8 +8602,8 @@ dependencies = [ "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-staking", "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-crypto-primitives 0.6.1", - "tangle-primitives 0.6.1", + "tangle-crypto-primitives", + "tangle-primitives", ] [[package]] @@ -8843,6 +8716,7 @@ dependencies = [ [[package]] name = "pallet-transaction-pause" version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "frame-support", "frame-system", @@ -8932,6 +8806,7 @@ dependencies = [ [[package]] name = "pallet-zksaas" version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "frame-benchmarking", "frame-support", @@ -8944,26 +8819,7 @@ dependencies = [ "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1", -] - -[[package]] -name = "pallet-zksaas" -version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec 3.6.9", - "scale-info", - "serde", - "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives", ] [[package]] @@ -9437,6 +9293,7 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "precompile-utils" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "affix", "environmental", @@ -9462,6 +9319,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "case", "num_enum 0.5.11", @@ -9573,6 +9431,7 @@ dependencies = [ [[package]] name = "primitives-ext" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "ethereum-types 0.14.1", "evm-tracing-events", @@ -10517,6 +10376,7 @@ dependencies = [ [[package]] name = "rpc-primitives-debug" version = "0.1.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "environmental", "ethereum", @@ -10534,6 +10394,7 @@ dependencies = [ [[package]] name = "rpc-primitives-txpool" version = "0.6.0" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "ethereum", "parity-scale-codec 3.6.9", @@ -13548,7 +13409,7 @@ dependencies = [ "futures", "gadget-common", "protocol-macros", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives", "tokio", ] @@ -13878,16 +13739,7 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" version = "0.6.1" -dependencies = [ - "parity-scale-codec 3.6.9", - "scale-info", - "sp-application-crypto 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", -] - -[[package]] -name = "tangle-crypto-primitives" -version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -13897,33 +13749,7 @@ dependencies = [ [[package]] name = "tangle-primitives" version = "0.6.1" -dependencies = [ - "ark-bn254", - "ark-crypto-primitives", - "ark-ec", - "ark-ff", - "ark-groth16", - "ark-serialize", - "ark-std", - "ethabi 15.0.0", - "frame-support", - "log", - "parity-scale-codec 3.6.9", - "scale-info", - "serde", - "smallvec", - "sp-arithmetic 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-consensus-babe", - "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "sp-staking", - "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", -] - -[[package]] -name = "tangle-primitives" -version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle#d46546bde3bcc6e37bf2f4fdd1fe9eb88e95b3ab" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "ark-bn254", "ark-crypto-primitives", @@ -13950,6 +13776,7 @@ dependencies = [ [[package]] name = "tangle-runtime" version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "evm-tracer", "fp-account", @@ -14003,7 +13830,7 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-insecure-randomness-collective-flip", - "pallet-jobs 0.6.1", + "pallet-jobs", "pallet-multisig", "pallet-nomination-pools", "pallet-offences", @@ -14044,13 +13871,14 @@ dependencies = [ "sp-version", "static_assertions", "substrate-wasm-builder", - "tangle-crypto-primitives 0.6.1", - "tangle-primitives 0.6.1", + "tangle-crypto-primitives", + "tangle-primitives", ] [[package]] name = "tangle-testnet-runtime" version = "0.6.1" +source = "git+https://github.com/webb-tools/tangle#7b25b6a99f21c95d6b13b63740456830ec33c8cb" dependencies = [ "evm-tracer", "fp-account", @@ -14075,7 +13903,7 @@ dependencies = [ "pallet-child-bounties", "pallet-collective", "pallet-democracy", - "pallet-dkg 0.6.1", + "pallet-dkg", "pallet-dynamic-fee", "pallet-election-provider-multi-phase", "pallet-elections-phragmen", @@ -14106,8 +13934,8 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-insecure-randomness-collective-flip", - "pallet-jobs 0.6.1", - "pallet-jobs-rpc-runtime-api 0.6.1", + "pallet-jobs", + "pallet-jobs-rpc-runtime-api", "pallet-multisig", "pallet-nomination-pools", "pallet-offences", @@ -14126,7 +13954,7 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-vesting", - "pallet-zksaas 0.6.1", + "pallet-zksaas", "parity-scale-codec 3.6.9", "precompile-utils", "rpc-primitives-debug", @@ -14149,8 +13977,8 @@ dependencies = [ "sp-version", "static_assertions", "substrate-wasm-builder", - "tangle-crypto-primitives 0.6.1", - "tangle-primitives 0.6.1", + "tangle-crypto-primitives", + "tangle-primitives", ] [[package]] @@ -14241,11 +14069,11 @@ dependencies = [ "gadget-core", "log", "pallet-balances", - "pallet-dkg 0.6.1 (git+https://github.com/webb-tools/tangle)", - "pallet-jobs 0.6.1 (git+https://github.com/webb-tools/tangle)", - "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-dkg", + "pallet-jobs", + "pallet-jobs-rpc-runtime-api", "pallet-timestamp", - "pallet-zksaas 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-zksaas", "parity-scale-codec 3.6.9", "parking_lot 0.12.1", "sc-client-api", @@ -14259,7 +14087,7 @@ dependencies = [ "sp-keystore 0.27.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives", "tokio", "tracing-subscriber 0.3.18", ] @@ -14834,7 +14662,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.4.6", + "rand 0.6.5", "static_assertions", ] @@ -16588,8 +16416,8 @@ dependencies = [ "hex", "itertools 0.12.1", "log", - "pallet-jobs 0.6.1 (git+https://github.com/webb-tools/tangle)", - "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-jobs", + "pallet-jobs-rpc-runtime-api", "parity-scale-codec 3.6.9", "protocol-macros", "rand 0.8.5", @@ -16604,7 +16432,7 @@ dependencies = [ "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-io 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives", "test-utils", "thiserror", "tokio", @@ -16694,7 +16522,7 @@ dependencies = [ "groth16", "log", "mpc-net", - "pallet-jobs-rpc-runtime-api 0.6.1 (git+https://github.com/webb-tools/tangle)", + "pallet-jobs-rpc-runtime-api", "parking_lot 0.12.1", "protocol-macros", "rayon", @@ -16706,7 +16534,7 @@ dependencies = [ "sp-api", "sp-core 21.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "sp-runtime 24.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "tangle-primitives 0.6.1 (git+https://github.com/webb-tools/tangle)", + "tangle-primitives", "test-utils", "tokio", "tokio-rustls", diff --git a/Cargo.toml b/Cargo.toml index f252c9061..d2ce1496b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,8 +29,8 @@ pallet-jobs = { git = "https://github.com/webb-tools/tangle" } pallet-dkg = { git = "https://github.com/webb-tools/tangle" } pallet-zksaas = { git = "https://github.com/webb-tools/tangle" } tangle-primitives = { git = "https://github.com/webb-tools/tangle" } -tangle-testnet-runtime = { path = "../tangle/runtime/testnet" } -tangle-mainnet-runtime = { package = "tangle-runtime", path = "../tangle/runtime/mainnet" } +tangle-testnet-runtime = { git = "https://github.com/webb-tools/tangle" } +tangle-mainnet-runtime = { package = "tangle-runtime", git = "https://github.com/webb-tools/tangle" } multi-party-ecdsa = { git = "https://github.com/webb-tools/cggmp-threshold-ecdsa/" } round-based = { git = "https://github.com/webb-tools/round-based-protocol", features = [] } From f3135c8218e93c6be6dc01e728acfbfa1dfcb21f Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 8 Feb 2024 23:17:10 +0200 Subject: [PATCH 16/66] Get test running --- Cargo.lock | 2 ++ Cargo.toml | 4 +-- gadget-common/Cargo.toml | 8 ++--- gadget-common/src/client.rs | 1 - gadget-common/src/config.rs | 3 -- gadget-common/src/gadget/mod.rs | 1 - protocols/mp-ecdsa/src/protocols/keygen.rs | 2 -- protocols/zcash-frost/src/protocols/keygen.rs | 29 ++++++++++++------- protocols/zcash-frost/src/protocols/sign.rs | 24 +++++++-------- protocols/zcash-frost/tests/frost.rs | 4 +-- 10 files changed, 40 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index de874252e..9c69de63a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15160,7 +15160,9 @@ version = "3.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "196bbee60607a195bc850e94f0e040bd090e45794ad8df0e9c5a422b9975a00f" dependencies = [ + "curve25519-dalek 4.1.1", "elliptic-curve 0.13.8", + "hex", "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", diff --git a/Cargo.toml b/Cargo.toml index 6f648e501..3f4ecf824 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,8 @@ protocol-macros = { path = "./protocol-macros" } dfns-cggmp21-protocol = { path = "./protocols/dfns-cggmp21" } zcash-frost-protocol = { path = "./protocols/zcash-frost" } -snowbridge-milagro-bls = { git = "https://github.com/Snowfork/milagro_bls", default-features = false, rev = "43a5d480ed6e3b83de4cf54888680d51604199e6" } -gennaro-dkg = { git = "https://github.com/mikelodder7/gennaro-dkg.git", default-features = false } +snowbridge-milagro-bls = { git = "https://github.com/Snowfork/milagro_bls", rev = "43a5d480ed6e3b83de4cf54888680d51604199e6" } +gennaro-dkg = { git = "https://github.com/mikelodder7/gennaro-dkg.git" } pallet-jobs-rpc-runtime-api = { git = "https://github.com/webb-tools/tangle.git" } pallet-jobs = { git = "https://github.com/webb-tools/tangle.git" } pallet-dkg = { git = "https://github.com/webb-tools/tangle.git" } diff --git a/gadget-common/Cargo.toml b/gadget-common/Cargo.toml index d02684353..f8898bc1e 100644 --- a/gadget-common/Cargo.toml +++ b/gadget-common/Cargo.toml @@ -28,10 +28,10 @@ sc-network = { workspace = true } sc-network-common = { workspace = true } sc-network-sync = { workspace = true } -tangle-primitives = { workspace = true, features = ["std"] } -tangle-testnet-runtime = { workspace = true, features = ["std"] } -tangle-mainnet-runtime = { workspace = true, optional = true, features = ["std"] } -pallet-jobs-rpc-runtime-api = { workspace = true, features = ["std"] } +tangle-primitives = { workspace = true } +tangle-testnet-runtime = { workspace = true } +tangle-mainnet-runtime = { workspace = true, optional = true } +pallet-jobs-rpc-runtime-api = { workspace = true } [features] default = [ diff --git a/gadget-common/src/client.rs b/gadget-common/src/client.rs index 63775ba10..893ef04d1 100644 --- a/gadget-common/src/client.rs +++ b/gadget-common/src/client.rs @@ -1,5 +1,4 @@ use crate::debug_logger::DebugLogger; -use crate::jobs_api_config::*; use crate::keystore::{ECDSAKeyStore, KeystoreBackend}; use async_trait::async_trait; use auto_impl::auto_impl; diff --git a/gadget-common/src/config.rs b/gadget-common/src/config.rs index 00b45f239..3626c2cbd 100644 --- a/gadget-common/src/config.rs +++ b/gadget-common/src/config.rs @@ -3,9 +3,6 @@ pub use crate::client::{AccountId, ClientWithApi}; pub use crate::debug_logger::DebugLogger; pub use crate::gadget::network::Network; pub use crate::gadget::GadgetProtocol; -use crate::jobs_api_config::{ - MaxDataLen, MaxKeyLen, MaxParticipants, MaxProofLen, MaxSignatureLen, MaxSubmissionLen, -}; use async_trait::async_trait; pub use pallet_jobs_rpc_runtime_api::JobsApi; pub use sc_client_api::Backend; diff --git a/gadget-common/src/gadget/mod.rs b/gadget-common/src/gadget/mod.rs index e8e9952f0..5b49b0e2a 100644 --- a/gadget-common/src/gadget/mod.rs +++ b/gadget-common/src/gadget/mod.rs @@ -2,7 +2,6 @@ use crate::client::{AccountId, ClientWithApi, GadgetJobType, JobsApiForGadget, J use crate::debug_logger::DebugLogger; use crate::gadget::message::GadgetProtocolMessage; use crate::gadget::work_manager::WorkManager; -use crate::jobs_api_config::*; use crate::protocol::{AsyncProtocol, AsyncProtocolRemote}; use crate::Error; use async_trait::async_trait; diff --git a/protocols/mp-ecdsa/src/protocols/keygen.rs b/protocols/mp-ecdsa/src/protocols/keygen.rs index 54c940d18..8d4968b69 100644 --- a/protocols/mp-ecdsa/src/protocols/keygen.rs +++ b/protocols/mp-ecdsa/src/protocols/keygen.rs @@ -34,8 +34,6 @@ use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; use tokio::sync::RwLock; -use super::sign; - pub struct MpEcdsaKeygenProtocol { client: JobsClient, key_store: ECDSAKeyStore, diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index 6b5d2695f..6447ad374 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -4,7 +4,11 @@ use frost_p256::P256Sha256; use frost_ristretto255::Ristretto255Sha512; use frost_secp256k1::Secp256K1Sha256; use futures::StreamExt; -use gadget_common::client::{AccountId, ClientWithApi, JobsClient}; +use gadget_common::client::JobsApiForGadget; +use gadget_common::client::{ + AccountId, ClientWithApi, GadgetJobResult, GadgetJobType, JobsClient, MaxKeyLen, + MaxParticipants, MaxSignatureLen, +}; use gadget_common::debug_logger::DebugLogger; use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::network::Network; @@ -16,7 +20,6 @@ use gadget_common::{Block, BlockImportNotification}; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use itertools::Itertools; -use pallet_jobs_rpc_runtime_api::JobsApi; use rand::SeedableRng; use sc_client_api::Backend; use sp_api::ProvideRuntimeApi; @@ -141,15 +144,14 @@ where fn role_filter(&self, role: RoleType) -> bool { matches!( role, - RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSr25519) + RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) ) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: GadgetJobType) -> bool { matches!(job, JobType::DKGTSSPhaseOne(_)) } @@ -448,14 +450,16 @@ async fn handle_public_key_gossip( let signatures = received_keys .into_iter() .sorted_by_key(|x| x.0) - .map(|r| r.1) + .map(|r| r.1.try_into().unwrap()) .collect::>(); let participants = received_participants .into_iter() .sorted_by_key(|x| x.0) - .map(|r| r.1 .0.to_vec()) - .collect(); + .map(|r| r.1 .0.to_vec().try_into().unwrap()) + .collect::>() + .try_into() + .unwrap(); if signatures.len() < t as usize { return Err(JobError { @@ -479,16 +483,19 @@ async fn handle_public_key_gossip( } _ => unreachable!("Invalid role"), }, - key: public_key_package.to_vec(), + key: public_key_package.to_vec().try_into().unwrap(), participants, - signatures, + signatures: signatures.try_into().unwrap(), threshold: t as _, }; verify_generated_dkg_key_ecdsa(res.clone(), logger); Ok(GadgetJobResult::DKGPhaseOne(res)) } -fn verify_generated_dkg_key_ecdsa(data: DKGTSSKeySubmissionResult, logger: &DebugLogger) { +fn verify_generated_dkg_key_ecdsa( + data: DKGTSSKeySubmissionResult, + logger: &DebugLogger, +) { // Ensure participants and signatures are not empty assert!(!data.participants.is_empty(), "NoParticipantsFound",); assert!(!data.signatures.is_empty(), "NoSignaturesFound"); diff --git a/protocols/zcash-frost/src/protocols/sign.rs b/protocols/zcash-frost/src/protocols/sign.rs index 0021845f9..d38d63cec 100644 --- a/protocols/zcash-frost/src/protocols/sign.rs +++ b/protocols/zcash-frost/src/protocols/sign.rs @@ -4,7 +4,8 @@ use frost_ed25519::Ed25519Sha512; use frost_p256::P256Sha256; use frost_ristretto255::Ristretto255Sha512; use frost_secp256k1::Secp256K1Sha256; -use gadget_common::client::{AccountId, ClientWithApi, JobsClient}; +use gadget_common::client::JobsApiForGadget; +use gadget_common::client::{AccountId, ClientWithApi, GadgetJobResult, GadgetJobType, JobsClient}; use gadget_common::debug_logger::DebugLogger; use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::network::Network; @@ -15,7 +16,6 @@ use gadget_common::protocol::AsyncProtocol; use gadget_common::{Block, BlockImportNotification}; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; -use pallet_jobs_rpc_runtime_api::JobsApi; use rand::SeedableRng; use round_based::MpcParty; use sc_client_api::Backend; @@ -86,7 +86,7 @@ where let JobType::DKGTSSPhaseTwo(p2_job) = job.job_type else { panic!("Should be valid type") }; - let input_data_to_sign = p2_job.submission; + let input_data_to_sign = p2_job.submission.try_into().unwrap(); let previous_job_id = p2_job.phase_one_id; let phase1_job = job.phase1_job.expect("Should exist for a phase 2 job"); @@ -155,7 +155,7 @@ where ) } - fn phase_filter(&self, job: JobType) -> bool { + fn phase_filter(&self, job: GadgetJobType) -> bool { matches!(job, JobType::DKGTSSPhaseTwo(_)) } @@ -371,12 +371,12 @@ where if let Some(signature) = protocol_output_clone.lock().await.take() { // Compute the signature bytes by first converting the signature // to a fixed byte array and then converting that to a Vec. - let (signature, signature_type) = match role { + let (signature, signature_scheme) = match role { ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { let mut signature_bytes = [0u8; 64]; signature_bytes.copy_from_slice(&signature.group_signature); ( - signature_bytes.to_vec(), + signature_bytes.to_vec().try_into().unwrap(), DigitalSignatureScheme::SchnorrSecp256k1, ) } @@ -384,7 +384,7 @@ where let mut signature_bytes = [0u8; 64]; signature_bytes.copy_from_slice(&signature.group_signature); ( - signature_bytes.to_vec(), + signature_bytes.to_vec().try_into().unwrap(), DigitalSignatureScheme::SchnorrEd25519, ) } @@ -392,7 +392,7 @@ where let mut signature_bytes = [0u8; 64]; signature_bytes.copy_from_slice(&signature.group_signature); ( - signature_bytes.to_vec(), + signature_bytes.to_vec().try_into().unwrap(), DigitalSignatureScheme::SchnorrP256, ) } @@ -400,7 +400,7 @@ where let mut signature_bytes = [0u8; 64]; signature_bytes.copy_from_slice(&signature.group_signature); ( - signature_bytes.to_vec(), + signature_bytes.to_vec().try_into().unwrap(), DigitalSignatureScheme::SchnorrSr25519, ) } @@ -412,10 +412,10 @@ where }; let job_result = GadgetJobResult::DKGPhaseTwo(DKGTSSSignatureResult { - signature_type, + signature_scheme, + data: additional_params.input_data_to_sign.try_into().unwrap(), signature, - data: additional_params.input_data_to_sign, - signing_key: keyshare2.pubkey_package, + signing_key: keyshare2.pubkey_package.try_into().unwrap(), }); client diff --git a/protocols/zcash-frost/tests/frost.rs b/protocols/zcash-frost/tests/frost.rs index 0441bcc75..90e4805cc 100644 --- a/protocols/zcash-frost/tests/frost.rs +++ b/protocols/zcash-frost/tests/frost.rs @@ -75,7 +75,7 @@ mod tests { expiry: 100, ttl: 100, job_type: JobType::DKGTSSPhaseOne(DKGTSSPhaseOneJobType { - participants: identities.clone(), + participants: identities.clone().try_into().unwrap(), threshold: T as _, permitted_caller: None, role_type: ThresholdSignatureRoleType::ZcashFrostRistretto255, @@ -112,7 +112,7 @@ mod tests { ttl: 100, job_type: JobType::DKGTSSPhaseTwo(DKGTSSPhaseTwoJobType { phase_one_id: keygen_job_id, - submission, + submission: submission.try_into().unwrap(), role_type: ThresholdSignatureRoleType::ZcashFrostRistretto255, }), }; From 316b524ee08bd593030ee1f2d138ce9e213930a3 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Fri, 9 Feb 2024 16:52:58 +0200 Subject: [PATCH 17/66] Keygen test working, sign not working --- Cargo.lock | 174 +++++++++++---------- Cargo.toml | 14 +- protocols/zcash-frost/Cargo.toml | 2 +- protocols/zcash-frost/src/rounds/keygen.rs | 4 +- protocols/zcash-frost/src/rounds/sign.rs | 24 ++- 5 files changed, 115 insertions(+), 103 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c69de63a..07bfdfa96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1366,9 +1366,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.14.2" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea31d69bda4949c1c1562c1e6f042a1caefac98cdc8a298260a2ff41c1e2d42b" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" dependencies = [ "bytemuck_derive", ] @@ -1424,9 +1424,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" +checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" dependencies = [ "serde", ] @@ -1498,9 +1498,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.6" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6100bc57b6209840798d95cb2775684849d332f7bd788db2a8c8caf7ef82a41a" +checksum = "fa50868b64a9a6fda9d593ce778849ea8715cd2a3d2cc17ffdb4a2f2f2f1961d" dependencies = [ "smallvec", ] @@ -3868,7 +3868,7 @@ dependencies = [ [[package]] name = "evm-tracer" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "ethereum-types 0.14.1", "evm", @@ -3888,7 +3888,7 @@ dependencies = [ [[package]] name = "evm-tracing-events" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "environmental", "ethereum", @@ -4533,7 +4533,7 @@ dependencies = [ [[package]] name = "frost-core" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "debugless-unwrap", "hex", @@ -4570,20 +4570,7 @@ dependencies = [ [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" -dependencies = [ - "curve25519-dalek-ml", - "document-features", - "frost-core 1.0.0-rc.0", - "frost-rerandomized", - "rand_core 0.6.4", - "sha2 0.10.8", -] - -[[package]] -name = "frost-ed25519" -version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -4594,22 +4581,22 @@ dependencies = [ ] [[package]] -name = "frost-ed448" +name = "frost-ed25519" version = "1.0.0-rc.0" source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ + "curve25519-dalek-ml", "document-features", - "ed448-goldilocks-plus 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "frost-core 1.0.0-rc.0", "frost-rerandomized", "rand_core 0.6.4", - "sha3 0.10.8", + "sha2 0.10.8", ] [[package]] name = "frost-ed448" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "ed448-goldilocks-plus 0.11.1 (git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize)", "frost-core 0.6.1", @@ -4620,22 +4607,22 @@ dependencies = [ ] [[package]] -name = "frost-p256" +name = "frost-ed448" version = "1.0.0-rc.0" source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ "document-features", + "ed448-goldilocks-plus 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "frost-core 1.0.0-rc.0", "frost-rerandomized", - "p256 0.13.2", "rand_core 0.6.4", - "sha2 0.10.8", + "sha3 0.10.8", ] [[package]] name = "frost-p256" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "frost-core 0.6.1", "p256 0.13.2", @@ -4646,14 +4633,14 @@ dependencies = [ ] [[package]] -name = "frost-p384" +name = "frost-p256" version = "1.0.0-rc.0" source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ "document-features", "frost-core 1.0.0-rc.0", "frost-rerandomized", - "p384", + "p256 0.13.2", "rand_core 0.6.4", "sha2 0.10.8", ] @@ -4661,7 +4648,7 @@ dependencies = [ [[package]] name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "frost-core 0.6.1", "p384", @@ -4672,33 +4659,33 @@ dependencies = [ ] [[package]] -name = "frost-rerandomized" +name = "frost-p384" version = "1.0.0-rc.0" source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ - "derive-getters", "document-features", "frost-core 1.0.0-rc.0", + "frost-rerandomized", + "p384", "rand_core 0.6.4", + "sha2 0.10.8", ] [[package]] -name = "frost-ristretto255" +name = "frost-rerandomized" version = "1.0.0-rc.0" source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ - "curve25519-dalek 4.1.1", + "derive-getters", "document-features", "frost-core 1.0.0-rc.0", - "frost-rerandomized", "rand_core 0.6.4", - "sha2 0.10.8", ] [[package]] name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -4709,14 +4696,14 @@ dependencies = [ ] [[package]] -name = "frost-secp256k1" +name = "frost-ristretto255" version = "1.0.0-rc.0" source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ + "curve25519-dalek 4.1.1", "document-features", "frost-core 1.0.0-rc.0", "frost-rerandomized", - "k256", "rand_core 0.6.4", "sha2 0.10.8", ] @@ -4724,7 +4711,7 @@ dependencies = [ [[package]] name = "frost-secp256k1" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "frost-core 0.6.1", "k256", @@ -4734,6 +4721,19 @@ dependencies = [ "subtle", ] +[[package]] +name = "frost-secp256k1" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" +dependencies = [ + "document-features", + "frost-core 1.0.0-rc.0", + "frost-rerandomized", + "k256", + "rand_core 0.6.4", + "sha2 0.10.8", +] + [[package]] name = "fs-err" version = "2.11.0" @@ -5807,12 +5807,12 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" +checksum = "fe8f25ce1159c7740ff0b9b2f5cdf4a8428742ba7c112b9f20f22cd5219c7dab" dependencies = [ "hermit-abi 0.3.5", - "rustix 0.38.31", + "libc", "windows-sys 0.52.0", ] @@ -7146,7 +7146,7 @@ dependencies = [ "round-based 0.1.7", "serde", "serde_repr", - "serde_with 3.6.0", + "serde_with 3.6.1", "sha2 0.9.9", "subtle", "thiserror", @@ -7766,7 +7766,7 @@ dependencies = [ "rand_core 0.6.4", "rug", "serde", - "serde_with 3.6.0", + "serde_with 3.6.1", "thiserror", ] @@ -7797,7 +7797,7 @@ dependencies = [ [[package]] name = "pallet-airdrop-claims" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "frame-support", "frame-system", @@ -7981,19 +7981,19 @@ dependencies = [ [[package]] name = "pallet-dkg" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "digest 0.10.7", "elliptic-curve 0.13.8", "frame-support", "frame-system", "frost-core 0.6.1", - "frost-ed25519 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git)", - "frost-ed448 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git)", - "frost-p256 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git)", - "frost-p384 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git)", - "frost-ristretto255 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git)", - "frost-secp256k1 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git)", + "frost-ed25519 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", + "frost-ed448 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", + "frost-p256 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", + "frost-p384 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", + "frost-ristretto255 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", + "frost-secp256k1 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", "generic-ec", "generic-ec-zkp", "hex", @@ -8002,7 +8002,7 @@ dependencies = [ "rand_core 0.6.4", "scale-info", "serde", - "serde_with 3.6.0", + "serde_with 3.6.1", "serdect", "sha2 0.10.8", "snowbridge-milagro-bls", @@ -8192,7 +8192,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-batch" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "evm", "evm-runtime", @@ -8232,7 +8232,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-call-permit" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "evm", "fp-evm", @@ -8263,7 +8263,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-democracy" version = "0.2.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "fp-evm", "frame-support", @@ -8305,7 +8305,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-jobs" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "fp-evm", "frame-support", @@ -8335,7 +8335,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-preimage" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "fp-evm", "frame-support", @@ -8355,7 +8355,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-proxy" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "evm", "fp-evm", @@ -8377,7 +8377,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-registry" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "fp-evm", "frame-support", @@ -8413,7 +8413,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-staking" version = "1.0.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "fp-evm", "frame-support", @@ -8435,7 +8435,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-vesting" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "evm", "fp-evm", @@ -8564,7 +8564,7 @@ dependencies = [ [[package]] name = "pallet-jobs" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "frame-benchmarking", "frame-support", @@ -8581,7 +8581,7 @@ dependencies = [ [[package]] name = "pallet-jobs-rpc-runtime-api" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", @@ -8677,7 +8677,7 @@ dependencies = [ [[package]] name = "pallet-roles" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8810,7 +8810,7 @@ dependencies = [ [[package]] name = "pallet-transaction-pause" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "frame-support", "frame-system", @@ -8900,7 +8900,7 @@ dependencies = [ [[package]] name = "pallet-zksaas" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "frame-benchmarking", "frame-support", @@ -9387,7 +9387,7 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "affix", "environmental", @@ -9413,7 +9413,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "case", "num_enum 0.5.11", @@ -9525,7 +9525,7 @@ dependencies = [ [[package]] name = "primitives-ext" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "ethereum-types 0.14.1", "evm-tracing-events", @@ -10452,6 +10452,7 @@ source = "git+https://github.com/ZenGo-X/round-based-protocol#1b372fe7d19de8cc52 dependencies = [ "futures-util", "phantom-type 0.3.1", + "round-based-derive", "thiserror", "tracing", ] @@ -10470,7 +10471,7 @@ dependencies = [ [[package]] name = "rpc-primitives-debug" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "environmental", "ethereum", @@ -10488,7 +10489,7 @@ dependencies = [ [[package]] name = "rpc-primitives-txpool" version = "0.6.0" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "ethereum", "parity-scale-codec 3.6.9", @@ -11574,9 +11575,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.6.0" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b0ed1662c5a68664f45b76d18deb0e234aff37207086803165c961eb695e981" +checksum = "15d167997bd841ec232f5b2b8e0e26606df2e7caa4c31b95ea9ca52b200bd270" dependencies = [ "base64 0.21.7", "chrono", @@ -11584,8 +11585,9 @@ dependencies = [ "indexmap 1.9.3", "indexmap 2.2.2", "serde", + "serde_derive", "serde_json", - "serde_with_macros 3.6.0", + "serde_with_macros 3.6.1", "time", ] @@ -11615,9 +11617,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.6.0" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568577ff0ef47b879f736cd66740e022f3672788cdf002a05a4e609ea5a6fb15" +checksum = "865f9743393e638991566a8b7a479043c2c8da94a33e0a31f18214c9cae0a64d" dependencies = [ "darling 0.20.5", "proc-macro2", @@ -13894,7 +13896,7 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -13904,7 +13906,7 @@ dependencies = [ [[package]] name = "tangle-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "ark-bn254", "ark-crypto-primitives", @@ -13931,7 +13933,7 @@ dependencies = [ [[package]] name = "tangle-runtime" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "evm-tracer", "fp-account", @@ -14033,7 +14035,7 @@ dependencies = [ [[package]] name = "tangle-testnet-runtime" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git#19ed43b09fa9f8bf505672ee0b51e0290f72c960" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" dependencies = [ "evm-tracer", "fp-account", diff --git a/Cargo.toml b/Cargo.toml index 3f4ecf824..d8b32d459 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,13 +28,13 @@ zcash-frost-protocol = { path = "./protocols/zcash-frost" } snowbridge-milagro-bls = { git = "https://github.com/Snowfork/milagro_bls", rev = "43a5d480ed6e3b83de4cf54888680d51604199e6" } gennaro-dkg = { git = "https://github.com/mikelodder7/gennaro-dkg.git" } -pallet-jobs-rpc-runtime-api = { git = "https://github.com/webb-tools/tangle.git" } -pallet-jobs = { git = "https://github.com/webb-tools/tangle.git" } -pallet-dkg = { git = "https://github.com/webb-tools/tangle.git" } -pallet-zksaas = { git = "https://github.com/webb-tools/tangle.git" } -tangle-primitives = { git = "https://github.com/webb-tools/tangle.git" } -tangle-testnet-runtime = { git = "https://github.com/webb-tools/tangle.git" } -tangle-mainnet-runtime = { package = "tangle-runtime", git = "https://github.com/webb-tools/tangle.git" } +pallet-jobs-rpc-runtime-api = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} +pallet-jobs = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} +pallet-dkg = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} +pallet-zksaas = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} +tangle-primitives = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} +tangle-testnet-runtime = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} +tangle-mainnet-runtime = { package = "tangle-runtime", git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} multi-party-ecdsa = { git = "https://github.com/webb-tools/cggmp-threshold-ecdsa/" } round-based = { git = "https://github.com/webb-tools/round-based-protocol", features = [] } diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml index abbeb928f..9ccb4007a 100644 --- a/protocols/zcash-frost/Cargo.toml +++ b/protocols/zcash-frost/Cargo.toml @@ -15,7 +15,7 @@ curv = { workspace = true } futures = { workspace = true } itertools = { workspace = true } bincode2 = { workspace = true } -round-based = { git = "https://github.com/ZenGo-X/round-based-protocol" } +round-based = { git = "https://github.com/ZenGo-X/round-based-protocol", features = ["derive"]} digest = "0.10" sha2 = "0.10" rand_core = "0.6" diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 42a50a000..62e30a692 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use dfns_cggmp21::{progress::Tracer, round_based::ProtocolMessage}; +use dfns_cggmp21::progress::Tracer; use frost_core::{ keys::{ dkg::{round1, round2}, @@ -13,7 +13,7 @@ use rand_core::{CryptoRng, RngCore}; use round_based::{ rounds_router::simple_store::RoundInput, rounds_router::{simple_store::RoundMsgs, RoundsRouter}, - Delivery, Mpc, MpcParty, Outgoing, + Delivery, Mpc, MpcParty, Outgoing, ProtocolMessage, }; use serde::{Deserialize, Serialize}; use tangle_primitives::roles::ThresholdSignatureRoleType; diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index 2be5d2e71..6597a60c7 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -1,5 +1,4 @@ use dfns_cggmp21::progress::Tracer; -use dfns_cggmp21::round_based::ProtocolMessage; use frost_core::keys::{KeyPackage, PublicKeyPackage}; use frost_core::round1::{SigningCommitments, SigningNonces}; use frost_core::round2::{self, SignatureShare}; @@ -7,7 +6,9 @@ use frost_core::{aggregate, round1, Ciphersuite, Field, Group, Identifier, Signi use futures::SinkExt; use rand_core::{CryptoRng, RngCore}; use round_based::rounds_router::simple_store::RoundInput; + use round_based::rounds_router::RoundsRouter; +use round_based::ProtocolMessage; use round_based::{Delivery, Mpc, MpcParty, Outgoing}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; @@ -69,7 +70,7 @@ where tracer.stage("Setup networking"); let MpcParty { delivery, .. } = party.into_party(); let (incomings, mut outgoings) = delivery.split(); - + println!("Signers: {:?}", signers); let mut rounds = RoundsRouter::::builder(); let round1 = rounds.add_round(RoundInput::::broadcast(i, signers.len() as u16)); let round2 = rounds.add_round(RoundInput::::broadcast(i, signers.len() as u16)); @@ -94,15 +95,19 @@ where tracer.round_begins(); tracer.receive_msgs(); - let round1_signing_commitments: BTreeMap, SigningCommitments> = rounds + let round1_msgs: Vec = rounds .complete(round1) .await .map_err(|e| SignError(Reason::IoError(IoError::receive_message(e))))? - .into_iter_indexed() - .map(|(party_inx, _msg_id, msg)| { + .into_vec_including_me(my_round1_msg); + + let round1_signing_commitments: BTreeMap, SigningCommitments> = round1_msgs + .into_iter() + .enumerate() + .map(|(party_inx, msg)| { let msg = SigningCommitments::::deserialize(&msg.msg) .unwrap_or_else(|_| panic!("Failed to deserialize round 1 signing commitments")); - let participant_identifier = Identifier::::try_from(party_inx) + let participant_identifier = Identifier::::try_from((party_inx + 1) as u16) .expect("Failed to convert party index to identifier"); (participant_identifier, msg) }) @@ -137,7 +142,7 @@ where .into_iter() .enumerate() .map(|(party_inx, msg)| { - let participant_identifier = Identifier::::try_from(party_inx as u16) + let participant_identifier = Identifier::::try_from((party_inx + 1) as u16) .expect("Failed to convert party index to identifier"); let ser = <::Field as Field>::Serialization::try_from(msg.msg) .map_err(|_e| SignError(Reason::::SerializationError)) @@ -212,6 +217,11 @@ fn participant_round2( _ => panic!("Invalid role"), }; + println!("Min signers: {:?}", key_package.min_signers()); + println!( + "Signing package commits: {:?}", + signing_package.signing_commitments().len() + ); round2::sign(signing_package, nonces, key_package).map_err(|e| { SignError(Reason::SignFailure(SignAborted::FrostError { parties: vec![], From 0369386c85575e161a2a41fead5c0fad40d49a32 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Mon, 12 Feb 2024 13:02:36 +0200 Subject: [PATCH 18/66] Cleanup --- Cargo.lock | 76 ++++---- Cargo.toml | 24 ++- protocols/zcash-frost/Cargo.toml | 2 +- protocols/zcash-frost/src/rounds/errors.rs | 43 ----- protocols/zcash-frost/src/rounds/keygen.rs | 9 +- protocols/zcash-frost/src/rounds/mod.rs | 192 ++++++++++++--------- protocols/zcash-frost/src/rounds/sign.rs | 83 ++++----- 7 files changed, 208 insertions(+), 221 deletions(-) delete mode 100644 protocols/zcash-frost/src/rounds/errors.rs diff --git a/Cargo.lock b/Cargo.lock index 07bfdfa96..c027e0b23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4548,7 +4548,6 @@ dependencies = [ [[package]] name = "frost-core" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ "byteorder", "const-crc32", @@ -4567,6 +4566,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "frost-ed25519" +version = "1.0.0-rc.0" +dependencies = [ + "curve25519-dalek-ml", + "document-features", + "frost-core 1.0.0-rc.0", + "frost-rerandomized", + "rand_core 0.6.4", + "sha2 0.10.8", +] + [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" @@ -4581,16 +4592,15 @@ dependencies = [ ] [[package]] -name = "frost-ed25519" +name = "frost-ed448" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ - "curve25519-dalek-ml", "document-features", + "ed448-goldilocks-plus 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "frost-core 1.0.0-rc.0", "frost-rerandomized", "rand_core 0.6.4", - "sha2 0.10.8", + "sha3 0.10.8", ] [[package]] @@ -4607,16 +4617,15 @@ dependencies = [ ] [[package]] -name = "frost-ed448" +name = "frost-p256" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ "document-features", - "ed448-goldilocks-plus 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "frost-core 1.0.0-rc.0", "frost-rerandomized", + "p256 0.13.2", "rand_core 0.6.4", - "sha3 0.10.8", + "sha2 0.10.8", ] [[package]] @@ -4633,14 +4642,13 @@ dependencies = [ ] [[package]] -name = "frost-p256" +name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ "document-features", "frost-core 1.0.0-rc.0", "frost-rerandomized", - "p256 0.13.2", + "p384", "rand_core 0.6.4", "sha2 0.10.8", ] @@ -4659,27 +4667,25 @@ dependencies = [ ] [[package]] -name = "frost-p384" +name = "frost-rerandomized" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ + "derive-getters", "document-features", "frost-core 1.0.0-rc.0", - "frost-rerandomized", - "p384", "rand_core 0.6.4", - "sha2 0.10.8", ] [[package]] -name = "frost-rerandomized" +name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ - "derive-getters", + "curve25519-dalek 4.1.1", "document-features", "frost-core 1.0.0-rc.0", + "frost-rerandomized", "rand_core 0.6.4", + "sha2 0.10.8", ] [[package]] @@ -4696,14 +4702,13 @@ dependencies = [ ] [[package]] -name = "frost-ristretto255" +name = "frost-secp256k1" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ - "curve25519-dalek 4.1.1", "document-features", "frost-core 1.0.0-rc.0", "frost-rerandomized", + "k256", "rand_core 0.6.4", "sha2 0.10.8", ] @@ -4721,19 +4726,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "frost-secp256k1" -version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" -dependencies = [ - "document-features", - "frost-core 1.0.0-rc.0", - "frost-rerandomized", - "k256", - "rand_core 0.6.4", - "sha2 0.10.8", -] - [[package]] name = "fs-err" version = "2.11.0" @@ -16638,13 +16630,13 @@ dependencies = [ "digest 0.10.7", "frame-support", "frost-core 1.0.0-rc.0", - "frost-ed25519 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", - "frost-ed448 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", - "frost-p256 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", - "frost-p384 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-ed25519 1.0.0-rc.0", + "frost-ed448 1.0.0-rc.0", + "frost-p256 1.0.0-rc.0", + "frost-p384 1.0.0-rc.0", "frost-rerandomized", - "frost-ristretto255 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", - "frost-secp256k1 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-ristretto255 1.0.0-rc.0", + "frost-secp256k1 1.0.0-rc.0", "futures", "gadget-common", "gadget-core", diff --git a/Cargo.toml b/Cargo.toml index d8b32d459..437ebb679 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,14 +41,22 @@ round-based = { git = "https://github.com/webb-tools/round-based-protocol", feat curv = { package = "curv-kzen", version = "0.10.0" } dfns-cggmp21 = { package = "cggmp21", version = "0.1.1", default-features = false } udigest = { version = "0.1", features = ["std", "derive"]} -frost-core = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-ed25519 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-ed448 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-p256 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-p384 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-ristretto255 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-secp256k1 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-rerandomized = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-core = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-ed25519 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-ed448 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-p256 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-p384 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-ristretto255 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-secp256k1 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-rerandomized = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-core = { path = "../frost/frost-core" } +frost-ed25519 = { path = "../frost/frost-ed25519" } +frost-ed448 = { path = "../frost/frost-ed448" } +frost-p256 = { path = "../frost/frost-p256" } +frost-p384 = { path = "../frost/frost-p384" } +frost-ristretto255 = { path = "../frost/frost-ristretto255" } +frost-secp256k1 = { path = "../frost/frost-secp256k1" } +frost-rerandomized = { path = "../frost/frost-rerandomized" } bls12_381_plus = "0.8.13" sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml index 9ccb4007a..4c857b5da 100644 --- a/protocols/zcash-frost/Cargo.toml +++ b/protocols/zcash-frost/Cargo.toml @@ -23,7 +23,7 @@ rand_chacha = { version = "0.3", default-features = false } dfns-cggmp21 = { workspace = true } udigest = { workspace = true } -frost-core = { workspace = true } +frost-core = { workspace = true, features = ["cheater-detection"] } frost-ed25519 = { workspace = true } frost-ed448 = { workspace = true } frost-p256 = { workspace = true } diff --git a/protocols/zcash-frost/src/rounds/errors.rs b/protocols/zcash-frost/src/rounds/errors.rs deleted file mode 100644 index 18abec701..000000000 --- a/protocols/zcash-frost/src/rounds/errors.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::convert::Infallible; - -use round_based::rounds_router::{ - errors::{self as router_error, CompleteRoundError}, - simple_store::RoundInputError, -}; -use thiserror::Error; - -pub type BoxedError = Box; - -#[derive(Debug, Error)] -pub enum IoError { - #[error("send message")] - SendMessage(#[source] BoxedError), - #[error("receive message")] - ReceiveMessage(#[source] BoxedError), - #[error("got eof while recieving messages")] - ReceiveMessageEof, - #[error("route received message (possibly malicious behavior)")] - RouteReceivedError(router_error::CompleteRoundError), -} - -impl IoError { - pub fn send_message(err: E) -> Self { - Self::SendMessage(Box::new(err)) - } - - pub fn receive_message( - err: CompleteRoundError, - ) -> Self { - match err { - CompleteRoundError::Io(router_error::IoError::Io(e)) => { - Self::ReceiveMessage(Box::new(e)) - } - CompleteRoundError::Io(router_error::IoError::UnexpectedEof) => Self::ReceiveMessageEof, - - CompleteRoundError::ProcessMessage(e) => { - Self::RouteReceivedError(CompleteRoundError::ProcessMessage(e)) - } - CompleteRoundError::Other(e) => Self::RouteReceivedError(CompleteRoundError::Other(e)), - } - } -} diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 62e30a692..a82247c28 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -18,7 +18,7 @@ use round_based::{ use serde::{Deserialize, Serialize}; use tangle_primitives::roles::ThresholdSignatureRoleType; -use super::{errors::IoError, KeygenAborted, KeygenError, Reason}; +use super::{IoError, KeygenAborted, KeygenError, Reason}; /// Message of key generation protocol #[derive(ProtocolMessage, Clone, Serialize, Deserialize)] @@ -90,6 +90,7 @@ where tracer.round_begins(); tracer.stage("Compute round 1 dkg secret package"); + println!("Keygen | i: {}, t: {}, n: {}", i, t, n); let (round1_secret_package, round1_package) = dkg_part1(i + 1, t, n, role, rng).map_err(|e| { KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { @@ -116,7 +117,7 @@ where .complete(round1) .await .map_err(|e| KeygenError(Reason::IoError(IoError::receive_message(e))))? - .into_vec_including_me(my_round1_msg) + .into_vec_including_me(my_round1_msg.clone()) .into_iter() .map(|msg| { round1::Package::deserialize(&msg.msg) @@ -124,7 +125,7 @@ where }) .collect(); tracer.msgs_received(); - + println!("Keygen | i: {}, my_package: {:#?}", i, round1_package); tracer.stage("Compute round 2 dkg secret package"); let round1_packages_map: BTreeMap, round1::Package> = round1_packages .iter() @@ -137,7 +138,7 @@ where }) .filter(|(inx, _)| *inx != Identifier::try_from(i + 1).unwrap()) .collect(); - + println!("Keygen | round1_packages_map: {:#?}", round1_packages_map); let (round2_secret_package, round2_packages_map) = dkg_part2(role, round1_secret_package, &round1_packages_map).map_err(|e| { KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index 3be817228..f62eb3801 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -1,95 +1,143 @@ use frost_core::Ciphersuite; -use frost_ed25519::Ed25519Sha512; -use frost_ed448::Ed448Shake256; -use frost_p256::P256Sha256; -use frost_p384::P384Sha384; -use frost_ristretto255::Ristretto255Sha512; -use frost_secp256k1::Secp256K1Sha256; +use round_based::rounds_router::{ + errors::{self as router_error, CompleteRoundError}, + simple_store::RoundInputError, +}; +use std::convert::Infallible; use thiserror::Error; -use self::errors::IoError; - -pub mod errors; pub mod keygen; pub mod sign; -/// Keygen protocol error +pub type BoxedError = Box; + #[derive(Debug, Error)] -#[error("keygen protocol is failed to complete")] -pub struct KeygenError(#[source] Reason); +pub enum IoError { + #[error("send message")] + SendMessage(#[source] BoxedError), + #[error("receive message")] + ReceiveMessage(#[source] BoxedError), + #[error("got eof while recieving messages")] + ReceiveMessageEof, + #[error("route received message (possibly malicious behavior)")] + RouteReceivedError(router_error::CompleteRoundError), +} -macro_rules! impl_keygen_error_from { - ($ciphersuite:ty) => { - impl From> for KeygenError<$ciphersuite> { - fn from(err: KeygenAborted<$ciphersuite>) -> Self { - KeygenError(Reason::KeygenFailure(err)) +impl IoError { + pub fn send_message(err: E) -> Self { + Self::SendMessage(Box::new(err)) + } + + pub fn receive_message( + err: CompleteRoundError, + ) -> Self { + match err { + CompleteRoundError::Io(router_error::IoError::Io(e)) => { + Self::ReceiveMessage(Box::new(e)) } - } + CompleteRoundError::Io(router_error::IoError::UnexpectedEof) => Self::ReceiveMessageEof, - impl From for KeygenError<$ciphersuite> { - fn from(err: IoError) -> Self { - KeygenError(Reason::IoError(err)) + CompleteRoundError::ProcessMessage(e) => { + Self::RouteReceivedError(CompleteRoundError::ProcessMessage(e)) } + CompleteRoundError::Other(e) => Self::RouteReceivedError(CompleteRoundError::Other(e)), } - }; + } } -impl_keygen_error_from!(Ed25519Sha512); -impl_keygen_error_from!(P256Sha256); -impl_keygen_error_from!(P384Sha384); -impl_keygen_error_from!(Ristretto255Sha512); -impl_keygen_error_from!(Secp256K1Sha256); -impl_keygen_error_from!(Ed448Shake256); +/// Error indicating that protocol was aborted by malicious party +#[derive(Debug, Error)] +enum KeygenAborted { + #[error("Frost keygen error")] + FrostError { + parties: Vec, + error: frost_core::Error, + }, +} /// Sign protocol error #[derive(Debug, Error)] +enum SignAborted { + #[error("Frost sign error")] + FrostError { + parties: Vec, + error: frost_core::Error, + }, + #[error("Invalid frost protocol")] + InvalidFrostProtocol, +} + +/// Keygen protocol error +#[derive(Debug, Error)] #[error("keygen protocol is failed to complete")] -pub struct SignError(#[source] Reason); +pub struct KeygenError(#[source] Reason); -macro_rules! impl_sign_error_from { - ($ciphersuite:ty) => { - impl From> for SignError<$ciphersuite> { - fn from(err: SignAborted<$ciphersuite>) -> Self { - SignError(Reason::SignFailure(err)) +impl From> for KeygenError { + fn from(err: frost_core::Error) -> Self { + match err { + frost_core::Error::::InvalidProofOfKnowledge { culprit } => { + let culprit_bytes: Vec = culprit.serialize().as_ref().to_vec(); + let culprit = u16::from_le_bytes([culprit_bytes[0], culprit_bytes[1]]); + KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { + parties: vec![culprit], + error: err, + })) } + _ => KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { + parties: vec![], + error: err, + })), } + } +} - impl From for SignError<$ciphersuite> { - fn from(err: IoError) -> Self { - SignError(Reason::IoError(err)) - } - } - }; +impl From for KeygenError { + fn from(err: IoError) -> Self { + KeygenError(Reason::IoError(err)) + } } -impl_sign_error_from!(Ed25519Sha512); -impl_sign_error_from!(P256Sha256); -impl_sign_error_from!(P384Sha384); -impl_sign_error_from!(Ristretto255Sha512); -impl_sign_error_from!(Secp256K1Sha256); -impl_sign_error_from!(Ed448Shake256); +impl From> for KeygenError { + fn from(err: KeygenAborted) -> Self { + KeygenError(Reason::KeygenFailure(err)) + } +} -/// Repair protocol error +/// Sign protocol error #[derive(Debug, Error)] -#[error("repair protocol is failed to complete")] -pub struct RepairError(Reason); - -macro_rules! impl_repair_error_from { - ($ciphersuite:ty) => { - impl From for RepairError<$ciphersuite> { - fn from(err: IoError) -> Self { - RepairError(Reason::IoError(err)) +#[error("keygen protocol is failed to complete")] +pub struct SignError(#[source] Reason); + +impl From> for SignError { + fn from(err: frost_core::Error) -> Self { + match err { + frost_core::Error::::InvalidSignatureShare { culprit } => { + let culprit_bytes: Vec = culprit.serialize().as_ref().to_vec(); + let culprit = u16::from_le_bytes([culprit_bytes[0], culprit_bytes[1]]); + SignError(Reason::SignFailure(SignAborted::FrostError { + parties: vec![culprit], + error: err, + })) } + _ => SignError(Reason::SignFailure(SignAborted::FrostError { + parties: vec![], + error: err, + })), } - }; + } } -impl_repair_error_from!(Ed25519Sha512); -impl_repair_error_from!(P256Sha256); -impl_repair_error_from!(P384Sha384); -impl_repair_error_from!(Ristretto255Sha512); -impl_repair_error_from!(Secp256K1Sha256); -impl_repair_error_from!(Ed448Shake256); +impl From for SignError { + fn from(err: IoError) -> Self { + SignError(Reason::IoError(err)) + } +} + +impl From> for SignError { + fn from(err: SignAborted) -> Self { + SignError(Reason::SignFailure(err)) + } +} #[derive(Debug, Error)] enum Reason { @@ -111,23 +159,3 @@ enum Reason { #[error("unknown error")] SerializationError, } - -/// Error indicating that protocol was aborted by malicious party -#[derive(Debug, Error)] -enum KeygenAborted { - #[error("Frost keygen error")] - FrostError { - parties: Vec, - error: frost_core::Error, - }, -} - -/// Sign protocol error -#[derive(Debug, Error)] -enum SignAborted { - #[error("Frost sign error")] - FrostError { - parties: Vec, - error: frost_core::Error, - }, -} diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index 6597a60c7..e27e12051 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -14,8 +14,7 @@ use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use tangle_primitives::roles::ThresholdSignatureRoleType; -use super::errors::IoError; -use super::{Reason, SignAborted, SignError}; +use super::{IoError, Reason, SignAborted, SignError}; /// Message of key generation protocol #[derive(ProtocolMessage, Clone, Serialize, Deserialize)] @@ -28,7 +27,7 @@ pub enum Msg { } /// Message from round 1 -#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] +#[derive(Clone, Debug, Serialize, Deserialize, udigest::Digestable)] #[serde(bound = "")] #[udigest(bound = "")] #[udigest(tag = "zcash.frost.sign.threshold.round1")] @@ -36,7 +35,7 @@ pub struct MsgRound1 { pub msg: Vec, } /// Message from round 2 -#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] +#[derive(Clone, Debug, Serialize, Deserialize, udigest::Digestable)] #[serde(bound = "")] #[udigest(bound = "")] #[udigest(tag = "zcash.frost.sign.threshold.round2")] @@ -81,14 +80,20 @@ where tracer.send_msg(); tracer.stage("Generate nonces and commitments for Round 1"); - let (nonces, commitments) = participant_round1(role, &frost_keyshare.0, rng); + let (nonces, commitments) = participant_round1(role, &frost_keyshare.0, rng)?; let my_round1_msg = MsgRound1 { msg: commitments.serialize().unwrap_or_default(), }; + println!( + " for party {:?}: <{:#?}, {:#?}>", + i, + frost_keyshare.0.identifier(), + commitments + ); outgoings .send(Outgoing::broadcast(Msg::Round1(my_round1_msg.clone()))) .await - .map_err(|e| SignError(Reason::IoError(IoError::send_message(e))))?; + .map_err(IoError::send_message)?; tracer.msg_sent(); // Round 2 @@ -98,20 +103,25 @@ where let round1_msgs: Vec = rounds .complete(round1) .await - .map_err(|e| SignError(Reason::IoError(IoError::receive_message(e))))? + .map_err(IoError::receive_message)? .into_vec_including_me(my_round1_msg); - let round1_signing_commitments: BTreeMap, SigningCommitments> = round1_msgs + let round1_signing_commitments = round1_msgs .into_iter() .enumerate() .map(|(party_inx, msg)| { - let msg = SigningCommitments::::deserialize(&msg.msg) - .unwrap_or_else(|_| panic!("Failed to deserialize round 1 signing commitments")); let participant_identifier = Identifier::::try_from((party_inx + 1) as u16) .expect("Failed to convert party index to identifier"); + let msg = SigningCommitments::::deserialize(&msg.msg) + .unwrap_or_else(|_| panic!("Failed to deserialize round 1 signing commitments")); (participant_identifier, msg) }) .collect(); + + println!( + "Received signing commitments: {:#?}", + round1_signing_commitments + ); tracer.msgs_received(); tracer.send_msg(); @@ -125,7 +135,7 @@ where msg: signature_share.serialize().as_ref().to_vec(), }))) .await - .map_err(|e| SignError(Reason::IoError(IoError::send_message(e))))?; + .map_err(IoError::send_message)?; tracer.msg_sent(); // Aggregation / output round @@ -158,13 +168,7 @@ where &signing_package, &round2_signature_shares, &frost_keyshare.1, - ) - .map_err(|e| { - SignError(Reason::SignFailure(SignAborted::FrostError { - parties: vec![], - error: e, - })) - })?; + )?; if frost_keyshare .1 @@ -185,21 +189,30 @@ where }) } -/// Participant generates nonces and commitments for Round 1. -fn participant_round1( - role: ThresholdSignatureRoleType, - key_package: &KeyPackage, - rng: &mut R, -) -> (SigningNonces, SigningCommitments) { +fn validate_role(role: ThresholdSignatureRoleType) -> Result<(), SignError> { match role { ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostEd448 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), + | ThresholdSignatureRoleType::ZcashFrostP384 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 => {} + _ => Err(SignError(Reason::SignFailure( + SignAborted::InvalidFrostProtocol, + )))?, }; - round1::commit(key_package.signing_share(), rng) + Ok(()) +} + +/// Participant generates nonces and commitments for Round 1. +fn participant_round1( + role: ThresholdSignatureRoleType, + key_package: &KeyPackage, + rng: &mut R, +) -> Result<(SigningNonces, SigningCommitments), SignError> { + validate_role::(role)?; + Ok(round1::commit(key_package.signing_share(), rng)) } /// Participant produces their signature share using the `SigningPackage` and their `SigningNonces` from Round 1. @@ -209,19 +222,7 @@ fn participant_round2( nonces: &SigningNonces, key_package: &KeyPackage, ) -> Result, SignError> { - match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 - | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), - }; - - println!("Min signers: {:?}", key_package.min_signers()); - println!( - "Signing package commits: {:?}", - signing_package.signing_commitments().len() - ); + validate_role::(role)?; round2::sign(signing_package, nonces, key_package).map_err(|e| { SignError(Reason::SignFailure(SignAborted::FrostError { parties: vec![], From 949aa9d1cfbe958dcf7d62df83597b04e96f2651 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Mon, 12 Feb 2024 14:02:24 +0200 Subject: [PATCH 19/66] Update readme --- README.md | 12 ++++-- protocols/zcash-frost/src/protocols/util.rs | 2 + protocols/zcash-frost/src/rounds/keygen.rs | 43 ++++++++++----------- protocols/zcash-frost/src/rounds/sign.rs | 16 +++----- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index c17db4a30..27bf0a2d7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,16 @@ # Gadget +This repo contains code for MPC and other restaking service gadgets. A gadget is a service that listens to a job management system (such as a blockchain w/ onchain job management logic) and communicates with other service providers using a peer to peer or alternative networking stack. Currently, the main services the gadget implements are multi-party computation services such as threshold signature MPCs and an MPC proving service for Groth16 zkSNARKs. -## Design +- [x] [DFNS CGGMP21](https://github.com/dfns/cggmp21/tree/m/cggmp21) +- [x] [Threshold BLS](https://github.com/mikelodder7/blsful) +- [ ] [LIT Protocol fork of ZCash Frost](https://github.com/LIT-Protocol/frost) +- [x] [Groth16 ZK-SaaS](https://github.com/webb-tools/zk-SaaS) -The core library is `gadget-core`. The core library allows gadgets to hold standardization of use across different blockchains. The core library is the base of all gadgets, and expects to receive `FinalityNotifications` and `BlockImportNotifications`. +## Design -Once such blockchain is a substrate blockchain. This is where `webb-gadget` comes into play. The `webb-gadget` is the `core-gadget` endowed with a connection to a substrate blockchain, a networking layer to communicate with other gadgets, and a `WebbGadgetModule` that has application-specific logic. +The core library is `gadget-core`. The core library allows gadgets to hold standardization of use across different blockchains that implement a compatible job management and submission infrastructure. All gadgets should implement the relevant traits from `gadget-core`, which implement job allocation, completion, and submission. Currently, gadgets expect to receive `FinalityNotifications` and `BlockImportNotifications` so blockchains with finality are mainly targetted. -Since `webb-gadget` allows varying connections to a substrate blockchain and differing network layers, we thus design above it various *protocols*. Some example protocols are `zk-saas-protocol`, `dfns-cggmp21-protocol`, `threshold-bls-protocol`, and `stub-protocol` (where the former is for getting a bare minimum skeleton of a protocol crate setup). These protocols are endowed with the same functionalities as the `webb-gadget` but with a (potentially) different blockchain connection, networking layer, and application-specific logic using assistance from macros. +Currently the repo is built around Substrate blockchain logic and networking. The job system implemented by [Tangle](https://github.com/webb-tools/tangle) drives the current job allocation mechanism. Validators of a Substrate chain implementing Tangle's runtime pallets execute jobs assigned to them from an onchain job submission system and use the underlying Substrate p2p layer to communicate with other service peers. ## Testing diff --git a/protocols/zcash-frost/src/protocols/util.rs b/protocols/zcash-frost/src/protocols/util.rs index 952347990..9bb7eb0bc 100644 --- a/protocols/zcash-frost/src/protocols/util.rs +++ b/protocols/zcash-frost/src/protocols/util.rs @@ -7,6 +7,7 @@ use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::network::Network; use gadget_common::gadget::work_manager::WorkManager; use gadget_core::job_manager::WorkManagerInterface; +use itertools::Itertools; use rand::seq::SliceRandom; use round_based::{Incoming, MessageDestination, MessageType, Outgoing, PartyIndex}; use serde::de::DeserializeOwned; @@ -477,6 +478,7 @@ pub fn choose_signers( let selected_participants_indices = selected_participants .iter() .map(|p| participants.iter().position(|x| x == p).unwrap() as u16) + // .sorted() .collect::>(); let j = participants diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index a82247c28..387ae70e7 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -125,32 +125,33 @@ where }) .collect(); tracer.msgs_received(); - println!("Keygen | i: {}, my_package: {:#?}", i, round1_package); + // println!("Keygen | i: {}, my_package: {:#?}", i, round1_package); tracer.stage("Compute round 2 dkg secret package"); let round1_packages_map: BTreeMap, round1::Package> = round1_packages .iter() .enumerate() + .filter(|(inx, _)| *inx != i as usize) .map(|(inx, p)| { ( ((inx + 1) as u16).try_into().expect("should be nonzero"), p.clone(), ) }) - .filter(|(inx, _)| *inx != Identifier::try_from(i + 1).unwrap()) .collect(); - println!("Keygen | round1_packages_map: {:#?}", round1_packages_map); + // println!("Keygen | round1_packages_map: {:#?}", round1_packages_map); let (round2_secret_package, round2_packages_map) = - dkg_part2(role, round1_secret_package, &round1_packages_map).map_err(|e| { - KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { - parties: vec![], - error: e, - })) - })?; + dkg_part2(role, round1_secret_package, &round1_packages_map)?; tracer.send_msg(); for (receiver_identifier, round2_package) in round2_packages_map { let receiver_index_bytes: Vec = receiver_identifier.serialize().as_ref().to_vec(); let receiver_index = u16::from_le_bytes([receiver_index_bytes[0], receiver_index_bytes[1]]); + println!( + "Sender ID: {:#?}, Sender: {}, Receiver: {}", + round2_secret_package.identifier, + i, + receiver_index - 1 + ); outgoings .send(Outgoing::p2p( receiver_index - 1, @@ -159,7 +160,7 @@ where }), )) .await - .map_err(|e| KeygenError(Reason::IoError(IoError::send_message(e))))?; + .map_err(IoError::send_message)?; } tracer.msg_sent(); @@ -170,14 +171,17 @@ where let round2_packages: RoundMsgs = rounds .complete(round2) .await - .map_err(|e| KeygenError(Reason::IoError(IoError::receive_message(e))))?; + .map_err(IoError::receive_message)?; tracer.msgs_received(); tracer.stage("Compute round 3 dkg secret package"); let round2_packages_map: BTreeMap, round2::Package> = round2_packages - .into_iter_indexed() - .map(|(inx, _msg_id, msg)| { - let identifier = (inx + 1).try_into().expect("should be nonzero"); + .into_vec_including_me(MsgRound2 { msg: vec![] }) + .into_iter() + .enumerate() + .filter(|(inx, _)| *inx != i as usize) + .map(|(inx, msg)| { + let identifier = (inx as u16 + 1).try_into().expect("should be nonzero"); let package = round2::Package::deserialize(&msg.msg) .unwrap_or_else(|_| panic!("Failed to deserialize round 2 package")); (identifier, package) @@ -188,16 +192,11 @@ where &round2_secret_package, &round1_packages_map, &round2_packages_map, - ) - .map_err(|e| { - KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { - parties: vec![], - error: e, - })) - })?; + )?; tracer.protocol_ends(); - + println!("Finished KEYGEN!"); + println!("Key Package for {}: {:#?}", i, key_package); Ok(FrostKeyShare { key_package: key_package.serialize().unwrap_or_default(), pubkey_package: pubkey_package.serialize().unwrap_or_default(), diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index e27e12051..59cd45a7c 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -100,12 +100,14 @@ where tracer.round_begins(); tracer.receive_msgs(); + println!("Receiving Round 1 messages"); let round1_msgs: Vec = rounds .complete(round1) .await .map_err(IoError::receive_message)? .into_vec_including_me(my_round1_msg); + println!("Received Round 1 messages"); let round1_signing_commitments = round1_msgs .into_iter() .enumerate() @@ -142,6 +144,7 @@ where tracer.round_begins(); tracer.receive_msgs(); + println!("Receiving Round 2 messages"); let round2_signature_shares: BTreeMap, SignatureShare> = rounds .complete(round2) .await @@ -162,6 +165,7 @@ where (participant_identifier, sig_share) }) .collect(); + println!("Received Round 2 messages"); tracer.msgs_received(); let group_signature = aggregate( @@ -176,10 +180,7 @@ where .verify(message_to_sign, &group_signature) .is_err() { - return Err(SignError(Reason::SignFailure(SignAborted::FrostError { - parties: vec![], - error: frost_core::Error::::InvalidSignature, - }))); + return Err(frost_core::Error::::InvalidSignature.into()); } tracer.protocol_ends(); @@ -223,10 +224,5 @@ fn participant_round2( key_package: &KeyPackage, ) -> Result, SignError> { validate_role::(role)?; - round2::sign(signing_package, nonces, key_package).map_err(|e| { - SignError(Reason::SignFailure(SignAborted::FrostError { - parties: vec![], - error: e, - })) - }) + Ok(round2::sign(signing_package, nonces, key_package)?) } From 802ee3b5d1e6ce9b4e8ff4e3574bf8fd56a899c4 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 14 Feb 2024 13:02:24 +0200 Subject: [PATCH 20/66] fix: successful keygen/sign against drew/fix-for-frost --- Cargo.lock | 307 ++++++++++-------- Cargo.toml | 38 +-- README.md | 2 +- protocols/bls/src/protocol/signing.rs | 4 +- protocols/dfns-cggmp21/src/protocols/sign.rs | 12 +- protocols/mp-ecdsa/src/protocols/sign.rs | 2 +- protocols/zcash-frost/src/protocols/keygen.rs | 2 +- protocols/zcash-frost/src/protocols/sign.rs | 21 +- protocols/zcash-frost/src/protocols/util.rs | 22 +- protocols/zcash-frost/src/rounds/keygen.rs | 14 +- protocols/zcash-frost/src/rounds/sign.rs | 37 +-- protocols/zcash-frost/tests/frost.rs | 6 +- 12 files changed, 242 insertions(+), 225 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c027e0b23..5d92d947a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,9 +59,9 @@ dependencies = [ [[package]] name = "aes" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", "cipher", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom 0.2.12", "once_cell", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" dependencies = [ "cfg-if", "getrandom 0.2.12", @@ -1559,9 +1559,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ "android-tzdata", "iana-time-zone", @@ -2089,9 +2089,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] @@ -2380,9 +2380,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de00f15a6fa069c99b88c5c78c4541d0e7899a33b86f7480e23df2431fce0bc" +checksum = "8aff472b83efd22bfc0176aa8ba34617dd5c17364670eb201a5f06d339b8abf7" dependencies = [ "cc", "cxxbridge-flags", @@ -2392,9 +2392,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a71e1e631fa2f2f5f92e8b0d860a00c198c6771623a6cefcc863e3554f0d8d6" +checksum = "bcf6e7a52c19013a9a0ec421c7d9c2d1125faf333551227e0a017288d71b47c3" dependencies = [ "cc", "codespan-reporting", @@ -2407,15 +2407,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f3fed61d56ba497c4efef9144dfdbaa25aa58f2f6b3a7cf441d4591c583745c" +checksum = "589e83d02fc1d4fb78f5ad56ca08835341e23499d086d2821315869426d618dc" [[package]] name = "cxxbridge-macro" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8908e380a8efd42150c017b0cfa31509fc49b6d47f7cb6b33e93ffb8f4e3661e" +checksum = "e2cb1fd8ffae4230c7cfbbaf3698dbeaf750fa8c5dadf7ed897df581b9b572a5" dependencies = [ "proc-macro2", "quote", @@ -3079,9 +3079,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "elliptic-curve" @@ -3213,18 +3213,18 @@ dependencies = [ [[package]] name = "enumflags2" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" +checksum = "3278c9d5fb675e0a51dabcf4c0d355f692b064171535ba72361be1528a9d8e8d" dependencies = [ "enumflags2_derive", ] [[package]] name = "enumflags2_derive" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" +checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" dependencies = [ "proc-macro2", "quote", @@ -3868,7 +3868,7 @@ dependencies = [ [[package]] name = "evm-tracer" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "ethereum-types 0.14.1", "evm", @@ -3888,7 +3888,7 @@ dependencies = [ [[package]] name = "evm-tracing-events" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "environmental", "ethereum", @@ -4533,11 +4533,12 @@ dependencies = [ [[package]] name = "frost-core" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "debugless-unwrap", "hex", "parity-scale-codec 3.6.9", + "postcard", "rand_core 0.6.4", "serde", "serdect", @@ -4548,6 +4549,7 @@ dependencies = [ [[package]] name = "frost-core" version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" dependencies = [ "byteorder", "const-crc32", @@ -4569,19 +4571,7 @@ dependencies = [ [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" -dependencies = [ - "curve25519-dalek-ml", - "document-features", - "frost-core 1.0.0-rc.0", - "frost-rerandomized", - "rand_core 0.6.4", - "sha2 0.10.8", -] - -[[package]] -name = "frost-ed25519" -version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -4592,21 +4582,22 @@ dependencies = [ ] [[package]] -name = "frost-ed448" +name = "frost-ed25519" version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" dependencies = [ + "curve25519-dalek-ml", "document-features", - "ed448-goldilocks-plus 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "frost-core 1.0.0-rc.0", "frost-rerandomized", "rand_core 0.6.4", - "sha3 0.10.8", + "sha2 0.10.8", ] [[package]] name = "frost-ed448" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "ed448-goldilocks-plus 0.11.1 (git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize)", "frost-core 0.6.1", @@ -4617,21 +4608,22 @@ dependencies = [ ] [[package]] -name = "frost-p256" +name = "frost-ed448" version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" dependencies = [ "document-features", + "ed448-goldilocks-plus 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "frost-core 1.0.0-rc.0", "frost-rerandomized", - "p256 0.13.2", "rand_core 0.6.4", - "sha2 0.10.8", + "sha3 0.10.8", ] [[package]] name = "frost-p256" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "frost-core 0.6.1", "p256 0.13.2", @@ -4642,13 +4634,14 @@ dependencies = [ ] [[package]] -name = "frost-p384" +name = "frost-p256" version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" dependencies = [ "document-features", "frost-core 1.0.0-rc.0", "frost-rerandomized", - "p384", + "p256 0.13.2", "rand_core 0.6.4", "sha2 0.10.8", ] @@ -4656,7 +4649,7 @@ dependencies = [ [[package]] name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "frost-core 0.6.1", "p384", @@ -4667,31 +4660,33 @@ dependencies = [ ] [[package]] -name = "frost-rerandomized" +name = "frost-p384" version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" dependencies = [ - "derive-getters", "document-features", "frost-core 1.0.0-rc.0", + "frost-rerandomized", + "p384", "rand_core 0.6.4", + "sha2 0.10.8", ] [[package]] -name = "frost-ristretto255" +name = "frost-rerandomized" version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" dependencies = [ - "curve25519-dalek 4.1.1", + "derive-getters", "document-features", "frost-core 1.0.0-rc.0", - "frost-rerandomized", "rand_core 0.6.4", - "sha2 0.10.8", ] [[package]] name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -4702,13 +4697,14 @@ dependencies = [ ] [[package]] -name = "frost-secp256k1" +name = "frost-ristretto255" version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" dependencies = [ + "curve25519-dalek 4.1.1", "document-features", "frost-core 1.0.0-rc.0", "frost-rerandomized", - "k256", "rand_core 0.6.4", "sha2 0.10.8", ] @@ -4716,7 +4712,7 @@ dependencies = [ [[package]] name = "frost-secp256k1" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "frost-core 0.6.1", "k256", @@ -4726,6 +4722,19 @@ dependencies = [ "subtle", ] +[[package]] +name = "frost-secp256k1" +version = "1.0.0-rc.0" +source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" +dependencies = [ + "document-features", + "frost-core 1.0.0-rc.0", + "frost-rerandomized", + "k256", + "rand_core 0.6.4", + "sha2 0.10.8", +] + [[package]] name = "fs-err" version = "2.11.0" @@ -5221,7 +5230,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.2.2", + "indexmap 2.2.3", "slab", "tokio", "tokio-util", @@ -5270,7 +5279,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.7", + "ahash 0.7.8", ] [[package]] @@ -5279,7 +5288,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.7", + "ahash 0.7.8", ] [[package]] @@ -5288,7 +5297,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.7", + "ahash 0.8.8", ] [[package]] @@ -5297,7 +5306,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.7", + "ahash 0.8.8", "allocator-api2", "serde", ] @@ -5360,9 +5369,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" +checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" [[package]] name = "hex" @@ -5712,9 +5721,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.2" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -5768,7 +5777,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.5", + "hermit-abi 0.3.6", "libc", "windows-sys 0.48.0", ] @@ -5799,11 +5808,11 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe8f25ce1159c7740ff0b9b2f5cdf4a8428742ba7c112b9f20f22cd5219c7dab" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.5", + "hermit-abi 0.3.6", "libc", "windows-sys 0.52.0", ] @@ -6807,6 +6816,29 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "malachite-base" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e960ee0e7e1b8eec9229f5b20d6b191762574225144ea638eb961d065c97b55d" +dependencies = [ + "hashbrown 0.14.3", + "itertools 0.11.0", + "libm", + "ryu", +] + +[[package]] +name = "malachite-nz" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770aaf1a4d59a82ed3d8644eb66aff7492a6dd7476def275a922d04d77ca8e57" +dependencies = [ + "itertools 0.11.0", + "libm", + "malachite-base", +] + [[package]] name = "maplit" version = "1.0.2" @@ -7514,7 +7546,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.5", + "hermit-abi 0.3.6", "libc", ] @@ -7789,7 +7821,7 @@ dependencies = [ [[package]] name = "pallet-airdrop-claims" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "frame-support", "frame-system", @@ -7973,24 +8005,27 @@ dependencies = [ [[package]] name = "pallet-dkg" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "digest 0.10.7", "elliptic-curve 0.13.8", "frame-support", "frame-system", "frost-core 0.6.1", - "frost-ed25519 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", - "frost-ed448 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", - "frost-p256 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", - "frost-p384 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", - "frost-ristretto255 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", - "frost-secp256k1 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework)", + "frost-ed25519 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost)", + "frost-ed448 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost)", + "frost-p256 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost)", + "frost-p384 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost)", + "frost-ristretto255 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost)", + "frost-secp256k1 1.0.0-rc.0 (git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost)", "generic-ec", "generic-ec-zkp", "hex", + "malachite-base", + "malachite-nz", "parity-scale-codec 3.6.9", "postcard", + "rand_chacha 0.3.1", "rand_core 0.6.4", "scale-info", "serde", @@ -8184,7 +8219,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-batch" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "evm", "evm-runtime", @@ -8224,7 +8259,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-call-permit" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "evm", "fp-evm", @@ -8255,7 +8290,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-democracy" version = "0.2.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "fp-evm", "frame-support", @@ -8297,7 +8332,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-jobs" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "fp-evm", "frame-support", @@ -8327,7 +8362,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-preimage" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "fp-evm", "frame-support", @@ -8347,7 +8382,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-proxy" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "evm", "fp-evm", @@ -8369,7 +8404,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-registry" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "fp-evm", "frame-support", @@ -8405,7 +8440,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-staking" version = "1.0.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "fp-evm", "frame-support", @@ -8427,7 +8462,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-vesting" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "evm", "fp-evm", @@ -8556,7 +8591,7 @@ dependencies = [ [[package]] name = "pallet-jobs" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8573,7 +8608,7 @@ dependencies = [ [[package]] name = "pallet-jobs-rpc-runtime-api" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", @@ -8669,7 +8704,7 @@ dependencies = [ [[package]] name = "pallet-roles" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8802,7 +8837,7 @@ dependencies = [ [[package]] name = "pallet-transaction-pause" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "frame-support", "frame-system", @@ -8892,7 +8927,7 @@ dependencies = [ [[package]] name = "pallet-zksaas" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9108,7 +9143,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.2.2", + "indexmap 2.2.3", ] [[package]] @@ -9261,9 +9296,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "platforms" @@ -9379,7 +9414,7 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "affix", "environmental", @@ -9405,7 +9440,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "case", "num_enum 0.5.11", @@ -9517,7 +9552,7 @@ dependencies = [ [[package]] name = "primitives-ext" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "ethereum-types 0.14.1", "evm-tracing-events", @@ -10463,7 +10498,7 @@ dependencies = [ [[package]] name = "rpc-primitives-debug" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "environmental", "ethereum", @@ -10481,7 +10516,7 @@ dependencies = [ [[package]] name = "rpc-primitives-txpool" version = "0.6.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "ethereum", "parity-scale-codec 3.6.9", @@ -11212,7 +11247,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.7", + "ahash 0.8.8", "cfg-if", "hashbrown 0.13.2", ] @@ -11575,7 +11610,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.2", + "indexmap 2.2.3", "serde", "serde_derive", "serde_json", @@ -13170,7 +13205,7 @@ version = "22.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4eeb7ef23f79eba8609db79ef9cef242f994f1f87a3c0387b4b5f177fda74" dependencies = [ - "ahash 0.8.7", + "ahash 0.8.8", "hash-db 0.16.0", "hashbrown 0.13.2", "lazy_static", @@ -13193,7 +13228,7 @@ name = "sp-trie" version = "22.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "ahash 0.8.7", + "ahash 0.8.8", "hash-db 0.16.0", "hashbrown 0.13.2", "lazy_static", @@ -13217,7 +13252,7 @@ version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9c4bf89a5bd74f696cd1f23d83bb6abe6bd0abad1f3c70d4b0d7ebec4098cfe" dependencies = [ - "ahash 0.8.7", + "ahash 0.8.8", "hash-db 0.16.0", "hashbrown 0.13.2", "lazy_static", @@ -13888,7 +13923,7 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -13898,7 +13933,7 @@ dependencies = [ [[package]] name = "tangle-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "ark-bn254", "ark-crypto-primitives", @@ -13925,7 +13960,7 @@ dependencies = [ [[package]] name = "tangle-runtime" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "evm-tracer", "fp-account", @@ -14027,7 +14062,7 @@ dependencies = [ [[package]] name = "tangle-testnet-runtime" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/sig-renaming-rework#8774446af41d523fccd51e807a979759f3a50116" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" dependencies = [ "evm-tracer", "fp-account", @@ -14261,18 +14296,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", @@ -14548,7 +14583,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.2", + "indexmap 2.2.3", "serde", "serde_spanned", "toml_datetime", @@ -14561,7 +14596,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap 2.2.2", + "indexmap 2.2.3", "serde", "serde_spanned", "toml_datetime", @@ -15295,9 +15330,9 @@ checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-encoder" -version = "0.41.1" +version = "0.41.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce14de623d48dda4c10698c4dadae2366b5c2c8e81bad981d5a0625a5fcf68c" +checksum = "972f97a5d8318f908dded23594188a90bcd09365986b1163e66d70170e5287ae" dependencies = [ "leb128", ] @@ -15850,9 +15885,9 @@ dependencies = [ [[package]] name = "wast" -version = "71.0.0" +version = "71.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a10dad39ea4623ed4c304fb42bd455eca6d212f7e5e0cb59681fed7e4d128a2e" +checksum = "647c3ac4354da32688537e8fc4d2fe6c578df51896298cb64727d98088a1fd26" dependencies = [ "bumpalo", "leb128", @@ -15863,9 +15898,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.86" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b724419d3bffeff174745b924f6ed053095ac58f9ae72e87d2e0f8ef6df6df96" +checksum = "b69c36f634411568a2c6d24828b674961e37ea03340fe1d605c337ed8162d901" dependencies = [ "wast", ] @@ -16073,7 +16108,7 @@ dependencies = [ [[package]] name = "webb-proposal-derive" version = "0.1.0" -source = "git+https://github.com/webb-tools/webb-rs.git#1f0d2635971b2d9c36af4bc0bd1501d0b2a1e675" +source = "git+https://github.com/webb-tools/webb-rs.git#a19d65bfa4218f5809feafca6a101cab5f3a4e0d" dependencies = [ "ethers-core", "quote", @@ -16083,7 +16118,7 @@ dependencies = [ [[package]] name = "webb-proposals" version = "0.8.0" -source = "git+https://github.com/webb-tools/webb-rs.git#1f0d2635971b2d9c36af4bc0bd1501d0b2a1e675" +source = "git+https://github.com/webb-tools/webb-rs.git#a19d65bfa4218f5809feafca6a101cab5f3a4e0d" dependencies = [ "frame-support", "hex", @@ -16477,9 +16512,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.39" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] @@ -16630,13 +16665,13 @@ dependencies = [ "digest 0.10.7", "frame-support", "frost-core 1.0.0-rc.0", - "frost-ed25519 1.0.0-rc.0", - "frost-ed448 1.0.0-rc.0", - "frost-p256 1.0.0-rc.0", - "frost-p384 1.0.0-rc.0", + "frost-ed25519 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-ed448 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-p256 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-p384 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", "frost-rerandomized", - "frost-ristretto255 1.0.0-rc.0", - "frost-secp256k1 1.0.0-rc.0", + "frost-ristretto255 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-secp256k1 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", "futures", "gadget-common", "gadget-core", diff --git a/Cargo.toml b/Cargo.toml index 437ebb679..22f1a96b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,35 +28,27 @@ zcash-frost-protocol = { path = "./protocols/zcash-frost" } snowbridge-milagro-bls = { git = "https://github.com/Snowfork/milagro_bls", rev = "43a5d480ed6e3b83de4cf54888680d51604199e6" } gennaro-dkg = { git = "https://github.com/mikelodder7/gennaro-dkg.git" } -pallet-jobs-rpc-runtime-api = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} -pallet-jobs = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} -pallet-dkg = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} -pallet-zksaas = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} -tangle-primitives = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} -tangle-testnet-runtime = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} -tangle-mainnet-runtime = { package = "tangle-runtime", git = "https://github.com/webb-tools/tangle.git", branch = "drew/sig-renaming-rework"} +pallet-jobs-rpc-runtime-api = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/fix-for-frost"} +pallet-jobs = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/fix-for-frost"} +pallet-dkg = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/fix-for-frost"} +pallet-zksaas = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/fix-for-frost"} +tangle-primitives = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/fix-for-frost"} +tangle-testnet-runtime = { git = "https://github.com/webb-tools/tangle.git", branch = "drew/fix-for-frost"} +tangle-mainnet-runtime = { package = "tangle-runtime", git = "https://github.com/webb-tools/tangle.git", branch = "drew/fix-for-frost"} multi-party-ecdsa = { git = "https://github.com/webb-tools/cggmp-threshold-ecdsa/" } round-based = { git = "https://github.com/webb-tools/round-based-protocol", features = [] } curv = { package = "curv-kzen", version = "0.10.0" } dfns-cggmp21 = { package = "cggmp21", version = "0.1.1", default-features = false } udigest = { version = "0.1", features = ["std", "derive"]} -# frost-core = { git = "https://github.com/LIT-Protocol/frost.git" } -# frost-ed25519 = { git = "https://github.com/LIT-Protocol/frost.git" } -# frost-ed448 = { git = "https://github.com/LIT-Protocol/frost.git" } -# frost-p256 = { git = "https://github.com/LIT-Protocol/frost.git" } -# frost-p384 = { git = "https://github.com/LIT-Protocol/frost.git" } -# frost-ristretto255 = { git = "https://github.com/LIT-Protocol/frost.git" } -# frost-secp256k1 = { git = "https://github.com/LIT-Protocol/frost.git" } -# frost-rerandomized = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-core = { path = "../frost/frost-core" } -frost-ed25519 = { path = "../frost/frost-ed25519" } -frost-ed448 = { path = "../frost/frost-ed448" } -frost-p256 = { path = "../frost/frost-p256" } -frost-p384 = { path = "../frost/frost-p384" } -frost-ristretto255 = { path = "../frost/frost-ristretto255" } -frost-secp256k1 = { path = "../frost/frost-secp256k1" } -frost-rerandomized = { path = "../frost/frost-rerandomized" } +frost-core = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-ed25519 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-ed448 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-p256 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-p384 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-ristretto255 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-secp256k1 = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-rerandomized = { git = "https://github.com/LIT-Protocol/frost.git" } bls12_381_plus = "0.8.13" sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } diff --git a/README.md b/README.md index 27bf0a2d7..0c4821bde 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Currently the repo is built around Substrate blockchain logic and networking. Th ## Testing -`cargo nextest run` is required to run tests, since 1-program per-program space is required for tests due to the nature of the use of static variables in test-only contexts. +`SKIP_WASM_BUILD=true RUST_LOG=debug cargo nextest run` is required to run tests, since 1-program per-program space is required for tests due to the nature of the use of static variables in test-only contexts. There is currently an issue with the WASM build so the `SKIP_WASM_BUILD` flag is required. The `RUST_LOG=debug` flag is optional but useful for debugging. ## Troubleshooting #### GMP Issues diff --git a/protocols/bls/src/protocol/signing.rs b/protocols/bls/src/protocol/signing.rs index 1d1e394e8..45cf0039c 100644 --- a/protocols/bls/src/protocol/signing.rs +++ b/protocols/bls/src/protocol/signing.rs @@ -299,7 +299,7 @@ where }); } - let signing_key = as_pk.as_uncompressed_bytes().to_vec(); + let verifying_key = as_pk.as_uncompressed_bytes().to_vec(); let signature = as_sig.as_bytes().to_vec(); logger.info("BlsSigningProtocol finished verification stage"); @@ -311,7 +311,7 @@ where .try_into() .unwrap(), signature: signature.try_into().unwrap(), - signing_key: signing_key.try_into().unwrap(), + verifying_key: verifying_key.try_into().unwrap(), }); *result.lock().await = Some(job_result); diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index 86d3875ca..fae4b1c54 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -254,9 +254,8 @@ where let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let delivery = (signing_rx_async_proto, signing_tx_to_outbound); let party = dfns_cggmp21::round_based::MpcParty::connected(delivery); - let data_hash = keccak_256(&input_data_to_sign); let data_to_sign = dfns_cggmp21::DataToSign::from_scalar( - dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(data_hash), + dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(input_data_to_sign), ); let signature = dfns_cggmp21::signing(eid, i, &signers, &key) .set_progress_tracer(&mut tracer) @@ -286,10 +285,11 @@ where let mut v = 0u8; loop { let mut signature_bytes = signature_bytes; - let data_hash = keccak_256(&input_data_to_sign2); signature_bytes[64] = v; - let res = - sp_io::crypto::secp256k1_ecdsa_recover(&signature_bytes, &data_hash); + let res = sp_io::crypto::secp256k1_ecdsa_recover( + &signature_bytes, + &input_data_to_sign2, + ); match res { Ok(key) if key[..32] == public_key_bytes[1..] => { // Found the correct v @@ -320,7 +320,7 @@ where signature_scheme: DigitalSignatureScheme::Ecdsa, data: additional_params.input_data_to_sign.try_into().unwrap(), signature: signature_bytes.to_vec().try_into().unwrap(), - signing_key: public_key_bytes.try_into().unwrap(), + verifying_key: public_key_bytes.try_into().unwrap(), }); client diff --git a/protocols/mp-ecdsa/src/protocols/sign.rs b/protocols/mp-ecdsa/src/protocols/sign.rs index 72a8fe195..7327b4ff5 100644 --- a/protocols/mp-ecdsa/src/protocols/sign.rs +++ b/protocols/mp-ecdsa/src/protocols/sign.rs @@ -343,7 +343,7 @@ where signature_scheme: DigitalSignatureScheme::Ecdsa, data: additional_params.input_data_to_sign.try_into().unwrap(), signature, - signing_key: public_key_bytes.try_into().unwrap(), + verifying_key: public_key_bytes.try_into().unwrap(), }); client diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index 6447ad374..964c144e7 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -333,7 +333,7 @@ where let job_result = handle_public_key_gossip( key_store2, &logger, - &frost_key_share_package.pubkey_package, + &frost_key_share_package.verifying_key, role, t, i, diff --git a/protocols/zcash-frost/src/protocols/sign.rs b/protocols/zcash-frost/src/protocols/sign.rs index d38d63cec..e86cd7911 100644 --- a/protocols/zcash-frost/src/protocols/sign.rs +++ b/protocols/zcash-frost/src/protocols/sign.rs @@ -1,4 +1,5 @@ use async_trait::async_trait; +use frame_support::BoundedVec; use frost_core::keys::{KeyPackage, PublicKeyPackage}; use frost_ed25519::Ed25519Sha512; use frost_p256::P256Sha256; @@ -177,7 +178,7 @@ where } macro_rules! deserialize_and_run_threshold_sign { - ($impl_type:ty, $keyshare:expr, $tracer:expr, $i:expr, $signers:expr, $data_hash:expr, $role:expr, $rng:expr, $party:expr) => {{ + ($impl_type:ty, $keyshare:expr, $tracer:expr, $i:expr, $signers:expr, $msg:expr, $role:expr, $rng:expr, $party:expr) => {{ let key_package = KeyPackage::<$impl_type>::deserialize(&$keyshare.key_package).map_err(|err| { JobError { @@ -191,12 +192,13 @@ macro_rules! deserialize_and_run_threshold_sign { .map_err(|err| JobError { reason: format!("Failed to deserialize public key package: {err:?}"), })?; + rounds::sign::run_threshold_sign( Some($tracer), $i, $signers, (key_package, public_key_package), - $data_hash, + $msg, $role, $rng, $party, @@ -267,8 +269,6 @@ where } }; - let keyshare2 = keyshare.clone(); - Ok(JobBuilder::new() .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); @@ -298,7 +298,6 @@ where let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let delivery = (signing_rx_async_proto, signing_tx_to_outbound); let party = MpcParty::connected(delivery); - let data_hash = keccak_256(&input_data_to_sign); let signature = match role { ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { deserialize_and_run_threshold_sign!( @@ -307,7 +306,7 @@ where &mut tracer, i, signers, - &data_hash, + &input_data_to_sign, role, &mut rng, party @@ -320,7 +319,7 @@ where &mut tracer, i, signers, - &data_hash, + &input_data_to_sign, role, &mut rng, party @@ -333,7 +332,7 @@ where &mut tracer, i, signers, - &data_hash, + &input_data_to_sign, role, &mut rng, party @@ -346,7 +345,7 @@ where &mut tracer, i, signers, - &data_hash, + &input_data_to_sign, role, &mut rng, party @@ -401,7 +400,7 @@ where signature_bytes.copy_from_slice(&signature.group_signature); ( signature_bytes.to_vec().try_into().unwrap(), - DigitalSignatureScheme::SchnorrSr25519, + DigitalSignatureScheme::SchnorrRistretto255, ) } _ => { @@ -415,7 +414,7 @@ where signature_scheme, data: additional_params.input_data_to_sign.try_into().unwrap(), signature, - signing_key: keyshare2.pubkey_package.try_into().unwrap(), + verifying_key: BoundedVec::new(), }); client diff --git a/protocols/zcash-frost/src/protocols/util.rs b/protocols/zcash-frost/src/protocols/util.rs index 9bb7eb0bc..65bb0b862 100644 --- a/protocols/zcash-frost/src/protocols/util.rs +++ b/protocols/zcash-frost/src/protocols/util.rs @@ -7,7 +7,6 @@ use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::network::Network; use gadget_common::gadget::work_manager::WorkManager; use gadget_core::job_manager::WorkManagerInterface; -use itertools::Itertools; use rand::seq::SliceRandom; use round_based::{Incoming, MessageDestination, MessageType, Outgoing, PartyIndex}; use serde::de::DeserializeOwned; @@ -478,15 +477,28 @@ pub fn choose_signers( let selected_participants_indices = selected_participants .iter() .map(|p| participants.iter().position(|x| x == p).unwrap() as u16) - // .sorted() .collect::>(); + let mut selected_participants_with_indices: Vec<(u16, AccountId)> = + selected_participants_indices + .iter() + .cloned() + .zip(selected_participants.into_iter()) + .collect(); + + selected_participants_with_indices.sort_by_key(|&(index, _)| index); + + let (sorted_selected_participants_indices, sorted_selected_participants): ( + Vec, + Vec, + ) = selected_participants_with_indices.into_iter().unzip(); + let j = participants .iter() .position(|p| p == my_account_id) .expect("Should exist") as u16; - let i = selected_participants_indices + let i = sorted_selected_participants_indices .iter() .position(|p| p == &j) .map(|i| i as u16) @@ -495,7 +507,7 @@ pub fn choose_signers( reason: String::from("we are not selected to sign"), })?; - let user_id_to_account_id_mapping = selected_participants + let user_id_to_account_id_mapping = sorted_selected_participants .clone() .into_iter() .enumerate() @@ -503,7 +515,7 @@ pub fn choose_signers( .collect(); Ok(( i, - selected_participants_indices, + sorted_selected_participants_indices, user_id_to_account_id_mapping, )) } diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 387ae70e7..296fc2c77 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -59,6 +59,7 @@ pub struct MsgRound3 { pub struct FrostKeyShare { pub key_package: Vec, pub pubkey_package: Vec, + pub verifying_key: Vec, } pub async fn run_threshold_keygen( @@ -88,9 +89,7 @@ where // Round 1 tracer.round_begins(); - tracer.stage("Compute round 1 dkg secret package"); - println!("Keygen | i: {}, t: {}, n: {}", i, t, n); let (round1_secret_package, round1_package) = dkg_part1(i + 1, t, n, role, rng).map_err(|e| { KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { @@ -125,7 +124,6 @@ where }) .collect(); tracer.msgs_received(); - // println!("Keygen | i: {}, my_package: {:#?}", i, round1_package); tracer.stage("Compute round 2 dkg secret package"); let round1_packages_map: BTreeMap, round1::Package> = round1_packages .iter() @@ -138,7 +136,6 @@ where ) }) .collect(); - // println!("Keygen | round1_packages_map: {:#?}", round1_packages_map); let (round2_secret_package, round2_packages_map) = dkg_part2(role, round1_secret_package, &round1_packages_map)?; @@ -146,12 +143,6 @@ where for (receiver_identifier, round2_package) in round2_packages_map { let receiver_index_bytes: Vec = receiver_identifier.serialize().as_ref().to_vec(); let receiver_index = u16::from_le_bytes([receiver_index_bytes[0], receiver_index_bytes[1]]); - println!( - "Sender ID: {:#?}, Sender: {}, Receiver: {}", - round2_secret_package.identifier, - i, - receiver_index - 1 - ); outgoings .send(Outgoing::p2p( receiver_index - 1, @@ -195,11 +186,10 @@ where )?; tracer.protocol_ends(); - println!("Finished KEYGEN!"); - println!("Key Package for {}: {:#?}", i, key_package); Ok(FrostKeyShare { key_package: key_package.serialize().unwrap_or_default(), pubkey_package: pubkey_package.serialize().unwrap_or_default(), + verifying_key: pubkey_package.verifying_key().serialize().as_ref().to_vec(), }) } diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index 59cd45a7c..bc0a3258e 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -8,6 +8,7 @@ use rand_core::{CryptoRng, RngCore}; use round_based::rounds_router::simple_store::RoundInput; use round_based::rounds_router::RoundsRouter; +use round_based::runtime::AsyncRuntime; use round_based::ProtocolMessage; use round_based::{Delivery, Mpc, MpcParty, Outgoing}; use serde::{Deserialize, Serialize}; @@ -67,9 +68,10 @@ where tracer.protocol_begins(); tracer.stage("Setup networking"); - let MpcParty { delivery, .. } = party.into_party(); + let MpcParty { + delivery, runtime, .. + } = party.into_party(); let (incomings, mut outgoings) = delivery.split(); - println!("Signers: {:?}", signers); let mut rounds = RoundsRouter::::builder(); let round1 = rounds.add_round(RoundInput::::broadcast(i, signers.len() as u16)); let round2 = rounds.add_round(RoundInput::::broadcast(i, signers.len() as u16)); @@ -77,19 +79,13 @@ where // Round 1 tracer.round_begins(); - - tracer.send_msg(); tracer.stage("Generate nonces and commitments for Round 1"); let (nonces, commitments) = participant_round1(role, &frost_keyshare.0, rng)?; + runtime.yield_now().await; + tracer.send_msg(); let my_round1_msg = MsgRound1 { msg: commitments.serialize().unwrap_or_default(), }; - println!( - " for party {:?}: <{:#?}, {:#?}>", - i, - frost_keyshare.0.identifier(), - commitments - ); outgoings .send(Outgoing::broadcast(Msg::Round1(my_round1_msg.clone()))) .await @@ -100,14 +96,12 @@ where tracer.round_begins(); tracer.receive_msgs(); - println!("Receiving Round 1 messages"); let round1_msgs: Vec = rounds .complete(round1) .await .map_err(IoError::receive_message)? .into_vec_including_me(my_round1_msg); - println!("Received Round 1 messages"); let round1_signing_commitments = round1_msgs .into_iter() .enumerate() @@ -119,19 +113,13 @@ where (participant_identifier, msg) }) .collect(); - - println!( - "Received signing commitments: {:#?}", - round1_signing_commitments - ); tracer.msgs_received(); - tracer.send_msg(); - tracer.stage( - "Produce signature share using the `SigningPackage` and `SigningNonces` from Round 1", - ); + tracer.stage("Produce signature share using the Round 1 data"); let signing_package = SigningPackage::::new(round1_signing_commitments, message_to_sign); let signature_share = participant_round2(role, &signing_package, &nonces, &frost_keyshare.0)?; + runtime.yield_now().await; + tracer.send_msg(); outgoings .send(Outgoing::broadcast(Msg::Round2(MsgRound2 { msg: signature_share.serialize().as_ref().to_vec(), @@ -144,7 +132,6 @@ where tracer.round_begins(); tracer.receive_msgs(); - println!("Receiving Round 2 messages"); let round2_signature_shares: BTreeMap, SignatureShare> = rounds .complete(round2) .await @@ -165,9 +152,9 @@ where (participant_identifier, sig_share) }) .collect(); - println!("Received Round 2 messages"); tracer.msgs_received(); + tracer.stage("Aggregate signature shares"); let group_signature = aggregate( &signing_package, &round2_signature_shares, @@ -181,10 +168,10 @@ where .is_err() { return Err(frost_core::Error::::InvalidSignature.into()); + } else { + tracer.protocol_ends(); } - tracer.protocol_ends(); - Ok(FrostSignature { group_signature: group_signature.serialize().as_ref().to_vec(), }) diff --git a/protocols/zcash-frost/tests/frost.rs b/protocols/zcash-frost/tests/frost.rs index 90e4805cc..9343d2470 100644 --- a/protocols/zcash-frost/tests/frost.rs +++ b/protocols/zcash-frost/tests/frost.rs @@ -2,6 +2,7 @@ mod tests { use futures::stream::FuturesUnordered; use futures::StreamExt; + use sp_core::keccak_256; use tangle_primitives::jobs::{ DKGTSSPhaseOneJobType, DKGTSSPhaseTwoJobType, JobId, JobSubmission, JobType, }; @@ -104,7 +105,8 @@ mod tests { ) -> JobId { let job_id = ext .execute_with_async(move || { - let submission = Vec::from("Hello, world!"); + let msg = Vec::from("Hello, world!"); + let submission = keccak_256(&msg); let job_id = Jobs::next_job_id(); let identities = (0..N).map(|i| id_to_public(i as u8)).collect::>(); let submission = JobSubmission { @@ -112,7 +114,7 @@ mod tests { ttl: 100, job_type: JobType::DKGTSSPhaseTwo(DKGTSSPhaseTwoJobType { phase_one_id: keygen_job_id, - submission: submission.try_into().unwrap(), + submission: submission.to_vec().try_into().unwrap(), role_type: ThresholdSignatureRoleType::ZcashFrostRistretto255, }), }; From 6d22dacfeae73974af05e044d5949e3bb73f4c16 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 14 Feb 2024 14:04:06 +0200 Subject: [PATCH 21/66] add remaining sig schemes, more cleanup --- Cargo.lock | 92 ++++--- protocols/dfns-cggmp21/Cargo.toml | 1 + .../dfns-cggmp21/src/protocols/keygen.rs | 51 +--- protocols/dfns-cggmp21/src/protocols/sign.rs | 6 +- protocols/mp-ecdsa/Cargo.toml | 1 + protocols/mp-ecdsa/src/protocols/keygen.rs | 51 +--- protocols/zcash-frost/Cargo.toml | 1 + protocols/zcash-frost/src/protocol.rs | 2 - protocols/zcash-frost/src/protocols/keygen.rs | 79 +++--- protocols/zcash-frost/src/protocols/sign.rs | 44 ++++ protocols/zcash-frost/src/rounds/keygen.rs | 78 +++--- protocols/zcash-frost/src/rounds/mod.rs | 2 + protocols/zcash-frost/src/rounds/sign.rs | 4 +- protocols/zcash-frost/tests/frost.rs | 224 ++++++++++++++++-- 14 files changed, 372 insertions(+), 264 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d92d947a..d400a5a4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1069,8 +1069,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" dependencies = [ "bitcoin_hashes", - "rand 0.8.5", - "rand_core 0.6.4", + "rand 0.6.5", + "rand_core 0.4.2", "serde", "unicode-normalization", ] @@ -2676,6 +2676,7 @@ dependencies = [ "hex", "itertools 0.12.1", "log", + "pallet-dkg", "pallet-jobs", "pallet-jobs-rpc-runtime-api", "parity-scale-codec 3.6.9", @@ -3868,7 +3869,7 @@ dependencies = [ [[package]] name = "evm-tracer" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "ethereum-types 0.14.1", "evm", @@ -3888,7 +3889,7 @@ dependencies = [ [[package]] name = "evm-tracing-events" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "environmental", "ethereum", @@ -4533,7 +4534,7 @@ dependencies = [ [[package]] name = "frost-core" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "debugless-unwrap", "hex", @@ -4571,7 +4572,7 @@ dependencies = [ [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -4597,7 +4598,7 @@ dependencies = [ [[package]] name = "frost-ed448" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "ed448-goldilocks-plus 0.11.1 (git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize)", "frost-core 0.6.1", @@ -4623,7 +4624,7 @@ dependencies = [ [[package]] name = "frost-p256" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "frost-core 0.6.1", "p256 0.13.2", @@ -4649,7 +4650,7 @@ dependencies = [ [[package]] name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "frost-core 0.6.1", "p384", @@ -4686,7 +4687,7 @@ dependencies = [ [[package]] name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -4712,7 +4713,7 @@ dependencies = [ [[package]] name = "frost-secp256k1" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "frost-core 0.6.1", "k256", @@ -5520,7 +5521,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.13", - "socket2 0.5.5", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -5568,7 +5569,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core 0.52.0", + "windows-core", ] [[package]] @@ -7112,6 +7113,7 @@ dependencies = [ "itertools 0.12.1", "log", "multi-party-ecdsa", + "pallet-dkg", "pallet-jobs", "pallet-jobs-rpc-runtime-api", "parity-scale-codec 3.6.9", @@ -7821,7 +7823,7 @@ dependencies = [ [[package]] name = "pallet-airdrop-claims" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "frame-support", "frame-system", @@ -8005,7 +8007,7 @@ dependencies = [ [[package]] name = "pallet-dkg" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "digest 0.10.7", "elliptic-curve 0.13.8", @@ -8219,7 +8221,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-batch" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "evm", "evm-runtime", @@ -8259,7 +8261,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-call-permit" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "evm", "fp-evm", @@ -8290,7 +8292,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-democracy" version = "0.2.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "fp-evm", "frame-support", @@ -8332,7 +8334,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-jobs" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "fp-evm", "frame-support", @@ -8362,7 +8364,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-preimage" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "fp-evm", "frame-support", @@ -8382,7 +8384,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-proxy" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "evm", "fp-evm", @@ -8404,7 +8406,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-registry" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "fp-evm", "frame-support", @@ -8440,7 +8442,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-staking" version = "1.0.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "fp-evm", "frame-support", @@ -8462,7 +8464,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-vesting" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "evm", "fp-evm", @@ -8591,7 +8593,7 @@ dependencies = [ [[package]] name = "pallet-jobs" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "frame-benchmarking", "frame-support", @@ -8608,7 +8610,7 @@ dependencies = [ [[package]] name = "pallet-jobs-rpc-runtime-api" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", @@ -8704,7 +8706,7 @@ dependencies = [ [[package]] name = "pallet-roles" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8837,7 +8839,7 @@ dependencies = [ [[package]] name = "pallet-transaction-pause" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "frame-support", "frame-system", @@ -8927,7 +8929,7 @@ dependencies = [ [[package]] name = "pallet-zksaas" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "frame-benchmarking", "frame-support", @@ -9414,7 +9416,7 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "affix", "environmental", @@ -9440,7 +9442,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "case", "num_enum 0.5.11", @@ -9552,7 +9554,7 @@ dependencies = [ [[package]] name = "primitives-ext" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "ethereum-types 0.14.1", "evm-tracing-events", @@ -10498,7 +10500,7 @@ dependencies = [ [[package]] name = "rpc-primitives-debug" version = "0.1.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "environmental", "ethereum", @@ -10516,7 +10518,7 @@ dependencies = [ [[package]] name = "rpc-primitives-txpool" version = "0.6.0" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "ethereum", "parity-scale-codec 3.6.9", @@ -13923,7 +13925,7 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -13933,7 +13935,7 @@ dependencies = [ [[package]] name = "tangle-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "ark-bn254", "ark-crypto-primitives", @@ -13960,7 +13962,7 @@ dependencies = [ [[package]] name = "tangle-runtime" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "evm-tracer", "fp-account", @@ -14062,7 +14064,7 @@ dependencies = [ [[package]] name = "tangle-testnet-runtime" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#8da89c4c7b8000c4dce3e084cac7448c3058216c" +source = "git+https://github.com/webb-tools/tangle.git?branch=drew/fix-for-frost#688b9e1d1d79dc09166bc70d84e0d4a3e62a955d" dependencies = [ "evm-tracer", "fp-account", @@ -14888,7 +14890,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.8.5", + "rand 0.4.6", "static_assertions", ] @@ -16247,7 +16249,7 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows-core 0.51.1", + "windows-core", "windows-targets 0.48.5", ] @@ -16260,15 +16262,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.0", -] - [[package]] name = "windows-sys" version = "0.33.0" @@ -16678,6 +16671,7 @@ dependencies = [ "hex", "itertools 0.12.1", "log", + "pallet-dkg", "pallet-jobs", "pallet-jobs-rpc-runtime-api", "parity-scale-codec 3.6.9", diff --git a/protocols/dfns-cggmp21/Cargo.toml b/protocols/dfns-cggmp21/Cargo.toml index 345a2cd8e..88cd49d5f 100644 --- a/protocols/dfns-cggmp21/Cargo.toml +++ b/protocols/dfns-cggmp21/Cargo.toml @@ -21,6 +21,7 @@ bincode2 = { workspace = true } pallet-jobs-rpc-runtime-api = { workspace = true, features = ["std"] } pallet-jobs = { workspace = true, features = ["std"] } +pallet-dkg = { workspace = true, features = ["std"] } tangle-primitives = { workspace = true, features = ["std"] } sp-core = { workspace = true, features = ["std"] } diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 8ed79f9c5..6a6199584 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -17,6 +17,8 @@ use gadget_common::{Block, BlockImportNotification}; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use itertools::Itertools; +use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; +use pallet_dkg::signatures_schemes::to_slice_33; use rand::SeedableRng; use sc_client_api::Backend; use sp_api::ProvideRuntimeApi; @@ -512,52 +514,3 @@ fn verify_generated_dkg_key_ecdsa( data.threshold + 1 )); } - -pub fn verify_signer_from_set_ecdsa( - maybe_signers: Vec, - msg: &[u8], - signature: &[u8], -) -> (Option, bool) { - let mut signer = None; - let res = maybe_signers.iter().any(|x| { - if let Some(data) = recover_ecdsa_pub_key(msg, signature) { - let recovered = &data[..32]; - if x.0[1..].to_vec() == recovered.to_vec() { - signer = Some(*x); - true - } else { - false - } - } else { - false - } - }); - - (signer, res) -} - -pub fn recover_ecdsa_pub_key(data: &[u8], signature: &[u8]) -> Option> { - const SIGNATURE_LENGTH: usize = 65; - if signature.len() != SIGNATURE_LENGTH { - return None; - } - let mut sig = [0u8; SIGNATURE_LENGTH]; - sig[..SIGNATURE_LENGTH].copy_from_slice(signature); - - let hash = keccak_256(data); - - sp_io::crypto::secp256k1_ecdsa_recover(&sig, &hash) - .ok() - .map(|x| x.to_vec()) -} - -pub fn to_slice_33(val: &[u8]) -> Option<[u8; 33]> { - const ECDSA_KEY_LENGTH: usize = 33; - if val.len() == ECDSA_KEY_LENGTH { - let mut key = [0u8; ECDSA_KEY_LENGTH]; - key[..ECDSA_KEY_LENGTH].copy_from_slice(val); - - return Some(key); - } - None -} diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index fae4b1c54..b10a2d22c 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -286,9 +286,13 @@ where loop { let mut signature_bytes = signature_bytes; signature_bytes[64] = v; + let res = sp_io::crypto::secp256k1_ecdsa_recover( &signature_bytes, - &input_data_to_sign2, + &input_data_to_sign2 + .clone() + .try_into() + .expect("Expected a 32-byte array"), ); match res { Ok(key) if key[..32] == public_key_bytes[1..] => { diff --git a/protocols/mp-ecdsa/Cargo.toml b/protocols/mp-ecdsa/Cargo.toml index 05014ed6b..557e2a095 100644 --- a/protocols/mp-ecdsa/Cargo.toml +++ b/protocols/mp-ecdsa/Cargo.toml @@ -22,6 +22,7 @@ bincode2 = { workspace = true } pallet-jobs-rpc-runtime-api = { workspace = true, features = ["std"] } pallet-jobs = { workspace = true, features = ["std"] } +pallet-dkg = { workspace = true, features = ["std"] } tangle-primitives = { workspace = true, features = ["std"] } sp-core = { workspace = true, features = ["std"] } diff --git a/protocols/mp-ecdsa/src/protocols/keygen.rs b/protocols/mp-ecdsa/src/protocols/keygen.rs index 8d4968b69..5ec54fcf6 100644 --- a/protocols/mp-ecdsa/src/protocols/keygen.rs +++ b/protocols/mp-ecdsa/src/protocols/keygen.rs @@ -19,6 +19,8 @@ use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use itertools::Itertools; use multi_party_ecdsa::gg_2020::state_machine::keygen::{Keygen, LocalKey}; +use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; +use pallet_dkg::signatures_schemes::to_slice_33; use round_based::async_runtime::watcher::StderrWatcher; use round_based::{Msg, StateMachine}; use sc_client_api::Backend; @@ -494,52 +496,3 @@ fn verify_generated_dkg_key_ecdsa( data.threshold + 1 )); } - -pub fn verify_signer_from_set_ecdsa( - maybe_signers: Vec, - msg: &[u8], - signature: &[u8], -) -> (Option, bool) { - let mut signer = None; - let res = maybe_signers.iter().any(|x| { - if let Some(data) = recover_ecdsa_pub_key(msg, signature) { - let recovered = &data[..32]; - if x.0[1..].to_vec() == recovered.to_vec() { - signer = Some(*x); - true - } else { - false - } - } else { - false - } - }); - - (signer, res) -} - -pub fn recover_ecdsa_pub_key(data: &[u8], signature: &[u8]) -> Option> { - const SIGNATURE_LENGTH: usize = 65; - if signature.len() != SIGNATURE_LENGTH { - return None; - } - let mut sig = [0u8; SIGNATURE_LENGTH]; - sig[..SIGNATURE_LENGTH].copy_from_slice(signature); - - let hash = keccak_256(data); - - sp_io::crypto::secp256k1_ecdsa_recover(&sig, &hash) - .ok() - .map(|x| x.to_vec()) -} - -pub fn to_slice_33(val: &[u8]) -> Option<[u8; 33]> { - const ECDSA_KEY_LENGTH: usize = 33; - if val.len() == ECDSA_KEY_LENGTH { - let mut key = [0u8; ECDSA_KEY_LENGTH]; - key[..ECDSA_KEY_LENGTH].copy_from_slice(val); - - return Some(key); - } - None -} diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml index 4c857b5da..5748ed836 100644 --- a/protocols/zcash-frost/Cargo.toml +++ b/protocols/zcash-frost/Cargo.toml @@ -34,6 +34,7 @@ frost-rerandomized = { workspace = true } pallet-jobs-rpc-runtime-api = { workspace = true, features = ["std"] } pallet-jobs = { workspace = true, features = ["std"] } +pallet-dkg = { workspace = true, features = ["std"] } tangle-primitives = { workspace = true, features = ["std"] } sp-core = { workspace = true, features = ["std"] } diff --git a/protocols/zcash-frost/src/protocol.rs b/protocols/zcash-frost/src/protocol.rs index dcd3a7408..7a3929cd8 100644 --- a/protocols/zcash-frost/src/protocol.rs +++ b/protocols/zcash-frost/src/protocol.rs @@ -51,8 +51,6 @@ where let job_id = job.job_id; let role_type = job.job_type.get_role_type(); - // ZcashFrostSr25519 | ZcashFrostP256 | ZcashFrostSecp256k1 | ZcashFrostRistretto255 | ZcashFrostEd25519 - // We can safely make this assumption because we are only creating jobs for phase one let JobType::DKGTSSPhaseOne(p1_job) = job.job_type else { diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index 964c144e7..058efb8a2 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -1,6 +1,8 @@ use async_trait::async_trait; use frost_ed25519::Ed25519Sha512; +use frost_ed448::Ed448Shake256; use frost_p256::P256Sha256; +use frost_p384::P384Sha384; use frost_ristretto255::Ristretto255Sha512; use frost_secp256k1::Secp256K1Sha256; use futures::StreamExt; @@ -20,6 +22,8 @@ use gadget_common::{Block, BlockImportNotification}; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use itertools::Itertools; +use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; +use pallet_dkg::signatures_schemes::to_slice_33; use rand::SeedableRng; use sc_client_api::Backend; use sp_api::ProvideRuntimeApi; @@ -145,7 +149,9 @@ where matches!( role, RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd448) | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP384) | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) ) @@ -286,6 +292,18 @@ where party ) } + ThresholdSignatureRoleType::ZcashFrostEd448 => { + run_threshold_keygen!( + Ed448Shake256, + &mut tracer, + i, + t, + n, + role, + &mut rng, + party + ) + } ThresholdSignatureRoleType::ZcashFrostP256 => { run_threshold_keygen!( P256Sha256, @@ -298,6 +316,18 @@ where party ) } + ThresholdSignatureRoleType::ZcashFrostP384 => { + run_threshold_keygen!( + P384Sha384, + &mut tracer, + i, + t, + n, + role, + &mut rng, + party + ) + } ThresholdSignatureRoleType::ZcashFrostRistretto255 => { run_threshold_keygen!( Ristretto255Sha512, @@ -543,52 +573,3 @@ fn verify_generated_dkg_key_ecdsa( data.threshold + 1 )); } - -pub fn verify_signer_from_set_ecdsa( - maybe_signers: Vec, - msg: &[u8], - signature: &[u8], -) -> (Option, bool) { - let mut signer = None; - let res = maybe_signers.iter().any(|x| { - if let Some(data) = recover_ecdsa_pub_key(msg, signature) { - let recovered = &data[..32]; - if x.0[1..].to_vec() == recovered.to_vec() { - signer = Some(*x); - true - } else { - false - } - } else { - false - } - }); - - (signer, res) -} - -pub fn recover_ecdsa_pub_key(data: &[u8], signature: &[u8]) -> Option> { - const SIGNATURE_LENGTH: usize = 65; - if signature.len() != SIGNATURE_LENGTH { - return None; - } - let mut sig = [0u8; SIGNATURE_LENGTH]; - sig[..SIGNATURE_LENGTH].copy_from_slice(signature); - - let hash = keccak_256(data); - - sp_io::crypto::secp256k1_ecdsa_recover(&sig, &hash) - .ok() - .map(|x| x.to_vec()) -} - -pub fn to_slice_33(val: &[u8]) -> Option<[u8; 33]> { - const ECDSA_KEY_LENGTH: usize = 33; - if val.len() == ECDSA_KEY_LENGTH { - let mut key = [0u8; ECDSA_KEY_LENGTH]; - key[..ECDSA_KEY_LENGTH].copy_from_slice(val); - - return Some(key); - } - None -} diff --git a/protocols/zcash-frost/src/protocols/sign.rs b/protocols/zcash-frost/src/protocols/sign.rs index e86cd7911..ab853de13 100644 --- a/protocols/zcash-frost/src/protocols/sign.rs +++ b/protocols/zcash-frost/src/protocols/sign.rs @@ -2,7 +2,9 @@ use async_trait::async_trait; use frame_support::BoundedVec; use frost_core::keys::{KeyPackage, PublicKeyPackage}; use frost_ed25519::Ed25519Sha512; +use frost_ed448::Ed448Shake256; use frost_p256::P256Sha256; +use frost_p384::P384Sha384; use frost_ristretto255::Ristretto255Sha512; use frost_secp256k1::Secp256K1Sha256; use gadget_common::client::JobsApiForGadget; @@ -325,6 +327,19 @@ where party ) } + ThresholdSignatureRoleType::ZcashFrostEd448 => { + deserialize_and_run_threshold_sign!( + Ed448Shake256, + keyshare, + &mut tracer, + i, + signers, + &input_data_to_sign, + role, + &mut rng, + party + ) + } ThresholdSignatureRoleType::ZcashFrostP256 => { deserialize_and_run_threshold_sign!( P256Sha256, @@ -338,6 +353,19 @@ where party ) } + ThresholdSignatureRoleType::ZcashFrostP384 => { + deserialize_and_run_threshold_sign!( + P384Sha384, + keyshare, + &mut tracer, + i, + signers, + &input_data_to_sign, + role, + &mut rng, + party + ) + } ThresholdSignatureRoleType::ZcashFrostRistretto255 => { deserialize_and_run_threshold_sign!( Ristretto255Sha512, @@ -387,6 +415,14 @@ where DigitalSignatureScheme::SchnorrEd25519, ) } + ThresholdSignatureRoleType::ZcashFrostEd448 => { + let mut signature_bytes = [0u8; 64]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec().try_into().unwrap(), + DigitalSignatureScheme::SchnorrEd448, + ) + } ThresholdSignatureRoleType::ZcashFrostP256 => { let mut signature_bytes = [0u8; 64]; signature_bytes.copy_from_slice(&signature.group_signature); @@ -395,6 +431,14 @@ where DigitalSignatureScheme::SchnorrP256, ) } + ThresholdSignatureRoleType::ZcashFrostP384 => { + let mut signature_bytes = [0u8; 64]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec().try_into().unwrap(), + DigitalSignatureScheme::SchnorrP384, + ) + } ThresholdSignatureRoleType::ZcashFrostRistretto255 => { let mut signature_bytes = [0u8; 64]; signature_bytes.copy_from_slice(&signature.group_signature); diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 296fc2c77..12881b7db 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -6,7 +6,7 @@ use frost_core::{ dkg::{round1, round2}, KeyPackage, PublicKeyPackage, }, - Ciphersuite, Error, Identifier, + Ciphersuite, Identifier, }; use futures::SinkExt; use rand_core::{CryptoRng, RngCore}; @@ -18,7 +18,7 @@ use round_based::{ use serde::{Deserialize, Serialize}; use tangle_primitives::roles::ThresholdSignatureRoleType; -use super::{IoError, KeygenAborted, KeygenError, Reason}; +use super::{IoError, KeygenAborted, KeygenError}; /// Message of key generation protocol #[derive(ProtocolMessage, Clone, Serialize, Deserialize)] @@ -90,13 +90,7 @@ where // Round 1 tracer.round_begins(); tracer.stage("Compute round 1 dkg secret package"); - let (round1_secret_package, round1_package) = - dkg_part1(i + 1, t, n, role, rng).map_err(|e| { - KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { - parties: vec![], - error: e, - })) - })?; + let (round1_secret_package, round1_package) = dkg_part1(i + 1, t, n, role, rng)?; tracer.send_msg(); let my_round1_msg = MsgRound1 { @@ -105,7 +99,7 @@ where outgoings .send(Outgoing::broadcast(Msg::Round1(my_round1_msg.clone()))) .await - .map_err(|e| KeygenError(Reason::IoError(IoError::send_message(e))))?; + .map_err(IoError::send_message)?; tracer.msg_sent(); // Round 2 @@ -115,7 +109,7 @@ where let round1_packages: Vec> = rounds .complete(round1) .await - .map_err(|e| KeygenError(Reason::IoError(IoError::receive_message(e))))? + .map_err(IoError::receive_message)? .into_vec_including_me(my_round1_msg.clone()) .into_iter() .map(|msg| { @@ -193,27 +187,40 @@ where }) } +fn validate_role(role: ThresholdSignatureRoleType) -> Result<(), KeygenError> { + match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostEd448 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 + | ThresholdSignatureRoleType::ZcashFrostP256 + | ThresholdSignatureRoleType::ZcashFrostP384 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 => {} + _ => Err(KeygenAborted::InvalidFrostProtocol)?, + }; + + Ok(()) +} + pub fn dkg_part1( i: u16, t: u16, n: u16, role: ThresholdSignatureRoleType, rng: R, -) -> Result<(round1::SecretPackage, round1::Package), Error> +) -> Result<(round1::SecretPackage, round1::Package), KeygenError> where R: RngCore + CryptoRng, C: Ciphersuite, { - match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 - | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), - }; + validate_role::(role)?; let participant_identifier = i.try_into().expect("should be nonzero"); - frost_core::keys::dkg::part1::(participant_identifier, n, t, rng) + Ok(frost_core::keys::dkg::part1::( + participant_identifier, + n, + t, + rng, + )?) } #[allow(clippy::type_complexity)] @@ -226,20 +233,17 @@ pub fn dkg_part2( round2::SecretPackage, BTreeMap, round2::Package>, ), - Error, + KeygenError, > where C: Ciphersuite, { - match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 - | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), - }; + validate_role::(role)?; - frost_core::keys::dkg::part2::(secret_package, round1_packages) + Ok(frost_core::keys::dkg::part2::( + secret_package, + round1_packages, + )?) } pub fn dkg_part3( @@ -247,17 +251,15 @@ pub fn dkg_part3( round2_secret_package: &round2::SecretPackage, round1_packages: &BTreeMap, round1::Package>, round2_packages: &BTreeMap, round2::Package>, -) -> Result<(KeyPackage, PublicKeyPackage), Error> +) -> Result<(KeyPackage, PublicKeyPackage), KeygenError> where C: Ciphersuite, { - match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 - | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), - }; + validate_role::(role)?; - frost_core::keys::dkg::part3::(round2_secret_package, round1_packages, round2_packages) + Ok(frost_core::keys::dkg::part3::( + round2_secret_package, + round1_packages, + round2_packages, + )?) } diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index f62eb3801..43a7ef57f 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -53,6 +53,8 @@ enum KeygenAborted { parties: Vec, error: frost_core::Error, }, + #[error("Invalid frost protocol")] + InvalidFrostProtocol, } /// Sign protocol error diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index bc0a3258e..7235efe1c 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -185,9 +185,7 @@ fn validate_role(role: ThresholdSignatureRoleType) -> Result<(), | ThresholdSignatureRoleType::ZcashFrostP256 | ThresholdSignatureRoleType::ZcashFrostP384 | ThresholdSignatureRoleType::ZcashFrostRistretto255 => {} - _ => Err(SignError(Reason::SignFailure( - SignAborted::InvalidFrostProtocol, - )))?, + _ => Err(SignAborted::InvalidFrostProtocol)?, }; Ok(()) diff --git a/protocols/zcash-frost/tests/frost.rs b/protocols/zcash-frost/tests/frost.rs index 9343d2470..665a1dc5e 100644 --- a/protocols/zcash-frost/tests/frost.rs +++ b/protocols/zcash-frost/tests/frost.rs @@ -22,24 +22,201 @@ mod tests { } #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_keygen() { + async fn test_externalities_keygen_zcash_frost_ed25519() { test_utils::setup_log(); const N: usize = 3; const T: usize = N - 1; let ext = new_test_ext::().await; - assert_eq!(wait_for_keygen::(&ext).await, 0); + assert_eq!( + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostEd25519).await, + 0 + ); } #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_signing() { + async fn test_externalities_keygen_zcash_frost_ed448() { test_utils::setup_log(); const N: usize = 3; const T: usize = N - 1; let ext = new_test_ext::().await; - let keygen_job_id = wait_for_keygen::(&ext).await; - assert_eq!(wait_for_signing::(&ext, keygen_job_id).await, 1); + assert_eq!( + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostEd448).await, + 0 + ); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_keygen_zcash_frost_p256() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + assert_eq!( + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostP256).await, + 0 + ); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_keygen_zcash_frost_p384() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + assert_eq!( + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostP384).await, + 0 + ); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_keygen_zcash_frost_ristretto255() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + assert_eq!( + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostRistretto255).await, + 0 + ); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_keygen_zcash_frost_secp256k1() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + assert_eq!( + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostSecp256k1).await, + 0 + ); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_signing_zcash_frost_ed25519() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + let keygen_job_id = + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostEd25519).await; + assert_eq!( + wait_for_signing::( + &ext, + keygen_job_id, + ThresholdSignatureRoleType::ZcashFrostEd25519 + ) + .await, + 1 + ); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_signing_zcash_frost_ed448() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + let keygen_job_id = + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostEd448).await; + assert_eq!( + wait_for_signing::( + &ext, + keygen_job_id, + ThresholdSignatureRoleType::ZcashFrostEd448 + ) + .await, + 1 + ); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_signing_zcash_frost_p256() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + let keygen_job_id = + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostP256).await; + assert_eq!( + wait_for_signing::( + &ext, + keygen_job_id, + ThresholdSignatureRoleType::ZcashFrostP256 + ) + .await, + 1 + ); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_signing_zcash_frost_p384() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + let keygen_job_id = + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostP384).await; + assert_eq!( + wait_for_signing::( + &ext, + keygen_job_id, + ThresholdSignatureRoleType::ZcashFrostP384 + ) + .await, + 1 + ); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_signing_zcash_frost_ristretto255() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + let keygen_job_id = + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostRistretto255).await; + assert_eq!( + wait_for_signing::( + &ext, + keygen_job_id, + ThresholdSignatureRoleType::ZcashFrostRistretto255 + ) + .await, + 1 + ); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_externalities_signing_zcash_frost_secp256k1() { + test_utils::setup_log(); + const N: usize = 3; + const T: usize = N - 1; + + let ext = new_test_ext::().await; + let keygen_job_id = + wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostSecp256k1).await; + assert_eq!( + wait_for_signing::( + &ext, + keygen_job_id, + ThresholdSignatureRoleType::ZcashFrostSecp256k1 + ) + .await, + 1 + ); } #[tokio::test(flavor = "multi_thread")] @@ -48,16 +225,23 @@ mod tests { test_utils::setup_log(); const N: usize = 3; const T: usize = N - 1; - const TEST_COUNT: usize = 2; + const FROST_ROLES: [ThresholdSignatureRoleType; 6] = [ + ThresholdSignatureRoleType::ZcashFrostEd25519, + ThresholdSignatureRoleType::ZcashFrostEd448, + ThresholdSignatureRoleType::ZcashFrostP256, + ThresholdSignatureRoleType::ZcashFrostP384, + ThresholdSignatureRoleType::ZcashFrostRistretto255, + ThresholdSignatureRoleType::ZcashFrostSecp256k1, + ]; let ext = new_test_ext::().await; let futures = FuturesUnordered::new(); - for _ in 0..TEST_COUNT { + for i in 0..FROST_ROLES.len() { let ext = ext.clone(); futures.push(Box::pin(async move { - let keygen_job_id = wait_for_keygen::(&ext).await; - wait_for_signing::(&ext, keygen_job_id).await; + let keygen_job_id = wait_for_keygen::(&ext, FROST_ROLES[i]).await; + wait_for_signing::(&ext, keygen_job_id, FROST_ROLES[i]).await; })); } @@ -66,9 +250,10 @@ mod tests { async fn wait_for_keygen( ext: &MultiThreadedTestExternalities, + role_type: ThresholdSignatureRoleType, ) -> JobId { let job_id = ext - .execute_with_async(|| { + .execute_with_async(move || { let job_id = Jobs::next_job_id(); let identities = (0..N).map(|i| id_to_public(i as u8)).collect::>(); @@ -79,7 +264,7 @@ mod tests { participants: identities.clone().try_into().unwrap(), threshold: T as _, permitted_caller: None, - role_type: ThresholdSignatureRoleType::ZcashFrostRistretto255, + role_type: role_type.clone(), }), }; @@ -90,18 +275,14 @@ mod tests { }) .await; - test_utils::wait_for_job_completion( - ext, - RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255), - job_id, - ) - .await; + test_utils::wait_for_job_completion(ext, RoleType::Tss(role_type), job_id).await; job_id } async fn wait_for_signing( ext: &MultiThreadedTestExternalities, keygen_job_id: JobId, + role_type: ThresholdSignatureRoleType, ) -> JobId { let job_id = ext .execute_with_async(move || { @@ -115,7 +296,7 @@ mod tests { job_type: JobType::DKGTSSPhaseTwo(DKGTSSPhaseTwoJobType { phase_one_id: keygen_job_id, submission: submission.to_vec().try_into().unwrap(), - role_type: ThresholdSignatureRoleType::ZcashFrostRistretto255, + role_type, }), }; @@ -126,12 +307,7 @@ mod tests { }) .await; - test_utils::wait_for_job_completion( - ext, - RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255), - job_id, - ) - .await; + test_utils::wait_for_job_completion(ext, RoleType::Tss(role_type), job_id).await; job_id } From b038bba9e0e41723ef9c516da06fb1b6d8efa7af Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 14 Feb 2024 14:32:53 +0200 Subject: [PATCH 22/66] Fix ed448 --- README.md | 2 +- protocols/zcash-frost/src/protocols/keygen.rs | 4 +++- protocols/zcash-frost/src/protocols/sign.rs | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0c4821bde..fc75bbbe3 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repo contains code for MPC and other restaking service gadgets. A gadget is - [x] [DFNS CGGMP21](https://github.com/dfns/cggmp21/tree/m/cggmp21) - [x] [Threshold BLS](https://github.com/mikelodder7/blsful) -- [ ] [LIT Protocol fork of ZCash Frost](https://github.com/LIT-Protocol/frost) +- [x] [LIT Protocol fork of ZCash Frost](https://github.com/LIT-Protocol/frost) - [x] [Groth16 ZK-SaaS](https://github.com/webb-tools/zk-SaaS) ## Design diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index 058efb8a2..3a2106f8f 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -504,9 +504,11 @@ async fn handle_public_key_gossip( let res = DKGTSSKeySubmissionResult { signature_scheme: match role { ThresholdSignatureRoleType::ZcashFrostEd25519 => DigitalSignatureScheme::SchnorrEd25519, + ThresholdSignatureRoleType::ZcashFrostEd448 => DigitalSignatureScheme::SchnorrEd448, ThresholdSignatureRoleType::ZcashFrostP256 => DigitalSignatureScheme::SchnorrP256, + ThresholdSignatureRoleType::ZcashFrostP384 => DigitalSignatureScheme::SchnorrP384, ThresholdSignatureRoleType::ZcashFrostRistretto255 => { - DigitalSignatureScheme::SchnorrSr25519 + DigitalSignatureScheme::SchnorrRistretto255 } ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { DigitalSignatureScheme::SchnorrSecp256k1 diff --git a/protocols/zcash-frost/src/protocols/sign.rs b/protocols/zcash-frost/src/protocols/sign.rs index ab853de13..e9191e833 100644 --- a/protocols/zcash-frost/src/protocols/sign.rs +++ b/protocols/zcash-frost/src/protocols/sign.rs @@ -152,7 +152,9 @@ where matches!( role, RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd448) | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP384) | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) ) @@ -416,7 +418,7 @@ where ) } ThresholdSignatureRoleType::ZcashFrostEd448 => { - let mut signature_bytes = [0u8; 64]; + let mut signature_bytes = [0u8; 114]; signature_bytes.copy_from_slice(&signature.group_signature); ( signature_bytes.to_vec().try_into().unwrap(), From a37ac65890b963cacac607d454093850cc0be0ad Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 14 Feb 2024 16:36:56 +0200 Subject: [PATCH 23/66] Cleanup errors --- protocols/zcash-frost/src/rounds/keygen.rs | 14 +-- protocols/zcash-frost/src/rounds/mod.rs | 117 +++------------------ protocols/zcash-frost/src/rounds/sign.rs | 16 +-- 3 files changed, 27 insertions(+), 120 deletions(-) diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 12881b7db..bf2f595a0 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -18,7 +18,7 @@ use round_based::{ use serde::{Deserialize, Serialize}; use tangle_primitives::roles::ThresholdSignatureRoleType; -use super::{IoError, KeygenAborted, KeygenError}; +use super::{Error, IoError}; /// Message of key generation protocol #[derive(ProtocolMessage, Clone, Serialize, Deserialize)] @@ -70,7 +70,7 @@ pub async fn run_threshold_keygen( role: ThresholdSignatureRoleType, rng: &mut R, party: M, -) -> Result> +) -> Result> where R: RngCore + CryptoRng, M: Mpc, @@ -187,7 +187,7 @@ where }) } -fn validate_role(role: ThresholdSignatureRoleType) -> Result<(), KeygenError> { +fn validate_role(role: ThresholdSignatureRoleType) -> Result<(), Error> { match role { ThresholdSignatureRoleType::ZcashFrostEd25519 | ThresholdSignatureRoleType::ZcashFrostEd448 @@ -195,7 +195,7 @@ fn validate_role(role: ThresholdSignatureRoleType) -> Result<(), | ThresholdSignatureRoleType::ZcashFrostP256 | ThresholdSignatureRoleType::ZcashFrostP384 | ThresholdSignatureRoleType::ZcashFrostRistretto255 => {} - _ => Err(KeygenAborted::InvalidFrostProtocol)?, + _ => Err(Error::InvalidFrostProtocol)?, }; Ok(()) @@ -207,7 +207,7 @@ pub fn dkg_part1( n: u16, role: ThresholdSignatureRoleType, rng: R, -) -> Result<(round1::SecretPackage, round1::Package), KeygenError> +) -> Result<(round1::SecretPackage, round1::Package), Error> where R: RngCore + CryptoRng, C: Ciphersuite, @@ -233,7 +233,7 @@ pub fn dkg_part2( round2::SecretPackage, BTreeMap, round2::Package>, ), - KeygenError, + Error, > where C: Ciphersuite, @@ -251,7 +251,7 @@ pub fn dkg_part3( round2_secret_package: &round2::SecretPackage, round1_packages: &BTreeMap, round1::Package>, round2_packages: &BTreeMap, round2::Package>, -) -> Result<(KeyPackage, PublicKeyPackage), KeygenError> +) -> Result<(KeyPackage, PublicKeyPackage), Error> where C: Ciphersuite, { diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index 43a7ef57f..f577d5085 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -45,119 +45,26 @@ impl IoError { } } -/// Error indicating that protocol was aborted by malicious party #[derive(Debug, Error)] -enum KeygenAborted { +pub enum Error { + #[error("i/o error")] + IoError(#[source] IoError), + #[error("unknown error")] + SerializationError, #[error("Frost keygen error")] - FrostError { - parties: Vec, - error: frost_core::Error, - }, - #[error("Invalid frost protocol")] - InvalidFrostProtocol, -} - -/// Sign protocol error -#[derive(Debug, Error)] -enum SignAborted { - #[error("Frost sign error")] - FrostError { - parties: Vec, - error: frost_core::Error, - }, + FrostError(#[source] frost_core::Error), #[error("Invalid frost protocol")] InvalidFrostProtocol, } -/// Keygen protocol error -#[derive(Debug, Error)] -#[error("keygen protocol is failed to complete")] -pub struct KeygenError(#[source] Reason); - -impl From> for KeygenError { - fn from(err: frost_core::Error) -> Self { - match err { - frost_core::Error::::InvalidProofOfKnowledge { culprit } => { - let culprit_bytes: Vec = culprit.serialize().as_ref().to_vec(); - let culprit = u16::from_le_bytes([culprit_bytes[0], culprit_bytes[1]]); - KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { - parties: vec![culprit], - error: err, - })) - } - _ => KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { - parties: vec![], - error: err, - })), - } - } -} - -impl From for KeygenError { - fn from(err: IoError) -> Self { - KeygenError(Reason::IoError(err)) - } -} - -impl From> for KeygenError { - fn from(err: KeygenAborted) -> Self { - KeygenError(Reason::KeygenFailure(err)) - } -} - -/// Sign protocol error -#[derive(Debug, Error)] -#[error("keygen protocol is failed to complete")] -pub struct SignError(#[source] Reason); - -impl From> for SignError { - fn from(err: frost_core::Error) -> Self { - match err { - frost_core::Error::::InvalidSignatureShare { culprit } => { - let culprit_bytes: Vec = culprit.serialize().as_ref().to_vec(); - let culprit = u16::from_le_bytes([culprit_bytes[0], culprit_bytes[1]]); - SignError(Reason::SignFailure(SignAborted::FrostError { - parties: vec![culprit], - error: err, - })) - } - _ => SignError(Reason::SignFailure(SignAborted::FrostError { - parties: vec![], - error: err, - })), - } +impl From for Error { + fn from(e: IoError) -> Self { + Self::IoError(e) } } -impl From for SignError { - fn from(err: IoError) -> Self { - SignError(Reason::IoError(err)) +impl From> for Error { + fn from(e: frost_core::Error) -> Self { + Self::FrostError(e) } } - -impl From> for SignError { - fn from(err: SignAborted) -> Self { - SignError(Reason::SignFailure(err)) - } -} - -#[derive(Debug, Error)] -enum Reason { - /// Keygen protocol was maliciously aborted by another party - #[error("keygen protocol was aborted by malicious party")] - KeygenFailure( - #[source] - #[from] - KeygenAborted, - ), - #[error("sign protocol was aborted by malicious party")] - SignFailure( - #[source] - #[from] - SignAborted, - ), - #[error("i/o error")] - IoError(#[source] IoError), - #[error("unknown error")] - SerializationError, -} diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index 7235efe1c..0163d9936 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use tangle_primitives::roles::ThresholdSignatureRoleType; -use super::{IoError, Reason, SignAborted, SignError}; +use super::{Error, IoError}; /// Message of key generation protocol #[derive(ProtocolMessage, Clone, Serialize, Deserialize)] @@ -59,7 +59,7 @@ pub async fn run_threshold_sign( role: ThresholdSignatureRoleType, rng: &mut R, party: M, -) -> Result> +) -> Result> where R: RngCore + CryptoRng, M: Mpc, @@ -135,7 +135,7 @@ where let round2_signature_shares: BTreeMap, SignatureShare> = rounds .complete(round2) .await - .map_err(|e| SignError(Reason::IoError(IoError::receive_message(e))))? + .map_err(IoError::receive_message)? .into_vec_including_me(MsgRound2 { msg: signature_share.serialize().as_ref().to_vec(), }) @@ -145,7 +145,7 @@ where let participant_identifier = Identifier::::try_from((party_inx + 1) as u16) .expect("Failed to convert party index to identifier"); let ser = <::Field as Field>::Serialization::try_from(msg.msg) - .map_err(|_e| SignError(Reason::::SerializationError)) + .map_err(|_e| Error::::SerializationError) .expect("Failed to deserialize round 2 signature share"); let sig_share = SignatureShare::::deserialize(ser) .unwrap_or_else(|_| panic!("Failed to deserialize round 2 signature share")); @@ -177,7 +177,7 @@ where }) } -fn validate_role(role: ThresholdSignatureRoleType) -> Result<(), SignError> { +fn validate_role(role: ThresholdSignatureRoleType) -> Result<(), Error> { match role { ThresholdSignatureRoleType::ZcashFrostEd25519 | ThresholdSignatureRoleType::ZcashFrostEd448 @@ -185,7 +185,7 @@ fn validate_role(role: ThresholdSignatureRoleType) -> Result<(), | ThresholdSignatureRoleType::ZcashFrostP256 | ThresholdSignatureRoleType::ZcashFrostP384 | ThresholdSignatureRoleType::ZcashFrostRistretto255 => {} - _ => Err(SignAborted::InvalidFrostProtocol)?, + _ => Err(Error::InvalidFrostProtocol)?, }; Ok(()) @@ -196,7 +196,7 @@ fn participant_round1( role: ThresholdSignatureRoleType, key_package: &KeyPackage, rng: &mut R, -) -> Result<(SigningNonces, SigningCommitments), SignError> { +) -> Result<(SigningNonces, SigningCommitments), Error> { validate_role::(role)?; Ok(round1::commit(key_package.signing_share(), rng)) } @@ -207,7 +207,7 @@ fn participant_round2( signing_package: &SigningPackage, nonces: &SigningNonces, key_package: &KeyPackage, -) -> Result, SignError> { +) -> Result, Error> { validate_role::(role)?; Ok(round2::sign(signing_package, nonces, key_package)?) } From de2ae2d52c7f4c1369883b882f8ba35374db359c Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 14 Feb 2024 17:20:36 +0200 Subject: [PATCH 24/66] fix: string --- protocols/zcash-frost/src/protocols/keygen.rs | 4 +--- protocols/zcash-frost/src/rounds/mod.rs | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index 3a2106f8f..d24e1b4da 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -190,9 +190,7 @@ macro_rules! run_threshold_keygen { $party, ) .await - .map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - })? + .map_err(|err| err.to_string())? }; } diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index f577d5085..fb3db8daa 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -1,4 +1,5 @@ use frost_core::Ciphersuite; +use gadget_common::JobError; use round_based::rounds_router::{ errors::{self as router_error, CompleteRoundError}, simple_store::RoundInputError, From 3ef1e3da707dd366d81d5993a35f55df0892ec8b Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 15 Feb 2024 12:32:29 +0200 Subject: [PATCH 25/66] fix: clippy w/ nightly, debug broken schemes --- .github/workflows/validate_pr.yml | 6 +-- protocols/zcash-frost/src/protocols/keygen.rs | 5 +- protocols/zcash-frost/src/rounds/keygen.rs | 47 +++++++++---------- protocols/zcash-frost/src/rounds/mod.rs | 1 - 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index 7eb9f642a..d31f9f75d 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -40,7 +40,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: stable + toolchain: nightly components: clippy - name: Install protobuf @@ -59,7 +59,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: stable + toolchain: nightly components: clippy - name: Install protobuf @@ -82,7 +82,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: stable + toolchain: nightly - name: Install protobuf run: brew install protobuf diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs index d24e1b4da..aa497605c 100644 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ b/protocols/zcash-frost/src/protocols/keygen.rs @@ -190,7 +190,10 @@ macro_rules! run_threshold_keygen { $party, ) .await - .map_err(|err| err.to_string())? + .map_err(|err| { + println!("Keygen protocol error: {err:#?}"); + err.to_string() + })? }; } diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index bf2f595a0..2b354ceb4 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -11,8 +11,11 @@ use frost_core::{ use futures::SinkExt; use rand_core::{CryptoRng, RngCore}; use round_based::{ - rounds_router::simple_store::RoundInput, - rounds_router::{simple_store::RoundMsgs, RoundsRouter}, + rounds_router::{ + simple_store::{RoundInput, RoundMsgs}, + RoundsRouter, + }, + runtime::AsyncRuntime, Delivery, Mpc, MpcParty, Outgoing, ProtocolMessage, }; use serde::{Deserialize, Serialize}; @@ -79,7 +82,9 @@ where tracer.protocol_begins(); tracer.stage("Setup networking"); - let MpcParty { delivery, .. } = party.into_party(); + let MpcParty { + delivery, runtime, .. + } = party.into_party(); let (incomings, mut outgoings) = delivery.split(); let mut rounds = RoundsRouter::::builder(); @@ -91,13 +96,12 @@ where tracer.round_begins(); tracer.stage("Compute round 1 dkg secret package"); let (round1_secret_package, round1_package) = dkg_part1(i + 1, t, n, role, rng)?; - + runtime.yield_now().await; tracer.send_msg(); - let my_round1_msg = MsgRound1 { - msg: round1_package.serialize().unwrap_or_default(), - }; outgoings - .send(Outgoing::broadcast(Msg::Round1(my_round1_msg.clone()))) + .send(Outgoing::broadcast(Msg::Round1(MsgRound1 { + msg: round1_package.serialize().unwrap_or_default(), + }))) .await .map_err(IoError::send_message)?; tracer.msg_sent(); @@ -106,30 +110,23 @@ where tracer.round_begins(); tracer.receive_msgs(); - let round1_packages: Vec> = rounds + let round1_packages_map: BTreeMap, round1::Package> = rounds .complete(round1) .await .map_err(IoError::receive_message)? - .into_vec_including_me(my_round1_msg.clone()) - .into_iter() - .map(|msg| { - round1::Package::deserialize(&msg.msg) - .unwrap_or_else(|_| panic!("Failed to deserialize round 1 package")) - }) - .collect(); - tracer.msgs_received(); - tracer.stage("Compute round 2 dkg secret package"); - let round1_packages_map: BTreeMap, round1::Package> = round1_packages - .iter() - .enumerate() - .filter(|(inx, _)| *inx != i as usize) - .map(|(inx, p)| { + .into_iter_indexed() + .map(|(party_index, _, msg)| { ( - ((inx + 1) as u16).try_into().expect("should be nonzero"), - p.clone(), + ((party_index + 1) as u16) + .try_into() + .expect("should be nonzero"), + round1::Package::deserialize(&msg.msg) + .unwrap_or_else(|_| panic!("Failed to deserialize round 1 package")), ) }) .collect(); + tracer.msgs_received(); + tracer.stage("Compute round 2 dkg secret package"); let (round2_secret_package, round2_packages_map) = dkg_part2(role, round1_secret_package, &round1_packages_map)?; diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index fb3db8daa..f577d5085 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -1,5 +1,4 @@ use frost_core::Ciphersuite; -use gadget_common::JobError; use round_based::rounds_router::{ errors::{self as router_error, CompleteRoundError}, simple_store::RoundInputError, From 12f397048de70267db48b89f680d4fdd34044c87 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 15 Feb 2024 16:39:33 +0200 Subject: [PATCH 26/66] fix: other protocols --- protocols/zcash-frost/src/protocols/sign.rs | 6 +++--- protocols/zcash-frost/src/rounds/keygen.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/protocols/zcash-frost/src/protocols/sign.rs b/protocols/zcash-frost/src/protocols/sign.rs index e9191e833..e7f17d70e 100644 --- a/protocols/zcash-frost/src/protocols/sign.rs +++ b/protocols/zcash-frost/src/protocols/sign.rs @@ -402,7 +402,7 @@ where // to a fixed byte array and then converting that to a Vec. let (signature, signature_scheme) = match role { ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { - let mut signature_bytes = [0u8; 64]; + let mut signature_bytes = [0u8; 65]; signature_bytes.copy_from_slice(&signature.group_signature); ( signature_bytes.to_vec().try_into().unwrap(), @@ -426,7 +426,7 @@ where ) } ThresholdSignatureRoleType::ZcashFrostP256 => { - let mut signature_bytes = [0u8; 64]; + let mut signature_bytes = [0u8; 65]; signature_bytes.copy_from_slice(&signature.group_signature); ( signature_bytes.to_vec().try_into().unwrap(), @@ -434,7 +434,7 @@ where ) } ThresholdSignatureRoleType::ZcashFrostP384 => { - let mut signature_bytes = [0u8; 64]; + let mut signature_bytes = [0u8; 97]; signature_bytes.copy_from_slice(&signature.group_signature); ( signature_bytes.to_vec().try_into().unwrap(), diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 2b354ceb4..928e8ab1b 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -133,7 +133,14 @@ where tracer.send_msg(); for (receiver_identifier, round2_package) in round2_packages_map { let receiver_index_bytes: Vec = receiver_identifier.serialize().as_ref().to_vec(); - let receiver_index = u16::from_le_bytes([receiver_index_bytes[0], receiver_index_bytes[1]]); + let receiver_index: u16 = if receiver_index_bytes[0] == 0 && receiver_index_bytes[1] == 0 { + u16::from_le_bytes([ + receiver_index_bytes[receiver_index_bytes.len() - 1], + receiver_index_bytes[receiver_index_bytes.len() - 2], + ]) + } else { + u16::from_le_bytes([receiver_index_bytes[0], receiver_index_bytes[1]]) + }; outgoings .send(Outgoing::p2p( receiver_index - 1, From 5fc0f8d42d2879d5c0824cfe4561331720092013 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 15 Feb 2024 17:58:02 +0200 Subject: [PATCH 27/66] clippy fix --- protocols/zcash-frost/src/protocols/util.rs | 2 +- protocols/zcash-frost/src/rounds/keygen.rs | 4 +--- protocols/zcash-frost/tests/frost.rs | 10 +++++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/protocols/zcash-frost/src/protocols/util.rs b/protocols/zcash-frost/src/protocols/util.rs index 65bb0b862..6825a652a 100644 --- a/protocols/zcash-frost/src/protocols/util.rs +++ b/protocols/zcash-frost/src/protocols/util.rs @@ -483,7 +483,7 @@ pub fn choose_signers( selected_participants_indices .iter() .cloned() - .zip(selected_participants.into_iter()) + .zip(selected_participants) .collect(); selected_participants_with_indices.sort_by_key(|&(index, _)| index); diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 928e8ab1b..93a72836b 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -117,9 +117,7 @@ where .into_iter_indexed() .map(|(party_index, _, msg)| { ( - ((party_index + 1) as u16) - .try_into() - .expect("should be nonzero"), + (party_index + 1).try_into().expect("should be nonzero"), round1::Package::deserialize(&msg.msg) .unwrap_or_else(|_| panic!("Failed to deserialize round 1 package")), ) diff --git a/protocols/zcash-frost/tests/frost.rs b/protocols/zcash-frost/tests/frost.rs index 665a1dc5e..37f295adc 100644 --- a/protocols/zcash-frost/tests/frost.rs +++ b/protocols/zcash-frost/tests/frost.rs @@ -237,11 +237,11 @@ mod tests { let ext = new_test_ext::().await; let futures = FuturesUnordered::new(); - for i in 0..FROST_ROLES.len() { + for role in &FROST_ROLES { let ext = ext.clone(); futures.push(Box::pin(async move { - let keygen_job_id = wait_for_keygen::(&ext, FROST_ROLES[i]).await; - wait_for_signing::(&ext, keygen_job_id, FROST_ROLES[i]).await; + let keygen_job_id = wait_for_keygen::(&ext, *role).await; + wait_for_signing::(&ext, keygen_job_id, *role).await; })); } @@ -264,7 +264,7 @@ mod tests { participants: identities.clone().try_into().unwrap(), threshold: T as _, permitted_caller: None, - role_type: role_type.clone(), + role_type, }), }; @@ -312,7 +312,7 @@ mod tests { } async fn new_test_ext() -> MultiThreadedTestExternalities { - test_utils::mock::new_test_ext::((), |_, mut node_input| async move { + test_utils::mock::new_test_ext::((), |mut node_input| async move { let keygen_client = node_input.mock_clients.pop().expect("No keygen client"); let signing_client = node_input.mock_clients.pop().expect("No signing client"); From e3e5a0afd2c1f115bc3e945e3fd5e81ed4d16a97 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 15 Feb 2024 17:58:54 +0200 Subject: [PATCH 28/66] change all to nightly --- .github/workflows/validate_pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index b4c2f994d..7d98a3f08 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -24,7 +24,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: stable + toolchain: nightly components: rustfmt - name: Check Formatting @@ -92,7 +92,7 @@ jobs: - name: install rust uses: actions-rs/toolchain@v1 with: - toolchain: stable + toolchain: nightly - uses: swatinem/rust-cache@v2 with: From 16d86feddc9067d3740e75aeee6476826de5b4ea Mon Sep 17 00:00:00 2001 From: salman01zp Date: Thu, 15 Feb 2024 21:42:58 +0530 Subject: [PATCH 29/66] use nightly-2023-09-28 in CI job --- .github/workflows/validate_pr.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index 7d98a3f08..26ba180aa 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -24,7 +24,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: nightly-2023-09-28 components: rustfmt - name: Check Formatting @@ -40,7 +40,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: nightly-2023-09-28 components: clippy - uses: Swatinem/rust-cache@v2 with: @@ -66,7 +66,7 @@ jobs: - name: install rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: nightly-2023-09-28 - uses: swatinem/rust-cache@v2 with: @@ -92,7 +92,7 @@ jobs: - name: install rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: nightly-2023-09-28 - uses: swatinem/rust-cache@v2 with: From ac15f3ed2f13a67f979780e7ba312a65c21975d8 Mon Sep 17 00:00:00 2001 From: salman01zp Date: Fri, 16 Feb 2024 08:43:45 +0530 Subject: [PATCH 30/66] add target --- .github/workflows/validate_pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index 26ba180aa..57c20dea9 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -42,6 +42,7 @@ jobs: with: toolchain: nightly-2023-09-28 components: clippy + target: wasm32-unknown-unknown - uses: Swatinem/rust-cache@v2 with: cache-on-failure: "true" From ac3513876baa30732574a1fdf2abb3ab92c2868e Mon Sep 17 00:00:00 2001 From: salman01zp Date: Fri, 16 Feb 2024 09:36:34 +0530 Subject: [PATCH 31/66] use latest nightly --- .github/workflows/validate_pr.yml | 10 +++++----- rust-toolchain.toml | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index 57c20dea9..ce6262162 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -24,7 +24,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2023-09-28 + toolchain: nightly components: rustfmt - name: Check Formatting @@ -40,9 +40,9 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2023-09-28 + toolchain: nightly components: clippy - target: wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 with: cache-on-failure: "true" @@ -67,7 +67,7 @@ jobs: - name: install rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2023-09-28 + toolchain: nightly - uses: swatinem/rust-cache@v2 with: @@ -93,7 +93,7 @@ jobs: - name: install rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2023-09-28 + toolchain: nightly - uses: swatinem/rust-cache@v2 with: diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 83b8c051f..db3a2149c 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,9 +1,7 @@ [toolchain] # We are using this old version of rustc since # substrate has issues with newer versions. -# See: https://substrate.stackexchange.com/questions/7714/cannot-run-substrate-on-a-fresh-macbook-m2 -# and: https://stackoverflow.com/questions/75955457/substrate-node-template-cannot-create-a-runtime-error-othercannot-deserialize -channel = "nightly-2023-09-28" +channel = "nightly" components = ["rustfmt", "clippy", "rust-src"] targets = ["wasm32-unknown-unknown"] profile = "minimal" From cc2c097210b8122ac9ebb350e15d5986abeedd76 Mon Sep 17 00:00:00 2001 From: salman01zp Date: Fri, 16 Feb 2024 10:15:36 +0530 Subject: [PATCH 32/66] revert latest nightly --- rust-toolchain.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index db3a2149c..83b8c051f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,9 @@ [toolchain] # We are using this old version of rustc since # substrate has issues with newer versions. -channel = "nightly" +# See: https://substrate.stackexchange.com/questions/7714/cannot-run-substrate-on-a-fresh-macbook-m2 +# and: https://stackoverflow.com/questions/75955457/substrate-node-template-cannot-create-a-runtime-error-othercannot-deserialize +channel = "nightly-2023-09-28" components = ["rustfmt", "clippy", "rust-src"] targets = ["wasm32-unknown-unknown"] profile = "minimal" From 2f74642bebaf7c48f9ae9836fd3d270544aef446 Mon Sep 17 00:00:00 2001 From: salman01zp Date: Sat, 17 Feb 2024 08:37:07 +0530 Subject: [PATCH 33/66] Update RolesHandler + push Cargo.lock --- Cargo.lock | 196 ++++++++++++++++++++--------------------- test-utils/src/mock.rs | 6 ++ 2 files changed, 104 insertions(+), 98 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba1679347..d4ce6b57c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -719,7 +719,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -736,7 +736,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -810,7 +810,7 @@ checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -1090,9 +1090,9 @@ dependencies = [ [[package]] name = "bls12_381_plus" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7533858fe2da020c4fba936036e702de0f73144fe13f9c71113f6f804cde3466" +checksum = "3125f174c275392512b904ff23317d722baf6daae5a392987a213a9740345ad5" dependencies = [ "arrayref", "elliptic-curve 0.13.8", @@ -1102,6 +1102,7 @@ dependencies = [ "pairing", "rand_core 0.6.4", "serde", + "sha2 0.10.8", "subtle", "zeroize", ] @@ -1135,9 +1136,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" [[package]] name = "byte-slice-cast" @@ -1190,7 +1191,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -1253,7 +1254,7 @@ dependencies = [ "paillier-zk", "rand_chacha 0.3.1", "rand_core 0.6.4", - "round-based 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "round-based 0.2.1", "serde", "serde_with 2.3.3", "sha2 0.10.8", @@ -1956,14 +1957,14 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] name = "curve25519-dalek-ml" -version = "4.1.2" +version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e7872afcaad92a4f3917ec9e66a3cca827d187419bcb1f5edc78e9f47a483ff" +checksum = "d8d84187ac3a5dddb1466f2f2707336cc6ebe3f658a5b74c0ca7538e07aea7af" dependencies = [ "cfg-if", "cpufeatures", @@ -2023,7 +2024,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2045,7 +2046,7 @@ checksum = "c5a91391accf613803c2a9bf9abccdbaa07c54b4244a5b64883f9c3c137c86be" dependencies = [ "darling_core 0.20.6", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2270,7 +2271,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2334,7 +2335,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.48", + "syn 2.0.49", "termcolor", "toml 0.8.2", "walkdir", @@ -2607,7 +2608,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2628,7 +2629,7 @@ dependencies = [ "darling 0.20.6", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2860,7 +2861,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3205,7 +3206,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3217,7 +3218,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3227,7 +3228,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3252,7 +3253,7 @@ dependencies = [ [[package]] name = "frost-core" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "debugless-unwrap", "hex", @@ -3268,7 +3269,7 @@ dependencies = [ [[package]] name = "frost-core" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" +source = "git+https://github.com/LIT-Protocol/frost.git#f1e6ab1f8ed163f64b358c9d3cfef185a29513f8" dependencies = [ "byteorder", "const-crc32", @@ -3290,7 +3291,7 @@ dependencies = [ [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" +source = "git+https://github.com/LIT-Protocol/frost.git#f1e6ab1f8ed163f64b358c9d3cfef185a29513f8" dependencies = [ "curve25519-dalek-ml", "document-features", @@ -3303,7 +3304,7 @@ dependencies = [ [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -3316,7 +3317,7 @@ dependencies = [ [[package]] name = "frost-ed448" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" +source = "git+https://github.com/LIT-Protocol/frost.git#f1e6ab1f8ed163f64b358c9d3cfef185a29513f8" dependencies = [ "document-features", "ed448-goldilocks-plus 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3329,7 +3330,7 @@ dependencies = [ [[package]] name = "frost-ed448" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "ed448-goldilocks-plus 0.11.1 (git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize)", "frost-core 0.6.1", @@ -3342,7 +3343,7 @@ dependencies = [ [[package]] name = "frost-p256" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" +source = "git+https://github.com/LIT-Protocol/frost.git#f1e6ab1f8ed163f64b358c9d3cfef185a29513f8" dependencies = [ "document-features", "frost-core 1.0.0-rc.0", @@ -3355,7 +3356,7 @@ dependencies = [ [[package]] name = "frost-p256" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "frost-core 0.6.1", "p256 0.13.2", @@ -3368,7 +3369,7 @@ dependencies = [ [[package]] name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" +source = "git+https://github.com/LIT-Protocol/frost.git#f1e6ab1f8ed163f64b358c9d3cfef185a29513f8" dependencies = [ "document-features", "frost-core 1.0.0-rc.0", @@ -3381,7 +3382,7 @@ dependencies = [ [[package]] name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "frost-core 0.6.1", "p384", @@ -3394,7 +3395,7 @@ dependencies = [ [[package]] name = "frost-rerandomized" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" +source = "git+https://github.com/LIT-Protocol/frost.git#f1e6ab1f8ed163f64b358c9d3cfef185a29513f8" dependencies = [ "derive-getters", "document-features", @@ -3405,7 +3406,7 @@ dependencies = [ [[package]] name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" +source = "git+https://github.com/LIT-Protocol/frost.git#f1e6ab1f8ed163f64b358c9d3cfef185a29513f8" dependencies = [ "curve25519-dalek 4.1.1", "document-features", @@ -3418,7 +3419,7 @@ dependencies = [ [[package]] name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -3431,7 +3432,7 @@ dependencies = [ [[package]] name = "frost-secp256k1" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#fed7ba93f6214f34711669c53522293b339aaa02" +source = "git+https://github.com/LIT-Protocol/frost.git#f1e6ab1f8ed163f64b358c9d3cfef185a29513f8" dependencies = [ "document-features", "frost-core 1.0.0-rc.0", @@ -3444,7 +3445,7 @@ dependencies = [ [[package]] name = "frost-secp256k1" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "frost-core 0.6.1", "k256", @@ -3566,7 +3567,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3697,13 +3698,12 @@ dependencies = [ [[package]] name = "generic-ec" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e61335b136fd9559af4284e642c081c2845e1f92650909eeec1fb47a8945a3f7" +checksum = "f20aec40cfb745f7af3d8e889bbfedbe1565cd383a645ceae86b32e8766d5060" dependencies = [ "generic-ec-core", "generic-ec-curves", - "getrandom 0.2.12", "hex", "phantom-type 0.4.2", "rand_core 0.6.4", @@ -3729,9 +3729,9 @@ dependencies = [ [[package]] name = "generic-ec-curves" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01b7dc4d4f06522f1c2bd8170c978f555a317c0e6c6f141b8b4f3db63c8c302" +checksum = "fd36d2998f36338ccff5c7e9155e280b8d7caeba2aa9ea72e06c4bd01760cf90" dependencies = [ "crypto-bigint 0.5.5", "elliptic-curve 0.13.8", @@ -3747,9 +3747,9 @@ dependencies = [ [[package]] name = "generic-ec-zkp" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98645d68f62951789a4aec46ef4416878c2827b2353f5267cf96b096eae60d9" +checksum = "aba23d4bd116ecc034402603a3d12c7032dd6c3476c6075b69eeae58d8054fa9" dependencies = [ "generic-array 0.14.7", "generic-ec", @@ -5234,7 +5234,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5248,7 +5248,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5259,7 +5259,7 @@ checksum = "d710e1214dffbab3b5dacb21475dde7d6ed84c69ff722b3a47a782668d44fbac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5270,7 +5270,7 @@ checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5877,7 +5877,7 @@ dependencies = [ "proc-macro-crate 2.0.2", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -6081,7 +6081,7 @@ dependencies = [ [[package]] name = "pallet-dkg" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "digest 0.10.7", "elliptic-curve 0.13.8", @@ -6122,7 +6122,7 @@ dependencies = [ [[package]] name = "pallet-jobs" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6139,7 +6139,7 @@ dependencies = [ [[package]] name = "pallet-jobs-rpc-runtime-api" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", @@ -6170,7 +6170,7 @@ dependencies = [ [[package]] name = "pallet-zksaas" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6417,7 +6417,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -6720,7 +6720,7 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -6766,7 +6766,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -6845,7 +6845,7 @@ version = "0.1.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -7280,7 +7280,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -7513,8 +7513,7 @@ dependencies = [ [[package]] name = "round-based" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50a0cb1a40a115430c0d124ee305cf118208a37f921a744d41e84d3468a2c1d0" +source = "git+https://github.com/ZenGo-X/round-based-protocol#1b372fe7d19de8cc5236cfcd0bcd92d610dacecd" dependencies = [ "futures-util", "phantom-type 0.3.1", @@ -7525,8 +7524,9 @@ dependencies = [ [[package]] name = "round-based" -version = "0.2.0" -source = "git+https://github.com/ZenGo-X/round-based-protocol#1b372fe7d19de8cc5236cfcd0bcd92d610dacecd" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0c7c6c07f090c99eea5fbfdae05d96cd82bf31459aec95a7720f5215cb692a" dependencies = [ "futures-util", "phantom-type 0.3.1", @@ -7537,9 +7537,9 @@ dependencies = [ [[package]] name = "round-based-derive" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0397bf224fdbcb3b286926e43bba90a96f81a82cc630ebfc9290d18e8b6331bd" +checksum = "1c3f220fb17bab108a448f516ce4ec470584675233ab3a799915ba71295da32e" dependencies = [ "proc-macro2", "quote", @@ -8357,7 +8357,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -8416,7 +8416,7 @@ dependencies = [ "darling 0.20.6", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -8428,7 +8428,7 @@ dependencies = [ "darling 0.20.6", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -8829,7 +8829,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -9099,7 +9099,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "quote", "sp-core-hashing 9.0.0", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -9118,7 +9118,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -9129,7 +9129,7 @@ checksum = "50535e1a5708d3ba5c1195b59ebefac61cc8679c2c24716b87a86e8b7ed2e4a1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -9386,7 +9386,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -9399,7 +9399,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -9632,7 +9632,7 @@ dependencies = [ "parity-scale-codec 3.6.9", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -9829,7 +9829,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -9927,7 +9927,7 @@ dependencies = [ "quote", "scale-info", "subxt-metadata", - "syn 2.0.48", + "syn 2.0.49", "thiserror", "tokio", ] @@ -9959,7 +9959,7 @@ dependencies = [ "parity-scale-codec 3.6.9", "proc-macro-error", "subxt-codegen", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -9988,9 +9988,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" dependencies = [ "proc-macro2", "quote", @@ -10033,7 +10033,7 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -10043,7 +10043,7 @@ dependencies = [ [[package]] name = "tangle-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#dc3e5e65dafa1c115facbc7977bafc216eded9fe" +source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" dependencies = [ "ark-bn254", "ark-crypto-primitives", @@ -10193,7 +10193,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -10359,7 +10359,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -10488,7 +10488,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -10712,7 +10712,7 @@ checksum = "8b29f121da05aa0857e7b96cf2f8782bd4140911506518486d4a125b97d7d609" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -10864,7 +10864,7 @@ checksum = "b3fd98999db9227cf28e59d83e1f120f42bc233d4b152e8fab9bc87d5bb1e0f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -10971,7 +10971,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", "wasm-bindgen-shared", ] @@ -11005,7 +11005,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -11018,9 +11018,9 @@ checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-encoder" -version = "0.41.2" +version = "0.200.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972f97a5d8318f908dded23594188a90bcd09365986b1163e66d70170e5287ae" +checksum = "b9e3fb0c8fbddd78aa6095b850dfeedbc7506cf5f81e633f69cf8f2333ab84b9" dependencies = [ "leb128", ] @@ -11533,9 +11533,9 @@ dependencies = [ [[package]] name = "wast" -version = "71.0.1" +version = "200.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "647c3ac4354da32688537e8fc4d2fe6c578df51896298cb64727d98088a1fd26" +checksum = "d1810d14e6b03ebb8fb05eef4009ad5749c989b65197d83bce7de7172ed91366" dependencies = [ "bumpalo", "leb128", @@ -11546,9 +11546,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.88" +version = "1.200.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69c36f634411568a2c6d24828b674961e37ea03340fe1d605c337ed8162d901" +checksum = "776cbd10e217f83869beaa3f40e312bb9e91d5eee29bbf6f560db1261b6a4c3d" dependencies = [ "wast", ] @@ -12046,7 +12046,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", - "round-based 0.2.0 (git+https://github.com/ZenGo-X/round-based-protocol)", + "round-based 0.2.0", "sc-client-api", "serde", "sha2 0.10.8", @@ -12079,7 +12079,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -12099,7 +12099,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] diff --git a/test-utils/src/mock.rs b/test-utils/src/mock.rs index 0fb4296c3..9367d9624 100644 --- a/test-utils/src/mock.rs +++ b/test-utils/src/mock.rs @@ -139,6 +139,8 @@ impl JobToFee for Job pub struct MockRolesHandler; impl RolesHandler for MockRolesHandler { + type Balance = Balance; + fn report_offence(_offence_report: ReportRestakerOffence) -> DispatchResult { Ok(()) } @@ -158,6 +160,10 @@ impl RolesHandler for MockRolesHandler { } }) } + + fn record_job_by_validators(_validators: Vec) -> DispatchResult { + Ok(()) + } } pub struct MockMPCHandler; From 367e34dbb267fab9ffa36501a4efe55d6c48da09 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Sat, 17 Feb 2024 23:33:17 +0200 Subject: [PATCH 34/66] cargo b -r works --- Cargo.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4ce6b57c..957a608db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2493,7 +2493,7 @@ dependencies = [ [[package]] name = "ed448-goldilocks-plus" version = "0.11.1" -source = "git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize#e5200a473655d2b8abb61263f62fdbe6a6c4d16c" +source = "git+https://github.com/mikelodder7/Ed448-Goldilocks#b133ca00a584e22322b98cc49c36db1a59b15a47" dependencies = [ "elliptic-curve 0.13.8", "rand_core 0.6.4", @@ -3253,7 +3253,7 @@ dependencies = [ [[package]] name = "frost-core" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "debugless-unwrap", "hex", @@ -3304,7 +3304,7 @@ dependencies = [ [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -3330,9 +3330,9 @@ dependencies = [ [[package]] name = "frost-ed448" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ - "ed448-goldilocks-plus 0.11.1 (git+https://github.com/drewstone/Ed448-Goldilocks.git?branch=drew/zeroize)", + "ed448-goldilocks-plus 0.11.1 (git+https://github.com/mikelodder7/Ed448-Goldilocks)", "frost-core 0.6.1", "parity-scale-codec 3.6.9", "rand_core 0.6.4", @@ -3356,7 +3356,7 @@ dependencies = [ [[package]] name = "frost-p256" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "frost-core 0.6.1", "p256 0.13.2", @@ -3382,7 +3382,7 @@ dependencies = [ [[package]] name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "frost-core 0.6.1", "p384", @@ -3419,7 +3419,7 @@ dependencies = [ [[package]] name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -3445,7 +3445,7 @@ dependencies = [ [[package]] name = "frost-secp256k1" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "frost-core 0.6.1", "k256", @@ -6081,7 +6081,7 @@ dependencies = [ [[package]] name = "pallet-dkg" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "digest 0.10.7", "elliptic-curve 0.13.8", @@ -6122,7 +6122,7 @@ dependencies = [ [[package]] name = "pallet-jobs" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "frame-benchmarking", "frame-support", @@ -6139,7 +6139,7 @@ dependencies = [ [[package]] name = "pallet-jobs-rpc-runtime-api" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", @@ -6170,7 +6170,7 @@ dependencies = [ [[package]] name = "pallet-zksaas" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "frame-benchmarking", "frame-support", @@ -10033,7 +10033,7 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -10043,7 +10043,7 @@ dependencies = [ [[package]] name = "tangle-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#a689893cebbb90de8ae3ae0c79724b8d45fbca1d" +source = "git+https://github.com/webb-tools/tangle/#7f57c5104259c074b121b6260c32a04e1dde75b0" dependencies = [ "ark-bn254", "ark-crypto-primitives", From ab28b9d88651bbd0f8140cf021b0c2c5d20c5e23 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Sun, 18 Feb 2024 00:30:06 +0200 Subject: [PATCH 35/66] fix dfns bug introduced --- protocols/dfns-cggmp21/src/protocols/sign.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index 0ab3ba6d9..adfecd39b 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -219,6 +219,12 @@ where ); let public_key_bytes = key.shared_public_key().to_bytes(true).to_vec(); + let input_data_to_sign = if input_data_to_sign.len() == 32 { + input_data_to_sign + } else { + keccak_256(&input_data_to_sign).to_vec() + }; + let input_data_to_sign2 = input_data_to_sign.clone(); Ok(JobBuilder::new() From 6edda8d0a9591fa4df266527a631d307d649bf61 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Mon, 19 Feb 2024 14:32:37 -0500 Subject: [PATCH 36/66] Fmt --- protocols/zcash-frost/src/rounds/sign.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index 0163d9936..f9b66b2a6 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -17,7 +17,7 @@ use tangle_primitives::roles::ThresholdSignatureRoleType; use super::{Error, IoError}; -/// Message of key generation protocol +/// Message of threshold FROST signing protocol #[derive(ProtocolMessage, Clone, Serialize, Deserialize)] #[serde(bound = "")] pub enum Msg { @@ -117,7 +117,8 @@ where tracer.stage("Produce signature share using the Round 1 data"); let signing_package = SigningPackage::::new(round1_signing_commitments, message_to_sign); - let signature_share = participant_round2(role, &signing_package, &nonces, &frost_keyshare.0)?; + let signature_share: SignatureShare = + participant_round2(role, &signing_package, &nonces, &frost_keyshare.0)?; runtime.yield_now().await; tracer.send_msg(); outgoings From 9e9a2fca9b0aa3bdf15af6ce46b5178c424554b7 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Mon, 19 Feb 2024 18:08:59 -0500 Subject: [PATCH 37/66] Cargo update --- Cargo.lock | 50 +++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a1adff30..53737c8bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -764,6 +764,12 @@ dependencies = [ "pin-project-lite 0.2.13", ] +[[package]] +name = "atomic" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" + [[package]] name = "atomic-polyfill" version = "1.0.3" @@ -773,12 +779,6 @@ dependencies = [ "critical-section", ] -[[package]] -name = "atomic-take" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" - [[package]] name = "atomic-waker" version = "1.1.2" @@ -6607,7 +6607,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -8994,7 +8994,7 @@ version = "9.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "quote", - "sp-core-hashing 9.0.0", + "sp-core-hashing 9.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", "syn 2.0.49", ] @@ -9017,17 +9017,6 @@ dependencies = [ "syn 2.0.49", ] -[[package]] -name = "sp-debug-derive" -version = "12.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50535e1a5708d3ba5c1195b59ebefac61cc8679c2c24716b87a86e8b7ed2e4a1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.49", -] - [[package]] name = "sp-externalities" version = "0.19.0" @@ -9182,19 +9171,6 @@ dependencies = [ "syn 2.0.49", ] -[[package]] -name = "sp-runtime-interface-proc-macro" -version = "15.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2afcbd1bd18d323371111b66b7ac2870bdc1c86c3d7b0dae67b112ca52b4d8" -dependencies = [ - "Inflector", - "proc-macro-crate 1.1.3", - "proc-macro2", - "quote", - "syn 2.0.49", -] - [[package]] name = "sp-staking" version = "4.0.0-dev" @@ -9914,7 +9890,7 @@ checksum = "e4c60d69f36615a077cc7663b9cb8e42275722d23e58a7fa3d2c7f2915d09d04" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -11750,10 +11726,10 @@ dependencies = [ "serde", "sha2 0.10.8", "sp-api", - "sp-application-crypto 23.0.0", - "sp-core 21.0.0", - "sp-io 23.0.0", - "sp-runtime 24.0.0", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-runtime", "tangle-primitives", "test-utils", "thiserror", From bdcf70e0c150806efd2dba546567b4c4a20604bf Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 22 Feb 2024 23:22:55 -0700 Subject: [PATCH 38/66] Update using the new macros --- .github/workflows/validate_pr.yml | 2 +- Cargo.lock | 24 + protocols/mp-ecdsa/Cargo.toml | 42 -- protocols/mp-ecdsa/src/protocols/keygen.rs | 498 --------------- protocols/mp-ecdsa/src/protocols/sign.rs | 441 ------------- protocols/zcash-frost/Cargo.toml | 3 +- protocols/zcash-frost/src/lib.rs | 211 +++---- protocols/zcash-frost/src/network.rs | 21 - protocols/zcash-frost/src/protocol.rs | 136 ----- protocols/zcash-frost/src/protocol/keygen.rs | 463 ++++++++++++++ .../src/{protocols => protocol}/mod.rs | 0 protocols/zcash-frost/src/protocol/sign.rs | 386 ++++++++++++ .../src/{protocols => protocol}/util.rs | 0 protocols/zcash-frost/src/protocols/keygen.rs | 578 ------------------ protocols/zcash-frost/src/protocols/sign.rs | 482 --------------- protocols/zcash-frost/tests/frost.rs | 341 ----------- 16 files changed, 961 insertions(+), 2667 deletions(-) delete mode 100644 protocols/mp-ecdsa/Cargo.toml delete mode 100644 protocols/mp-ecdsa/src/protocols/keygen.rs delete mode 100644 protocols/mp-ecdsa/src/protocols/sign.rs delete mode 100644 protocols/zcash-frost/src/network.rs delete mode 100644 protocols/zcash-frost/src/protocol.rs create mode 100644 protocols/zcash-frost/src/protocol/keygen.rs rename protocols/zcash-frost/src/{protocols => protocol}/mod.rs (100%) create mode 100644 protocols/zcash-frost/src/protocol/sign.rs rename protocols/zcash-frost/src/{protocols => protocol}/util.rs (100%) delete mode 100644 protocols/zcash-frost/src/protocols/keygen.rs delete mode 100644 protocols/zcash-frost/src/protocols/sign.rs delete mode 100644 protocols/zcash-frost/tests/frost.rs diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index 363ea8ef8..22725a531 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -85,7 +85,7 @@ jobs: runs-on: macos-latest strategy: matrix: - package: [gadget-core, gadget-common, zk-saas-protocol, dfns-cggmp21-protocol, threshold-bls-protocol] + package: [gadget-core, gadget-common, zk-saas-protocol, dfns-cggmp21-protocol, threshold-bls-protocol, zcash-frost-protocol] steps: - name: checkout code uses: actions/checkout@v2 diff --git a/Cargo.lock b/Cargo.lock index d1659be1e..fcdf7db99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2384,6 +2384,15 @@ dependencies = [ "walkdir", ] +[[package]] +name = "document-features" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" +dependencies = [ + "litrs", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -4061,6 +4070,20 @@ dependencies = [ "hashbrown 0.14.3", ] +[[package]] +name = "heapless" +version = "0.7.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" +dependencies = [ + "atomic-polyfill", + "hash32", + "rustc_version", + "serde", + "spin 0.9.8", + "stable_deref_trait", +] + [[package]] name = "heck" version = "0.3.3" @@ -12133,6 +12156,7 @@ dependencies = [ "pallet-jobs", "pallet-jobs-rpc-runtime-api", "parity-scale-codec 3.6.9", + "parking_lot 0.12.1", "protocol-macros", "rand 0.8.5", "rand_chacha 0.3.1", diff --git a/protocols/mp-ecdsa/Cargo.toml b/protocols/mp-ecdsa/Cargo.toml deleted file mode 100644 index 557e2a095..000000000 --- a/protocols/mp-ecdsa/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "mp-ecdsa-protocol" -version = "0.1.0" -edition = "2021" - -[features] -mainnet = ["gadget-common/mainnet"] - -[dependencies] -tokio = { workspace = true, features = ["macros", "rt-multi-thread", "time", "net"] } -gadget-common = { workspace = true } -gadget-core = { workspace = true } -async-trait = { workspace = true } -protocol-macros = { workspace = true } -log = { workspace = true } -multi-party-ecdsa = { workspace = true } -round-based = { workspace = true } -curv = { workspace = true } -futures = { workspace = true } -itertools = { workspace = true } -bincode2 = { workspace = true } - -pallet-jobs-rpc-runtime-api = { workspace = true, features = ["std"] } -pallet-jobs = { workspace = true, features = ["std"] } -pallet-dkg = { workspace = true, features = ["std"] } -tangle-primitives = { workspace = true, features = ["std"] } - -sp-core = { workspace = true, features = ["std"] } -sp-io = { workspace = true, features = ["std"] } -sp-api = { workspace = true, features = ["std"] } -sp-runtime = { workspace = true, features = ["std"] } -sp-application-crypto = { workspace = true, features = ["std"] } - -sc-client-api = { workspace = true } - -frame-support = { workspace = true } -parity-scale-codec = { workspace = true } - -serde = { version = "1.0.193", features = ["derive"] } - -[dev-dependencies] -test-utils = { workspace = true } diff --git a/protocols/mp-ecdsa/src/protocols/keygen.rs b/protocols/mp-ecdsa/src/protocols/keygen.rs deleted file mode 100644 index 5ec54fcf6..000000000 --- a/protocols/mp-ecdsa/src/protocols/keygen.rs +++ /dev/null @@ -1,498 +0,0 @@ -use crate::protocols::state_machine::{CurrentRoundBlame, StateMachineWrapper}; -use crate::protocols::util; -use crate::protocols::util::PublicKeyGossipMessage; -use async_trait::async_trait; -use curv::elliptic::curves::Secp256k1; -use gadget_common::client::{ - AccountId, ClientWithApi, GadgetJobResult, GadgetJobType, JobsApiForGadget, JobsClient, - MaxKeyLen, MaxParticipants, MaxSignatureLen, -}; -use gadget_common::debug_logger::DebugLogger; -use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; -use gadget_common::gadget::network::Network; -use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::gadget::{GadgetProtocol, JobInitMetadata, WorkManagerConfig}; -use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; -use gadget_common::protocol::AsyncProtocol; -use gadget_common::{Block, BlockImportNotification}; -use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; -use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; -use itertools::Itertools; -use multi_party_ecdsa::gg_2020::state_machine::keygen::{Keygen, LocalKey}; -use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; -use pallet_dkg::signatures_schemes::to_slice_33; -use round_based::async_runtime::watcher::StderrWatcher; -use round_based::{Msg, StateMachine}; -use sc_client_api::Backend; -use sp_api::ProvideRuntimeApi; -use sp_application_crypto::sp_core::keccak_256; -use sp_core::{ecdsa, Pair}; -use std::collections::{BTreeMap, HashMap}; -use std::sync::Arc; -use tangle_primitives::jobs::{ - DKGTSSKeySubmissionResult, DigitalSignatureScheme, JobId, JobResult, JobType, -}; -use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; -use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; -use tokio::sync::RwLock; - -pub struct MpEcdsaKeygenProtocol { - client: JobsClient, - key_store: ECDSAKeyStore, - network: N, - round_blames: Arc< - RwLock< - HashMap< - ::TaskID, - tokio::sync::watch::Receiver, - >, - >, - >, - logger: DebugLogger, - account_id: AccountId, -} - -pub async fn create_protocol( - account_id: AccountId, - client: JobsClient, - network: N, - logger: DebugLogger, - key_store: ECDSAKeyStore, -) -> MpEcdsaKeygenProtocol -where - B: Block, - BE: Backend, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - >::Api: JobsApiForGadget, -{ - MpEcdsaKeygenProtocol { - client, - network, - key_store, - round_blames: Arc::new(RwLock::new(HashMap::new())), - logger, - account_id, - } -} - -#[async_trait] -impl< - B: Block, - BE: Backend + 'static, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - > GadgetProtocol for MpEcdsaKeygenProtocol -where - >::Api: JobsApiForGadget, -{ - fn name(&self) -> String { - "mp-ecdsa-keygen".to_string() - } - - async fn create_next_job( - &self, - job: JobInitMetadata, - ) -> Result<::AdditionalParams, gadget_common::Error> { - let now = job.now; - self.logger.info(format!("At finality notification {now}")); - - let job_id = job.job_id; - let role_type = job.job_type.get_role_type(); - - // We can safely make this assumption because we are only creating jobs for phase one - let JobType::DKGTSSPhaseOne(p1_job) = job.job_type else { - panic!("Should be valid type") - }; - - let participants = p1_job.participants; - let threshold = p1_job.threshold; - - let user_id_to_account_id_mapping = Arc::new( - participants - .clone() - .into_iter() - .enumerate() - .map(|r| ((r.0 + 1) as UserID, r.1)) - .collect(), - ); - - let params = MpEcdsaKeygenExtraParams { - i: participants - .iter() - .position(|p| p == &self.account_id) - .expect("Should exist") as u16 - + 1, - t: threshold as u16, - n: participants.len() as u16, - role_type, - job_id, - user_id_to_account_id_mapping, - }; - - Ok(params) - } - - async fn process_block_import_notification( - &self, - _notification: BlockImportNotification, - _job_manager: &ProtocolWorkManager, - ) -> Result<(), gadget_common::Error> { - Ok(()) - } - - async fn process_error( - &self, - error: gadget_common::Error, - _job_manager: &ProtocolWorkManager, - ) { - log::error!(target: "mp-ecdsa", "Error: {error:?}"); - } - - fn account_id(&self) -> &AccountId { - &self.account_id - } - - fn role_filter(&self, role: RoleType) -> bool { - matches!( - role, - RoleType::Tss(ThresholdSignatureRoleType::ZengoGG20Secp256k1) - ) - } - - fn phase_filter(&self, job: GadgetJobType) -> bool { - matches!(job, JobType::DKGTSSPhaseOne(_)) - } - - fn client(&self) -> &JobsClient { - &self.client - } - - fn logger(&self) -> &DebugLogger { - &self.logger - } - - fn get_work_manager_config(&self) -> WorkManagerConfig { - WorkManagerConfig { - interval: None, // Manual polling - max_active_tasks: crate::constants::keygen_worker::MAX_RUNNING_TASKS, - max_pending_tasks: crate::constants::keygen_worker::MAX_ENQUEUED_TASKS, - } - } -} - -pub struct MpEcdsaKeygenExtraParams { - i: u16, - t: u16, - n: u16, - job_id: JobId, - role_type: RoleType, - user_id_to_account_id_mapping: Arc>, -} - -#[async_trait] -impl< - B: Block, - BE: Backend + 'static, - KBE: KeystoreBackend, - C: ClientWithApi, - N: Network, - > AsyncProtocol for MpEcdsaKeygenProtocol -where - >::Api: JobsApiForGadget, -{ - type AdditionalParams = MpEcdsaKeygenExtraParams; - async fn generate_protocol_from( - &self, - associated_block_id: ::Clock, - associated_retry_id: ::RetryID, - associated_session_id: ::SessionID, - associated_task_id: ::TaskID, - protocol_message_rx: UnboundedReceiver, - additional_params: Self::AdditionalParams, - ) -> Result { - let key_store = self.key_store.clone(); - let key_store2 = self.key_store.clone(); - let blame = self.round_blames.clone(); - let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); - let protocol_output_clone = protocol_output.clone(); - let client = self.client.clone(); - let logger = self.logger.clone(); - let logger_clone = logger.clone(); - let round_blames = self.round_blames.clone(); - let network = self.network.clone(); - - let (i, t, n, mapping) = ( - additional_params.i, - additional_params.t, - additional_params.n, - additional_params.user_id_to_account_id_mapping, - ); - - Ok(JobBuilder::new() - .protocol(async move { - logger.info(format!( - "Starting Keygen Protocol with params: i={i}, t={t}, n={n}" - )); - let keygen = Keygen::new(i, t, n).map_err(|err| JobError { - reason: format!("Keygen setup error: {err:?}"), - })?; - let (current_round_blame_tx, current_round_blame_rx) = - tokio::sync::watch::channel(CurrentRoundBlame::default()); - - round_blames - .write() - .await - .insert(associated_task_id, current_round_blame_rx); - - let ( - keygen_tx_to_outbound, - keygen_rx_async_proto, - broadcast_tx_to_outbound, - broadcast_rx_from_gadget, - ) = util::create_job_manager_to_async_protocol_channel_split::< - _, - Msg<::MessageBody>, - PublicKeyGossipMessage, - >( - protocol_message_rx, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping, - network, - ); - - let state_machine_wrapper = - StateMachineWrapper::new(keygen, current_round_blame_tx, logger.clone()); - logger.debug("Beginning AsyncProtocol - Keygen"); - let local_key = round_based::AsyncProtocol::new( - state_machine_wrapper, - keygen_rx_async_proto, - keygen_tx_to_outbound, - ) - .set_watcher(StderrWatcher) - .run() - .await - .map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - })?; - - logger.debug("Finished AsyncProtocol - Keygen"); - - let job_result = handle_public_key_gossip( - key_store, - &logger, - &local_key, - t, - i, - broadcast_tx_to_outbound, - broadcast_rx_from_gadget, - ) - .await?; - - *protocol_output.lock().await = Some((local_key, job_result)); - Ok(()) - }) - .post(async move { - // Check to see if there is any blame at the end of the protocol - if let Some(blame) = blame.write().await.remove(&associated_task_id) { - let blame = blame.borrow(); - // TODO: consider the fact that ids from the async protocol are offset by +1 - if !blame.blamed_parties.is_empty() { - logger_clone.error(format!("Blame: {blame:?}")); - return Err(JobError { - reason: format!("Keygen blame: {blame:?}"), - }); - } - } - - // Store the keys locally, as well as submitting them to the blockchain - if let Some((local_key, job_result)) = protocol_output_clone.lock().await.take() { - key_store2 - .set_job_result(additional_params.job_id, local_key) - .await - .map_err(|err| JobError { - reason: format!("Failed to store key: {err:?}"), - })?; - - client - .submit_job_result( - additional_params.role_type, - additional_params.job_id, - job_result, - ) - .await - .map_err(|err| JobError { - reason: format!("Failed to submit job result: {err:?}"), - })?; - } - - Ok(()) - }) - .build()) - } -} - -#[allow(clippy::too_many_arguments)] -async fn handle_public_key_gossip( - key_store: ECDSAKeyStore, - logger: &DebugLogger, - local_key: &LocalKey, - t: u16, - i: u16, - broadcast_tx_to_outbound: UnboundedSender, - mut broadcast_rx_from_gadget: UnboundedReceiver, -) -> Result { - let serialized_public_key = local_key.public_key().to_bytes(true).to_vec(); - let key_hashed = keccak_256(&serialized_public_key); - let signature = key_store.pair().sign_prehashed(&key_hashed).0.to_vec(); - let my_id = key_store.pair().public(); - let mut received_keys = BTreeMap::new(); - received_keys.insert(i, signature.clone()); - let mut received_participants = BTreeMap::new(); - received_participants.insert(i, my_id); - - broadcast_tx_to_outbound - .send(PublicKeyGossipMessage { - from: i as _, - to: None, - signature, - id: my_id, - }) - .map_err(|err| JobError { - reason: format!("Failed to send public key: {err:?}"), - })?; - - for _ in 0..t { - let message = broadcast_rx_from_gadget - .recv() - .await - .ok_or_else(|| JobError { - reason: "Failed to receive public key".to_string(), - })?; - - let from = message.from; - logger.debug(format!("Received public key from {from}")); - - if received_keys.contains_key(&(from as u16)) { - logger.warn("Received duplicate key"); - continue; - } - // verify signature - let maybe_signature = sp_core::ecdsa::Signature::from_slice(&message.signature); - match maybe_signature.and_then(|s| s.recover_prehashed(&key_hashed)) { - Some(p) if p != message.id => { - logger.warn(format!( - "Received invalid signature from {from} not signed by them" - )); - } - Some(p) if p == message.id => { - logger.debug(format!("Received valid signature from {from}")); - } - Some(_) => unreachable!("Should not happen"), - None => { - logger.warn(format!("Received invalid signature from {from}")); - continue; - } - } - - received_keys.insert(from as u16, message.signature); - received_participants.insert(from as u16, message.id); - logger.debug(format!( - "Received {}/{} signatures", - received_keys.len(), - t + 1 - )); - } - - // Order and collect the map to ensure symmetric submission to blockchain - let signatures = received_keys - .into_iter() - .sorted_by_key(|x| x.0) - .map(|r| r.1.try_into().unwrap()) - .collect::>(); - - let participants = received_participants - .into_iter() - .sorted_by_key(|x| x.0) - .map(|r| r.1 .0.to_vec().try_into().unwrap()) - .collect::>() - .try_into() - .unwrap(); - - if signatures.len() < t as usize { - return Err(JobError { - reason: format!( - "Received {} signatures, expected at least {}", - signatures.len(), - t + 1, - ), - }); - } - - let res = DKGTSSKeySubmissionResult { - signature_scheme: DigitalSignatureScheme::Ecdsa, - key: serialized_public_key.try_into().unwrap(), - participants, - signatures: signatures.try_into().unwrap(), - threshold: t as _, - }; - verify_generated_dkg_key_ecdsa(res.clone(), logger); - Ok(JobResult::DKGPhaseOne(res)) -} - -fn verify_generated_dkg_key_ecdsa( - data: DKGTSSKeySubmissionResult, - logger: &DebugLogger, -) { - // Ensure participants and signatures are not empty - assert!(!data.participants.is_empty(), "NoParticipantsFound",); - assert!(!data.signatures.is_empty(), "NoSignaturesFound"); - - // Generate the required ECDSA signers - let maybe_signers = data - .participants - .iter() - .map(|x| { - ecdsa::Public( - to_slice_33(x) - .unwrap_or_else(|| panic!("Failed to convert input to ecdsa public key")), - ) - }) - .collect::>(); - - assert!(!maybe_signers.is_empty(), "NoParticipantsFound"); - - let mut known_signers: Vec = Default::default(); - - for signature in data.signatures { - // Ensure the required signer signature exists - let (maybe_authority, success) = - verify_signer_from_set_ecdsa(maybe_signers.clone(), &data.key, &signature); - - if success { - let authority = maybe_authority.expect("CannotRetreiveSigner"); - - // Ensure no duplicate signatures - assert!(!known_signers.contains(&authority), "DuplicateSignature"); - - logger.debug(format!("Verified signature from {}", authority)); - known_signers.push(authority); - } - } - - // Ensure a sufficient number of unique signers are present - assert!( - known_signers.len() > data.threshold as usize, - "NotEnoughSigners" - ); - logger.debug(format!( - "Verified {}/{} signatures", - known_signers.len(), - data.threshold + 1 - )); -} diff --git a/protocols/mp-ecdsa/src/protocols/sign.rs b/protocols/mp-ecdsa/src/protocols/sign.rs deleted file mode 100644 index 7327b4ff5..000000000 --- a/protocols/mp-ecdsa/src/protocols/sign.rs +++ /dev/null @@ -1,441 +0,0 @@ -use crate::protocols::state_machine::{CurrentRoundBlame, StateMachineWrapper}; -use crate::protocols::util; -use crate::protocols::util::VotingMessage; -use async_trait::async_trait; -use curv::arithmetic::Converter; -use curv::elliptic::curves::Secp256k1; -use curv::BigInt; -use gadget_common::client::{ - AccountId, ClientWithApi, GadgetJobType, JobsApiForGadget, JobsClient, -}; -use gadget_common::debug_logger::DebugLogger; -use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; -use gadget_common::gadget::network::Network; -use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::gadget::{GadgetProtocol, JobInitMetadata, WorkManagerConfig}; -use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; -use gadget_common::protocol::AsyncProtocol; -use gadget_common::{Block, BlockImportNotification}; -use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; -use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; -use multi_party_ecdsa::gg_2020::party_i::verify; -use multi_party_ecdsa::gg_2020::state_machine::keygen::LocalKey; -use multi_party_ecdsa::gg_2020::state_machine::sign::{ - CompletedOfflineStage, OfflineStage, PartialSignature, SignManual, -}; -use round_based::async_runtime::watcher::StderrWatcher; -use round_based::{Msg, StateMachine}; -use sc_client_api::Backend; -use sp_api::ProvideRuntimeApi; -use sp_core::ecdsa::Signature; -use std::collections::HashMap; -use std::sync::Arc; -use tangle_primitives::jobs::{ - DKGTSSSignatureResult, DigitalSignatureScheme, JobId, JobResult, JobType, -}; -use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; -use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; -use tokio::sync::RwLock; - -pub struct MpEcdsaSigningProtocol { - client: JobsClient, - key_store: ECDSAKeyStore, - network: N, - round_blames: Arc< - RwLock< - HashMap< - ::TaskID, - tokio::sync::watch::Receiver, - >, - >, - >, - logger: DebugLogger, - account_id: AccountId, -} - -pub async fn create_protocol( - account_id: AccountId, - logger: DebugLogger, - client: JobsClient, - network: N, - key_store: ECDSAKeyStore, -) -> MpEcdsaSigningProtocol -where - B: Block, - BE: Backend, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - >::Api: JobsApiForGadget, -{ - MpEcdsaSigningProtocol { - client, - network, - key_store, - round_blames: Arc::new(Default::default()), - logger, - account_id, - } -} - -#[async_trait] -impl< - B: Block, - BE: Backend + 'static, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - > GadgetProtocol for MpEcdsaSigningProtocol -where - >::Api: JobsApiForGadget, -{ - fn name(&self) -> String { - "mp-ecdsa-signing".to_string() - } - - async fn create_next_job( - &self, - job: JobInitMetadata, - ) -> Result<::AdditionalParams, gadget_common::Error> { - let job_id = job.job_id; - - let role_type = job.job_type.get_role_type(); - let JobType::DKGTSSPhaseTwo(p2_job) = job.job_type else { - panic!("Should be valid type") - }; - let input_data_to_sign = p2_job.submission; - let previous_job_id = p2_job.phase_one_id; - - let phase1_job = job.phase1_job.expect("Should exist for a phase 2 job"); - let participants = phase1_job.clone().get_participants().expect("Should exist"); - let threshold = phase1_job.get_threshold().expect("Should exist") as u16; - - if let Some(key) = self - .key_store - .get_job_result(previous_job_id) - .await - .map_err(|err| gadget_common::Error::ClientError { - err: err.to_string(), - })? - { - let user_id_to_account_id_mapping = Arc::new( - participants - .clone() - .into_iter() - .enumerate() - .map(|r| ((r.0 + 1) as UserID, r.1)) - .collect(), - ); - - let params = MpEcdsaSigningExtraParams { - i: participants - .iter() - .position(|p| p == &self.account_id) - .expect("Should exist") as u16 - + 1, - t: threshold, - signers: (0..participants.len()).map(|r| (r + 1) as u16).collect(), - job_id, - key, - input_data_to_sign: input_data_to_sign.try_into().unwrap(), - role_type, - user_id_to_account_id_mapping, - }; - - Ok(params) - } else { - Err(gadget_common::Error::ClientError { - err: format!("No key found for job ID: {job_id:?}", job_id = job.job_id), - }) - } - } - - async fn process_block_import_notification( - &self, - _notification: BlockImportNotification, - _job_manager: &ProtocolWorkManager, - ) -> Result<(), gadget_common::Error> { - Ok(()) - } - - async fn process_error( - &self, - error: gadget_common::Error, - _job_manager: &ProtocolWorkManager, - ) { - log::error!(target: "gadget", "Error: {error:?}"); - } - - fn account_id(&self) -> &AccountId { - &self.account_id - } - - fn role_filter(&self, role: RoleType) -> bool { - matches!( - role, - RoleType::Tss(ThresholdSignatureRoleType::ZengoGG20Secp256k1) - ) - } - - fn phase_filter(&self, job: GadgetJobType) -> bool { - matches!(job, JobType::DKGTSSPhaseTwo(_)) - } - - fn client(&self) -> &JobsClient { - &self.client - } - - fn logger(&self) -> &DebugLogger { - &self.logger - } - - fn get_work_manager_config(&self) -> WorkManagerConfig { - WorkManagerConfig { - interval: Some(crate::constants::signing_worker::JOB_POLL_INTERVAL), - max_active_tasks: crate::constants::signing_worker::MAX_RUNNING_TASKS, - max_pending_tasks: crate::constants::signing_worker::MAX_ENQUEUED_TASKS, - } - } -} - -pub struct MpEcdsaSigningExtraParams { - i: u16, - t: u16, - signers: Vec, - job_id: JobId, - key: LocalKey, - role_type: RoleType, - input_data_to_sign: Vec, - user_id_to_account_id_mapping: Arc>, -} - -#[async_trait] -impl< - B: Block, - BE: Backend + 'static, - KBE: KeystoreBackend, - C: ClientWithApi, - N: Network, - > AsyncProtocol for MpEcdsaSigningProtocol -where - >::Api: JobsApiForGadget, -{ - type AdditionalParams = MpEcdsaSigningExtraParams; - async fn generate_protocol_from( - &self, - associated_block_id: ::Clock, - associated_retry_id: ::RetryID, - associated_session_id: ::SessionID, - associated_task_id: ::TaskID, - protocol_message_rx: UnboundedReceiver, - additional_params: Self::AdditionalParams, - ) -> Result { - let blame = self.round_blames.clone(); - let debug_logger_post = self.logger.clone(); - let debug_logger_proto = debug_logger_post.clone(); - let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); - let protocol_output_clone = protocol_output.clone(); - let client = self.client.clone(); - let round_blames = self.round_blames.clone(); - let network = self.network.clone(); - let role_type = additional_params.role_type; - - let (i, signers, t, key, input_data_to_sign, mapping) = ( - additional_params.i, - additional_params.signers, - additional_params.t, - additional_params.key, - additional_params.input_data_to_sign.clone(), - additional_params.user_id_to_account_id_mapping.clone(), - ); - - let public_key_bytes = key.public_key().to_bytes(true).to_vec(); - - Ok(JobBuilder::new() - .protocol(async move { - let signing = OfflineStage::new(i, signers, key).map_err(|err| JobError { - reason: format!("Failed to create offline stage: {err:?}"), - })?; - let (current_round_blame_tx, current_round_blame_rx) = - tokio::sync::watch::channel(CurrentRoundBlame::default()); - - round_blames - .write() - .await - .insert(associated_task_id, current_round_blame_rx); - - let ( - tx_to_outbound_offline, - rx_async_proto_offline, - tx_to_outbound_voting, - rx_async_proto_voting, - ) = util::create_job_manager_to_async_protocol_channel_split::< - _, - Msg<::MessageBody>, - VotingMessage, - >( - protocol_message_rx, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping, - network, - ); - - let state_machine_wrapper = StateMachineWrapper::new( - signing, - current_round_blame_tx, - debug_logger_proto.clone(), - ); - let completed_offline_stage = round_based::AsyncProtocol::new( - state_machine_wrapper, - rx_async_proto_offline, - tx_to_outbound_offline, - ) - .set_watcher(StderrWatcher) - .run() - .await - .map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - })?; - - debug_logger_proto.info(format!( - "*** Completed offline stage: {:?}", - completed_offline_stage.public_key() - )); - - // We will sign over the unique task ID - let message = BigInt::from_bytes(&input_data_to_sign); - - // Conclude with the voting stage - let signature = voting_stage( - i, - t, - message, - completed_offline_stage, - rx_async_proto_voting, - tx_to_outbound_voting, - &debug_logger_proto, - ) - .await?; - *protocol_output.lock().await = Some(signature); - Ok(()) - }) - .post(async move { - // Check to see if there is any blame at the end of the protocol - if let Some(blame) = blame.write().await.remove(&associated_task_id) { - // TODO: consider that this blame is offset by +1 - let blame = blame.borrow(); - if !blame.blamed_parties.is_empty() { - debug_logger_post.error(format!("Blame: {blame:?}")); - return Err(JobError { - reason: format!("Signing blame: {blame:?}"), - }); - } - } - - // Submit the protocol output to the blockchain - if let Some(signature) = protocol_output_clone.lock().await.take() { - let signature = signature.0.to_vec().try_into().unwrap(); - - let job_result = JobResult::DKGPhaseTwo(DKGTSSSignatureResult { - signature_scheme: DigitalSignatureScheme::Ecdsa, - data: additional_params.input_data_to_sign.try_into().unwrap(), - signature, - verifying_key: public_key_bytes.try_into().unwrap(), - }); - - client - .submit_job_result(role_type, additional_params.job_id, job_result) - .await - .map_err(|err| JobError { - reason: format!("Failed to submit job result: {err:?}"), - })?; - } - - Ok(()) - }) - .build()) - } -} - -async fn voting_stage( - offline_i: u16, - threshold: u16, - message: BigInt, - completed_offline_stage: CompletedOfflineStage, - mut msg_rx: UnboundedReceiver, - msg_tx: UnboundedSender, - debug_logger: &DebugLogger, -) -> Result { - let offline_stage_pub_key = completed_offline_stage.public_key().clone(); - let (signing, partial_signature) = SignManual::new(message.clone(), completed_offline_stage) - .map_err(|err| JobError { - reason: format!("Failed to create voting stage: {err:?}"), - })?; - - let partial_sig_bytes = bincode2::serialize(&partial_signature).map_err(|err| JobError { - reason: format!("Failed to serialize partial signature: {err:?}"), - })?; - - let payload = VotingMessage { - from: offline_i as UserID, - to: None, // Broadcast to everyone - payload: partial_sig_bytes, - }; - - msg_tx.send(payload).map_err(|err| JobError { - reason: format!("Failed to send partial signature: {err:?}"), - })?; - - let mut sigs = HashMap::with_capacity(threshold as _); - - while let Some(vote_message) = msg_rx.recv().await { - let vote_message: VotingMessage = vote_message; - if sigs.contains_key(&vote_message.from) { - debug_logger.warn(format!( - "Received duplicate signature from {}", - vote_message.from - )); - continue; - } - - if let Ok(p_sig) = bincode2::deserialize::(&vote_message.payload) { - sigs.insert(vote_message.from, p_sig); - - if sigs.len() == threshold as usize { - break; - } - } else { - debug_logger.warn(format!( - "Received invalid signature bytes from {}", - vote_message.from - )); - } - } - - if sigs.len() != threshold as usize { - return Err(JobError { - reason: format!( - "Failed to collect enough signatures: {}/{}", - sigs.len(), - threshold - ), - }); - } - - // Aggregate and complete the signature - let sigs: Vec = sigs.into_values().collect(); - let signature = signing.complete(&sigs).map_err(|err| JobError { - reason: format!("Failed to complete signature: {err:?}"), - })?; - - // Verify the signature - verify(&signature, &offline_stage_pub_key, &message).map_err(|err| JobError { - reason: format!("Failed to verify signature: {err:?}"), - })?; - - // Convert the signature to a substrate-compatible format - Ok(crate::util::convert_signature(&signature)) -} diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml index 5748ed836..775c01e64 100644 --- a/protocols/zcash-frost/Cargo.toml +++ b/protocols/zcash-frost/Cargo.toml @@ -51,6 +51,5 @@ parity-scale-codec = { workspace = true } serde = { version = "1.0.193", features = ["derive"] } rand = { workspace = true } hex = { workspace = true } - -[dev-dependencies] +parking_lot = { workspace = true } test-utils = { workspace = true } diff --git a/protocols/zcash-frost/src/lib.rs b/protocols/zcash-frost/src/lib.rs index 6fc9a48ff..be5756173 100644 --- a/protocols/zcash-frost/src/lib.rs +++ b/protocols/zcash-frost/src/lib.rs @@ -1,140 +1,101 @@ -use gadget_common::client::*; -use gadget_common::config::*; -use gadget_common::keystore::ECDSAKeyStore; -use gadget_common::keystore::KeystoreBackend; +use crate::protocol::keygen::ZcashFrostKeygenExtraParams; +use crate::protocol::sign::ZcashFrostSigningExtraParams; +use async_trait::async_trait; +use gadget_common::full_protocol::SharedOptional; +use gadget_common::gadget::JobInitMetadata; +use gadget_common::prelude::*; +use gadget_common::{ + generate_protocol, generate_setup_and_run_command, BuiltExecutableJobWrapper, Error, JobError, + ProtocolWorkManager, WorkManagerInterface, +}; use protocol_macros::protocol; -use protocols::keygen::ZcashFrostKeygenProtocol; -use protocols::sign::ZcashFrostSigningProtocol; use std::sync::Arc; pub mod constants; -pub mod network; -pub mod protocols; +pub mod protocol; pub mod rounds; -/// A Helper macro to declare a protocol, used -/// to avoid code duplication. -macro_rules! decl_porto { - ($name:ident + $proto:ident = $im:path) => { - - #[protocol] - pub struct $name< - N: Network, - B: Block, - BE: Backend, - KBE: KeystoreBackend, - C: ClientWithApi, - > where - >::Api: JobsApi, - { - pub account_id: AccountId, - pub network: N, - pub keystore_backend: ECDSAKeyStore, - pub client: C, - pub logger: DebugLogger, - pub pallet_tx: Arc, - pub _pd: std::marker::PhantomData<(B, BE)>, - } - - #[async_trait::async_trait] - impl, KBE: KeystoreBackend, C: ClientWithApi> - NetworkAndProtocolSetup for $name - where - >::Api: JobsApi, - { - type Network = N; - type Protocol = $proto; - type Client = C; - type Block = B; - type Backend = BE; - - async fn build_network_and_protocol( - &self, - jobs_client: JobsClient, - ) -> Result<(Self::Network, Self::Protocol), gadget_common::Error> { - use $im as m; - let protocol = m::create_protocol( - self.account_id, - jobs_client, - self.network.clone(), - self.logger.clone(), - self.keystore_backend.clone(), - ) - .await; - - Ok((self.network.clone(), protocol)) - } - - fn pallet_tx(&self) -> Arc { - self.pallet_tx.clone() - } - - fn logger(&self) -> DebugLogger { - self.logger.clone() - } +generate_protocol!( + "Zcash-FROST-Keygen-Protocol", + ZcashFrostKeygenProtocol, + ZcashFrostKeygenExtraParams, + crate::protocol::keygen::generate_protocol_from, + crate::protocol::keygen::create_next_job, + GadgetJobType::DKGTSSPhaseOne(_), + RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd448) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP384) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) +); +generate_protocol!( + "Zcash-FROST-Signing-Protocol", + ZcashFrostSigningProtocol, + ZcashFrostSigningExtraParams, + crate::protocol::sign::generate_protocol_from, + crate::protocol::sign::create_next_job, + GadgetJobType::DKGTSSPhaseTwo(_), + RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd448) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP384) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) + | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) +); - fn client(&self) -> Self::Client { - self.client.clone() - } - } +generate_setup_and_run_command!(ZcashFrostKeygenProtocol, ZcashFrostSigningProtocol); - }; - // recursive case with optional trailing comma - ($($name:ident + $proto:ident = $im:path),+ $(,)?) => { - $(decl_porto!($name + $proto = $im);)+ - }; +mod secp256k1 { + test_utils::generate_signing_and_keygen_tss_tests!( + 2, + 3, + 2, + ThresholdSignatureRoleType::ZcashFrostSecp256k1 + ); } -// A macro to declare all the protocols -decl_porto!( - ZcashFrostKeygenConfig + ZcashFrostKeygenProtocol = protocols::keygen, - ZcashFrostSigningConfig + ZcashFrostSigningProtocol = protocols::sign, -); +mod ristretto255 { + test_utils::generate_signing_and_keygen_tss_tests!( + 2, + 3, + 2, + ThresholdSignatureRoleType::ZcashFrostRistretto255 + ); +} -#[allow(clippy::too_many_arguments)] -pub async fn run( - account_id: AccountId, - logger: DebugLogger, - keystore: ECDSAKeyStore, - pallet_tx: Tx, - (client_keygen, client_signing): (C, C), - (network_keygen, network_signing): (N, N), -) -> Result<(), gadget_common::Error> -where - B: Block, - BE: Backend + 'static, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - Tx: PalletSubmitter, - >::Api: JobsApiForGadget, -{ - let pallet_tx = Arc::new(pallet_tx) as Arc; - let keygen_config = ZcashFrostKeygenConfig { - account_id, - network: network_keygen, - keystore_backend: keystore.clone(), - client: client_keygen, - logger: logger.clone(), - pallet_tx: pallet_tx.clone(), - _pd: std::marker::PhantomData, - }; +mod p256 { + test_utils::generate_signing_and_keygen_tss_tests!( + 2, + 3, + 2, + ThresholdSignatureRoleType::ZcashFrostP256 + ); +} - let sign_config = ZcashFrostSigningConfig { - account_id, - network: network_signing, - keystore_backend: keystore.clone(), - client: client_signing, - logger: logger.clone(), - pallet_tx: pallet_tx.clone(), - _pd: std::marker::PhantomData, - }; +mod p384 { + test_utils::generate_signing_and_keygen_tss_tests!( + 2, + 3, + 2, + ThresholdSignatureRoleType::ZcashFrostP384 + ); +} - let keygen_future = keygen_config.execute(); - let sign_future = sign_config.execute(); +mod ed25519 { + test_utils::generate_signing_and_keygen_tss_tests!( + 2, + 3, + 2, + ThresholdSignatureRoleType::ZcashFrostEd25519 + ); +} - tokio::select! { - res0 = keygen_future => res0, - res1 = sign_future => res1, - } +mod ed448 { + test_utils::generate_signing_and_keygen_tss_tests!( + 2, + 3, + 2, + ThresholdSignatureRoleType::ZcashFrostEd448 + ); } diff --git a/protocols/zcash-frost/src/network.rs b/protocols/zcash-frost/src/network.rs deleted file mode 100644 index 87ca56d0f..000000000 --- a/protocols/zcash-frost/src/network.rs +++ /dev/null @@ -1,21 +0,0 @@ -use async_trait::async_trait; -use gadget_common::config::Network; -use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::{Error, WorkManagerInterface}; - -#[derive(Clone)] -pub struct ZcashFrostNetworkService; - -#[async_trait] -impl Network for ZcashFrostNetworkService { - async fn next_message(&self) -> Option<::ProtocolMessage> { - futures::future::pending().await - } - - async fn send_message( - &self, - _message: ::ProtocolMessage, - ) -> Result<(), Error> { - Ok(()) - } -} diff --git a/protocols/zcash-frost/src/protocol.rs b/protocols/zcash-frost/src/protocol.rs deleted file mode 100644 index 7a3929cd8..000000000 --- a/protocols/zcash-frost/src/protocol.rs +++ /dev/null @@ -1,136 +0,0 @@ -use std::collections::HashMap; -use std::sync::Arc; - -use async_trait::async_trait; -use gadget_common::client::{AccountId, ClientWithApi, JobsClient}; -use gadget_common::config::{DebugLogger, JobsApi, ProvideRuntimeApi}; -use gadget_common::gadget::message::GadgetProtocolMessage; -use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::gadget::{GadgetProtocol, JobInitMetadata}; -use gadget_common::protocol::AsyncProtocol; -use gadget_common::gadget::message::UserID; -use gadget_common::{ - Backend, Block, BuiltExecutableJobWrapper, Error, JobBuilder, JobError, ProtocolWorkManager, WorkManagerInterface -}; -use sc_client_api::BlockImportNotification; -use tangle_primitives::jobs::{JobId, JobType}; -use tangle_primitives::roles::RoleType; - -pub struct ZcashFrostProtocol, C: ClientWithApi> -where - >::Api: JobsApi, -{ - pub jobs_client: JobsClient, - pub account_id: AccountId, - pub logger: DebugLogger, -} - -pub type Curve = u8; - -pub struct ZcashFrostKeygenExtraParams { - i: u16, - t: u16, - n: u16, - job_id: JobId, - role_type: RoleType, - user_id_to_account_id_mapping: Arc>, -} - -#[async_trait] -impl, C: ClientWithApi> GadgetProtocol - for ZcashFrostProtocol -where - >::Api: JobsApi, -{ - async fn create_next_job( - &self, - job: JobInitMetadata, - ) -> Result<::AdditionalParams, Error> { - let now = job.now; - self.logger.info(format!("At finality notification {now}")); - - let job_id = job.job_id; - let role_type = job.job_type.get_role_type(); - - // We can safely make this assumption because we are only creating jobs for phase one - let JobType::DKGTSSPhaseOne(p1_job) = job.job_type else { - panic!("Should be valid type") - }; - - let participants = p1_job.participants; - let threshold = p1_job.threshold; - - let user_id_to_account_id_mapping = Arc::new( - participants - .clone() - .into_iter() - .enumerate() - .map(|r| (r.0 as UserID, r.1)) - .collect(), - ); - - let params = ZcashFrostKeygenExtraParams { - i: participants - .iter() - .position(|p| p == &self.account_id) - .expect("Should exist") as u16, - t: threshold as u16, - n: participants.len() as u16, - role_type, - job_id, - user_id_to_account_id_mapping, - }; - - Ok(params) - } - - async fn process_block_import_notification( - &self, - _notification: BlockImportNotification, - _job_manager: &ProtocolWorkManager, - ) -> Result<(), Error> { - Ok(()) - } - - async fn process_error(&self, _error: Error, _job_manager: &ProtocolWorkManager) {} - - fn account_id(&self) -> &AccountId { - &self.account_id - } - - fn role_type(&self) -> RoleType { - RoleType::LightClientRelaying - } - - fn is_phase_one(&self) -> bool { - true - } - - fn client(&self) -> &JobsClient { - &self.jobs_client - } - - fn logger(&self) -> &DebugLogger { - &self.logger - } -} - -#[async_trait] -impl, C: ClientWithApi> AsyncProtocol for ZcashFrostProtocol -where - >::Api: JobsApi, -{ - type AdditionalParams = ZcashFrostKeygenExtraParams; - - async fn generate_protocol_from( - &self, - _associated_block_id: ::Clock, - _associated_retry_id: ::RetryID, - _associated_session_id: ::SessionID, - _associated_task_id: ::TaskID, - _protocol_message_rx: tokio::sync::mpsc::UnboundedReceiver, - _additional_params: Self::AdditionalParams, - ) -> Result { - Ok(JobBuilder::new().protocol(async move { Ok(()) }).build()) - } -} diff --git a/protocols/zcash-frost/src/protocol/keygen.rs b/protocols/zcash-frost/src/protocol/keygen.rs new file mode 100644 index 000000000..4ec4f0296 --- /dev/null +++ b/protocols/zcash-frost/src/protocol/keygen.rs @@ -0,0 +1,463 @@ +use frost_ed25519::Ed25519Sha512; +use frost_ed448::Ed448Shake256; +use frost_p256::P256Sha256; +use frost_p384::P384Sha384; +use frost_ristretto255::Ristretto255Sha512; +use frost_secp256k1::Secp256K1Sha256; +use futures::StreamExt; +use gadget_common::client::JobsApiForGadget; +use gadget_common::client::{ + AccountId, ClientWithApi, GadgetJobResult, MaxKeyLen, MaxParticipants, MaxSignatureLen, +}; +use gadget_common::config::{Network, ProvideRuntimeApi}; +use gadget_common::debug_logger::DebugLogger; +use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; +use gadget_common::gadget::work_manager::WorkManager; +use gadget_common::gadget::{GadgetProtocol, JobInitMetadata}; +use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; +use gadget_common::Block; +use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; +use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; +use itertools::Itertools; +use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; +use pallet_dkg::signatures_schemes::to_slice_33; +use rand::SeedableRng; +use sc_client_api::Backend; +use sp_application_crypto::sp_core::keccak_256; +use sp_core::{ecdsa, Pair}; +use std::collections::{BTreeMap, HashMap}; +use std::sync::Arc; +use tangle_primitives::jobs::{DKGTSSKeySubmissionResult, DigitalSignatureScheme, JobId, JobType}; +use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; +use tokio::sync::mpsc::UnboundedReceiver; + +use crate::rounds; + +use super::util::PublicKeyGossipMessage; + +#[derive(Clone)] +pub struct ZcashFrostKeygenExtraParams { + pub i: u16, + pub t: u16, + pub n: u16, + pub job_id: JobId, + pub role_type: RoleType, + pub user_id_to_account_id_mapping: Arc>, +} + +pub async fn create_next_job< + B: Block, + BE: Backend, + C: ClientWithApi, + N: Network, + KBE: KeystoreBackend, +>( + config: &crate::ZcashFrostKeygenProtocol, + job: JobInitMetadata, + _work_manager: &ProtocolWorkManager, +) -> Result +where + >::Api: JobsApiForGadget, +{ + let job_id = job.job_id; + let role_type = job.job_type.get_role_type(); + + // We can safely make this assumption because we are only creating jobs for phase one + let JobType::DKGTSSPhaseOne(p1_job) = job.job_type else { + panic!("Should be valid type") + }; + + let participants = p1_job.participants; + let threshold = p1_job.threshold; + + let user_id_to_account_id_mapping = Arc::new( + participants + .clone() + .into_iter() + .enumerate() + .map(|r| (r.0 as UserID, r.1)) + .collect(), + ); + + let params = ZcashFrostKeygenExtraParams { + i: participants + .iter() + .position(|p| p == &config.account_id) + .expect("Should exist") as u16, + t: threshold as u16, + n: participants.len() as u16, + role_type, + job_id, + user_id_to_account_id_mapping, + }; + + Ok(params) +} + +macro_rules! run_threshold_keygen { + ($impl_type:ty, $tracer:expr, $i:expr, $t:expr, $n:expr, $role:expr, $rng:expr, $party:expr) => { + rounds::keygen::run_threshold_keygen::<$impl_type, _, _>( + Some($tracer), + $i, + $t, + $n, + $role, + $rng, + $party, + ) + .await + .map_err(|err| { + println!("Keygen protocol error: {err:#?}"); + err.to_string() + })? + }; +} + +pub async fn generate_protocol_from< + B: Block, + BE: Backend, + C: ClientWithApi, + N: Network, + KBE: KeystoreBackend, +>( + config: &crate::ZcashFrostKeygenProtocol, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + protocol_message_channel: UnboundedReceiver, + additional_params: ZcashFrostKeygenExtraParams, +) -> Result +where + >::Api: JobsApiForGadget, +{ + let key_store = config.key_store.clone(); + let key_store2 = config.key_store.clone(); + let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); + let protocol_output_clone = protocol_output.clone(); + let pallet_tx = config.pallet_tx.clone(); + let id = config.account_id; + let logger = config.logger.clone(); + let network = config.network.clone(); + + let (i, t, n, mapping, role_type) = ( + additional_params.i, + additional_params.t, + additional_params.n, + additional_params.user_id_to_account_id_mapping, + additional_params.role_type, + ); + + let role = match role_type { + RoleType::Tss(role) => role, + _ => { + return Err(JobError { + reason: "Invalid role type".to_string(), + }) + } + }; + + Ok(JobBuilder::new() + .protocol(async move { + let mut rng = rand::rngs::StdRng::from_entropy(); + let protocol_message_channel = + super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + logger.info(format!( + "Starting Keygen Protocol with params: i={i}, t={t}, n={n}" + )); + + let ( + keygen_tx_to_outbound, + keygen_rx_async_proto, + broadcast_tx_to_outbound, + broadcast_rx_from_gadget, + ) = super::util::create_job_manager_to_async_protocol_channel_split( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); + let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); + let party = round_based::MpcParty::connected(delivery); + let frost_key_share_package = match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 => { + run_threshold_keygen!( + Ed25519Sha512, + &mut tracer, + i, + t, + n, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostEd448 => { + run_threshold_keygen!( + Ed448Shake256, + &mut tracer, + i, + t, + n, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostP256 => { + run_threshold_keygen!(P256Sha256, &mut tracer, i, t, n, role, &mut rng, party) + } + ThresholdSignatureRoleType::ZcashFrostP384 => { + run_threshold_keygen!(P384Sha384, &mut tracer, i, t, n, role, &mut rng, party) + } + ThresholdSignatureRoleType::ZcashFrostRistretto255 => { + run_threshold_keygen!( + Ristretto255Sha512, + &mut tracer, + i, + t, + n, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { + run_threshold_keygen!( + Secp256K1Sha256, + &mut tracer, + i, + t, + n, + role, + &mut rng, + party + ) + } + _ => unreachable!("Invalid role"), + }; + let perf_report = tracer.get_report().map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })?; + logger.trace(format!("Incomplete Keygen protocol report: {perf_report}")); + logger.debug("Finished AsyncProtocol - Incomplete Keygen"); + + let job_result = handle_public_key_gossip( + key_store2, + &logger, + &frost_key_share_package.verifying_key, + role, + t, + i, + broadcast_tx_to_outbound, + broadcast_rx_from_gadget, + ) + .await?; + + *protocol_output.lock().await = Some((frost_key_share_package, job_result)); + Ok(()) + }) + .post(async move { + // TODO: handle protocol blames + // Store the keys locally, as well as submitting them to the blockchain + if let Some((local_key, job_result)) = protocol_output_clone.lock().await.take() { + key_store + .set_job_result(additional_params.job_id, local_key) + .await + .map_err(|err| JobError { + reason: format!("Failed to store key: {err:?}"), + })?; + + pallet_tx + .submit_job_result( + additional_params.role_type, + additional_params.job_id, + job_result, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to submit job result: {err:?}"), + })?; + } + + Ok(()) + }) + .build()) +} + +#[allow(clippy::too_many_arguments)] +async fn handle_public_key_gossip( + key_store: ECDSAKeyStore, + logger: &DebugLogger, + public_key_package: &[u8], + role: ThresholdSignatureRoleType, + t: u16, + i: u16, + broadcast_tx_to_outbound: futures::channel::mpsc::UnboundedSender, + mut broadcast_rx_from_gadget: futures::channel::mpsc::UnboundedReceiver, +) -> Result { + let key_hashed = keccak_256(public_key_package); + let signature = key_store.pair().sign_prehashed(&key_hashed).0.to_vec(); + let my_id = key_store.pair().public(); + let mut received_keys = BTreeMap::new(); + received_keys.insert(i, signature.clone()); + let mut received_participants = BTreeMap::new(); + received_participants.insert(i, my_id); + + broadcast_tx_to_outbound + .unbounded_send(PublicKeyGossipMessage { + from: i as _, + to: None, + signature, + id: my_id, + }) + .map_err(|err| JobError { + reason: format!("Failed to send public key: {err:?}"), + })?; + + for _ in 0..t { + let message = broadcast_rx_from_gadget + .next() + .await + .ok_or_else(|| JobError { + reason: "Failed to receive public key".to_string(), + })?; + + let from = message.from; + logger.debug(format!("Received public key from {from}")); + + if received_keys.contains_key(&(from as u16)) { + logger.warn("Received duplicate key"); + continue; + } + // verify signature + let maybe_signature = sp_core::ecdsa::Signature::from_slice(&message.signature); + match maybe_signature.and_then(|s| s.recover_prehashed(&key_hashed)) { + Some(p) if p != message.id => { + logger.warn(format!( + "Received invalid signature from {from} not signed by them" + )); + } + Some(p) if p == message.id => { + logger.debug(format!("Received valid signature from {from}")); + } + Some(_) => unreachable!("Should not happen"), + None => { + logger.warn(format!("Received invalid signature from {from}")); + continue; + } + } + + received_keys.insert(from as u16, message.signature); + received_participants.insert(from as u16, message.id); + logger.debug(format!( + "Received {}/{} signatures", + received_keys.len(), + t + 1 + )); + } + + // Order and collect the map to ensure symmetric submission to blockchain + let signatures = received_keys + .into_iter() + .sorted_by_key(|x| x.0) + .map(|r| r.1.try_into().unwrap()) + .collect::>(); + + let participants = received_participants + .into_iter() + .sorted_by_key(|x| x.0) + .map(|r| r.1 .0.to_vec().try_into().unwrap()) + .collect::>() + .try_into() + .unwrap(); + + if signatures.len() < t as usize { + return Err(JobError { + reason: format!( + "Received {} signatures, expected at least {}", + signatures.len(), + t + 1, + ), + }); + } + + let res = DKGTSSKeySubmissionResult { + signature_scheme: match role { + ThresholdSignatureRoleType::ZcashFrostEd25519 => DigitalSignatureScheme::SchnorrEd25519, + ThresholdSignatureRoleType::ZcashFrostEd448 => DigitalSignatureScheme::SchnorrEd448, + ThresholdSignatureRoleType::ZcashFrostP256 => DigitalSignatureScheme::SchnorrP256, + ThresholdSignatureRoleType::ZcashFrostP384 => DigitalSignatureScheme::SchnorrP384, + ThresholdSignatureRoleType::ZcashFrostRistretto255 => { + DigitalSignatureScheme::SchnorrRistretto255 + } + ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { + DigitalSignatureScheme::SchnorrSecp256k1 + } + _ => unreachable!("Invalid role"), + }, + key: public_key_package.to_vec().try_into().unwrap(), + participants, + signatures: signatures.try_into().unwrap(), + threshold: t as _, + }; + verify_generated_dkg_key_ecdsa(res.clone(), logger); + Ok(GadgetJobResult::DKGPhaseOne(res)) +} + +fn verify_generated_dkg_key_ecdsa( + data: DKGTSSKeySubmissionResult, + logger: &DebugLogger, +) { + // Ensure participants and signatures are not empty + assert!(!data.participants.is_empty(), "NoParticipantsFound",); + assert!(!data.signatures.is_empty(), "NoSignaturesFound"); + + // Generate the required ECDSA signers + let maybe_signers = data + .participants + .iter() + .map(|x| { + ecdsa::Public( + to_slice_33(x) + .unwrap_or_else(|| panic!("Failed to convert input to ecdsa public key")), + ) + }) + .collect::>(); + + assert!(!maybe_signers.is_empty(), "NoParticipantsFound"); + + let mut known_signers: Vec = Default::default(); + + for signature in data.signatures { + // Ensure the required signer signature exists + let (maybe_authority, success) = + verify_signer_from_set_ecdsa(maybe_signers.clone(), &data.key, &signature); + + if success { + let authority = maybe_authority.expect("CannotRetreiveSigner"); + + // Ensure no duplicate signatures + assert!(!known_signers.contains(&authority), "DuplicateSignature"); + + logger.debug(format!("Verified signature from {}", authority)); + known_signers.push(authority); + } + } + + // Ensure a sufficient number of unique signers are present + assert!( + known_signers.len() > data.threshold as usize, + "NotEnoughSigners" + ); + logger.debug(format!( + "Verified {}/{} signatures", + known_signers.len(), + data.threshold + 1 + )); +} diff --git a/protocols/zcash-frost/src/protocols/mod.rs b/protocols/zcash-frost/src/protocol/mod.rs similarity index 100% rename from protocols/zcash-frost/src/protocols/mod.rs rename to protocols/zcash-frost/src/protocol/mod.rs diff --git a/protocols/zcash-frost/src/protocol/sign.rs b/protocols/zcash-frost/src/protocol/sign.rs new file mode 100644 index 000000000..ab243d295 --- /dev/null +++ b/protocols/zcash-frost/src/protocol/sign.rs @@ -0,0 +1,386 @@ +use frame_support::BoundedVec; +use frost_core::keys::{KeyPackage, PublicKeyPackage}; +use frost_ed25519::Ed25519Sha512; +use frost_ed448::Ed448Shake256; +use frost_p256::P256Sha256; +use frost_p384::P384Sha384; +use frost_ristretto255::Ristretto255Sha512; +use frost_secp256k1::Secp256K1Sha256; +use gadget_common::client::JobsApiForGadget; +use gadget_common::client::{AccountId, ClientWithApi, GadgetJobResult}; +use gadget_common::config::{Network, ProvideRuntimeApi}; + +use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; +use gadget_common::gadget::work_manager::WorkManager; +use gadget_common::gadget::{GadgetProtocol, JobInitMetadata}; +use gadget_common::keystore::KeystoreBackend; + +use gadget_common::Block; +use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; +use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; +use rand::SeedableRng; +use round_based::MpcParty; +use sc_client_api::Backend; +use sp_core::keccak_256; +use std::collections::HashMap; +use std::sync::Arc; +use tangle_primitives::jobs::{DKGTSSSignatureResult, DigitalSignatureScheme, JobId, JobType}; +use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; +use tokio::sync::mpsc::UnboundedReceiver; + +use crate::rounds; +use crate::rounds::keygen::FrostKeyShare; + +#[derive(Clone)] +pub struct ZcashFrostSigningExtraParams { + pub i: u16, + pub t: u16, + pub signers: Vec, + pub job_id: JobId, + pub role_type: RoleType, + pub keyshare: FrostKeyShare, + pub input_data_to_sign: Vec, + pub user_id_to_account_id_mapping: Arc>, +} + +pub async fn create_next_job< + B: Block, + BE: Backend, + C: ClientWithApi, + N: Network, + KBE: KeystoreBackend, +>( + config: &crate::ZcashFrostSigningProtocol, + job: JobInitMetadata, + _work_manager: &ProtocolWorkManager, +) -> Result +where + >::Api: JobsApiForGadget, +{ + let job_id = job.job_id; + + let JobType::DKGTSSPhaseTwo(p2_job) = job.job_type else { + panic!("Should be valid type") + }; + let input_data_to_sign = p2_job.submission.try_into().unwrap(); + let previous_job_id = p2_job.phase_one_id; + + let phase1_job = job.phase1_job.expect("Should exist for a phase 2 job"); + let participants = phase1_job.clone().get_participants().expect("Should exist"); + let t = phase1_job.get_threshold().expect("Should exist") as u16; + + let seed = keccak_256(&[&job_id.to_be_bytes()[..], &job.retry_id.to_be_bytes()[..]].concat()); + let mut rng = rand_chacha::ChaChaRng::from_seed(seed); + + let (i, signers, mapping) = + super::util::choose_signers(&mut rng, &config.account_id, &participants, t)?; + let key = config + .key_store + .get_job_result(previous_job_id) + .await + .map_err(|err| gadget_common::Error::ClientError { + err: err.to_string(), + })? + .ok_or_else(|| gadget_common::Error::ClientError { + err: format!("No key found for job ID: {job_id:?}"), + })?; + + let user_id_to_account_id_mapping = Arc::new(mapping); + + let params = ZcashFrostSigningExtraParams { + i, + t, + signers, + job_id, + role_type: job.role_type, + keyshare: key, + input_data_to_sign, + user_id_to_account_id_mapping, + }; + Ok(params) +} + +macro_rules! deserialize_and_run_threshold_sign { + ($impl_type:ty, $keyshare:expr, $tracer:expr, $i:expr, $signers:expr, $msg:expr, $role:expr, $rng:expr, $party:expr) => {{ + let key_package = + KeyPackage::<$impl_type>::deserialize(&$keyshare.key_package).map_err(|err| { + JobError { + reason: format!("Failed to deserialize key share: {err:?}"), + } + })?; + + let public_key_package = PublicKeyPackage::<$impl_type>::deserialize( + &$keyshare.pubkey_package, + ) + .map_err(|err| JobError { + reason: format!("Failed to deserialize public key package: {err:?}"), + })?; + + rounds::sign::run_threshold_sign( + Some($tracer), + $i, + $signers, + (key_package, public_key_package), + $msg, + $role, + $rng, + $party, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to run threshold sign: {err:?}"), + })? + }}; +} + +pub async fn generate_protocol_from< + B: Block, + BE: Backend, + C: ClientWithApi, + N: Network, + KBE: KeystoreBackend, +>( + config: &crate::ZcashFrostSigningProtocol, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + protocol_message_channel: UnboundedReceiver, + additional_params: ZcashFrostSigningExtraParams, +) -> Result +where + >::Api: JobsApiForGadget, +{ + let debug_logger_post = config.logger.clone(); + let logger = debug_logger_post.clone(); + let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); + let protocol_output_clone = protocol_output.clone(); + let pallet_tx = config.pallet_tx.clone(); + let id = config.account_id; + let network = config.network.clone(); + + let (i, signers, t, keyshare, role_type, input_data_to_sign, mapping) = ( + additional_params.i, + additional_params.signers, + additional_params.t, + additional_params.keyshare, + additional_params.role_type, + additional_params.input_data_to_sign.clone(), + additional_params.user_id_to_account_id_mapping.clone(), + ); + + let role = match role_type { + RoleType::Tss(role) => role, + _ => { + return Err(JobError { + reason: "Invalid role type".to_string(), + }) + } + }; + + Ok(JobBuilder::new() + .protocol(async move { + let mut rng = rand::rngs::StdRng::from_entropy(); + let protocol_message_channel = + super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + + logger.info(format!( + "Starting Signing Protocol with params: i={i}, t={t}" + )); + + let ( + signing_tx_to_outbound, + signing_rx_async_proto, + _broadcast_tx_to_outbound, + _broadcast_rx_from_gadget, + ) = super::util::create_job_manager_to_async_protocol_channel_split::<_, (), _>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + + let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); + let delivery = (signing_rx_async_proto, signing_tx_to_outbound); + let party = MpcParty::connected(delivery); + let signature = match role { + ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { + deserialize_and_run_threshold_sign!( + Secp256K1Sha256, + keyshare, + &mut tracer, + i, + signers, + &input_data_to_sign, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostEd25519 => { + deserialize_and_run_threshold_sign!( + Ed25519Sha512, + keyshare, + &mut tracer, + i, + signers, + &input_data_to_sign, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostEd448 => { + deserialize_and_run_threshold_sign!( + Ed448Shake256, + keyshare, + &mut tracer, + i, + signers, + &input_data_to_sign, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostP256 => { + deserialize_and_run_threshold_sign!( + P256Sha256, + keyshare, + &mut tracer, + i, + signers, + &input_data_to_sign, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostP384 => { + deserialize_and_run_threshold_sign!( + P384Sha384, + keyshare, + &mut tracer, + i, + signers, + &input_data_to_sign, + role, + &mut rng, + party + ) + } + ThresholdSignatureRoleType::ZcashFrostRistretto255 => { + deserialize_and_run_threshold_sign!( + Ristretto255Sha512, + keyshare, + &mut tracer, + i, + signers, + &input_data_to_sign, + role, + &mut rng, + party + ) + } + _ => { + return Err(JobError { + reason: "Invalid role type".to_string(), + }) + } + }; + let perf_report = tracer.get_report().map_err(|err| JobError { + reason: format!("Signing protocol error: {err:?}"), + })?; + logger.trace(format!("Signing protocol report: {perf_report}")); + logger.debug("Finished AsyncProtocol - Signing"); + *protocol_output.lock().await = Some(signature); + Ok(()) + }) + .post(async move { + // Submit the protocol output to the blockchain + if let Some(signature) = protocol_output_clone.lock().await.take() { + // Compute the signature bytes by first converting the signature + // to a fixed byte array and then converting that to a Vec. + let (signature, signature_scheme) = match role { + ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { + let mut signature_bytes = [0u8; 65]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec().try_into().unwrap(), + DigitalSignatureScheme::SchnorrSecp256k1, + ) + } + ThresholdSignatureRoleType::ZcashFrostEd25519 => { + let mut signature_bytes = [0u8; 64]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec().try_into().unwrap(), + DigitalSignatureScheme::SchnorrEd25519, + ) + } + ThresholdSignatureRoleType::ZcashFrostEd448 => { + let mut signature_bytes = [0u8; 114]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec().try_into().unwrap(), + DigitalSignatureScheme::SchnorrEd448, + ) + } + ThresholdSignatureRoleType::ZcashFrostP256 => { + let mut signature_bytes = [0u8; 65]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec().try_into().unwrap(), + DigitalSignatureScheme::SchnorrP256, + ) + } + ThresholdSignatureRoleType::ZcashFrostP384 => { + let mut signature_bytes = [0u8; 97]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec().try_into().unwrap(), + DigitalSignatureScheme::SchnorrP384, + ) + } + ThresholdSignatureRoleType::ZcashFrostRistretto255 => { + let mut signature_bytes = [0u8; 64]; + signature_bytes.copy_from_slice(&signature.group_signature); + ( + signature_bytes.to_vec().try_into().unwrap(), + DigitalSignatureScheme::SchnorrRistretto255, + ) + } + _ => { + return Err(JobError { + reason: "Invalid role type".to_string(), + }) + } + }; + + let job_result = GadgetJobResult::DKGPhaseTwo(DKGTSSSignatureResult { + signature_scheme, + data: additional_params.input_data_to_sign.try_into().unwrap(), + signature, + verifying_key: BoundedVec::new(), + }); + + pallet_tx + .submit_job_result( + additional_params.role_type, + additional_params.job_id, + job_result, + ) + .await + .map_err(|err| JobError { + reason: format!("Failed to submit job result: {err:?}"), + })?; + } + + Ok(()) + }) + .build()) +} diff --git a/protocols/zcash-frost/src/protocols/util.rs b/protocols/zcash-frost/src/protocol/util.rs similarity index 100% rename from protocols/zcash-frost/src/protocols/util.rs rename to protocols/zcash-frost/src/protocol/util.rs diff --git a/protocols/zcash-frost/src/protocols/keygen.rs b/protocols/zcash-frost/src/protocols/keygen.rs deleted file mode 100644 index 0ec650229..000000000 --- a/protocols/zcash-frost/src/protocols/keygen.rs +++ /dev/null @@ -1,578 +0,0 @@ -use async_trait::async_trait; -use frost_ed25519::Ed25519Sha512; -use frost_ed448::Ed448Shake256; -use frost_p256::P256Sha256; -use frost_p384::P384Sha384; -use frost_ristretto255::Ristretto255Sha512; -use frost_secp256k1::Secp256K1Sha256; -use futures::StreamExt; -use gadget_common::client::JobsApiForGadget; -use gadget_common::client::{ - AccountId, ClientWithApi, GadgetJobResult, GadgetJobType, JobsClient, MaxKeyLen, - MaxParticipants, MaxSignatureLen, -}; -use gadget_common::debug_logger::DebugLogger; -use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; -use gadget_common::gadget::network::Network; -use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::gadget::{GadgetProtocol, JobInitMetadata, WorkManagerConfig}; -use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; -use gadget_common::protocol::AsyncProtocol; -use gadget_common::{Block, BlockImportNotification}; -use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; -use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; -use itertools::Itertools; -use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; -use pallet_dkg::signatures_schemes::to_slice_33; -use rand::SeedableRng; -use sc_client_api::Backend; -use sp_api::ProvideRuntimeApi; -use sp_application_crypto::sp_core::keccak_256; -use sp_core::{ecdsa, Pair}; -use std::collections::{BTreeMap, HashMap}; -use std::sync::Arc; -use tangle_primitives::jobs::{DKGTSSKeySubmissionResult, DigitalSignatureScheme, JobId, JobType}; -use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; -use tokio::sync::mpsc::UnboundedReceiver; - -use crate::rounds; - -use super::util::PublicKeyGossipMessage; - -pub struct ZcashFrostKeygenProtocol { - client: JobsClient, - key_store: ECDSAKeyStore, - network: N, - logger: DebugLogger, - account_id: AccountId, -} - -pub async fn create_protocol( - account_id: AccountId, - client: JobsClient, - network: N, - logger: DebugLogger, - key_store: ECDSAKeyStore, -) -> ZcashFrostKeygenProtocol -where - B: Block, - BE: Backend, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - >::Api: JobsApiForGadget, -{ - ZcashFrostKeygenProtocol { - client, - network, - key_store, - logger, - account_id, - } -} - -#[async_trait] -impl< - B: Block, - BE: Backend + 'static, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - > GadgetProtocol for ZcashFrostKeygenProtocol -where - >::Api: JobsApiForGadget, -{ - fn name(&self) -> String { - "zcash-frost-keygen".to_string() - } - - async fn create_next_job( - &self, - job: JobInitMetadata, - ) -> Result<::AdditionalParams, gadget_common::Error> { - let job_id = job.job_id; - let role_type = job.job_type.get_role_type(); - - // We can safely make this assumption because we are only creating jobs for phase one - let JobType::DKGTSSPhaseOne(p1_job) = job.job_type else { - panic!("Should be valid type") - }; - - let participants = p1_job.participants; - let threshold = p1_job.threshold; - - let user_id_to_account_id_mapping = Arc::new( - participants - .clone() - .into_iter() - .enumerate() - .map(|r| (r.0 as UserID, r.1)) - .collect(), - ); - - let params = ZcashFrostKeygenExtraParams { - i: participants - .iter() - .position(|p| p == &self.account_id) - .expect("Should exist") as u16, - t: threshold as u16, - n: participants.len() as u16, - role_type, - job_id, - user_id_to_account_id_mapping, - }; - - Ok(params) - } - - async fn process_block_import_notification( - &self, - _notification: BlockImportNotification, - _job_manager: &ProtocolWorkManager, - ) -> Result<(), gadget_common::Error> { - Ok(()) - } - - async fn process_error( - &self, - error: gadget_common::Error, - _job_manager: &ProtocolWorkManager, - ) { - log::error!(target: "zcash_frost", "Error: {error:?}"); - } - - fn account_id(&self) -> &AccountId { - &self.account_id - } - - fn role_filter(&self, role: RoleType) -> bool { - matches!( - role, - RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd448) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP384) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) - ) - } - - fn phase_filter(&self, job: GadgetJobType) -> bool { - matches!(job, JobType::DKGTSSPhaseOne(_)) - } - - fn client(&self) -> JobsClient { - self.client.clone() - } - - fn logger(&self) -> DebugLogger { - self.logger.clone() - } - - fn get_work_manager_config(&self) -> WorkManagerConfig { - WorkManagerConfig { - interval: None, // Manual polling - max_active_tasks: crate::constants::keygen_worker::MAX_RUNNING_TASKS, - max_pending_tasks: crate::constants::keygen_worker::MAX_ENQUEUED_TASKS, - } - } -} - -macro_rules! run_threshold_keygen { - ($impl_type:ty, $tracer:expr, $i:expr, $t:expr, $n:expr, $role:expr, $rng:expr, $party:expr) => { - rounds::keygen::run_threshold_keygen::<$impl_type, _, _>( - Some($tracer), - $i, - $t, - $n, - $role, - $rng, - $party, - ) - .await - .map_err(|err| { - println!("Keygen protocol error: {err:#?}"); - err.to_string() - })? - }; -} - -pub struct ZcashFrostKeygenExtraParams { - i: u16, - t: u16, - n: u16, - job_id: JobId, - role_type: RoleType, - user_id_to_account_id_mapping: Arc>, -} - -#[async_trait] -impl< - B: Block, - BE: Backend + 'static, - KBE: KeystoreBackend, - C: ClientWithApi, - N: Network, - > AsyncProtocol for ZcashFrostKeygenProtocol -where - >::Api: JobsApiForGadget, -{ - type AdditionalParams = ZcashFrostKeygenExtraParams; - async fn generate_protocol_from( - &self, - associated_block_id: ::Clock, - associated_retry_id: ::RetryID, - associated_session_id: ::SessionID, - associated_task_id: ::TaskID, - protocol_message_channel: UnboundedReceiver, - additional_params: Self::AdditionalParams, - ) -> Result { - let key_store = self.key_store.clone(); - let key_store2 = self.key_store.clone(); - let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); - let protocol_output_clone = protocol_output.clone(); - let client = self.client.clone(); - let id = self.account_id; - let logger = self.logger.clone(); - let network = self.network.clone(); - - let (i, t, n, mapping, role_type) = ( - additional_params.i, - additional_params.t, - additional_params.n, - additional_params.user_id_to_account_id_mapping, - additional_params.role_type, - ); - - let role = match role_type { - RoleType::Tss(role) => role, - _ => { - return Err(JobError { - reason: "Invalid role type".to_string(), - }) - } - }; - - Ok(JobBuilder::new() - .protocol(async move { - let mut rng = rand::rngs::StdRng::from_entropy(); - let protocol_message_channel = - super::util::CloneableUnboundedReceiver::from(protocol_message_channel); - logger.info(format!( - "Starting Keygen Protocol with params: i={i}, t={t}, n={n}" - )); - - let ( - keygen_tx_to_outbound, - keygen_rx_async_proto, - broadcast_tx_to_outbound, - broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - id, - network.clone(), - ); - let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); - let party = round_based::MpcParty::connected(delivery); - let frost_key_share_package = match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 => { - run_threshold_keygen!( - Ed25519Sha512, - &mut tracer, - i, - t, - n, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostEd448 => { - run_threshold_keygen!( - Ed448Shake256, - &mut tracer, - i, - t, - n, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostP256 => { - run_threshold_keygen!( - P256Sha256, - &mut tracer, - i, - t, - n, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostP384 => { - run_threshold_keygen!( - P384Sha384, - &mut tracer, - i, - t, - n, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostRistretto255 => { - run_threshold_keygen!( - Ristretto255Sha512, - &mut tracer, - i, - t, - n, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { - run_threshold_keygen!( - Secp256K1Sha256, - &mut tracer, - i, - t, - n, - role, - &mut rng, - party - ) - } - _ => unreachable!("Invalid role"), - }; - let perf_report = tracer.get_report().map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - })?; - logger.trace(format!("Incomplete Keygen protocol report: {perf_report}")); - logger.debug("Finished AsyncProtocol - Incomplete Keygen"); - - let job_result = handle_public_key_gossip( - key_store2, - &logger, - &frost_key_share_package.verifying_key, - role, - t, - i, - broadcast_tx_to_outbound, - broadcast_rx_from_gadget, - ) - .await?; - - *protocol_output.lock().await = Some((frost_key_share_package, job_result)); - Ok(()) - }) - .post(async move { - // TODO: handle protocol blames - // Store the keys locally, as well as submitting them to the blockchain - if let Some((local_key, job_result)) = protocol_output_clone.lock().await.take() { - key_store - .set_job_result(additional_params.job_id, local_key) - .await - .map_err(|err| JobError { - reason: format!("Failed to store key: {err:?}"), - })?; - - client - .submit_job_result( - additional_params.role_type, - additional_params.job_id, - job_result, - ) - .await - .map_err(|err| JobError { - reason: format!("Failed to submit job result: {err:?}"), - })?; - } - - Ok(()) - }) - .build()) - } -} - -#[allow(clippy::too_many_arguments)] -async fn handle_public_key_gossip( - key_store: ECDSAKeyStore, - logger: &DebugLogger, - public_key_package: &[u8], - role: ThresholdSignatureRoleType, - t: u16, - i: u16, - broadcast_tx_to_outbound: futures::channel::mpsc::UnboundedSender, - mut broadcast_rx_from_gadget: futures::channel::mpsc::UnboundedReceiver, -) -> Result { - let key_hashed = keccak_256(public_key_package); - let signature = key_store.pair().sign_prehashed(&key_hashed).0.to_vec(); - let my_id = key_store.pair().public(); - let mut received_keys = BTreeMap::new(); - received_keys.insert(i, signature.clone()); - let mut received_participants = BTreeMap::new(); - received_participants.insert(i, my_id); - - broadcast_tx_to_outbound - .unbounded_send(PublicKeyGossipMessage { - from: i as _, - to: None, - signature, - id: my_id, - }) - .map_err(|err| JobError { - reason: format!("Failed to send public key: {err:?}"), - })?; - - for _ in 0..t { - let message = broadcast_rx_from_gadget - .next() - .await - .ok_or_else(|| JobError { - reason: "Failed to receive public key".to_string(), - })?; - - let from = message.from; - logger.debug(format!("Received public key from {from}")); - - if received_keys.contains_key(&(from as u16)) { - logger.warn("Received duplicate key"); - continue; - } - // verify signature - let maybe_signature = sp_core::ecdsa::Signature::from_slice(&message.signature); - match maybe_signature.and_then(|s| s.recover_prehashed(&key_hashed)) { - Some(p) if p != message.id => { - logger.warn(format!( - "Received invalid signature from {from} not signed by them" - )); - } - Some(p) if p == message.id => { - logger.debug(format!("Received valid signature from {from}")); - } - Some(_) => unreachable!("Should not happen"), - None => { - logger.warn(format!("Received invalid signature from {from}")); - continue; - } - } - - received_keys.insert(from as u16, message.signature); - received_participants.insert(from as u16, message.id); - logger.debug(format!( - "Received {}/{} signatures", - received_keys.len(), - t + 1 - )); - } - - // Order and collect the map to ensure symmetric submission to blockchain - let signatures = received_keys - .into_iter() - .sorted_by_key(|x| x.0) - .map(|r| r.1.try_into().unwrap()) - .collect::>(); - - let participants = received_participants - .into_iter() - .sorted_by_key(|x| x.0) - .map(|r| r.1 .0.to_vec().try_into().unwrap()) - .collect::>() - .try_into() - .unwrap(); - - if signatures.len() < t as usize { - return Err(JobError { - reason: format!( - "Received {} signatures, expected at least {}", - signatures.len(), - t + 1, - ), - }); - } - - let res = DKGTSSKeySubmissionResult { - signature_scheme: match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 => DigitalSignatureScheme::SchnorrEd25519, - ThresholdSignatureRoleType::ZcashFrostEd448 => DigitalSignatureScheme::SchnorrEd448, - ThresholdSignatureRoleType::ZcashFrostP256 => DigitalSignatureScheme::SchnorrP256, - ThresholdSignatureRoleType::ZcashFrostP384 => DigitalSignatureScheme::SchnorrP384, - ThresholdSignatureRoleType::ZcashFrostRistretto255 => { - DigitalSignatureScheme::SchnorrRistretto255 - } - ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { - DigitalSignatureScheme::SchnorrSecp256k1 - } - _ => unreachable!("Invalid role"), - }, - key: public_key_package.to_vec().try_into().unwrap(), - participants, - signatures: signatures.try_into().unwrap(), - threshold: t as _, - }; - verify_generated_dkg_key_ecdsa(res.clone(), logger); - Ok(GadgetJobResult::DKGPhaseOne(res)) -} - -fn verify_generated_dkg_key_ecdsa( - data: DKGTSSKeySubmissionResult, - logger: &DebugLogger, -) { - // Ensure participants and signatures are not empty - assert!(!data.participants.is_empty(), "NoParticipantsFound",); - assert!(!data.signatures.is_empty(), "NoSignaturesFound"); - - // Generate the required ECDSA signers - let maybe_signers = data - .participants - .iter() - .map(|x| { - ecdsa::Public( - to_slice_33(x) - .unwrap_or_else(|| panic!("Failed to convert input to ecdsa public key")), - ) - }) - .collect::>(); - - assert!(!maybe_signers.is_empty(), "NoParticipantsFound"); - - let mut known_signers: Vec = Default::default(); - - for signature in data.signatures { - // Ensure the required signer signature exists - let (maybe_authority, success) = - verify_signer_from_set_ecdsa(maybe_signers.clone(), &data.key, &signature); - - if success { - let authority = maybe_authority.expect("CannotRetreiveSigner"); - - // Ensure no duplicate signatures - assert!(!known_signers.contains(&authority), "DuplicateSignature"); - - logger.debug(format!("Verified signature from {}", authority)); - known_signers.push(authority); - } - } - - // Ensure a sufficient number of unique signers are present - assert!( - known_signers.len() > data.threshold as usize, - "NotEnoughSigners" - ); - logger.debug(format!( - "Verified {}/{} signatures", - known_signers.len(), - data.threshold + 1 - )); -} diff --git a/protocols/zcash-frost/src/protocols/sign.rs b/protocols/zcash-frost/src/protocols/sign.rs deleted file mode 100644 index 381af5478..000000000 --- a/protocols/zcash-frost/src/protocols/sign.rs +++ /dev/null @@ -1,482 +0,0 @@ -use async_trait::async_trait; -use frame_support::BoundedVec; -use frost_core::keys::{KeyPackage, PublicKeyPackage}; -use frost_ed25519::Ed25519Sha512; -use frost_ed448::Ed448Shake256; -use frost_p256::P256Sha256; -use frost_p384::P384Sha384; -use frost_ristretto255::Ristretto255Sha512; -use frost_secp256k1::Secp256K1Sha256; -use gadget_common::client::JobsApiForGadget; -use gadget_common::client::{AccountId, ClientWithApi, GadgetJobResult, GadgetJobType, JobsClient}; -use gadget_common::debug_logger::DebugLogger; -use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; -use gadget_common::gadget::network::Network; -use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::gadget::{GadgetProtocol, JobInitMetadata, WorkManagerConfig}; -use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; -use gadget_common::protocol::AsyncProtocol; -use gadget_common::{Block, BlockImportNotification}; -use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; -use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; -use rand::SeedableRng; -use round_based::MpcParty; -use sc_client_api::Backend; -use sp_api::ProvideRuntimeApi; -use sp_core::keccak_256; -use std::collections::HashMap; -use std::sync::Arc; -use tangle_primitives::jobs::{DKGTSSSignatureResult, DigitalSignatureScheme, JobId, JobType}; -use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; -use tokio::sync::mpsc::UnboundedReceiver; - -use crate::rounds; -use crate::rounds::keygen::FrostKeyShare; - -pub struct ZcashFrostSigningProtocol { - client: JobsClient, - key_store: ECDSAKeyStore, - network: N, - logger: DebugLogger, - account_id: AccountId, -} - -pub async fn create_protocol( - account_id: AccountId, - client: JobsClient, - network: N, - logger: DebugLogger, - key_store: ECDSAKeyStore, -) -> ZcashFrostSigningProtocol -where - B: Block, - BE: Backend, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - >::Api: JobsApiForGadget, -{ - ZcashFrostSigningProtocol { - client, - network, - key_store, - logger, - account_id, - } -} - -#[async_trait] -impl< - B: Block, - BE: Backend + 'static, - C: ClientWithApi, - KBE: KeystoreBackend, - N: Network, - > GadgetProtocol for ZcashFrostSigningProtocol -where - >::Api: JobsApiForGadget, -{ - fn name(&self) -> String { - "zcash-frost-signing".to_string() - } - - async fn create_next_job( - &self, - job: JobInitMetadata, - ) -> Result<::AdditionalParams, gadget_common::Error> { - let job_id = job.job_id; - - let JobType::DKGTSSPhaseTwo(p2_job) = job.job_type else { - panic!("Should be valid type") - }; - let input_data_to_sign = p2_job.submission.try_into().unwrap(); - let previous_job_id = p2_job.phase_one_id; - - let phase1_job = job.phase1_job.expect("Should exist for a phase 2 job"); - let participants = phase1_job.clone().get_participants().expect("Should exist"); - let t = phase1_job.get_threshold().expect("Should exist") as u16; - - let seed = - keccak_256(&[&job_id.to_be_bytes()[..], &job.retry_id.to_be_bytes()[..]].concat()); - let mut rng = rand_chacha::ChaChaRng::from_seed(seed); - - let (i, signers, mapping) = - super::util::choose_signers(&mut rng, &self.account_id, &participants, t)?; - let key = self - .key_store - .get_job_result(previous_job_id) - .await - .map_err(|err| gadget_common::Error::ClientError { - err: err.to_string(), - })? - .ok_or_else(|| gadget_common::Error::ClientError { - err: format!("No key found for job ID: {job_id:?}"), - })?; - - let user_id_to_account_id_mapping = Arc::new(mapping); - - let params = ZcashFrostSigningExtraParams { - i, - t, - signers, - job_id, - role_type: job.role_type, - keyshare: key, - input_data_to_sign, - user_id_to_account_id_mapping, - }; - Ok(params) - } - - async fn process_block_import_notification( - &self, - _notification: BlockImportNotification, - _job_manager: &ProtocolWorkManager, - ) -> Result<(), gadget_common::Error> { - Ok(()) - } - - async fn process_error( - &self, - error: gadget_common::Error, - _job_manager: &ProtocolWorkManager, - ) { - log::error!(target: "gadget", "Error: {error:?}"); - } - - fn account_id(&self) -> &AccountId { - &self.account_id - } - - fn role_filter(&self, role: RoleType) -> bool { - matches!( - role, - RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd25519) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostEd448) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP256) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostP384) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostRistretto255) - | RoleType::Tss(ThresholdSignatureRoleType::ZcashFrostSecp256k1) - ) - } - - fn phase_filter(&self, job: GadgetJobType) -> bool { - matches!(job, JobType::DKGTSSPhaseTwo(_)) - } - - fn client(&self) -> JobsClient { - self.client.clone() - } - - fn logger(&self) -> DebugLogger { - self.logger.clone() - } - - fn get_work_manager_config(&self) -> WorkManagerConfig { - WorkManagerConfig { - interval: Some(crate::constants::signing_worker::JOB_POLL_INTERVAL), - max_active_tasks: crate::constants::signing_worker::MAX_RUNNING_TASKS, - max_pending_tasks: crate::constants::signing_worker::MAX_ENQUEUED_TASKS, - } - } -} - -macro_rules! deserialize_and_run_threshold_sign { - ($impl_type:ty, $keyshare:expr, $tracer:expr, $i:expr, $signers:expr, $msg:expr, $role:expr, $rng:expr, $party:expr) => {{ - let key_package = - KeyPackage::<$impl_type>::deserialize(&$keyshare.key_package).map_err(|err| { - JobError { - reason: format!("Failed to deserialize key share: {err:?}"), - } - })?; - - let public_key_package = PublicKeyPackage::<$impl_type>::deserialize( - &$keyshare.pubkey_package, - ) - .map_err(|err| JobError { - reason: format!("Failed to deserialize public key package: {err:?}"), - })?; - - rounds::sign::run_threshold_sign( - Some($tracer), - $i, - $signers, - (key_package, public_key_package), - $msg, - $role, - $rng, - $party, - ) - .await - .map_err(|err| JobError { - reason: format!("Failed to run threshold sign: {err:?}"), - })? - }}; -} - -pub struct ZcashFrostSigningExtraParams { - i: u16, - t: u16, - signers: Vec, - job_id: JobId, - role_type: RoleType, - keyshare: FrostKeyShare, - input_data_to_sign: Vec, - user_id_to_account_id_mapping: Arc>, -} - -#[async_trait] -impl< - B: Block, - BE: Backend + 'static, - KBE: KeystoreBackend, - C: ClientWithApi, - N: Network, - > AsyncProtocol for ZcashFrostSigningProtocol -where - >::Api: JobsApiForGadget, -{ - type AdditionalParams = ZcashFrostSigningExtraParams; - async fn generate_protocol_from( - &self, - associated_block_id: ::Clock, - associated_retry_id: ::RetryID, - associated_session_id: ::SessionID, - associated_task_id: ::TaskID, - protocol_message_channel: UnboundedReceiver, - additional_params: Self::AdditionalParams, - ) -> Result { - let debug_logger_post = self.logger.clone(); - let logger = debug_logger_post.clone(); - let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); - let protocol_output_clone = protocol_output.clone(); - let client = self.client.clone(); - let id = self.account_id; - let network = self.network.clone(); - - let (i, signers, t, keyshare, role_type, input_data_to_sign, mapping) = ( - additional_params.i, - additional_params.signers, - additional_params.t, - additional_params.keyshare, - additional_params.role_type, - additional_params.input_data_to_sign.clone(), - additional_params.user_id_to_account_id_mapping.clone(), - ); - - let role = match role_type { - RoleType::Tss(role) => role, - _ => { - return Err(JobError { - reason: "Invalid role type".to_string(), - }) - } - }; - - Ok(JobBuilder::new() - .protocol(async move { - let mut rng = rand::rngs::StdRng::from_entropy(); - let protocol_message_channel = - super::util::CloneableUnboundedReceiver::from(protocol_message_channel); - - logger.info(format!( - "Starting Signing Protocol with params: i={i}, t={t}" - )); - - let ( - signing_tx_to_outbound, - signing_rx_async_proto, - _broadcast_tx_to_outbound, - _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split::<_, (), _>( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - id, - network.clone(), - ); - - let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - let delivery = (signing_rx_async_proto, signing_tx_to_outbound); - let party = MpcParty::connected(delivery); - let signature = match role { - ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { - deserialize_and_run_threshold_sign!( - Secp256K1Sha256, - keyshare, - &mut tracer, - i, - signers, - &input_data_to_sign, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostEd25519 => { - deserialize_and_run_threshold_sign!( - Ed25519Sha512, - keyshare, - &mut tracer, - i, - signers, - &input_data_to_sign, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostEd448 => { - deserialize_and_run_threshold_sign!( - Ed448Shake256, - keyshare, - &mut tracer, - i, - signers, - &input_data_to_sign, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostP256 => { - deserialize_and_run_threshold_sign!( - P256Sha256, - keyshare, - &mut tracer, - i, - signers, - &input_data_to_sign, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostP384 => { - deserialize_and_run_threshold_sign!( - P384Sha384, - keyshare, - &mut tracer, - i, - signers, - &input_data_to_sign, - role, - &mut rng, - party - ) - } - ThresholdSignatureRoleType::ZcashFrostRistretto255 => { - deserialize_and_run_threshold_sign!( - Ristretto255Sha512, - keyshare, - &mut tracer, - i, - signers, - &input_data_to_sign, - role, - &mut rng, - party - ) - } - _ => { - return Err(JobError { - reason: "Invalid role type".to_string(), - }) - } - }; - let perf_report = tracer.get_report().map_err(|err| JobError { - reason: format!("Signing protocol error: {err:?}"), - })?; - logger.trace(format!("Signing protocol report: {perf_report}")); - logger.debug("Finished AsyncProtocol - Signing"); - *protocol_output.lock().await = Some(signature); - Ok(()) - }) - .post(async move { - // Submit the protocol output to the blockchain - if let Some(signature) = protocol_output_clone.lock().await.take() { - // Compute the signature bytes by first converting the signature - // to a fixed byte array and then converting that to a Vec. - let (signature, signature_scheme) = match role { - ThresholdSignatureRoleType::ZcashFrostSecp256k1 => { - let mut signature_bytes = [0u8; 65]; - signature_bytes.copy_from_slice(&signature.group_signature); - ( - signature_bytes.to_vec().try_into().unwrap(), - DigitalSignatureScheme::SchnorrSecp256k1, - ) - } - ThresholdSignatureRoleType::ZcashFrostEd25519 => { - let mut signature_bytes = [0u8; 64]; - signature_bytes.copy_from_slice(&signature.group_signature); - ( - signature_bytes.to_vec().try_into().unwrap(), - DigitalSignatureScheme::SchnorrEd25519, - ) - } - ThresholdSignatureRoleType::ZcashFrostEd448 => { - let mut signature_bytes = [0u8; 114]; - signature_bytes.copy_from_slice(&signature.group_signature); - ( - signature_bytes.to_vec().try_into().unwrap(), - DigitalSignatureScheme::SchnorrEd448, - ) - } - ThresholdSignatureRoleType::ZcashFrostP256 => { - let mut signature_bytes = [0u8; 65]; - signature_bytes.copy_from_slice(&signature.group_signature); - ( - signature_bytes.to_vec().try_into().unwrap(), - DigitalSignatureScheme::SchnorrP256, - ) - } - ThresholdSignatureRoleType::ZcashFrostP384 => { - let mut signature_bytes = [0u8; 97]; - signature_bytes.copy_from_slice(&signature.group_signature); - ( - signature_bytes.to_vec().try_into().unwrap(), - DigitalSignatureScheme::SchnorrP384, - ) - } - ThresholdSignatureRoleType::ZcashFrostRistretto255 => { - let mut signature_bytes = [0u8; 64]; - signature_bytes.copy_from_slice(&signature.group_signature); - ( - signature_bytes.to_vec().try_into().unwrap(), - DigitalSignatureScheme::SchnorrRistretto255, - ) - } - _ => { - return Err(JobError { - reason: "Invalid role type".to_string(), - }) - } - }; - - let job_result = GadgetJobResult::DKGPhaseTwo(DKGTSSSignatureResult { - signature_scheme, - data: additional_params.input_data_to_sign.try_into().unwrap(), - signature, - verifying_key: BoundedVec::new(), - }); - - client - .submit_job_result( - additional_params.role_type, - additional_params.job_id, - job_result, - ) - .await - .map_err(|err| JobError { - reason: format!("Failed to submit job result: {err:?}"), - })?; - } - - Ok(()) - }) - .build()) - } -} diff --git a/protocols/zcash-frost/tests/frost.rs b/protocols/zcash-frost/tests/frost.rs deleted file mode 100644 index 37f295adc..000000000 --- a/protocols/zcash-frost/tests/frost.rs +++ /dev/null @@ -1,341 +0,0 @@ -#[cfg(test)] -mod tests { - use futures::stream::FuturesUnordered; - use futures::StreamExt; - use sp_core::keccak_256; - use tangle_primitives::jobs::{ - DKGTSSPhaseOneJobType, DKGTSSPhaseTwoJobType, JobId, JobSubmission, JobType, - }; - use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; - use test_utils::mock::{id_to_public, Jobs, MockBackend, RuntimeOrigin}; - use test_utils::sync::substrate_test_channel::MultiThreadedTestExternalities; - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_gadget_starts() { - test_utils::setup_log(); - new_test_ext::<1>() - .await - .execute_with_async(|| { - assert_eq!(1, 1); - }) - .await - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_keygen_zcash_frost_ed25519() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - assert_eq!( - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostEd25519).await, - 0 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_keygen_zcash_frost_ed448() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - assert_eq!( - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostEd448).await, - 0 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_keygen_zcash_frost_p256() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - assert_eq!( - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostP256).await, - 0 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_keygen_zcash_frost_p384() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - assert_eq!( - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostP384).await, - 0 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_keygen_zcash_frost_ristretto255() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - assert_eq!( - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostRistretto255).await, - 0 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_keygen_zcash_frost_secp256k1() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - assert_eq!( - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostSecp256k1).await, - 0 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_signing_zcash_frost_ed25519() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - let keygen_job_id = - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostEd25519).await; - assert_eq!( - wait_for_signing::( - &ext, - keygen_job_id, - ThresholdSignatureRoleType::ZcashFrostEd25519 - ) - .await, - 1 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_signing_zcash_frost_ed448() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - let keygen_job_id = - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostEd448).await; - assert_eq!( - wait_for_signing::( - &ext, - keygen_job_id, - ThresholdSignatureRoleType::ZcashFrostEd448 - ) - .await, - 1 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_signing_zcash_frost_p256() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - let keygen_job_id = - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostP256).await; - assert_eq!( - wait_for_signing::( - &ext, - keygen_job_id, - ThresholdSignatureRoleType::ZcashFrostP256 - ) - .await, - 1 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_signing_zcash_frost_p384() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - let keygen_job_id = - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostP384).await; - assert_eq!( - wait_for_signing::( - &ext, - keygen_job_id, - ThresholdSignatureRoleType::ZcashFrostP384 - ) - .await, - 1 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_signing_zcash_frost_ristretto255() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - let keygen_job_id = - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostRistretto255).await; - assert_eq!( - wait_for_signing::( - &ext, - keygen_job_id, - ThresholdSignatureRoleType::ZcashFrostRistretto255 - ) - .await, - 1 - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_externalities_signing_zcash_frost_secp256k1() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - - let ext = new_test_ext::().await; - let keygen_job_id = - wait_for_keygen::(&ext, ThresholdSignatureRoleType::ZcashFrostSecp256k1).await; - assert_eq!( - wait_for_signing::( - &ext, - keygen_job_id, - ThresholdSignatureRoleType::ZcashFrostSecp256k1 - ) - .await, - 1 - ); - } - - #[tokio::test(flavor = "multi_thread")] - #[ignore = "takes a long time to work on CI"] - async fn test_externalities_parallel_jobs() { - test_utils::setup_log(); - const N: usize = 3; - const T: usize = N - 1; - const FROST_ROLES: [ThresholdSignatureRoleType; 6] = [ - ThresholdSignatureRoleType::ZcashFrostEd25519, - ThresholdSignatureRoleType::ZcashFrostEd448, - ThresholdSignatureRoleType::ZcashFrostP256, - ThresholdSignatureRoleType::ZcashFrostP384, - ThresholdSignatureRoleType::ZcashFrostRistretto255, - ThresholdSignatureRoleType::ZcashFrostSecp256k1, - ]; - - let ext = new_test_ext::().await; - let futures = FuturesUnordered::new(); - - for role in &FROST_ROLES { - let ext = ext.clone(); - futures.push(Box::pin(async move { - let keygen_job_id = wait_for_keygen::(&ext, *role).await; - wait_for_signing::(&ext, keygen_job_id, *role).await; - })); - } - - futures.collect::<()>().await; - } - - async fn wait_for_keygen( - ext: &MultiThreadedTestExternalities, - role_type: ThresholdSignatureRoleType, - ) -> JobId { - let job_id = ext - .execute_with_async(move || { - let job_id = Jobs::next_job_id(); - let identities = (0..N).map(|i| id_to_public(i as u8)).collect::>(); - - let submission = JobSubmission { - expiry: 100, - ttl: 100, - job_type: JobType::DKGTSSPhaseOne(DKGTSSPhaseOneJobType { - participants: identities.clone().try_into().unwrap(), - threshold: T as _, - permitted_caller: None, - role_type, - }), - }; - - assert!(Jobs::submit_job(RuntimeOrigin::signed(identities[0]), submission).is_ok()); - - log::info!(target: "gadget", "******* Submitted Keygen Job {job_id}"); - job_id - }) - .await; - - test_utils::wait_for_job_completion(ext, RoleType::Tss(role_type), job_id).await; - job_id - } - - async fn wait_for_signing( - ext: &MultiThreadedTestExternalities, - keygen_job_id: JobId, - role_type: ThresholdSignatureRoleType, - ) -> JobId { - let job_id = ext - .execute_with_async(move || { - let msg = Vec::from("Hello, world!"); - let submission = keccak_256(&msg); - let job_id = Jobs::next_job_id(); - let identities = (0..N).map(|i| id_to_public(i as u8)).collect::>(); - let submission = JobSubmission { - expiry: 100, - ttl: 100, - job_type: JobType::DKGTSSPhaseTwo(DKGTSSPhaseTwoJobType { - phase_one_id: keygen_job_id, - submission: submission.to_vec().try_into().unwrap(), - role_type, - }), - }; - - assert!(Jobs::submit_job(RuntimeOrigin::signed(identities[0]), submission).is_ok()); - - log::info!(target: "gadget", "******* Submitted Signing Job {job_id}"); - job_id - }) - .await; - - test_utils::wait_for_job_completion(ext, RoleType::Tss(role_type), job_id).await; - job_id - } - - async fn new_test_ext() -> MultiThreadedTestExternalities { - test_utils::mock::new_test_ext::((), |mut node_input| async move { - let keygen_client = node_input.mock_clients.pop().expect("No keygen client"); - let signing_client = node_input.mock_clients.pop().expect("No signing client"); - - let keygen_network = node_input.mock_networks.pop().expect("No keygen network"); - let signing_network = node_input.mock_networks.pop().expect("No signing network"); - let account_id = node_input.account_id; - - let logger = node_input.logger.clone(); - let (pallet_tx, keystore) = (node_input.pallet_tx, node_input.keystore); - logger.info("Starting gadget"); - if let Err(err) = zcash_frost_protocol::run::<_, MockBackend, _, _, _, _>( - account_id, - logger.clone(), - keystore, - pallet_tx, - (keygen_client, signing_client), - (keygen_network, signing_network), - ) - .await - { - log::error!(target: "gadget", "Error running gadget: {err:?}"); - } - }) - .await - } -} From 85c5a9e84b70943c0005d62a1e611a1ed26edea0 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 22 Feb 2024 23:24:52 -0700 Subject: [PATCH 39/66] fix: clippy --- protocols/zcash-frost/src/protocol/keygen.rs | 2 +- protocols/zcash-frost/src/protocol/sign.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/zcash-frost/src/protocol/keygen.rs b/protocols/zcash-frost/src/protocol/keygen.rs index 4ec4f0296..176a1d10c 100644 --- a/protocols/zcash-frost/src/protocol/keygen.rs +++ b/protocols/zcash-frost/src/protocol/keygen.rs @@ -13,7 +13,7 @@ use gadget_common::config::{Network, ProvideRuntimeApi}; use gadget_common::debug_logger::DebugLogger; use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::gadget::{GadgetProtocol, JobInitMetadata}; +use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; diff --git a/protocols/zcash-frost/src/protocol/sign.rs b/protocols/zcash-frost/src/protocol/sign.rs index ab243d295..ba6613ba4 100644 --- a/protocols/zcash-frost/src/protocol/sign.rs +++ b/protocols/zcash-frost/src/protocol/sign.rs @@ -12,7 +12,7 @@ use gadget_common::config::{Network, ProvideRuntimeApi}; use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::gadget::{GadgetProtocol, JobInitMetadata}; +use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; use gadget_common::Block; From 687446e2ead0569122eea74e8be13eceefea8cee Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Fri, 23 Feb 2024 13:47:51 -0700 Subject: [PATCH 40/66] cargo update --- Cargo.lock | 332 ++++++++++++++++++++++++++--------------------------- 1 file changed, 162 insertions(+), 170 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4ccde3e0..2ae46f283 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,9 +95,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" +checksum = "d713b3834d76b85304d4d525563c1276e2e30dc97cc67bfb4585a4a29fc2c89f" dependencies = [ "cfg-if", "getrandom 0.2.12", @@ -147,9 +147,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "approx" @@ -563,7 +563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", - "event-listener 5.0.0", + "event-listener 5.1.0", "event-listener-strategy 0.5.0", "futures-core", "pin-project-lite 0.2.13", @@ -627,7 +627,7 @@ dependencies = [ "futures-io", "futures-lite 2.2.0", "parking", - "polling 3.4.0", + "polling 3.5.0", "rustix 0.38.31", "slab", "tracing", @@ -719,7 +719,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -736,7 +736,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -819,7 +819,7 @@ checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -1146,9 +1146,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.0" +version = "3.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" [[package]] name = "byte-slice-cast" @@ -1201,7 +1201,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -1227,11 +1227,10 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" dependencies = [ - "jobserver", "libc", ] @@ -1306,7 +1305,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -1976,7 +1975,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2023,12 +2022,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.6" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c376d08ea6aa96aafe61237c7200d1241cb177b7d3a542d791f2d118e9cbb955" +checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" dependencies = [ - "darling_core 0.20.6", - "darling_macro 0.20.6", + "darling_core 0.20.8", + "darling_macro 0.20.8", ] [[package]] @@ -2047,16 +2046,16 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.6" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33043dcd19068b8192064c704b3f83eb464f91f1ff527b44a4e2b08d9cdb8855" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2072,13 +2071,13 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.6" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5a91391accf613803c2a9bf9abccdbaa07c54b4244a5b64883f9c3c137c86be" +checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ - "darling_core 0.20.6", + "darling_core 0.20.8", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2304,7 +2303,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2368,7 +2367,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.49", + "syn 2.0.50", "termcolor", "toml 0.8.2", "walkdir", @@ -2642,7 +2641,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2660,10 +2659,10 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ - "darling 0.20.6", + "darling 0.20.8", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2867,9 +2866,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.0.0" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72557800024fabbaa2449dd4bf24e37b93702d457a4d4f2b0dd1f0f039f20c1" +checksum = "b7ad6fd685ce13acd6d9541a30f6db6567a7a24c9ffd4ba2955d29e3f22c8b27" dependencies = [ "concurrent-queue", "parking", @@ -2892,7 +2891,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" dependencies = [ - "event-listener 5.0.0", + "event-listener 5.1.0", "pin-project-lite 0.2.13", ] @@ -2906,7 +2905,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -3269,7 +3268,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -3281,7 +3280,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -3291,7 +3290,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -3316,7 +3315,7 @@ dependencies = [ [[package]] name = "frost-core" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "byteorder", "debugless-unwrap", @@ -3369,7 +3368,7 @@ dependencies = [ [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -3395,7 +3394,7 @@ dependencies = [ [[package]] name = "frost-ed448" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "ed448-goldilocks-plus 0.11.2 (git+https://github.com/mikelodder7/Ed448-Goldilocks)", "frost-core 0.6.1", @@ -3421,7 +3420,7 @@ dependencies = [ [[package]] name = "frost-p256" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "frost-core 0.6.1", "p256 0.13.2", @@ -3447,7 +3446,7 @@ dependencies = [ [[package]] name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "frost-core 0.6.1", "p384", @@ -3484,7 +3483,7 @@ dependencies = [ [[package]] name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "curve25519-dalek 4.1.1", "frost-core 0.6.1", @@ -3510,7 +3509,7 @@ dependencies = [ [[package]] name = "frost-secp256k1" version = "1.0.0-rc.0" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "frost-core 0.6.1", "k256", @@ -3643,7 +3642,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -3671,9 +3670,9 @@ checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" [[package]] name = "futures-util" @@ -3841,14 +3840,15 @@ dependencies = [ [[package]] name = "gennaro-dkg" -version = "0.8.1" -source = "git+https://github.com/mikelodder7/gennaro-dkg.git#1c15242b3f833c0fe42f36c3f623f2c6d8bc64b1" +version = "0.9.0" +source = "git+https://github.com/mikelodder7/gennaro-dkg.git#b054b46641a6410600c1b341cb6646f692b3312b" dependencies = [ "anyhow", "data-encoding", "rand_chacha 0.3.1", "rand_core 0.6.4", "serde", + "serde_bare", "soteria-rs", "thiserror", "uint-zigzag", @@ -4049,7 +4049,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.8", + "ahash 0.8.9", ] [[package]] @@ -4058,7 +4058,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.8", + "ahash 0.8.9", "allocator-api2", "serde", ] @@ -4260,7 +4260,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.13", - "socket2 0.5.5", + "socket2 0.5.6", "tokio", "tower-service", "tracing", @@ -4518,7 +4518,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.5", + "socket2 0.5.6", "widestring", "windows-sys 0.48.0", "winreg", @@ -4574,15 +4574,6 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" -[[package]] -name = "jobserver" -version = "0.1.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.68" @@ -5330,7 +5321,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5344,7 +5335,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5355,7 +5346,7 @@ checksum = "d710e1214dffbab3b5dacb21475dde7d6ed84c69ff722b3a47a782668d44fbac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5366,7 +5357,7 @@ checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5694,9 +5685,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.3" +version = "0.32.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" +checksum = "4541eb06dce09c0241ebbaab7102f0a01a0c8994afed2e5d0d66775016e25ac2" dependencies = [ "approx", "matrixmultiply", @@ -6000,7 +5991,7 @@ dependencies = [ "proc-macro-crate 2.0.2", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -6204,7 +6195,7 @@ dependencies = [ [[package]] name = "pallet-dkg" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "digest 0.10.7", "elliptic-curve 0.13.8", @@ -6246,7 +6237,7 @@ dependencies = [ [[package]] name = "pallet-jobs" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "frame-benchmarking", "frame-support", @@ -6263,7 +6254,7 @@ dependencies = [ [[package]] name = "pallet-jobs-rpc-runtime-api" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "parity-scale-codec 3.6.9", "sp-api", @@ -6294,7 +6285,7 @@ dependencies = [ [[package]] name = "pallet-zksaas" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "frame-benchmarking", "frame-support", @@ -6541,7 +6532,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -6662,9 +6653,9 @@ dependencies = [ [[package]] name = "polling" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30054e72317ab98eddd8561db0f6524df3367636884b7b21b703e4b280a84a14" +checksum = "24f040dee2588b4963afb4e420540439d126f73fdacf4a9c486a96d840bac3c9" dependencies = [ "cfg-if", "concurrent-queue", @@ -6768,7 +6759,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -6865,7 +6856,7 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -6911,7 +6902,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -6990,7 +6981,7 @@ version = "0.1.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -7365,7 +7356,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48406db8ac1f3cbc7dcdb56ec355343817958a356ff430259bb07baf7607e1e1" dependencies = [ "pem 3.0.3", - "ring 0.17.7", + "ring 0.17.8", "time", "yasna", ] @@ -7425,7 +7416,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -7579,16 +7570,17 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", "getrandom 0.2.12", "libc", "spin 0.9.8", "untrusted 0.9.0", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -7846,7 +7838,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", - "ring 0.17.7", + "ring 0.17.8", "rustls-webpki", "sct", ] @@ -7878,7 +7870,7 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -7912,9 +7904,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "safe_arch" @@ -8298,7 +8290,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.8", + "ahash 0.8.9", "cfg-if", "hashbrown 0.13.2", ] @@ -8350,7 +8342,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -8472,15 +8464,15 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -8515,20 +8507,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -8577,10 +8569,10 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" dependencies = [ - "darling 0.20.6", + "darling 0.20.8", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -8589,10 +8581,10 @@ version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "865f9743393e638991566a8b7a479043c2c8da94a33e0a31f18214c9cae0a64d" dependencies = [ - "darling 0.20.6", + "darling 0.20.8", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -8880,7 +8872,7 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek 4.1.1", "rand_core 0.6.4", - "ring 0.17.7", + "ring 0.17.8", "rustc_version", "sha2 0.10.8", "subtle", @@ -8922,12 +8914,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -8994,7 +8986,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -9188,7 +9180,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "quote", "sp-core-hashing 9.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0)", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -9207,7 +9199,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -9361,7 +9353,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -9477,7 +9469,7 @@ name = "sp-trie" version = "22.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "ahash 0.8.8", + "ahash 0.8.9", "hash-db", "hashbrown 0.13.2", "lazy_static", @@ -9520,7 +9512,7 @@ dependencies = [ "parity-scale-codec 3.6.9", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -9616,7 +9608,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd4cef4251aabbae751a3710927945901ee1d97ee96d757f6880ebb9a79bfd53" dependencies = [ - "ahash 0.8.8", + "ahash 0.8.9", "atoi", "byteorder", "bytes", @@ -9906,7 +9898,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -10007,7 +9999,7 @@ dependencies = [ "quote", "scale-info", "subxt-metadata", - "syn 2.0.49", + "syn 2.0.50", "thiserror", "tokio", ] @@ -10035,10 +10027,10 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afe9f7e2994a20ab9748a9a040a3fe96054faa219a60ed21af51b9ab9e5f7da6" dependencies = [ - "darling 0.20.6", + "darling 0.20.8", "proc-macro-error", "subxt-codegen", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -10088,9 +10080,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.49" +version = "2.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" dependencies = [ "proc-macro2", "quote", @@ -10133,7 +10125,7 @@ dependencies = [ [[package]] name = "tangle-crypto-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "parity-scale-codec 3.6.9", "scale-info", @@ -10143,7 +10135,7 @@ dependencies = [ [[package]] name = "tangle-primitives" version = "0.6.1" -source = "git+https://github.com/webb-tools/tangle/#73ef53335f942137ec19078d062dd2bc29803ddd" +source = "git+https://github.com/webb-tools/tangle/#03507d1ac9d0e83617a083e8a092b945f59722f6" dependencies = [ "ark-bn254", "ark-crypto-primitives", @@ -10176,9 +10168,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.13" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" +checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "tempfile" @@ -10303,7 +10295,7 @@ checksum = "e4c60d69f36615a077cc7663b9cb8e42275722d23e58a7fa3d2c7f2915d09d04" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -10314,7 +10306,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -10339,9 +10331,9 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if", "once_cell", @@ -10467,7 +10459,7 @@ dependencies = [ "num_cpus", "parking_lot 0.12.1", "pin-project-lite 0.2.13", - "socket2 0.5.5", + "socket2 0.5.6", "tokio-macros", "windows-sys 0.48.0", ] @@ -10480,7 +10472,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -10588,7 +10580,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -10799,7 +10791,7 @@ checksum = "8b29f121da05aa0857e7b96cf2f8782bd4140911506518486d4a125b97d7d609" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -10957,7 +10949,7 @@ checksum = "b3fd98999db9227cf28e59d83e1f120f42bc233d4b152e8fab9bc87d5bb1e0f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -10968,15 +10960,15 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "vsss-rs" -version = "3.3.4" +version = "4.0.0-rc2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196bbee60607a195bc850e94f0e040bd090e45794ad8df0e9c5a422b9975a00f" +checksum = "d7eac81128b4ad540f259117e25900fe68ea0d4309f176d164944346cb94921e" dependencies = [ "elliptic-curve 0.13.8", - "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", "serde", + "sha3 0.10.8", "subtle", "thiserror-no-std", "zeroize", @@ -11040,7 +11032,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", "wasm-bindgen-shared", ] @@ -11074,7 +11066,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -11657,7 +11649,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -11775,7 +11767,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -11815,7 +11807,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -11850,17 +11842,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.3", + "windows_aarch64_msvc 0.52.3", + "windows_i686_gnu 0.52.3", + "windows_i686_msvc 0.52.3", + "windows_x86_64_gnu 0.52.3", + "windows_x86_64_gnullvm 0.52.3", + "windows_x86_64_msvc 0.52.3", ] [[package]] @@ -11877,9 +11869,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" [[package]] name = "windows_aarch64_msvc" @@ -11901,9 +11893,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" [[package]] name = "windows_i686_gnu" @@ -11925,9 +11917,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" [[package]] name = "windows_i686_msvc" @@ -11949,9 +11941,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" [[package]] name = "windows_x86_64_gnu" @@ -11973,9 +11965,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" [[package]] name = "windows_x86_64_gnullvm" @@ -11991,9 +11983,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" [[package]] name = "windows_x86_64_msvc" @@ -12015,9 +12007,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" [[package]] name = "winnow" @@ -12189,7 +12181,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -12209,7 +12201,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] From 10f86ee3baabbe7de1057da1d19a3a671ef42dfb Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Fri, 23 Feb 2024 13:59:27 -0700 Subject: [PATCH 41/66] Fix tests --- protocols/zcash-frost/src/protocol/keygen.rs | 2 +- protocols/zcash-frost/src/protocol/sign.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/zcash-frost/src/protocol/keygen.rs b/protocols/zcash-frost/src/protocol/keygen.rs index 176a1d10c..3a704fb6b 100644 --- a/protocols/zcash-frost/src/protocol/keygen.rs +++ b/protocols/zcash-frost/src/protocol/keygen.rs @@ -138,7 +138,7 @@ where let pallet_tx = config.pallet_tx.clone(); let id = config.account_id; let logger = config.logger.clone(); - let network = config.network.clone(); + let network = config.clone(); let (i, t, n, mapping, role_type) = ( additional_params.i, diff --git a/protocols/zcash-frost/src/protocol/sign.rs b/protocols/zcash-frost/src/protocol/sign.rs index ba6613ba4..7a0271d59 100644 --- a/protocols/zcash-frost/src/protocol/sign.rs +++ b/protocols/zcash-frost/src/protocol/sign.rs @@ -157,7 +157,7 @@ where let protocol_output_clone = protocol_output.clone(); let pallet_tx = config.pallet_tx.clone(); let id = config.account_id; - let network = config.network.clone(); + let network = config.clone(); let (i, signers, t, keyshare, role_type, input_data_to_sign, mapping) = ( additional_params.i, From 862cc56a8aee758f91b0cf73eaad3cfc485eb76c Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Sun, 25 Feb 2024 23:26:19 -0500 Subject: [PATCH 42/66] feature: generalize dfns - wip --- Cargo.lock | 1 + Cargo.toml | 2 + protocols/dfns-cggmp21/Cargo.toml | 1 + .../dfns-cggmp21/src/protocols/keygen.rs | 200 +++++++++++++++--- protocols/zcash-frost/Cargo.toml | 2 +- 5 files changed, 174 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6183392f..c84d992e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2211,6 +2211,7 @@ dependencies = [ "bincode2", "cggmp21", "curv-kzen", + "digest 0.10.7", "frame-support", "futures", "gadget-common", diff --git a/Cargo.toml b/Cargo.toml index 7e25b2b26..b8dd9ab96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ subxt-signer = { version = "0.31.0", default-features = false } multi-party-ecdsa = { git = "https://github.com/webb-tools/cggmp-threshold-ecdsa/" } round-based = { git = "https://github.com/webb-tools/round-based-protocol", features = [] } curv = { package = "curv-kzen", version = "0.10.0" } +digest = "0.10" dfns-cggmp21 = { package = "cggmp21", version = "0.1.1", default-features = false } udigest = { version = "0.1", features = ["std", "derive"]} frost-core = { git = "https://github.com/LIT-Protocol/frost.git" } @@ -145,3 +146,4 @@ thiserror = { version = "1.0" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } lazy_static = "1.4.0" sqlx = "=0.7.1" +postcard = "1.0.8" \ No newline at end of file diff --git a/protocols/dfns-cggmp21/Cargo.toml b/protocols/dfns-cggmp21/Cargo.toml index 40eaecf13..cfdb4e2c1 100644 --- a/protocols/dfns-cggmp21/Cargo.toml +++ b/protocols/dfns-cggmp21/Cargo.toml @@ -15,6 +15,7 @@ curv = { workspace = true } futures = { workspace = true } itertools = { workspace = true } bincode2 = { workspace = true } +digest = { workspace = true } pallet-jobs-rpc-runtime-api = { workspace = true, features = ["std"] } pallet-jobs = { workspace = true, features = ["std"] } diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 86cb3431d..0448e076d 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -1,4 +1,9 @@ -use dfns_cggmp21::supported_curves::Secp256k1; +use curv::cryptographic_primitives::hashing::Digest; +use dfns_cggmp21::generic_ec::Curve; +use dfns_cggmp21::keygen::msg::threshold; +use dfns_cggmp21::round_based::{Delivery, Mpc}; +use dfns_cggmp21::security_level::SecurityLevel; +use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; use dfns_cggmp21::KeyShare; use futures::StreamExt; use gadget_common::client::{ @@ -18,8 +23,10 @@ use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use itertools::Itertools; use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; use pallet_dkg::signatures_schemes::to_slice_33; +use rand::rngs::StdRng; use rand::SeedableRng; use sc_client_api::Backend; +use serde::Serialize; use sp_api::ProvideRuntimeApi; use sp_application_crypto::sp_core::keccak_256; use sp_core::{ecdsa, Pair}; @@ -28,7 +35,7 @@ use std::sync::Arc; use tangle_primitives::jobs::{ DKGTSSKeySubmissionResult, DigitalSignatureScheme, JobId, JobResult, JobType, }; -use tangle_primitives::roles::RoleType; +use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; use super::util::PublicKeyGossipMessage; @@ -92,6 +99,105 @@ pub struct DfnsCGGMP21KeygenExtraParams { user_id_to_account_id_mapping: Arc>, } +use dfns_cggmp21::keygen::KeygenBuilder; + +pub async fn run_and_serialize_keygen<'r, E: Curve, M, D, L, DG>( + tracer: dfns_cggmp21::progress::PerfProfiler, + eid: dfns_cggmp21::ExecutionId<'r>, + i: u16, + n: u16, + t: u16, + party: dfns_cggmp21::round_based::MpcParty, + rng: StdRng, +) -> Result, JobError> +where + M: Send + 'static, + D: Delivery, + DG: Digest + digest::FixedOutput + digest::HashMarker + Default, + M: Mpc>, + L: SecurityLevel, +{ + let incomplete_key_share = dfns_cggmp21::keygen::(eid, i, n) + .set_progress_tracer(&mut tracer) + .set_threshold(t) + .start(&mut rng, party) + .await + .map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })?; + bincode2::serialize(&incomplete_key_share).map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + }) +} +macro_rules! run_keygen_protocol { + ($curve_type:ty, $tracer:expr, $eid:expr, $i:expr, $n:expr, $t:expr, $party:expr, $rng:expr,) => { + run_and_serialize_keygen::<$curve_type, _, _, _, _>($tracer, $eid, $i, $n, $t, $party, $rng) + .await? + }; +} + +pub async fn run_and_serialize_keyrefresh<'r, E: Curve, M, D, L, DG>( + logger: &DebugLogger, + incomplete_key_share: Vec, + pregenerated_primes: dfns_cggmp21::PregeneratedPrimes, + tracer: dfns_cggmp21::progress::PerfProfiler, + aux_eid: dfns_cggmp21::ExecutionId<'r>, + i: u16, + n: u16, + party: dfns_cggmp21::round_based::MpcParty, + rng: StdRng, +) -> Result, JobError> +where + M: Send + 'static, + D: Delivery, + DG: Digest + digest::FixedOutput + digest::HashMarker + Default, + M: Mpc>, + L: SecurityLevel, +{ + let incomplete_key_share: dfns_cggmp21::key_share::Valid< + dfns_cggmp21::key_share::DirtyIncompleteKeyShare<_>, + > = bincode2::deserialize(&incomplete_key_share).map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })?; + let aux_info = dfns_cggmp21::aux_info_gen(aux_eid, i, n, pregenerated_primes) + .set_progress_tracer(&mut tracer) + .start(&mut rng, party) + .await + .map_err(|err| JobError { + reason: format!("Aux info protocol error: {err:?}"), + })?; + let perf_report = tracer.get_report().map_err(|err| JobError { + reason: format!("Aux info protocol error: {err:?}"), + })?; + logger.trace(format!("Aux info protocol report: {perf_report}")); + logger.debug("Finished AsyncProtocol - Aux Info"); + + let key_share = + dfns_cggmp21::KeyShare::make(incomplete_key_share, aux_info).map_err(|err| JobError { + reason: format!("Key share error: {err:?}"), + })?; + bincode2::serialize(&key_share).map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + }) +} + +macro_rules! run_keyrefresh_protocol { + ($curve_type:ty, $logger:expr, $incomplete_key_share:expr, $pregenerated_primes:expr, $tracer:expr, $eid:expr, $i:expr, $n:expr, $party:expr, $rng:expr,) => { + run_and_serialize_keyrefresh::<$curve_type, _, _, _, _>( + $logger, + $incomplete_key_share, + $pregenerated_primes, + $tracer, + $eid, + $i, + $n, + $t, + $party, + $rng, + ) + .await? + }; +} pub async fn generate_protocol_from< B: Block, BE: Backend + 'static, @@ -119,10 +225,11 @@ where let logger = config.logger.clone(); let network = config.clone(); - let (i, t, n, mapping) = ( + let (i, t, n, role_type, mapping) = ( additional_params.i, additional_params.t, additional_params.n, + additional_params.role_type, additional_params.user_id_to_account_id_mapping, ); @@ -161,14 +268,18 @@ where let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); let party = dfns_cggmp21::round_based::MpcParty::connected(delivery); - let incomplete_key_share = dfns_cggmp21::keygen::(eid, i, n) - .set_progress_tracer(&mut tracer) - .set_threshold(t) - .start(&mut rng, party) - .await - .map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - })?; + let incomplete_key_share: Vec = match role_type { + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { + run_keygen_protocol!(Secp256k1, tracer, eid, i, n, t, party, rng,) + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { + run_keygen_protocol!(Secp256r1, tracer, eid, i, n, t, party, rng,) + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { + run_keygen_protocol!(Stark, tracer, eid, i, n, t, party, rng,) + } + _ => unreachable!("Invalid role type"), + }; let perf_report = tracer.get_report().map_err(|err| JobError { reason: format!("Keygen protocol error: {err:?}"), @@ -204,25 +315,52 @@ where })?; let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); let party = dfns_cggmp21::round_based::MpcParty::connected(delivery); - let aux_info = dfns_cggmp21::aux_info_gen(aux_eid, i, n, pregenerated_primes) - .set_progress_tracer(&mut tracer) - .start(&mut rng, party) - .await - .map_err(|err| JobError { - reason: format!("Aux info protocol error: {err:?}"), - })?; - let perf_report = tracer.get_report().map_err(|err| JobError { - reason: format!("Aux info protocol error: {err:?}"), - })?; - logger.trace(format!("Aux info protocol report: {perf_report}")); - logger.debug("Finished AsyncProtocol - Aux Info"); - - let key_share = - dfns_cggmp21::KeyShare::make(incomplete_key_share, aux_info).map_err(|err| { - JobError { - reason: format!("Key share error: {err:?}"), - } - })?; + + let key_share: Vec = match role_type { + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { + run_keyrefresh_protocol!( + Secp256k1, + &logger, + incomplete_key_share, + pregenerated_primes, + tracer, + aux_eid, + i, + n, + party, + rng, + )? + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { + run_keyrefresh_protocol!( + Secp256r1, + &logger, + incomplete_key_share, + pregenerated_primes, + tracer, + aux_eid, + i, + n, + party, + rng, + )? + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { + run_keyrefresh_protocol!( + Stark, + &logger, + incomplete_key_share, + pregenerated_primes, + tracer, + aux_eid, + i, + n, + party, + rng, + )? + } + _ => unreachable!("Invalid role type"), + }; logger.debug("Finished AsyncProtocol - Keygen"); @@ -272,7 +410,7 @@ where async fn handle_public_key_gossip( key_store: ECDSAKeyStore, logger: &DebugLogger, - local_key: &KeyShare, + local_key: &[u8], t: u16, i: u16, broadcast_tx_to_outbound: futures::channel::mpsc::UnboundedSender, diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml index 775c01e64..23bcfc860 100644 --- a/protocols/zcash-frost/Cargo.toml +++ b/protocols/zcash-frost/Cargo.toml @@ -16,7 +16,7 @@ futures = { workspace = true } itertools = { workspace = true } bincode2 = { workspace = true } round-based = { git = "https://github.com/ZenGo-X/round-based-protocol", features = ["derive"]} -digest = "0.10" +digest = { workspace = true } sha2 = "0.10" rand_core = "0.6" rand_chacha = { version = "0.3", default-features = false } From 2dd63421b1078711047a27605e9bf2ef2a3735aa Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Sun, 25 Feb 2024 23:29:58 -0500 Subject: [PATCH 43/66] update --- .../dfns-cggmp21/src/protocols/keygen.rs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 0448e076d..ca3b5807f 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -146,7 +146,7 @@ pub async fn run_and_serialize_keyrefresh<'r, E: Curve, M, D, L, DG>( n: u16, party: dfns_cggmp21::round_based::MpcParty, rng: StdRng, -) -> Result, JobError> +) -> Result<(Vec, Vec), JobError> where M: Send + 'static, D: Delivery, @@ -176,9 +176,11 @@ where dfns_cggmp21::KeyShare::make(incomplete_key_share, aux_info).map_err(|err| JobError { reason: format!("Key share error: {err:?}"), })?; - bincode2::serialize(&key_share).map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - }) + bincode2::serialize(&key_share) + .map(|ks| (ks, key_share.shared_public_key().to_bytes(true).to_vec())) + .map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + }) } macro_rules! run_keyrefresh_protocol { @@ -191,7 +193,6 @@ macro_rules! run_keyrefresh_protocol { $eid, $i, $n, - $t, $party, $rng, ) @@ -316,7 +317,7 @@ where let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); let party = dfns_cggmp21::round_based::MpcParty::connected(delivery); - let key_share: Vec = match role_type { + let (key_share, serialized_public_key): (Vec, Vec) = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { run_keyrefresh_protocol!( Secp256k1, @@ -329,7 +330,7 @@ where n, party, rng, - )? + ) } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { run_keyrefresh_protocol!( @@ -343,7 +344,7 @@ where n, party, rng, - )? + ) } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { run_keyrefresh_protocol!( @@ -357,7 +358,7 @@ where n, party, rng, - )? + ) } _ => unreachable!("Invalid role type"), }; @@ -368,6 +369,7 @@ where key_store2, &logger, &key_share, + &serialized_public_key, t, i, broadcast_tx_to_outbound, @@ -411,12 +413,12 @@ async fn handle_public_key_gossip( key_store: ECDSAKeyStore, logger: &DebugLogger, local_key: &[u8], + serialized_public_key: &[u8], t: u16, i: u16, broadcast_tx_to_outbound: futures::channel::mpsc::UnboundedSender, mut broadcast_rx_from_gadget: futures::channel::mpsc::UnboundedReceiver, ) -> Result { - let serialized_public_key = local_key.shared_public_key().to_bytes(true).to_vec(); let key_hashed = keccak_256(&serialized_public_key); let signature = key_store.pair().sign_prehashed(&key_hashed).0.to_vec(); let my_id = key_store.pair().public(); From 082dbe01929ce2864edd1a45acdb41b5e03b841f Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 26 Feb 2024 13:30:44 -0500 Subject: [PATCH 44/66] Dedup code --- .config/nextest.toml | 3 +- gadget-common/src/lib.rs | 2 + gadget-common/src/utils.rs | 54 ++++++++++++++++++ .../dfns-cggmp21/src/protocols/key_refresh.rs | 3 +- .../dfns-cggmp21/src/protocols/key_rotate.rs | 3 +- .../dfns-cggmp21/src/protocols/keygen.rs | 3 +- protocols/dfns-cggmp21/src/protocols/sign.rs | 3 +- protocols/dfns-cggmp21/src/protocols/util.rs | 56 +------------------ protocols/zcash-frost/src/protocol/keygen.rs | 2 +- protocols/zcash-frost/src/protocol/sign.rs | 2 +- protocols/zcash-frost/src/protocol/util.rs | 55 +----------------- 11 files changed, 73 insertions(+), 113 deletions(-) create mode 100644 gadget-common/src/utils.rs diff --git a/.config/nextest.toml b/.config/nextest.toml index 8948928b7..2340d1b69 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,2 +1,3 @@ [profile.default] -test-threads = 1 \ No newline at end of file +test-threads = 1 +retries = 2 \ No newline at end of file diff --git a/gadget-common/src/lib.rs b/gadget-common/src/lib.rs index 392515819..263275889 100644 --- a/gadget-common/src/lib.rs +++ b/gadget-common/src/lib.rs @@ -54,6 +54,8 @@ pub mod keystore; pub mod locks; pub mod prometheus; pub mod protocol; +pub mod utils; + #[derive(Debug)] pub enum Error { RegistryCreateError { err: String }, diff --git a/gadget-common/src/utils.rs b/gadget-common/src/utils.rs new file mode 100644 index 000000000..bfae4c289 --- /dev/null +++ b/gadget-common/src/utils.rs @@ -0,0 +1,54 @@ +use futures::Stream; +use std::sync::atomic::AtomicBool; +use std::sync::Arc; +use tokio::sync::mpsc::UnboundedReceiver; + +/// A Channel Receiver that can be cloned. +/// +/// On the second clone, the original channel will stop sending messages +/// and the new channel will start sending messages. +pub struct CloneableUnboundedReceiver { + rx: Arc>>, + is_in_use: Arc, +} + +impl Clone for CloneableUnboundedReceiver { + fn clone(&self) -> Self { + // on the clone, we switch the is_in_use flag to false + // and we return a new channel + self.is_in_use + .store(false, std::sync::atomic::Ordering::SeqCst); + Self { + rx: self.rx.clone(), + is_in_use: Arc::new(AtomicBool::new(true)), + } + } +} + +impl From> for CloneableUnboundedReceiver { + fn from(rx: UnboundedReceiver) -> Self { + Self { + rx: Arc::new(tokio::sync::Mutex::new(rx)), + is_in_use: Arc::new(AtomicBool::new(false)), + } + } +} + +impl Stream for CloneableUnboundedReceiver { + type Item = T; + fn poll_next( + self: std::pin::Pin<&mut Self>, + cx: &mut std::task::Context<'_>, + ) -> std::task::Poll> { + if !self.is_in_use.load(std::sync::atomic::Ordering::SeqCst) { + return std::task::Poll::Ready(None); + } + let mut rx = match self.rx.try_lock() { + Ok(rx) => rx, + Err(_) => return std::task::Poll::Pending, + }; + let rx = &mut *rx; + tokio::pin!(rx); + rx.poll_recv(cx) + } +} diff --git a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs index 0ad386256..f88a452a5 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs @@ -7,6 +7,7 @@ use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; use gadget_common::prelude::FullProtocolConfig; +use gadget_common::utils::CloneableUnboundedReceiver; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; @@ -141,7 +142,7 @@ where .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); let protocol_message_channel = - super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( "Starting KeyRefresh Protocol with params: i={i}, t={t}, n={n}" )); diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index ffacf095b..1feb4a900 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -7,6 +7,7 @@ use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; use gadget_common::prelude::FullProtocolConfig; +use gadget_common::utils::CloneableUnboundedReceiver; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; @@ -157,7 +158,7 @@ where .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); let protocol_message_channel = - super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( "Starting Key Rotation Protocol with params: i={i}, t={t}" diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 86cb3431d..29d488e99 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -12,6 +12,7 @@ use gadget_common::gadget::network::Network; use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; +use gadget_common::utils::CloneableUnboundedReceiver; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; @@ -130,7 +131,7 @@ where .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); let protocol_message_channel = - super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( "Starting Keygen Protocol with params: i={i}, t={t}, n={n}" )); diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index c5949c300..862b148c0 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -6,6 +6,7 @@ use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; use gadget_common::prelude::{FullProtocolConfig, Network}; +use gadget_common::utils::CloneableUnboundedReceiver; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; @@ -132,7 +133,7 @@ where .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); let protocol_message_channel = - super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( "Starting Signing Protocol with params: i={i}, t={t}" diff --git a/protocols/dfns-cggmp21/src/protocols/util.rs b/protocols/dfns-cggmp21/src/protocols/util.rs index 481bc6330..1c62f5c0d 100644 --- a/protocols/dfns-cggmp21/src/protocols/util.rs +++ b/protocols/dfns-cggmp21/src/protocols/util.rs @@ -2,69 +2,19 @@ //! When delivering messages to an async protocol, we want to make sure we don't mix up voting and public key gossip messages //! Thus, this file contains a function that takes a channel from the gadget to the async protocol and splits it into two channels use dfns_cggmp21::round_based::{Incoming, MessageDestination, MessageType, Outgoing, PartyIndex}; -use futures::{Stream, StreamExt}; +use futures::StreamExt; use gadget_common::client::AccountId; use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::network::Network; use gadget_common::gadget::work_manager::WorkManager; +use gadget_common::utils::CloneableUnboundedReceiver; use gadget_core::job_manager::WorkManagerInterface; use rand::seq::SliceRandom; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; -use tokio::sync::mpsc::UnboundedReceiver; -/// A Channel Receiver that can be cloned. -/// -/// On the second clone, the original channel will stop sending messages -/// and the new channel will start sending messages. -pub struct CloneableUnboundedReceiver { - rx: Arc>>, - is_in_use: Arc, -} - -impl Clone for CloneableUnboundedReceiver { - fn clone(&self) -> Self { - // on the clone, we switch the is_in_use flag to false - // and we return a new channel - self.is_in_use - .store(false, std::sync::atomic::Ordering::SeqCst); - Self { - rx: self.rx.clone(), - is_in_use: Arc::new(AtomicBool::new(true)), - } - } -} - -impl From> for CloneableUnboundedReceiver { - fn from(rx: UnboundedReceiver) -> Self { - Self { - rx: Arc::new(tokio::sync::Mutex::new(rx)), - is_in_use: Arc::new(AtomicBool::new(false)), - } - } -} - -impl Stream for CloneableUnboundedReceiver { - type Item = T; - fn poll_next( - self: std::pin::Pin<&mut Self>, - cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { - if !self.is_in_use.load(std::sync::atomic::Ordering::SeqCst) { - return std::task::Poll::Ready(None); - } - let mut rx = match self.rx.try_lock() { - Ok(rx) => rx, - Err(_) => return std::task::Poll::Pending, - }; - let rx = &mut *rx; - tokio::pin!(rx); - rx.poll_recv(cx) - } -} +use std::sync::Arc; #[derive(Serialize, Deserialize, Debug)] pub enum SplitChannelMessage { diff --git a/protocols/zcash-frost/src/protocol/keygen.rs b/protocols/zcash-frost/src/protocol/keygen.rs index 3a704fb6b..54ac116fe 100644 --- a/protocols/zcash-frost/src/protocol/keygen.rs +++ b/protocols/zcash-frost/src/protocol/keygen.rs @@ -161,7 +161,7 @@ where .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); let protocol_message_channel = - super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + gadget_common::utils::CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( "Starting Keygen Protocol with params: i={i}, t={t}, n={n}" )); diff --git a/protocols/zcash-frost/src/protocol/sign.rs b/protocols/zcash-frost/src/protocol/sign.rs index 7a0271d59..6dafb05a8 100644 --- a/protocols/zcash-frost/src/protocol/sign.rs +++ b/protocols/zcash-frost/src/protocol/sign.rs @@ -182,7 +182,7 @@ where .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); let protocol_message_channel = - super::util::CloneableUnboundedReceiver::from(protocol_message_channel); + gadget_common::utils::CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( "Starting Signing Protocol with params: i={i}, t={t}" diff --git a/protocols/zcash-frost/src/protocol/util.rs b/protocols/zcash-frost/src/protocol/util.rs index 6825a652a..8e313c73e 100644 --- a/protocols/zcash-frost/src/protocol/util.rs +++ b/protocols/zcash-frost/src/protocol/util.rs @@ -1,70 +1,19 @@ #![allow(clippy::type_complexity, clippy::too_many_arguments)] //! When delivering messages to an async protocol, we want to make sure we don't mix up voting and public key gossip messages //! Thus, this file contains a function that takes a channel from the gadget to the async protocol and splits it into two channels -use futures::{Stream, StreamExt}; +use futures::StreamExt; use gadget_common::client::AccountId; use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::network::Network; use gadget_common::gadget::work_manager::WorkManager; +use gadget_common::utils::CloneableUnboundedReceiver; use gadget_core::job_manager::WorkManagerInterface; use rand::seq::SliceRandom; use round_based::{Incoming, MessageDestination, MessageType, Outgoing, PartyIndex}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use std::sync::atomic::AtomicBool; use std::sync::Arc; -use tokio::sync::mpsc::UnboundedReceiver; - -/// A Channel Receiver that can be cloned. -/// -/// On the second clone, the original channel will stop sending messages -/// and the new channel will start sending messages. -pub struct CloneableUnboundedReceiver { - rx: Arc>>, - is_in_use: Arc, -} - -impl Clone for CloneableUnboundedReceiver { - fn clone(&self) -> Self { - // on the clone, we switch the is_in_use flag to false - // and we return a new channel - self.is_in_use - .store(false, std::sync::atomic::Ordering::SeqCst); - Self { - rx: self.rx.clone(), - is_in_use: Arc::new(AtomicBool::new(true)), - } - } -} - -impl From> for CloneableUnboundedReceiver { - fn from(rx: UnboundedReceiver) -> Self { - Self { - rx: Arc::new(tokio::sync::Mutex::new(rx)), - is_in_use: Arc::new(AtomicBool::new(false)), - } - } -} - -impl Stream for CloneableUnboundedReceiver { - type Item = T; - fn poll_next( - self: std::pin::Pin<&mut Self>, - cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { - if !self.is_in_use.load(std::sync::atomic::Ordering::SeqCst) { - return std::task::Poll::Ready(None); - } - let mut rx = match self.rx.try_lock() { - Ok(rx) => rx, - Err(_) => return std::task::Poll::Pending, - }; - let rx = &mut *rx; - tokio::pin!(rx); - rx.poll_recv(cx) - } -} #[derive(Serialize, Deserialize, Debug)] pub enum SplitChannelMessage { From 2588823c485d7e8bc9a3d2bba902eaa00a766c17 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 26 Feb 2024 13:42:12 -0500 Subject: [PATCH 45/66] use rust nightly 1.78.0 in pipeline --- .github/workflows/validate_pr.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index 1c017ee98..39a7736dd 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -26,7 +26,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: 1.78.0 components: rustfmt - name: Check Formatting @@ -42,7 +42,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: 1.78.0 components: clippy - uses: Swatinem/rust-cache@v2 @@ -69,7 +69,7 @@ jobs: - name: install rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: 1.78.0 - uses: swatinem/rust-cache@v2 with: @@ -95,7 +95,7 @@ jobs: - name: install rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: 1.78.0 - uses: swatinem/rust-cache@v2 with: From 2d2a5bc09bc60b192d58a85640a33d86a5e398c6 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 26 Feb 2024 14:43:47 -0500 Subject: [PATCH 46/66] Cleanup, bump rust version --- .github/workflows/validate_pr.yml | 8 ++++---- gadget-core/src/job_manager.rs | 1 - protocols/bls/src/lib.rs | 7 +------ protocols/bls/src/protocol/keygen.rs | 5 ----- protocols/dfns-cggmp21/src/lib.rs | 17 +---------------- .../dfns-cggmp21/src/protocols/key_rotate.rs | 2 +- protocols/stub/src/lib.rs | 2 -- protocols/zcash-frost/src/lib.rs | 7 +------ protocols/zcash-frost/src/protocol/sign.rs | 2 +- protocols/zk-saas/src/lib.rs | 8 -------- rust-toolchain.toml | 2 +- 11 files changed, 10 insertions(+), 51 deletions(-) diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index 39a7736dd..1c017ee98 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -26,7 +26,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.78.0 + toolchain: nightly components: rustfmt - name: Check Formatting @@ -42,7 +42,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.78.0 + toolchain: nightly components: clippy - uses: Swatinem/rust-cache@v2 @@ -69,7 +69,7 @@ jobs: - name: install rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.78.0 + toolchain: nightly - uses: swatinem/rust-cache@v2 with: @@ -95,7 +95,7 @@ jobs: - name: install rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.78.0 + toolchain: nightly - uses: swatinem/rust-cache@v2 with: diff --git a/gadget-core/src/job_manager.rs b/gadget-core/src/job_manager.rs index 0e9c692f1..238d8acbf 100644 --- a/gadget-core/src/job_manager.rs +++ b/gadget-core/src/job_manager.rs @@ -668,7 +668,6 @@ mod tests { use crate::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use parking_lot::Mutex; use std::sync::atomic::{AtomicBool, Ordering}; - use std::sync::Arc; use std::time::Duration; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; diff --git a/protocols/bls/src/lib.rs b/protocols/bls/src/lib.rs index 4f6999831..02d98060c 100644 --- a/protocols/bls/src/lib.rs +++ b/protocols/bls/src/lib.rs @@ -1,15 +1,10 @@ use crate::protocol::keygen::BlsKeygenAdditionalParams; use async_trait::async_trait; use gadget_common::full_protocol::SharedOptional; -use gadget_common::gadget::JobInitMetadata; use gadget_common::prelude::*; -use gadget_common::{ - generate_protocol, generate_setup_and_run_command, BuiltExecutableJobWrapper, Error, JobError, - ProtocolWorkManager, WorkManagerInterface, -}; +use gadget_common::{generate_protocol, generate_setup_and_run_command}; use protocol::signing::BlsSigningAdditionalParams; use protocol_macros::protocol; -use std::sync::Arc; pub mod protocol; diff --git a/protocols/bls/src/protocol/keygen.rs b/protocols/bls/src/protocol/keygen.rs index 3f4d07000..60371d50c 100644 --- a/protocols/bls/src/protocol/keygen.rs +++ b/protocols/bls/src/protocol/keygen.rs @@ -1,16 +1,11 @@ use crate::protocol::state_machine::payloads::RoundPayload; use crate::protocol::state_machine::BlsStateMachine; use gadget_common::gadget::message::UserID; -use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; use gadget_common::prelude::*; use gadget_common::sp_core::keccak_256; use itertools::Itertools; use round_based::Msg; use std::collections::{BTreeMap, HashMap}; -use tangle_primitives::jobs::{ - DKGTSSKeySubmissionResult, DigitalSignatureScheme, JobId, JobResult, -}; -use tokio::sync::mpsc::UnboundedSender; #[derive(Clone)] pub struct BlsKeygenAdditionalParams { diff --git a/protocols/dfns-cggmp21/src/lib.rs b/protocols/dfns-cggmp21/src/lib.rs index 65257c456..cddbfcb09 100644 --- a/protocols/dfns-cggmp21/src/lib.rs +++ b/protocols/dfns-cggmp21/src/lib.rs @@ -3,26 +3,11 @@ use crate::protocols::key_rotate::DfnsCGGMP21KeyRotateExtraParams; use crate::protocols::keygen::DfnsCGGMP21KeygenExtraParams; use crate::protocols::sign::DfnsCGGMP21SigningExtraParams; use async_trait::async_trait; -use gadget_common::client::{AccountId, ClientWithApi, JobsClient, PalletSubmitter}; -use gadget_common::client::{GadgetJobType, JobsApiForGadget}; -use gadget_common::debug_logger::DebugLogger; use gadget_common::full_protocol::SharedOptional; -use gadget_common::gadget::network::Network; -use gadget_common::gadget::JobInitMetadata; -use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; use gadget_common::prelude::*; -use gadget_common::prelude::{FullProtocolConfig, GadgetProtocolMessage, Mutex, WorkManager}; -use gadget_common::{generate_protocol, generate_setup_and_run_command, Error}; -use gadget_core::job::{BuiltExecutableJobWrapper, JobError}; -use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; +use gadget_common::{generate_protocol, generate_setup_and_run_command}; use protocol_macros::protocol; -use sc_client_api::Backend; -use sp_api::ProvideRuntimeApi; -use sp_runtime::traits::Block; -use std::sync::Arc; -use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use test_utils::generate_signing_and_keygen_tss_tests; -use tokio::sync::mpsc::UnboundedReceiver; pub mod constants; pub mod error; diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index 1feb4a900..ef831df65 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -94,7 +94,7 @@ where new_phase_one_id, role_type: job.role_type, key, - new_key: new_key.try_into().unwrap(), + new_key: new_key.into(), user_id_to_account_id_mapping, }; Ok(params) diff --git a/protocols/stub/src/lib.rs b/protocols/stub/src/lib.rs index 6263b3680..9b1f9c583 100644 --- a/protocols/stub/src/lib.rs +++ b/protocols/stub/src/lib.rs @@ -1,7 +1,5 @@ use gadget_common::full_protocol::SharedOptional; -use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; use gadget_common::prelude::*; -use gadget_common::ProtocolWorkManager; #[protocol] pub struct StubProtocol< diff --git a/protocols/zcash-frost/src/lib.rs b/protocols/zcash-frost/src/lib.rs index be5756173..b57d61a04 100644 --- a/protocols/zcash-frost/src/lib.rs +++ b/protocols/zcash-frost/src/lib.rs @@ -2,14 +2,9 @@ use crate::protocol::keygen::ZcashFrostKeygenExtraParams; use crate::protocol::sign::ZcashFrostSigningExtraParams; use async_trait::async_trait; use gadget_common::full_protocol::SharedOptional; -use gadget_common::gadget::JobInitMetadata; use gadget_common::prelude::*; -use gadget_common::{ - generate_protocol, generate_setup_and_run_command, BuiltExecutableJobWrapper, Error, JobError, - ProtocolWorkManager, WorkManagerInterface, -}; +use gadget_common::{generate_protocol, generate_setup_and_run_command}; use protocol_macros::protocol; -use std::sync::Arc; pub mod constants; pub mod protocol; diff --git a/protocols/zcash-frost/src/protocol/sign.rs b/protocols/zcash-frost/src/protocol/sign.rs index 6dafb05a8..b01841615 100644 --- a/protocols/zcash-frost/src/protocol/sign.rs +++ b/protocols/zcash-frost/src/protocol/sign.rs @@ -62,7 +62,7 @@ where let JobType::DKGTSSPhaseTwo(p2_job) = job.job_type else { panic!("Should be valid type") }; - let input_data_to_sign = p2_job.submission.try_into().unwrap(); + let input_data_to_sign = p2_job.submission.into(); let previous_job_id = p2_job.phase_one_id; let phase1_job = job.phase1_job.expect("Should exist for a phase 2 job"); diff --git a/protocols/zk-saas/src/lib.rs b/protocols/zk-saas/src/lib.rs index efa52ef42..7a0de0570 100644 --- a/protocols/zk-saas/src/lib.rs +++ b/protocols/zk-saas/src/lib.rs @@ -1,20 +1,12 @@ use crate::network::ZkNetworkService; use crate::protocol::ZkJobAdditionalParams; use async_trait::async_trait; -use gadget_common::client::{ - AccountId, ClientWithApi, JobsApiForGadget, JobsClient, PalletSubmitter, -}; -use gadget_common::debug_logger::DebugLogger; use gadget_common::full_protocol::SharedOptional; use gadget_common::prelude::*; use gadget_common::{generate_protocol, Error}; use mpc_net::prod::RustlsCertificate; use network::ZkProtocolNetworkConfig; use protocol_macros::protocol; -use sc_client_api::Backend; -use sp_api::ProvideRuntimeApi; -use sp_runtime::traits::Block; -use std::sync::Arc; use tangle_primitives::roles::ZeroKnowledgeRoleType; use tokio_rustls::rustls::{Certificate, PrivateKey, RootCertStore}; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 83b8c051f..59f29b754 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -3,7 +3,7 @@ # substrate has issues with newer versions. # See: https://substrate.stackexchange.com/questions/7714/cannot-run-substrate-on-a-fresh-macbook-m2 # and: https://stackoverflow.com/questions/75955457/substrate-node-template-cannot-create-a-runtime-error-othercannot-deserialize -channel = "nightly-2023-09-28" +channel = "nightly-2024-02-26" components = ["rustfmt", "clippy", "rust-src"] targets = ["wasm32-unknown-unknown"] profile = "minimal" From faba66967de53b4645ba15e944b4b0e9077e3db1 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 26 Feb 2024 14:55:51 -0500 Subject: [PATCH 47/66] revert toolchain --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 59f29b754..83b8c051f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -3,7 +3,7 @@ # substrate has issues with newer versions. # See: https://substrate.stackexchange.com/questions/7714/cannot-run-substrate-on-a-fresh-macbook-m2 # and: https://stackoverflow.com/questions/75955457/substrate-node-template-cannot-create-a-runtime-error-othercannot-deserialize -channel = "nightly-2024-02-26" +channel = "nightly-2023-09-28" components = ["rustfmt", "clippy", "rust-src"] targets = ["wasm32-unknown-unknown"] profile = "minimal" From 35f383d94d5bb77ea58909c51ebb250c58b2e7f8 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 26 Feb 2024 17:31:29 -0500 Subject: [PATCH 48/66] merge branch drew/dfns-generalize --- Cargo.lock | 1 + Cargo.toml | 3 +- protocols/dfns-cggmp21/Cargo.toml | 1 + .../dfns-cggmp21/src/protocols/keygen.rs | 334 ++++++++++++------ 4 files changed, 224 insertions(+), 115 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c84d992e0..f7f14367b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2229,6 +2229,7 @@ dependencies = [ "rand_chacha 0.3.1", "sc-client-api", "serde", + "sha2 0.10.8", "sp-api", "sp-application-crypto", "sp-core", diff --git a/Cargo.toml b/Cargo.toml index b8dd9ab96..a2d2ae801 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -146,4 +146,5 @@ thiserror = { version = "1.0" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } lazy_static = "1.4.0" sqlx = "=0.7.1" -postcard = "1.0.8" \ No newline at end of file +postcard = "1.0.8" +sha2 = "0.10.8" \ No newline at end of file diff --git a/protocols/dfns-cggmp21/Cargo.toml b/protocols/dfns-cggmp21/Cargo.toml index cfdb4e2c1..b8f31558c 100644 --- a/protocols/dfns-cggmp21/Cargo.toml +++ b/protocols/dfns-cggmp21/Cargo.toml @@ -39,3 +39,4 @@ rand_chacha = { workspace = true } hex = { workspace = true } test-utils = { workspace = true } parking_lot = { workspace = true } +sha2 = { workspace = true } \ No newline at end of file diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index bc1cd2d9b..22358b86d 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -1,10 +1,12 @@ -use curv::cryptographic_primitives::hashing::Digest; use dfns_cggmp21::generic_ec::Curve; +use dfns_cggmp21::key_refresh::msg::aux_only; use dfns_cggmp21::keygen::msg::threshold; -use dfns_cggmp21::round_based::{Delivery, Mpc}; -use dfns_cggmp21::security_level::SecurityLevel; +use dfns_cggmp21::keygen::msg::threshold::Msg; +use dfns_cggmp21::keygen::ThresholdMsg; +use dfns_cggmp21::round_based::{Delivery, Incoming, MpcParty, Outgoing}; +use dfns_cggmp21::security_level::SecurityLevel128; use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; -use dfns_cggmp21::KeyShare; +use futures::channel::mpsc::{TryRecvError, UnboundedSender}; use futures::StreamExt; use gadget_common::client::{ AccountId, ClientWithApi, GadgetJobResult, JobsApiForGadget, MaxKeyLen, MaxParticipants, @@ -27,7 +29,7 @@ use pallet_dkg::signatures_schemes::to_slice_33; use rand::rngs::StdRng; use rand::SeedableRng; use sc_client_api::Backend; -use serde::Serialize; +use sha2::Sha256; use sp_api::ProvideRuntimeApi; use sp_application_crypto::sp_core::keccak_256; use sp_core::{ecdsa, Pair}; @@ -100,26 +102,20 @@ pub struct DfnsCGGMP21KeygenExtraParams { user_id_to_account_id_mapping: Arc>, } -use dfns_cggmp21::keygen::KeygenBuilder; - -pub async fn run_and_serialize_keygen<'r, E: Curve, M, D, L, DG>( - tracer: dfns_cggmp21::progress::PerfProfiler, +pub async fn run_and_serialize_keygen<'r, E: Curve, D>( + tracer: &mut dfns_cggmp21::progress::PerfProfiler, eid: dfns_cggmp21::ExecutionId<'r>, i: u16, n: u16, t: u16, - party: dfns_cggmp21::round_based::MpcParty, - rng: StdRng, + party: MpcParty, D>, + mut rng: StdRng, ) -> Result, JobError> where - M: Send + 'static, - D: Delivery, - DG: Digest + digest::FixedOutput + digest::HashMarker + Default, - M: Mpc>, - L: SecurityLevel, + D: Delivery>, { let incomplete_key_share = dfns_cggmp21::keygen::(eid, i, n) - .set_progress_tracer(&mut tracer) + .set_progress_tracer(tracer) .set_threshold(t) .start(&mut rng, party) .await @@ -130,43 +126,34 @@ where reason: format!("Keygen protocol error: {err:?}"), }) } -macro_rules! run_keygen_protocol { - ($curve_type:ty, $tracer:expr, $eid:expr, $i:expr, $n:expr, $t:expr, $party:expr, $rng:expr,) => { - run_and_serialize_keygen::<$curve_type, _, _, _, _>($tracer, $eid, $i, $n, $t, $party, $rng) - .await? - }; -} -pub async fn run_and_serialize_keyrefresh<'r, E: Curve, M, D, L, DG>( +pub async fn run_and_serialize_keyrefresh<'r, E: Curve, D>( logger: &DebugLogger, incomplete_key_share: Vec, - pregenerated_primes: dfns_cggmp21::PregeneratedPrimes, - tracer: dfns_cggmp21::progress::PerfProfiler, + pregenerated_primes: dfns_cggmp21::PregeneratedPrimes, + tracer: &mut dfns_cggmp21::progress::PerfProfiler, aux_eid: dfns_cggmp21::ExecutionId<'r>, i: u16, n: u16, - party: dfns_cggmp21::round_based::MpcParty, - rng: StdRng, + party: MpcParty, D>, + mut rng: StdRng, ) -> Result<(Vec, Vec), JobError> where - M: Send + 'static, - D: Delivery, - DG: Digest + digest::FixedOutput + digest::HashMarker + Default, - M: Mpc>, - L: SecurityLevel, + D: Delivery>, { let incomplete_key_share: dfns_cggmp21::key_share::Valid< dfns_cggmp21::key_share::DirtyIncompleteKeyShare<_>, > = bincode2::deserialize(&incomplete_key_share).map_err(|err| JobError { reason: format!("Keygen protocol error: {err:?}"), })?; - let aux_info = dfns_cggmp21::aux_info_gen(aux_eid, i, n, pregenerated_primes) - .set_progress_tracer(&mut tracer) - .start(&mut rng, party) - .await - .map_err(|err| JobError { - reason: format!("Aux info protocol error: {err:?}"), - })?; + let aux_info = + dfns_cggmp21::aux_info_gen::(aux_eid, i, n, pregenerated_primes) + .set_progress_tracer(tracer) + .start(&mut rng, party) + .await + .map_err(|err| JobError { + reason: format!("Aux info protocol error: {err:?}"), + })?; let perf_report = tracer.get_report().map_err(|err| JobError { reason: format!("Aux info protocol error: {err:?}"), })?; @@ -174,9 +161,10 @@ where logger.debug("Finished AsyncProtocol - Aux Info"); let key_share = - dfns_cggmp21::KeyShare::make(incomplete_key_share, aux_info).map_err(|err| JobError { - reason: format!("Key share error: {err:?}"), - })?; + dfns_cggmp21::KeyShare::::make(incomplete_key_share, aux_info) + .map_err(|err| JobError { + reason: format!("Key share error: {err:?}"), + })?; bincode2::serialize(&key_share) .map(|ks| (ks, key_share.shared_public_key().to_bytes(true).to_vec())) .map_err(|err| JobError { @@ -184,22 +172,6 @@ where }) } -macro_rules! run_keyrefresh_protocol { - ($curve_type:ty, $logger:expr, $incomplete_key_share:expr, $pregenerated_primes:expr, $tracer:expr, $eid:expr, $i:expr, $n:expr, $party:expr, $rng:expr,) => { - run_and_serialize_keyrefresh::<$curve_type, _, _, _, _>( - $logger, - $incomplete_key_share, - $pregenerated_primes, - $tracer, - $eid, - $i, - $n, - $party, - $rng, - ) - .await? - }; -} pub async fn generate_protocol_from< B: Block, BE: Backend + 'static, @@ -251,34 +223,88 @@ where let mix = keccak_256(b"dnfs-cggmp21-keygen-aux"); let aux_eid_bytes = [&job_id_bytes[..], &mix[..]].concat(); let aux_eid = dfns_cggmp21::ExecutionId::new(&aux_eid_bytes); - - let ( - keygen_tx_to_outbound, - keygen_rx_async_proto, - _broadcast_tx_to_outbound, - _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split::<_, (), _>( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - id, - network.clone(), - ); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); - let party = dfns_cggmp21::round_based::MpcParty::connected(delivery); + + fn create_party( + protocol_message_channel: CloneableUnboundedReceiver, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + mapping: Arc>, + id: AccountId, + network: N, + ) -> MpcParty< + Msg, + ( + futures::channel::mpsc::UnboundedReceiver< + Result>, TryRecvError>, + >, + UnboundedSender>>, + ), + > { + let ( + keygen_tx_to_outbound, + keygen_rx_async_proto, + _broadcast_tx_to_outbound, + _broadcast_rx_from_gadget, + ) = super::util::create_job_manager_to_async_protocol_channel_split::< + _, + (), + threshold::Msg, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping, + id, + network, + ); + let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); + MpcParty::connected(delivery) + } + let incomplete_key_share: Vec = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - run_keygen_protocol!(Secp256k1, tracer, eid, i, n, t, party, rng,) + let party = create_party::( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + run_and_serialize_keygen(&mut tracer, eid, i, n, t, party, rng.clone()).await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - run_keygen_protocol!(Secp256r1, tracer, eid, i, n, t, party, rng,) + let party = create_party::( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + run_and_serialize_keygen(&mut tracer, eid, i, n, t, party, rng.clone()).await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - run_keygen_protocol!(Stark, tracer, eid, i, n, t, party, rng,) + let party = create_party::( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + run_and_serialize_keygen(&mut tracer, eid, i, n, t, party, rng.clone()).await? } _ => unreachable!("Invalid role type"), }; @@ -288,78 +314,158 @@ where })?; logger.trace(format!("Incomplete Keygen protocol report: {perf_report}")); logger.debug("Finished AsyncProtocol - Incomplete Keygen"); - - let ( - keygen_tx_to_outbound, - keygen_rx_async_proto, - broadcast_tx_to_outbound, - broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping, - id, - network, - ); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let pregenerated_primes_key = keccak_256(&[&b"dfns-cggmp21-keygen-primes"[..], &job_id_bytes[..]].concat()); - let pregenerated_primes = dfns_cggmp21::PregeneratedPrimes::generate(&mut rng); + let pregenerated_primes = + dfns_cggmp21::PregeneratedPrimes::::generate(&mut rng); key_store2 .set(&pregenerated_primes_key, pregenerated_primes.clone()) .await .map_err(|err| JobError { reason: format!("Failed to store pregenerated primes: {err:?}"), })?; - let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); - let party = dfns_cggmp21::round_based::MpcParty::connected(delivery); - let (key_share, serialized_public_key): (Vec, Vec) = match role_type { + fn create_party_refresh( + protocol_message_channel: CloneableUnboundedReceiver, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + mapping: Arc>, + id: AccountId, + network: N, + ) -> ( + UnboundedSender, + futures::channel::mpsc::UnboundedReceiver, + MpcParty< + dfns_cggmp21::key_refresh::msg::aux_only::Msg, + ( + futures::channel::mpsc::UnboundedReceiver< + Result< + Incoming< + dfns_cggmp21::key_refresh::msg::aux_only::Msg< + Sha256, + SecurityLevel128, + >, + >, + TryRecvError, + >, + >, + UnboundedSender< + Outgoing< + dfns_cggmp21::key_refresh::msg::aux_only::Msg< + Sha256, + SecurityLevel128, + >, + >, + >, + ), + >, + ) { + let ( + keyrefresh_tx_to_outbound, + keyrefresh_rx_async_proto, + broadcast_tx_to_outbound, + broadcast_rx_from_gadget, + ) = super::util::create_job_manager_to_async_protocol_channel_split::< + _, + PublicKeyGossipMessage, + aux_only::Msg, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping, + id, + network, + ); + let delivery = (keyrefresh_rx_async_proto, keyrefresh_tx_to_outbound); + ( + broadcast_tx_to_outbound, + broadcast_rx_from_gadget, + MpcParty::connected(delivery), + ) + } + + let (tx, rx, key_share, serialized_public_key) = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - run_keyrefresh_protocol!( - Secp256k1, + let (tx, rx, party) = create_party_refresh( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + let (ks, pk) = run_and_serialize_keyrefresh::( &logger, incomplete_key_share, pregenerated_primes, - tracer, + &mut tracer, aux_eid, i, n, party, rng, ) + .await?; + (tx, rx, ks, pk) } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - run_keyrefresh_protocol!( - Secp256r1, + let (tx, rx, party) = create_party_refresh( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + let (kx, pk) = run_and_serialize_keyrefresh::( &logger, incomplete_key_share, pregenerated_primes, - tracer, + &mut tracer, aux_eid, i, n, party, rng, ) + .await?; + (tx, rx, kx, pk) } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - run_keyrefresh_protocol!( - Stark, + let (tx, rx, party) = create_party_refresh( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + id, + network.clone(), + ); + let (ks, pk) = run_and_serialize_keyrefresh::( &logger, incomplete_key_share, pregenerated_primes, - tracer, + &mut tracer, aux_eid, i, n, party, rng, ) + .await?; + (tx, rx, ks, pk) } _ => unreachable!("Invalid role type"), }; @@ -373,8 +479,8 @@ where &serialized_public_key, t, i, - broadcast_tx_to_outbound, - broadcast_rx_from_gadget, + tx, + rx, ) .await?; @@ -413,14 +519,14 @@ where async fn handle_public_key_gossip( key_store: ECDSAKeyStore, logger: &DebugLogger, - local_key: &[u8], + _local_key: &[u8], serialized_public_key: &[u8], t: u16, i: u16, broadcast_tx_to_outbound: futures::channel::mpsc::UnboundedSender, mut broadcast_rx_from_gadget: futures::channel::mpsc::UnboundedReceiver, ) -> Result { - let key_hashed = keccak_256(&serialized_public_key); + let key_hashed = keccak_256(serialized_public_key); let signature = key_store.pair().sign_prehashed(&key_hashed).0.to_vec(); let my_id = key_store.pair().public(); let mut received_keys = BTreeMap::new(); @@ -508,7 +614,7 @@ async fn handle_public_key_gossip( let res = DKGTSSKeySubmissionResult { signature_scheme: DigitalSignatureScheme::Ecdsa, - key: serialized_public_key.try_into().unwrap(), + key: serialized_public_key.to_vec().try_into().unwrap(), participants, signatures: signatures.try_into().unwrap(), threshold: t as _, From 8574f19b6ba20109ac91e5792f05a444eaebb07e Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Tue, 27 Feb 2024 10:35:46 -0500 Subject: [PATCH 49/66] Add spawn_blocking around blocking task --- .../dfns-cggmp21/src/protocols/key_refresh.rs | 2 +- .../dfns-cggmp21/src/protocols/key_rotate.rs | 2 +- .../dfns-cggmp21/src/protocols/keygen.rs | 24 ++++++++++++++----- protocols/dfns-cggmp21/src/protocols/sign.rs | 2 +- protocols/dfns-cggmp21/src/protocols/util.rs | 2 +- protocols/zcash-frost/src/protocol/keygen.rs | 2 +- protocols/zcash-frost/src/protocol/sign.rs | 2 +- protocols/zcash-frost/src/protocol/util.rs | 2 +- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs index f88a452a5..57a572c86 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs @@ -157,7 +157,7 @@ where key_refresh_rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split::<_, (), _>( + ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::<_, (), _>( protocol_message_channel.clone(), associated_block_id, associated_retry_id, diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index ef831df65..c24a9bd2f 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -173,7 +173,7 @@ where key_rotate_rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split::<_, (), _>( + ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::<_, (), _>( protocol_message_channel.clone(), associated_block_id, associated_retry_id, diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 22358b86d..a320bc818 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -26,7 +26,7 @@ use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use itertools::Itertools; use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; use pallet_dkg::signatures_schemes::to_slice_33; -use rand::rngs::StdRng; +use rand::rngs::{OsRng, StdRng}; use rand::SeedableRng; use sc_client_api::Backend; use sha2::Sha256; @@ -209,7 +209,7 @@ where Ok(JobBuilder::new() .protocol(async move { - let mut rng = rand::rngs::StdRng::from_entropy(); + let rng = rand::rngs::StdRng::from_entropy(); let protocol_message_channel = CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( @@ -248,7 +248,7 @@ where keygen_rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split::< + ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::< _, (), threshold::Msg, @@ -318,8 +318,19 @@ where let pregenerated_primes_key = keccak_256(&[&b"dfns-cggmp21-keygen-primes"[..], &job_id_bytes[..]].concat()); - let pregenerated_primes = - dfns_cggmp21::PregeneratedPrimes::::generate(&mut rng); + let now = tokio::time::Instant::now(); + let pregenerated_primes = tokio::task::spawn_blocking(|| { + let mut rng = OsRng; + dfns_cggmp21::PregeneratedPrimes::::generate(&mut rng) + }) + .await + .map_err(|err| JobError { + reason: format!("Failed to generate pregenerated primes: {err:?}"), + })?; + + let elapsed = now.elapsed(); + logger.debug(format!("Pregenerated primes took {elapsed:?}")); + key_store2 .set(&pregenerated_primes_key, pregenerated_primes.clone()) .await @@ -369,7 +380,7 @@ where keyrefresh_rx_async_proto, broadcast_tx_to_outbound, broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split::< + ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::< _, PublicKeyGossipMessage, aux_only::Msg, @@ -391,6 +402,7 @@ where ) } + logger.info(format!("Will now run Keygen protocol: {role_type:?}")); let (tx, rx, key_share, serialized_public_key) = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { let (tx, rx, party) = create_party_refresh( diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index 862b148c0..a46eb3e03 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -148,7 +148,7 @@ where signing_rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split::<_, (), _>( + ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::<_, (), _>( protocol_message_channel.clone(), associated_block_id, associated_retry_id, diff --git a/protocols/dfns-cggmp21/src/protocols/util.rs b/protocols/dfns-cggmp21/src/protocols/util.rs index 1c62f5c0d..100793dad 100644 --- a/protocols/dfns-cggmp21/src/protocols/util.rs +++ b/protocols/dfns-cggmp21/src/protocols/util.rs @@ -238,7 +238,7 @@ impl MaybeSenderReceiver for () { } } -pub(crate) fn create_job_manager_to_async_protocol_channel_split< +pub(crate) fn create_job_manager_to_async_protocol_channel_split_futures< N: Network + 'static, C2: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, M: Serialize + DeserializeOwned + Send + 'static, diff --git a/protocols/zcash-frost/src/protocol/keygen.rs b/protocols/zcash-frost/src/protocol/keygen.rs index 54ac116fe..25f846230 100644 --- a/protocols/zcash-frost/src/protocol/keygen.rs +++ b/protocols/zcash-frost/src/protocol/keygen.rs @@ -171,7 +171,7 @@ where keygen_rx_async_proto, broadcast_tx_to_outbound, broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split( + ) = super::util::create_job_manager_to_async_protocol_channel_split_futures( protocol_message_channel.clone(), associated_block_id, associated_retry_id, diff --git a/protocols/zcash-frost/src/protocol/sign.rs b/protocols/zcash-frost/src/protocol/sign.rs index b01841615..8338ac75d 100644 --- a/protocols/zcash-frost/src/protocol/sign.rs +++ b/protocols/zcash-frost/src/protocol/sign.rs @@ -193,7 +193,7 @@ where signing_rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split::<_, (), _>( + ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::<_, (), _>( protocol_message_channel.clone(), associated_block_id, associated_retry_id, diff --git a/protocols/zcash-frost/src/protocol/util.rs b/protocols/zcash-frost/src/protocol/util.rs index 8e313c73e..e5dfdae0d 100644 --- a/protocols/zcash-frost/src/protocol/util.rs +++ b/protocols/zcash-frost/src/protocol/util.rs @@ -237,7 +237,7 @@ impl MaybeSenderReceiver for () { } } -pub(crate) fn create_job_manager_to_async_protocol_channel_split< +pub(crate) fn create_job_manager_to_async_protocol_channel_split_futures< N: Network + 'static, C2: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, M: Serialize + DeserializeOwned + Send + 'static, From 8128513a4ff0d8925d57eb2c6c86dc0cd71b08ce Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Tue, 27 Feb 2024 12:30:57 -0500 Subject: [PATCH 50/66] Refactor channels (merge code) --- Cargo.lock | 16 +- Cargo.toml | 6 + gadget-common/Cargo.toml | 1 + gadget-common/src/channels.rs | 423 +++++++++++++++++- protocols/dfns-cggmp21/Cargo.toml | 1 + .../dfns-cggmp21/src/protocols/key_refresh.rs | 13 +- .../dfns-cggmp21/src/protocols/key_rotate.rs | 12 +- .../dfns-cggmp21/src/protocols/keygen.rs | 14 +- protocols/dfns-cggmp21/src/protocols/sign.rs | 12 +- protocols/dfns-cggmp21/src/protocols/util.rs | 406 +---------------- protocols/zcash-frost/Cargo.toml | 2 +- protocols/zcash-frost/src/protocol/keygen.rs | 15 +- protocols/zcash-frost/src/protocol/sign.rs | 12 +- protocols/zcash-frost/src/protocol/util.rs | 398 +--------------- protocols/zcash-frost/src/rounds/keygen.rs | 1 + protocols/zcash-frost/src/rounds/mod.rs | 2 +- protocols/zcash-frost/src/rounds/sign.rs | 1 + 17 files changed, 494 insertions(+), 841 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7f14367b..c09a81d46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2227,6 +2227,7 @@ dependencies = [ "protocol-macros", "rand 0.8.5", "rand_chacha 0.3.1", + "round-based 0.2.1", "sc-client-api", "serde", "sha2 0.10.8", @@ -3724,6 +3725,7 @@ dependencies = [ "parking_lot 0.12.1", "protocol-macros", "round-based 0.1.7", + "round-based 0.2.1", "sc-client-api", "sc-network", "sc-network-common", @@ -7650,18 +7652,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "round-based" -version = "0.2.0" -source = "git+https://github.com/ZenGo-X/round-based-protocol#1b372fe7d19de8cc5236cfcd0bcd92d610dacecd" -dependencies = [ - "futures-util", - "phantom-type 0.3.1", - "round-based-derive", - "thiserror", - "tracing", -] - [[package]] name = "round-based" version = "0.2.1" @@ -12151,7 +12141,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", - "round-based 0.2.0", + "round-based 0.2.1", "sc-client-api", "serde", "sha2 0.10.8", diff --git a/Cargo.toml b/Cargo.toml index a2d2ae801..aff2bdb66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,13 @@ webb = { git = "https://github.com/webb-tools/webb-rs", default-features = false subxt-signer = { version = "0.31.0", default-features = false } multi-party-ecdsa = { git = "https://github.com/webb-tools/cggmp-threshold-ecdsa/" } + +# Round-based dependencies round-based = { git = "https://github.com/webb-tools/round-based-protocol", features = [] } +round-based-21 = { package = "round-based", version = "0.2.1" } +round-based-zengo = { package = "round-based", git = "https://github.com/ZenGo-X/round-based-protocol", features = ["derive"]} + + curv = { package = "curv-kzen", version = "0.10.0" } digest = "0.10" dfns-cggmp21 = { package = "cggmp21", version = "0.1.1", default-features = false } diff --git a/gadget-common/Cargo.toml b/gadget-common/Cargo.toml index 629718d89..0b1b3e4da 100644 --- a/gadget-common/Cargo.toml +++ b/gadget-common/Cargo.toml @@ -37,6 +37,7 @@ subxt-signer = { workspace = true, features = ["subxt", "sr25519"] } anyhow = { workspace = true } futures = { workspace = true } round-based = { workspace = true } +round-based-21 = { workspace = true, features = ["derive"]} sp-api = { workspace = true } sp-io = { workspace = true } sqlx = { workspace = true, features = ["runtime-tokio-rustls", "sqlite"] } diff --git a/gadget-common/src/channels.rs b/gadget-common/src/channels.rs index 0758b4221..7b8b6a256 100644 --- a/gadget-common/src/channels.rs +++ b/gadget-common/src/channels.rs @@ -4,21 +4,17 @@ use crate::client::AccountId; use crate::gadget::message::{GadgetProtocolMessage, UserID}; use crate::gadget::network::Network; use crate::gadget::work_manager::WorkManager; +use crate::utils::CloneableUnboundedReceiver; use futures::StreamExt; use gadget_core::job_manager::WorkManagerInterface; use round_based::Msg; +use round_based_21::{Incoming, MessageDestination, MessageType, MsgId, Outgoing, PartyIndex}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::sync::Arc; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; -#[derive(Serialize, Deserialize, Debug)] -pub enum SplitChannelMessage { - Channel1(C1), - Channel2(C2), -} - pub fn create_job_manager_to_async_protocol_channel_split< N: Network + 'static, C1: Serialize + DeserializeOwned + HasSenderAndReceiver + Send + 'static, @@ -130,7 +126,7 @@ pub fn create_job_manager_to_async_protocol_channel_split< ) } -fn get_to_and_from_account_id( +pub fn get_to_and_from_account_id( mapping: &HashMap, from: UserID, to: Option, @@ -168,3 +164,416 @@ impl HasSenderAndReceiver for () { unimplemented!("Stub implementation") } } + +#[derive(Serialize, Deserialize, Debug)] +pub enum SplitChannelMessage { + Channel1(C1), + Channel2(C2), +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct VotingMessage { + pub from: UserID, + pub to: Option, + pub payload: Vec, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct PublicKeyGossipMessage { + pub from: UserID, + pub to: Option, + pub signature: Vec, + pub id: AccountId, +} + +/// All possible senders of a message +#[derive(Debug, Default, Serialize, Deserialize)] +pub enum MaybeSender { + /// We are the sender of the message + Myself, + /// The sender is someone else + /// it could also be us, double check the [`UserID`] + SomeoneElse(UserID), + /// The sender is unknown. + #[default] + Unknown, +} + +impl MaybeSender { + /// Returns `true` if the maybe sender is [`Myself`]. + /// + /// [`Myself`]: MaybeSender::Myself + #[must_use] + pub fn is_myself(&self) -> bool { + matches!(self, Self::Myself) + } + + /// Returns `true` if the maybe sender is [`Myself`]. + /// Or if the sender is [`SomeoneElse`] but the [`UserID`] is the same as `my_user_id` + /// + /// [`Myself`]: MaybeSender::Myself + /// [`SomeoneElse`]: MaybeSender::SomeoneElse + #[must_use] + pub fn is_myself_check(&self, my_user_id: UserID) -> bool { + match self { + Self::Myself => true, + Self::SomeoneElse(id) if (*id == my_user_id) => true, + _ => false, + } + } + + /// Returns `true` if the maybe sender is [`SomeoneElse`]. + /// + /// [`SomeoneElse`]: MaybeSender::SomeoneElse + #[must_use] + pub fn is_someone_else(&self) -> bool { + matches!(self, Self::SomeoneElse(..)) + } + + /// Returns `true` if the maybe sender is [`Unknown`]. + /// + /// [`Unknown`]: MaybeSender::Unknown + #[must_use] + pub fn is_unknown(&self) -> bool { + matches!(self, Self::Unknown) + } + + /// Returns the sender as [`UserID`] if it is knwon. + #[must_use] + pub fn as_user_id(&self) -> Option { + match self { + Self::Myself => None, + Self::SomeoneElse(id) => Some(*id), + Self::Unknown => None, + } + } +} + +#[derive(Debug, Default, Serialize, Deserialize)] +pub enum MaybeReceiver { + /// The message is broadcasted to everyone + Broadcast, + /// The message is sent to a specific party + P2P(UserID), + /// The receiver is us. + Myself, + /// The receiver is unknown. + #[default] + Unknown, +} + +impl MaybeReceiver { + /// Returns `true` if the maybe receiver is [`Broadcast`]. + /// + /// [`Broadcast`]: MaybeReceiver::Broadcast + #[must_use] + pub fn is_broadcast(&self) -> bool { + matches!(self, Self::Broadcast) + } + + /// Returns `true` if the maybe receiver is [`P2P`]. + /// + /// [`P2P`]: MaybeReceiver::P2P + #[must_use] + pub fn is_p2_p(&self) -> bool { + matches!(self, Self::P2P(..)) + } + + /// Returns `true` if the maybe receiver is [`Myself`]. + /// + /// [`Myself`]: MaybeReceiver::Myself + #[must_use] + pub fn is_myself(&self) -> bool { + matches!(self, Self::Myself) + } + + /// Returns `true` if the maybe receiver is [`Myself`] + /// Or if the receiver is [`P2P`] but the [`UserID`] is the same as `my_user_id` + /// + /// [`Myself`]: MaybeReceiver::Myself + /// [`P2P`]: MaybeReceiver::P2P + #[must_use] + pub fn is_myself_check(&self, my_user_id: UserID) -> bool { + match self { + Self::Myself => true, + Self::P2P(id) if (*id == my_user_id) => true, + _ => false, + } + } + + /// Returns `true` if the maybe receiver is [`Unknown`]. + /// + /// [`Unknown`]: MaybeReceiver::Unknown + #[must_use] + pub fn is_unknown(&self) -> bool { + matches!(self, Self::Unknown) + } + + /// Returns the receiver as [`UserID`] if it is knwon. + #[must_use] + pub fn as_user_id(&self) -> Option { + match self { + Self::Broadcast => None, + Self::P2P(id) => Some(*id), + Self::Myself => None, + Self::Unknown => None, + } + } +} + +pub trait InnerMessage { + type Inner: Serialize + DeserializeOwned + Send + 'static; + fn inner_message(self) -> Self::Inner; +} + +pub trait InnerMessageFromInbound: Sized + InnerMessage { + fn from_inbound( + id: MsgId, + sender: PartyIndex, + msg_type: MessageType, + msg: ::Inner, + ) -> Self; +} + +impl InnerMessage for Outgoing { + type Inner = M; + + fn inner_message(self) -> Self::Inner { + self.msg + } +} + +impl InnerMessage for Incoming { + type Inner = M; + + fn inner_message(self) -> Self::Inner { + self.msg + } +} + +/// A Simple trait to extract the sender and the receiver from a message +pub trait MaybeSenderReceiver { + fn maybe_sender(&self) -> MaybeSender; + fn maybe_receiver(&self) -> MaybeReceiver; +} + +impl MaybeSenderReceiver for PublicKeyGossipMessage { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::SomeoneElse(self.from) + } + fn maybe_receiver(&self) -> MaybeReceiver { + match self.to { + Some(id) => MaybeReceiver::P2P(id), + None => MaybeReceiver::Broadcast, + } + } +} + +impl MaybeSenderReceiver for VotingMessage { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::SomeoneElse(self.from) + } + fn maybe_receiver(&self) -> MaybeReceiver { + match self.to { + Some(id) => MaybeReceiver::P2P(id), + None => MaybeReceiver::Broadcast, + } + } +} + +impl MaybeSenderReceiver for Outgoing { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::Myself + } + + fn maybe_receiver(&self) -> MaybeReceiver { + match self.recipient { + MessageDestination::AllParties => MaybeReceiver::Broadcast, + MessageDestination::OneParty(i) => MaybeReceiver::P2P(i as UserID), + } + } +} + +impl MaybeSenderReceiver for Incoming { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::SomeoneElse(self.sender as UserID) + } + + fn maybe_receiver(&self) -> MaybeReceiver { + match self.msg_type { + MessageType::Broadcast => MaybeReceiver::Broadcast, + MessageType::P2P => MaybeReceiver::Myself, + } + } +} + +impl InnerMessageFromInbound for Incoming { + fn from_inbound( + id: MsgId, + sender: PartyIndex, + msg_type: MessageType, + msg: ::Inner, + ) -> Self { + Incoming { + id, + sender, + msg_type, + msg, + } + } +} + +impl MaybeSenderReceiver for () { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::Unknown + } + + fn maybe_receiver(&self) -> MaybeReceiver { + MaybeReceiver::Unknown + } +} + +pub fn create_job_manager_to_async_protocol_channel_split_io< + N: Network + 'static, + C2: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, + O: InnerMessage + MaybeSenderReceiver + Send + 'static, + I: InnerMessage + InnerMessageFromInbound + MaybeSenderReceiver + Send + 'static, +>( + mut rx_gadget: CloneableUnboundedReceiver, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + user_id_mapping: Arc>, + my_account_id: AccountId, + network: N, +) -> ( + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver>, + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver, +) { + let (tx_to_async_proto_1, rx_for_async_proto_1) = futures::channel::mpsc::unbounded(); + let (tx_to_async_proto_2, rx_for_async_proto_2) = futures::channel::mpsc::unbounded(); + + // Take the messages from the gadget and send them to the async protocol + tokio::task::spawn(async move { + let mut id = 0; + while let Some(msg_orig) = rx_gadget.next().await { + if msg_orig.payload.is_empty() { + log::warn!(target: "gadget", "Received empty message from Peer {}", msg_orig.from); + continue; + } + match bincode2::deserialize::>(&msg_orig.payload) { + Ok(msg) => match msg { + SplitChannelMessage::Channel1(msg) => { + let msg_type = if msg_orig.to.is_some() { + MessageType::P2P + } else { + MessageType::Broadcast + }; + + let incoming = + I::from_inbound(id, msg_orig.from as PartyIndex, msg_type, msg); + + if tx_to_async_proto_1.unbounded_send(Ok(incoming)).is_err() { + log::error!(target: "gadget", "Failed to send Incoming message to protocol"); + } + + id += 1; + } + SplitChannelMessage::Channel2(msg) => { + if tx_to_async_proto_2.unbounded_send(msg).is_err() { + log::error!(target: "gadget", "Failed to send C2 message to protocol"); + } + } + }, + Err(err) => { + log::error!(target: "gadget", "Failed to deserialize message: {err:?}"); + } + } + } + }); + + let (tx_to_outbound_1, mut rx_to_outbound_1) = futures::channel::mpsc::unbounded::(); + let (tx_to_outbound_2, mut rx_to_outbound_2) = futures::channel::mpsc::unbounded::(); + let network_clone = network.clone(); + let user_id_mapping_clone = user_id_mapping.clone(); + let my_user_id = user_id_mapping + .iter() + .find_map(|(user_id, account_id)| { + if *account_id == my_account_id { + Some(*user_id) + } else { + None + } + }) + .expect("Failed to find my user id"); + // Take the messages from the async protocol and send them to the gadget + tokio::task::spawn(async move { + let offline_task = async move { + while let Some(msg) = rx_to_outbound_1.next().await { + let from = msg.maybe_sender(); + let to = msg.maybe_receiver(); + let (to_account_id, from_account_id) = get_to_and_from_account_id( + &user_id_mapping_clone, + from.as_user_id().unwrap_or(my_user_id), + to.as_user_id(), + ); + let msg = SplitChannelMessage::::Channel1(msg.inner_message()); + let msg = GadgetProtocolMessage { + associated_block_id, + associated_session_id, + associated_retry_id, + task_hash: associated_task_id, + from: from.as_user_id().unwrap_or(my_user_id), + to: to.as_user_id(), + payload: bincode2::serialize(&msg).expect("Failed to serialize message"), + from_network_id: from_account_id, + to_network_id: to_account_id, + }; + + if let Err(err) = network.send_message(msg).await { + log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + } + } + }; + + let voting_task = async move { + while let Some(msg) = rx_to_outbound_2.next().await { + let from = msg.maybe_sender(); + let to = msg.maybe_receiver(); + let (to_account_id, from_account_id) = get_to_and_from_account_id( + &user_id_mapping, + from.as_user_id().unwrap_or(my_user_id), + to.as_user_id(), + ); + let msg = SplitChannelMessage::::Channel2(msg); + let msg = GadgetProtocolMessage { + associated_block_id, + associated_session_id, + associated_retry_id, + task_hash: associated_task_id, + from: from.as_user_id().unwrap_or(my_user_id), + to: to.as_user_id(), + payload: bincode2::serialize(&msg).expect("Failed to serialize message"), + from_network_id: from_account_id, + to_network_id: to_account_id, + }; + + if let Err(err) = network_clone.send_message(msg).await { + log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + } + } + }; + + tokio::join!(offline_task, voting_task); + }); + + ( + tx_to_outbound_1, + rx_for_async_proto_1, + tx_to_outbound_2, + rx_for_async_proto_2, + ) +} diff --git a/protocols/dfns-cggmp21/Cargo.toml b/protocols/dfns-cggmp21/Cargo.toml index b8f31558c..f91a3c865 100644 --- a/protocols/dfns-cggmp21/Cargo.toml +++ b/protocols/dfns-cggmp21/Cargo.toml @@ -11,6 +11,7 @@ protocol-macros = { workspace = true } async-trait = { workspace = true } log = { workspace = true } dfns-cggmp21 = { workspace = true, features = ["all-curves"] } +round-based-21 = { workspace = true } curv = { workspace = true } futures = { workspace = true } itertools = { workspace = true } diff --git a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs index 57a572c86..4c1fa27cc 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs @@ -1,3 +1,5 @@ +use dfns_cggmp21::key_refresh::msg::aux_only; +use dfns_cggmp21::security_level::SecurityLevel128; use dfns_cggmp21::supported_curves::Secp256k1; use dfns_cggmp21::KeyShare; use gadget_common::client::{AccountId, ClientWithApi, JobsApiForGadget}; @@ -12,7 +14,9 @@ use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use rand::SeedableRng; +use round_based_21::{Incoming, Outgoing}; use sc_client_api::Backend; +use sha2::Sha256; use sp_api::ProvideRuntimeApi; use sp_application_crypto::sp_core::keccak_256; use std::collections::HashMap; @@ -157,7 +161,12 @@ where key_refresh_rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::<_, (), _>( + ) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< + _, + (), + Outgoing>, + Incoming>, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -170,7 +179,7 @@ where let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let delivery = (key_refresh_rx_async_proto, key_refresh_tx_to_outbound); - let party = dfns_cggmp21::round_based::MpcParty::connected(delivery); + let party = round_based_21::MpcParty::connected(delivery); let aux_info = dfns_cggmp21::aux_info_gen(eid, i, n, pregenerated_primes) .set_progress_tracer(&mut tracer) .start(&mut rng, party) diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index c24a9bd2f..3e68b7a83 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -1,3 +1,4 @@ +use dfns_cggmp21::signing::msg::Msg; use dfns_cggmp21::supported_curves::Secp256k1; use dfns_cggmp21::KeyShare; use gadget_common::client::{AccountId, ClientWithApi, JobsApiForGadget}; @@ -12,7 +13,9 @@ use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use rand::SeedableRng; +use round_based_21::{Incoming, Outgoing}; use sc_client_api::Backend; +use sha2::Sha256; use sp_api::ProvideRuntimeApi; use sp_core::keccak_256; use std::collections::HashMap; @@ -173,7 +176,12 @@ where key_rotate_rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::<_, (), _>( + ) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< + _, + (), + Outgoing>, + Incoming>, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -185,7 +193,7 @@ where ); let delivery = (key_rotate_rx_async_proto, key_rotate_tx_to_outbound); - let party = dfns_cggmp21::round_based::MpcParty::connected(delivery); + let party = round_based_21::MpcParty::connected(delivery); let data_hash = keccak_256(&new_key); let data_to_sign = dfns_cggmp21::DataToSign::from_scalar( dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(data_hash), diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index a320bc818..f6fb458b6 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -3,7 +3,6 @@ use dfns_cggmp21::key_refresh::msg::aux_only; use dfns_cggmp21::keygen::msg::threshold; use dfns_cggmp21::keygen::msg::threshold::Msg; use dfns_cggmp21::keygen::ThresholdMsg; -use dfns_cggmp21::round_based::{Delivery, Incoming, MpcParty, Outgoing}; use dfns_cggmp21::security_level::SecurityLevel128; use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; use futures::channel::mpsc::{TryRecvError, UnboundedSender}; @@ -28,6 +27,7 @@ use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; use pallet_dkg::signatures_schemes::to_slice_33; use rand::rngs::{OsRng, StdRng}; use rand::SeedableRng; +use round_based_21::{Delivery, Incoming, MpcParty, Outgoing}; use sc_client_api::Backend; use sha2::Sha256; use sp_api::ProvideRuntimeApi; @@ -41,7 +41,7 @@ use tangle_primitives::jobs::{ use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; -use super::util::PublicKeyGossipMessage; +use gadget_common::channels::PublicKeyGossipMessage; pub async fn create_next_job< B: Block, @@ -248,10 +248,11 @@ where keygen_rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::< + ) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< _, (), - threshold::Msg, + Outgoing>, + Incoming>, >( protocol_message_channel, associated_block_id, @@ -380,10 +381,11 @@ where keyrefresh_rx_async_proto, broadcast_tx_to_outbound, broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::< + ) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< _, PublicKeyGossipMessage, - aux_only::Msg, + Outgoing>, + Incoming>, >( protocol_message_channel, associated_block_id, diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index a46eb3e03..770d99aed 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -1,3 +1,4 @@ +use dfns_cggmp21::signing::msg::Msg; use dfns_cggmp21::supported_curves::Secp256k1; use dfns_cggmp21::KeyShare; use gadget_common::client::{AccountId, ClientWithApi, JobsApiForGadget}; @@ -11,7 +12,9 @@ use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use rand::SeedableRng; +use round_based_21::{Incoming, Outgoing}; use sc_client_api::Backend; +use sha2::Sha256; use sp_api::ProvideRuntimeApi; use sp_core::keccak_256; use std::collections::HashMap; @@ -148,7 +151,12 @@ where signing_rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::<_, (), _>( + ) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< + _, + (), + Outgoing>, + Incoming>, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -161,7 +169,7 @@ where let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let delivery = (signing_rx_async_proto, signing_tx_to_outbound); - let party = dfns_cggmp21::round_based::MpcParty::connected(delivery); + let party = round_based_21::MpcParty::connected(delivery); let data_hash = keccak_256(&input_data_to_sign); let data_to_sign = dfns_cggmp21::DataToSign::from_scalar( dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(data_hash), diff --git a/protocols/dfns-cggmp21/src/protocols/util.rs b/protocols/dfns-cggmp21/src/protocols/util.rs index 100793dad..fb9ce53e0 100644 --- a/protocols/dfns-cggmp21/src/protocols/util.rs +++ b/protocols/dfns-cggmp21/src/protocols/util.rs @@ -1,408 +1,8 @@ -#![allow(clippy::type_complexity, clippy::too_many_arguments)] -//! When delivering messages to an async protocol, we want to make sure we don't mix up voting and public key gossip messages -//! Thus, this file contains a function that takes a channel from the gadget to the async protocol and splits it into two channels -use dfns_cggmp21::round_based::{Incoming, MessageDestination, MessageType, Outgoing, PartyIndex}; -use futures::StreamExt; -use gadget_common::client::AccountId; -use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; -use gadget_common::gadget::network::Network; -use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::utils::CloneableUnboundedReceiver; -use gadget_core::job_manager::WorkManagerInterface; -use rand::seq::SliceRandom; -use serde::de::DeserializeOwned; -use serde::{Deserialize, Serialize}; +use gadget_common::gadget::message::UserID; +use gadget_common::prelude::AccountId; +use rand::prelude::SliceRandom; use std::collections::HashMap; -use std::sync::Arc; - -#[derive(Serialize, Deserialize, Debug)] -pub enum SplitChannelMessage { - Channel1(C1), - Channel2(C2), -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct VotingMessage { - pub from: UserID, - pub to: Option, - pub payload: Vec, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct PublicKeyGossipMessage { - pub from: UserID, - pub to: Option, - pub signature: Vec, - pub id: AccountId, -} - -/// All possible senders of a message -#[derive(Debug, Default, Serialize, Deserialize)] -pub enum MaybeSender { - /// We are the sender of the message - Myself, - /// The sender is someone else - /// it could also be us, double check the [`UserID`] - SomeoneElse(UserID), - /// The sender is unknown. - #[default] - Unknown, -} - -impl MaybeSender { - /// Returns `true` if the maybe sender is [`Myself`]. - /// - /// [`Myself`]: MaybeSender::Myself - #[must_use] - pub fn is_myself(&self) -> bool { - matches!(self, Self::Myself) - } - - /// Returns `true` if the maybe sender is [`Myself`]. - /// Or if the sender is [`SomeoneElse`] but the [`UserID`] is the same as `my_user_id` - /// - /// [`Myself`]: MaybeSender::Myself - /// [`SomeoneElse`]: MaybeSender::SomeoneElse - #[must_use] - pub fn is_myself_check(&self, my_user_id: UserID) -> bool { - match self { - Self::Myself => true, - Self::SomeoneElse(id) if (*id == my_user_id) => true, - _ => false, - } - } - - /// Returns `true` if the maybe sender is [`SomeoneElse`]. - /// - /// [`SomeoneElse`]: MaybeSender::SomeoneElse - #[must_use] - pub fn is_someone_else(&self) -> bool { - matches!(self, Self::SomeoneElse(..)) - } - - /// Returns `true` if the maybe sender is [`Unknown`]. - /// - /// [`Unknown`]: MaybeSender::Unknown - #[must_use] - pub fn is_unknown(&self) -> bool { - matches!(self, Self::Unknown) - } - - /// Returns the sender as [`UserID`] if it is knwon. - #[must_use] - pub fn as_user_id(&self) -> Option { - match self { - Self::Myself => None, - Self::SomeoneElse(id) => Some(*id), - Self::Unknown => None, - } - } -} - -#[derive(Debug, Default, Serialize, Deserialize)] -pub enum MaybeReceiver { - /// The message is broadcasted to everyone - Broadcast, - /// The message is sent to a specific party - P2P(UserID), - /// The receiver is us. - Myself, - /// The receiver is unknown. - #[default] - Unknown, -} - -impl MaybeReceiver { - /// Returns `true` if the maybe receiver is [`Broadcast`]. - /// - /// [`Broadcast`]: MaybeReceiver::Broadcast - #[must_use] - pub fn is_broadcast(&self) -> bool { - matches!(self, Self::Broadcast) - } - - /// Returns `true` if the maybe receiver is [`P2P`]. - /// - /// [`P2P`]: MaybeReceiver::P2P - #[must_use] - pub fn is_p2_p(&self) -> bool { - matches!(self, Self::P2P(..)) - } - - /// Returns `true` if the maybe receiver is [`Myself`]. - /// - /// [`Myself`]: MaybeReceiver::Myself - #[must_use] - pub fn is_myself(&self) -> bool { - matches!(self, Self::Myself) - } - - /// Returns `true` if the maybe receiver is [`Myself`] - /// Or if the receiver is [`P2P`] but the [`UserID`] is the same as `my_user_id` - /// - /// [`Myself`]: MaybeReceiver::Myself - /// [`P2P`]: MaybeReceiver::P2P - #[must_use] - pub fn is_myself_check(&self, my_user_id: UserID) -> bool { - match self { - Self::Myself => true, - Self::P2P(id) if (*id == my_user_id) => true, - _ => false, - } - } - - /// Returns `true` if the maybe receiver is [`Unknown`]. - /// - /// [`Unknown`]: MaybeReceiver::Unknown - #[must_use] - pub fn is_unknown(&self) -> bool { - matches!(self, Self::Unknown) - } - - /// Returns the receiver as [`UserID`] if it is knwon. - #[must_use] - pub fn as_user_id(&self) -> Option { - match self { - Self::Broadcast => None, - Self::P2P(id) => Some(*id), - Self::Myself => None, - Self::Unknown => None, - } - } -} - -/// A Simple trait to extract the sender and the receiver from a message -pub trait MaybeSenderReceiver { - fn maybe_sender(&self) -> MaybeSender; - fn maybe_receiver(&self) -> MaybeReceiver; -} - -impl MaybeSenderReceiver for PublicKeyGossipMessage { - fn maybe_sender(&self) -> MaybeSender { - MaybeSender::SomeoneElse(self.from) - } - fn maybe_receiver(&self) -> MaybeReceiver { - match self.to { - Some(id) => MaybeReceiver::P2P(id), - None => MaybeReceiver::Broadcast, - } - } -} - -impl MaybeSenderReceiver for VotingMessage { - fn maybe_sender(&self) -> MaybeSender { - MaybeSender::SomeoneElse(self.from) - } - fn maybe_receiver(&self) -> MaybeReceiver { - match self.to { - Some(id) => MaybeReceiver::P2P(id), - None => MaybeReceiver::Broadcast, - } - } -} - -impl MaybeSenderReceiver for Outgoing { - fn maybe_sender(&self) -> MaybeSender { - MaybeSender::Myself - } - - fn maybe_receiver(&self) -> MaybeReceiver { - match self.recipient { - MessageDestination::AllParties => MaybeReceiver::Broadcast, - MessageDestination::OneParty(i) => MaybeReceiver::P2P(i as UserID), - } - } -} - -impl MaybeSenderReceiver for Incoming { - fn maybe_sender(&self) -> MaybeSender { - MaybeSender::SomeoneElse(self.sender as UserID) - } - - fn maybe_receiver(&self) -> MaybeReceiver { - match self.msg_type { - MessageType::Broadcast => MaybeReceiver::Broadcast, - MessageType::P2P => MaybeReceiver::Myself, - } - } -} - -impl MaybeSenderReceiver for () { - fn maybe_sender(&self) -> MaybeSender { - MaybeSender::Unknown - } - - fn maybe_receiver(&self) -> MaybeReceiver { - MaybeReceiver::Unknown - } -} - -pub(crate) fn create_job_manager_to_async_protocol_channel_split_futures< - N: Network + 'static, - C2: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, - M: Serialize + DeserializeOwned + Send + 'static, ->( - mut rx_gadget: CloneableUnboundedReceiver, - associated_block_id: ::Clock, - associated_retry_id: ::RetryID, - associated_session_id: ::SessionID, - associated_task_id: ::TaskID, - user_id_mapping: Arc>, - my_account_id: AccountId, - network: N, -) -> ( - futures::channel::mpsc::UnboundedSender>, - futures::channel::mpsc::UnboundedReceiver< - Result, futures::channel::mpsc::TryRecvError>, - >, - futures::channel::mpsc::UnboundedSender, - futures::channel::mpsc::UnboundedReceiver, -) { - let (tx_to_async_proto_1, rx_for_async_proto_1) = futures::channel::mpsc::unbounded(); - let (tx_to_async_proto_2, rx_for_async_proto_2) = futures::channel::mpsc::unbounded(); - - // Take the messages from the gadget and send them to the async protocol - tokio::task::spawn(async move { - let mut id = 0; - while let Some(msg_orig) = rx_gadget.next().await { - if msg_orig.payload.is_empty() { - log::warn!(target: "gadget", "Received empty message from Peer {}", msg_orig.from); - continue; - } - match bincode2::deserialize::>(&msg_orig.payload) { - Ok(msg) => match msg { - SplitChannelMessage::Channel1(msg) => { - let msg_type = if msg_orig.to.is_some() { - MessageType::P2P - } else { - MessageType::Broadcast - }; - let incoming = Incoming { - id, - sender: msg_orig.from as PartyIndex, - msg_type, - msg, - }; - - if tx_to_async_proto_1.unbounded_send(Ok(incoming)).is_err() { - log::error!(target: "gadget", "Failed to send Incoming message to protocol"); - } - - id += 1; - } - SplitChannelMessage::Channel2(msg) => { - if tx_to_async_proto_2.unbounded_send(msg).is_err() { - log::error!(target: "gadget", "Failed to send C2 message to protocol"); - } - } - }, - Err(err) => { - log::error!(target: "gadget", "Failed to deserialize message: {err:?}"); - } - } - } - }); - - let (tx_to_outbound_1, mut rx_to_outbound_1) = - futures::channel::mpsc::unbounded::>(); - let (tx_to_outbound_2, mut rx_to_outbound_2) = futures::channel::mpsc::unbounded::(); - let network_clone = network.clone(); - let user_id_mapping_clone = user_id_mapping.clone(); - let my_user_id = user_id_mapping - .iter() - .find_map(|(user_id, account_id)| { - if *account_id == my_account_id { - Some(*user_id) - } else { - None - } - }) - .expect("Failed to find my user id"); - // Take the messages from the async protocol and send them to the gadget - tokio::task::spawn(async move { - let offline_task = async move { - while let Some(msg) = rx_to_outbound_1.next().await { - let from = msg.maybe_sender(); - let to = msg.maybe_receiver(); - let (to_account_id, from_account_id) = get_to_and_from_account_id( - &user_id_mapping_clone, - from.as_user_id().unwrap_or(my_user_id), - to.as_user_id(), - ); - let msg = SplitChannelMessage::::Channel1(msg.msg); - let msg = GadgetProtocolMessage { - associated_block_id, - associated_session_id, - associated_retry_id, - task_hash: associated_task_id, - from: from.as_user_id().unwrap_or(my_user_id), - to: to.as_user_id(), - payload: bincode2::serialize(&msg).expect("Failed to serialize message"), - from_network_id: from_account_id, - to_network_id: to_account_id, - }; - - if let Err(err) = network.send_message(msg).await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); - } - } - }; - - let voting_task = async move { - while let Some(msg) = rx_to_outbound_2.next().await { - let from = msg.maybe_sender(); - let to = msg.maybe_receiver(); - let (to_account_id, from_account_id) = get_to_and_from_account_id( - &user_id_mapping, - from.as_user_id().unwrap_or(my_user_id), - to.as_user_id(), - ); - let msg = SplitChannelMessage::::Channel2(msg); - let msg = GadgetProtocolMessage { - associated_block_id, - associated_session_id, - associated_retry_id, - task_hash: associated_task_id, - from: from.as_user_id().unwrap_or(my_user_id), - to: to.as_user_id(), - payload: bincode2::serialize(&msg).expect("Failed to serialize message"), - from_network_id: from_account_id, - to_network_id: to_account_id, - }; - - if let Err(err) = network_clone.send_message(msg).await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); - } - } - }; - - tokio::join!(offline_task, voting_task); - }); - - ( - tx_to_outbound_1, - rx_for_async_proto_1, - tx_to_outbound_2, - rx_for_async_proto_2, - ) -} - -fn get_to_and_from_account_id( - mapping: &HashMap, - from: UserID, - to: Option, -) -> (Option, Option) { - let from_account_id = mapping.get(&from).cloned(); - let to_account_id = if let Some(to) = to { - mapping.get(&to).cloned() - } else { - None - }; - - (to_account_id, from_account_id) -} - /// Given a list of participants, choose `t` of them and return the index of the current participant /// and the indices of the chosen participants, as well as a mapping from the index to the account /// id. diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml index 23bcfc860..b2bd6e772 100644 --- a/protocols/zcash-frost/Cargo.toml +++ b/protocols/zcash-frost/Cargo.toml @@ -15,7 +15,7 @@ curv = { workspace = true } futures = { workspace = true } itertools = { workspace = true } bincode2 = { workspace = true } -round-based = { git = "https://github.com/ZenGo-X/round-based-protocol", features = ["derive"]} +round-based-21 = { workspace = true, features = ["derive"]} digest = { workspace = true } sha2 = "0.10" rand_core = "0.6" diff --git a/protocols/zcash-frost/src/protocol/keygen.rs b/protocols/zcash-frost/src/protocol/keygen.rs index 25f846230..fd93f8f57 100644 --- a/protocols/zcash-frost/src/protocol/keygen.rs +++ b/protocols/zcash-frost/src/protocol/keygen.rs @@ -15,13 +15,14 @@ use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; -use gadget_common::Block; +use gadget_common::{channels, Block}; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use itertools::Itertools; use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; use pallet_dkg::signatures_schemes::to_slice_33; use rand::SeedableRng; +use round_based_21::{Incoming, Outgoing}; use sc_client_api::Backend; use sp_application_crypto::sp_core::keccak_256; use sp_core::{ecdsa, Pair}; @@ -32,8 +33,9 @@ use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; use crate::rounds; +use crate::rounds::keygen::Msg; -use super::util::PublicKeyGossipMessage; +use gadget_common::channels::PublicKeyGossipMessage; #[derive(Clone)] pub struct ZcashFrostKeygenExtraParams { @@ -171,7 +173,12 @@ where keygen_rx_async_proto, broadcast_tx_to_outbound, broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split_futures( + ) = channels::create_job_manager_to_async_protocol_channel_split_io::< + _, + _, + Outgoing, + Incoming, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -183,7 +190,7 @@ where ); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); - let party = round_based::MpcParty::connected(delivery); + let party = round_based_21::MpcParty::connected(delivery); let frost_key_share_package = match role { ThresholdSignatureRoleType::ZcashFrostEd25519 => { run_threshold_keygen!( diff --git a/protocols/zcash-frost/src/protocol/sign.rs b/protocols/zcash-frost/src/protocol/sign.rs index 8338ac75d..ffbb71ca5 100644 --- a/protocols/zcash-frost/src/protocol/sign.rs +++ b/protocols/zcash-frost/src/protocol/sign.rs @@ -15,11 +15,11 @@ use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; -use gadget_common::Block; +use gadget_common::{channels, Block}; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use rand::SeedableRng; -use round_based::MpcParty; +use round_based_21::{Incoming, MpcParty, Outgoing}; use sc_client_api::Backend; use sp_core::keccak_256; use std::collections::HashMap; @@ -30,6 +30,7 @@ use tokio::sync::mpsc::UnboundedReceiver; use crate::rounds; use crate::rounds::keygen::FrostKeyShare; +use crate::rounds::sign::Msg; #[derive(Clone)] pub struct ZcashFrostSigningExtraParams { @@ -193,7 +194,12 @@ where signing_rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget, - ) = super::util::create_job_manager_to_async_protocol_channel_split_futures::<_, (), _>( + ) = channels::create_job_manager_to_async_protocol_channel_split_io::< + _, + (), + Outgoing, + Incoming, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, diff --git a/protocols/zcash-frost/src/protocol/util.rs b/protocols/zcash-frost/src/protocol/util.rs index e5dfdae0d..323356bfc 100644 --- a/protocols/zcash-frost/src/protocol/util.rs +++ b/protocols/zcash-frost/src/protocol/util.rs @@ -1,406 +1,10 @@ #![allow(clippy::type_complexity, clippy::too_many_arguments)] //! When delivering messages to an async protocol, we want to make sure we don't mix up voting and public key gossip messages //! Thus, this file contains a function that takes a channel from the gadget to the async protocol and splits it into two channels -use futures::StreamExt; use gadget_common::client::AccountId; -use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; -use gadget_common::gadget::network::Network; -use gadget_common::gadget::work_manager::WorkManager; -use gadget_common::utils::CloneableUnboundedReceiver; -use gadget_core::job_manager::WorkManagerInterface; +use gadget_common::gadget::message::UserID; use rand::seq::SliceRandom; -use round_based::{Incoming, MessageDestination, MessageType, Outgoing, PartyIndex}; -use serde::de::DeserializeOwned; -use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use std::sync::Arc; - -#[derive(Serialize, Deserialize, Debug)] -pub enum SplitChannelMessage { - Channel1(C1), - Channel2(C2), -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct VotingMessage { - pub from: UserID, - pub to: Option, - pub payload: Vec, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct PublicKeyGossipMessage { - pub from: UserID, - pub to: Option, - pub signature: Vec, - pub id: AccountId, -} - -/// All possible senders of a message -#[derive(Debug, Default, Serialize, Deserialize)] -pub enum MaybeSender { - /// We are the sender of the message - Myself, - /// The sender is someone else - /// it could also be us, double check the [`UserID`] - SomeoneElse(UserID), - /// The sender is unknown. - #[default] - Unknown, -} - -impl MaybeSender { - /// Returns `true` if the maybe sender is [`Myself`]. - /// - /// [`Myself`]: MaybeSender::Myself - #[must_use] - pub fn is_myself(&self) -> bool { - matches!(self, Self::Myself) - } - - /// Returns `true` if the maybe sender is [`Myself`]. - /// Or if the sender is [`SomeoneElse`] but the [`UserID`] is the same as `my_user_id` - /// - /// [`Myself`]: MaybeSender::Myself - /// [`SomeoneElse`]: MaybeSender::SomeoneElse - #[must_use] - pub fn is_myself_check(&self, my_user_id: UserID) -> bool { - match self { - Self::Myself => true, - Self::SomeoneElse(id) if (*id == my_user_id) => true, - _ => false, - } - } - - /// Returns `true` if the maybe sender is [`SomeoneElse`]. - /// - /// [`SomeoneElse`]: MaybeSender::SomeoneElse - #[must_use] - pub fn is_someone_else(&self) -> bool { - matches!(self, Self::SomeoneElse(..)) - } - - /// Returns `true` if the maybe sender is [`Unknown`]. - /// - /// [`Unknown`]: MaybeSender::Unknown - #[must_use] - pub fn is_unknown(&self) -> bool { - matches!(self, Self::Unknown) - } - - /// Returns the sender as [`UserID`] if it is knwon. - #[must_use] - pub fn as_user_id(&self) -> Option { - match self { - Self::Myself => None, - Self::SomeoneElse(id) => Some(*id), - Self::Unknown => None, - } - } -} - -#[derive(Debug, Default, Serialize, Deserialize)] -pub enum MaybeReceiver { - /// The message is broadcasted to everyone - Broadcast, - /// The message is sent to a specific party - P2P(UserID), - /// The receiver is us. - Myself, - /// The receiver is unknown. - #[default] - Unknown, -} - -impl MaybeReceiver { - /// Returns `true` if the maybe receiver is [`Broadcast`]. - /// - /// [`Broadcast`]: MaybeReceiver::Broadcast - #[must_use] - pub fn is_broadcast(&self) -> bool { - matches!(self, Self::Broadcast) - } - - /// Returns `true` if the maybe receiver is [`P2P`]. - /// - /// [`P2P`]: MaybeReceiver::P2P - #[must_use] - pub fn is_p2_p(&self) -> bool { - matches!(self, Self::P2P(..)) - } - - /// Returns `true` if the maybe receiver is [`Myself`]. - /// - /// [`Myself`]: MaybeReceiver::Myself - #[must_use] - pub fn is_myself(&self) -> bool { - matches!(self, Self::Myself) - } - - /// Returns `true` if the maybe receiver is [`Myself`] - /// Or if the receiver is [`P2P`] but the [`UserID`] is the same as `my_user_id` - /// - /// [`Myself`]: MaybeReceiver::Myself - /// [`P2P`]: MaybeReceiver::P2P - #[must_use] - pub fn is_myself_check(&self, my_user_id: UserID) -> bool { - match self { - Self::Myself => true, - Self::P2P(id) if (*id == my_user_id) => true, - _ => false, - } - } - - /// Returns `true` if the maybe receiver is [`Unknown`]. - /// - /// [`Unknown`]: MaybeReceiver::Unknown - #[must_use] - pub fn is_unknown(&self) -> bool { - matches!(self, Self::Unknown) - } - - /// Returns the receiver as [`UserID`] if it is knwon. - #[must_use] - pub fn as_user_id(&self) -> Option { - match self { - Self::Broadcast => None, - Self::P2P(id) => Some(*id), - Self::Myself => None, - Self::Unknown => None, - } - } -} - -/// A Simple trait to extract the sender and the receiver from a message -pub trait MaybeSenderReceiver { - fn maybe_sender(&self) -> MaybeSender; - fn maybe_receiver(&self) -> MaybeReceiver; -} - -impl MaybeSenderReceiver for PublicKeyGossipMessage { - fn maybe_sender(&self) -> MaybeSender { - MaybeSender::SomeoneElse(self.from) - } - fn maybe_receiver(&self) -> MaybeReceiver { - match self.to { - Some(id) => MaybeReceiver::P2P(id), - None => MaybeReceiver::Broadcast, - } - } -} - -impl MaybeSenderReceiver for VotingMessage { - fn maybe_sender(&self) -> MaybeSender { - MaybeSender::SomeoneElse(self.from) - } - fn maybe_receiver(&self) -> MaybeReceiver { - match self.to { - Some(id) => MaybeReceiver::P2P(id), - None => MaybeReceiver::Broadcast, - } - } -} - -impl MaybeSenderReceiver for Outgoing { - fn maybe_sender(&self) -> MaybeSender { - MaybeSender::Myself - } - - fn maybe_receiver(&self) -> MaybeReceiver { - match self.recipient { - MessageDestination::AllParties => MaybeReceiver::Broadcast, - MessageDestination::OneParty(i) => MaybeReceiver::P2P(i as UserID), - } - } -} - -impl MaybeSenderReceiver for Incoming { - fn maybe_sender(&self) -> MaybeSender { - MaybeSender::SomeoneElse(self.sender as UserID) - } - - fn maybe_receiver(&self) -> MaybeReceiver { - match self.msg_type { - MessageType::Broadcast => MaybeReceiver::Broadcast, - MessageType::P2P => MaybeReceiver::Myself, - } - } -} - -impl MaybeSenderReceiver for () { - fn maybe_sender(&self) -> MaybeSender { - MaybeSender::Unknown - } - - fn maybe_receiver(&self) -> MaybeReceiver { - MaybeReceiver::Unknown - } -} - -pub(crate) fn create_job_manager_to_async_protocol_channel_split_futures< - N: Network + 'static, - C2: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, - M: Serialize + DeserializeOwned + Send + 'static, ->( - mut rx_gadget: CloneableUnboundedReceiver, - associated_block_id: ::Clock, - associated_retry_id: ::RetryID, - associated_session_id: ::SessionID, - associated_task_id: ::TaskID, - user_id_mapping: Arc>, - my_account_id: AccountId, - network: N, -) -> ( - futures::channel::mpsc::UnboundedSender>, - futures::channel::mpsc::UnboundedReceiver< - Result, futures::channel::mpsc::TryRecvError>, - >, - futures::channel::mpsc::UnboundedSender, - futures::channel::mpsc::UnboundedReceiver, -) { - let (tx_to_async_proto_1, rx_for_async_proto_1) = futures::channel::mpsc::unbounded(); - let (tx_to_async_proto_2, rx_for_async_proto_2) = futures::channel::mpsc::unbounded(); - - // Take the messages from the gadget and send them to the async protocol - tokio::task::spawn(async move { - let mut id = 0; - while let Some(msg_orig) = rx_gadget.next().await { - if msg_orig.payload.is_empty() { - log::warn!(target: "gadget", "Received empty message from Peer {}", msg_orig.from); - continue; - } - match bincode2::deserialize::>(&msg_orig.payload) { - Ok(msg) => match msg { - SplitChannelMessage::Channel1(msg) => { - let msg_type = if msg_orig.to.is_some() { - MessageType::P2P - } else { - MessageType::Broadcast - }; - let incoming = Incoming { - id, - sender: msg_orig.from as PartyIndex, - msg_type, - msg, - }; - - if tx_to_async_proto_1.unbounded_send(Ok(incoming)).is_err() { - log::error!(target: "gadget", "Failed to send Incoming message to protocol"); - } - - id += 1; - } - SplitChannelMessage::Channel2(msg) => { - if tx_to_async_proto_2.unbounded_send(msg).is_err() { - log::error!(target: "gadget", "Failed to send C2 message to protocol"); - } - } - }, - Err(err) => { - log::error!(target: "gadget", "Failed to deserialize message: {err:?}"); - } - } - } - }); - - let (tx_to_outbound_1, mut rx_to_outbound_1) = - futures::channel::mpsc::unbounded::>(); - let (tx_to_outbound_2, mut rx_to_outbound_2) = futures::channel::mpsc::unbounded::(); - let network_clone = network.clone(); - let user_id_mapping_clone = user_id_mapping.clone(); - let my_user_id = user_id_mapping - .iter() - .find_map(|(user_id, account_id)| { - if *account_id == my_account_id { - Some(*user_id) - } else { - None - } - }) - .expect("Failed to find my user id"); - // Take the messages from the async protocol and send them to the gadget - tokio::task::spawn(async move { - let offline_task = async move { - while let Some(msg) = rx_to_outbound_1.next().await { - let from = msg.maybe_sender(); - let to = msg.maybe_receiver(); - let (to_account_id, from_account_id) = get_to_and_from_account_id( - &user_id_mapping_clone, - from.as_user_id().unwrap_or(my_user_id), - to.as_user_id(), - ); - let msg = SplitChannelMessage::::Channel1(msg.msg); - let msg = GadgetProtocolMessage { - associated_block_id, - associated_session_id, - associated_retry_id, - task_hash: associated_task_id, - from: from.as_user_id().unwrap_or(my_user_id), - to: to.as_user_id(), - payload: bincode2::serialize(&msg).expect("Failed to serialize message"), - from_network_id: from_account_id, - to_network_id: to_account_id, - }; - - if let Err(err) = network.send_message(msg).await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); - } - } - }; - - let voting_task = async move { - while let Some(msg) = rx_to_outbound_2.next().await { - let from = msg.maybe_sender(); - let to = msg.maybe_receiver(); - let (to_account_id, from_account_id) = get_to_and_from_account_id( - &user_id_mapping, - from.as_user_id().unwrap_or(my_user_id), - to.as_user_id(), - ); - let msg = SplitChannelMessage::::Channel2(msg); - let msg = GadgetProtocolMessage { - associated_block_id, - associated_session_id, - associated_retry_id, - task_hash: associated_task_id, - from: from.as_user_id().unwrap_or(my_user_id), - to: to.as_user_id(), - payload: bincode2::serialize(&msg).expect("Failed to serialize message"), - from_network_id: from_account_id, - to_network_id: to_account_id, - }; - - if let Err(err) = network_clone.send_message(msg).await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); - } - } - }; - - tokio::join!(offline_task, voting_task); - }); - - ( - tx_to_outbound_1, - rx_for_async_proto_1, - tx_to_outbound_2, - rx_for_async_proto_2, - ) -} - -fn get_to_and_from_account_id( - mapping: &HashMap, - from: UserID, - to: Option, -) -> (Option, Option) { - let from_account_id = mapping.get(&from).cloned(); - let to_account_id = if let Some(to) = to { - mapping.get(&to).cloned() - } else { - None - }; - - (to_account_id, from_account_id) -} /// Given a list of participants, choose `t` of them and return the index of the current participant /// and the indices of the chosen participants, as well as a mapping from the index to the account diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 93a72836b..16e05fd02 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -18,6 +18,7 @@ use round_based::{ runtime::AsyncRuntime, Delivery, Mpc, MpcParty, Outgoing, ProtocolMessage, }; +use round_based_21 as round_based; use serde::{Deserialize, Serialize}; use tangle_primitives::roles::ThresholdSignatureRoleType; diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index f577d5085..d98533154 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -1,5 +1,5 @@ use frost_core::Ciphersuite; -use round_based::rounds_router::{ +use round_based_21::rounds_router::{ errors::{self as router_error, CompleteRoundError}, simple_store::RoundInputError, }; diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index f9b66b2a6..8824767f8 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -6,6 +6,7 @@ use frost_core::{aggregate, round1, Ciphersuite, Field, Group, Identifier, Signi use futures::SinkExt; use rand_core::{CryptoRng, RngCore}; use round_based::rounds_router::simple_store::RoundInput; +use round_based_21 as round_based; use round_based::rounds_router::RoundsRouter; use round_based::runtime::AsyncRuntime; From 49f99f8e3d8631732f0313fd5225f7b22263a3a5 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Tue, 27 Feb 2024 14:55:24 -0500 Subject: [PATCH 51/66] Update JobsApi functions --- test-utils/src/mock.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test-utils/src/mock.rs b/test-utils/src/mock.rs index 1122ca163..3aa9edc4d 100644 --- a/test-utils/src/mock.rs +++ b/test-utils/src/mock.rs @@ -309,6 +309,18 @@ sp_api::mock_impl_runtime_apis! { Jobs::query_job_result(role_type, job_id) }) } + + fn query_next_job_id() -> JobId { + TEST_EXTERNALITIES.lock().as_ref().unwrap().execute_with(move || { + Jobs::query_next_job_id() + }) + } + + fn query_restaker_role_key(address: AccountId) -> Option> { + TEST_EXTERNALITIES.lock().as_ref().unwrap().execute_with(move || { + MockRolesHandler::get_validator_role_key(address) + }) + } } } From 459bd27d8f42f00bd797da04e86d554f15b4b490 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Tue, 27 Feb 2024 17:31:33 -0500 Subject: [PATCH 52/66] Update signing to generalize curves --- .../dfns-cggmp21/src/protocols/key_rotate.rs | 173 ++++++++------ .../dfns-cggmp21/src/protocols/keygen.rs | 108 ++++----- protocols/dfns-cggmp21/src/protocols/sign.rs | 223 +++++++++++------- test-utils/src/mock.rs | 2 +- 4 files changed, 293 insertions(+), 213 deletions(-) diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index 84eb7df2e..08d5cef65 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -1,6 +1,8 @@ +use crate::protocols::sign::run_and_serialize_signing; +use dfns_cggmp21::security_level::SecurityLevel128; use dfns_cggmp21::signing::msg::Msg; -use dfns_cggmp21::supported_curves::Secp256k1; -use dfns_cggmp21::KeyShare; +use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; + use gadget_common::client::{ClientWithApi, JobsApiForGadget}; use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::network::Network; @@ -8,12 +10,13 @@ use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; use gadget_common::prelude::FullProtocolConfig; +use gadget_common::prelude::*; use gadget_common::utils::CloneableUnboundedReceiver; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use rand::SeedableRng; -use round_based_21::{Incoming, Outgoing}; + use sc_client_api::Backend; use sha2::Sha256; use sp_api::ProvideRuntimeApi; @@ -26,6 +29,8 @@ use tangle_primitives::jobs::{ use tangle_primitives::roles::RoleType; use tokio::sync::mpsc::UnboundedReceiver; +use super::keygen::create_party; + pub async fn create_next_job< B: Block, BE: Backend + 'static, @@ -115,7 +120,7 @@ pub struct DfnsCGGMP21KeyRotateExtraParams { phase_one_id: JobId, new_phase_one_id: JobId, role_type: RoleType, - key: KeyShare, + key: Vec, new_key: Vec, user_id_to_account_id_mapping: Arc>, } @@ -147,17 +152,18 @@ where let phase_one_id = additional_params.phase_one_id; let network = config.clone(); - let (i, signers, t, new_phase_one_id, key, new_key, mapping) = ( + let (i, signers, t, new_phase_one_id, key, role_type, new_key, mapping) = ( additional_params.i, additional_params.signers, additional_params.t, additional_params.new_phase_one_id, additional_params.key, + additional_params.role_type, additional_params.new_key.clone(), additional_params.user_id_to_account_id_mapping.clone(), ); - let public_key_bytes = key.shared_public_key().to_bytes(true).to_vec(); + let key2 = key.clone(); let new_key2 = new_key.clone(); Ok(JobBuilder::new() @@ -174,42 +180,92 @@ where let mix = keccak_256(b"dnfs-cggmp21-key-rotate"); let eid_bytes = [&job_id_bytes[..], &mix[..]].concat(); let eid = dfns_cggmp21::ExecutionId::new(&eid_bytes); - let ( - key_rotate_tx_to_outbound, - key_rotate_rx_async_proto, - _broadcast_tx_to_outbound, - _broadcast_rx_from_gadget, - ) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< - _, - (), - Outgoing>, - Incoming>, - >( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - role_id, - network.clone(), - ); - - let delivery = (key_rotate_rx_async_proto, key_rotate_tx_to_outbound); - let party = round_based_21::MpcParty::connected(delivery); + let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let data_hash = keccak_256(&new_key); let data_to_sign = dfns_cggmp21::DataToSign::from_scalar( dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(data_hash), ); - let signature = dfns_cggmp21::signing(eid, i, &signers, &key) - .sign(&mut rng, party, data_to_sign) - .await - .map_err(|err| JobError { - reason: format!("Key Rotation protocol error: {err:?}"), - })?; - - // Normalize the signature - let signature = signature.normalize_s(); + let signature = match role_type { + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { + let party = + create_party::>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + role_id, + network.clone(), + ); + run_and_serialize_signing::<_, SecurityLevel128, _, _>( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + key, + party, + &mut rng, + ) + .await? + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { + let party = + create_party::>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + role_id, + network.clone(), + ); + run_and_serialize_signing::<_, SecurityLevel128, _, _>( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + key, + party, + &mut rng, + ) + .await? + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { + let party = create_party::>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + role_id, + network.clone(), + ); + run_and_serialize_signing::<_, SecurityLevel128, _, _>( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + key, + party, + &mut rng, + ) + .await? + } + _ => { + return Err(JobError { + reason: format!("Unsupported role type: {role_type:?}"), + }); + } + }; logger.debug("Finished AsyncProtocol - Key Rotation"); *protocol_output.lock().await = Some(signature); Ok(()) @@ -217,50 +273,13 @@ where .post(async move { // Submit the protocol output to the blockchain if let Some(signature) = protocol_output_clone.lock().await.take() { - let mut signature_bytes = [0u8; 65]; - signature.write_to_slice(&mut signature_bytes[0..64]); - // To figure out the recovery ID, we need to try all possible values of v - // in our case, v can be 0 or 1 - let mut v = 0u8; - loop { - let mut signature_bytes = signature_bytes; - let data_hash = keccak_256(&new_key2); - signature_bytes[64] = v; - let res = sp_io::crypto::secp256k1_ecdsa_recover(&signature_bytes, &data_hash); - match res { - Ok(key) if key[..32] == public_key_bytes[1..] => { - // Found the correct v - break; - } - Ok(_) => { - // Found a key, but not the correct one - // Try the other v value - v = 1; - continue; - } - Err(_) if v == 1 => { - // We tried both v values, but no key was found - // This should never happen, but if it does, we will just - // leave v as 1 and break - break; - } - Err(_) => { - // No key was found, try the other v value - v = 1; - continue; - } - } - } - // Add 27 to the recovery ID - signature_bytes[64] = v + 27; - let job_result = JobResult::DKGPhaseFour(DKGTSSKeyRotationResult { signature_scheme: DigitalSignatureScheme::Ecdsa, - signature: signature_bytes.to_vec().try_into().unwrap(), + signature: signature.try_into().unwrap(), phase_one_id, new_phase_one_id, new_key: new_key2.try_into().unwrap(), - key: public_key_bytes.try_into().unwrap(), + key: key2.try_into().unwrap(), }); client diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 7c617f4b3..b2e9e6a1d 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -1,9 +1,8 @@ use dfns_cggmp21::generic_ec::Curve; use dfns_cggmp21::key_refresh::msg::aux_only; -use dfns_cggmp21::keygen::msg::threshold; + use dfns_cggmp21::keygen::msg::threshold::Msg; -use dfns_cggmp21::keygen::ThresholdMsg; -use dfns_cggmp21::security_level::SecurityLevel128; +use dfns_cggmp21::security_level::{SecurityLevel, SecurityLevel128}; use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; use futures::channel::mpsc::{TryRecvError, UnboundedSender}; use futures::StreamExt; @@ -25,13 +24,15 @@ use itertools::Itertools; use pallet_dkg::signatures_schemes::ecdsa::verify_signer_from_set_ecdsa; use pallet_dkg::signatures_schemes::to_slice_33; use rand::rngs::{OsRng, StdRng}; -use rand::SeedableRng; +use rand::{CryptoRng, RngCore, SeedableRng}; use round_based_21::{Delivery, Incoming, MpcParty, Outgoing}; use sc_client_api::Backend; +use serde::{Serialize}; use sha2::Sha256; use sp_api::ProvideRuntimeApi; use sp_application_crypto::sp_core::keccak_256; use sp_core::{ecdsa, Pair}; +use sp_runtime::DeserializeOwned; use std::collections::{BTreeMap, HashMap}; use std::sync::Arc; use tangle_primitives::jobs::{ @@ -104,17 +105,18 @@ pub struct DfnsCGGMP21KeygenExtraParams { user_id_to_account_id_mapping: Arc>, } -pub async fn run_and_serialize_keygen<'r, E: Curve, D>( +pub async fn run_and_serialize_keygen<'r, E: Curve, D, R>( tracer: &mut dfns_cggmp21::progress::PerfProfiler, eid: dfns_cggmp21::ExecutionId<'r>, i: u16, n: u16, t: u16, - party: MpcParty, D>, - mut rng: StdRng, + party: MpcParty, D>, + mut rng: R, ) -> Result, JobError> where - D: Delivery>, + D: Delivery>, + R: RngCore + CryptoRng, { let incomplete_key_share = dfns_cggmp21::keygen::(eid, i, n) .set_progress_tracer(tracer) @@ -174,6 +176,48 @@ where }) } +pub fn create_party( + protocol_message_channel: CloneableUnboundedReceiver, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + mapping: Arc>, + id: ecdsa::Public, + network: N, +) -> MpcParty< + M, + ( + futures::channel::mpsc::UnboundedReceiver, TryRecvError>>, + UnboundedSender>, + ), +> +where + N: Network, + L: SecurityLevel, + E: Curve, + M: Serialize + DeserializeOwned + Send + Sync + 'static, +{ + let (tx_to_outbound, rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget) = + gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< + _, + (), + Outgoing, + Incoming, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping, + id, + network, + ); + let delivery = (rx_async_proto, tx_to_outbound); + MpcParty::connected(delivery) +} + pub async fn generate_protocol_from< B: Block, BE: Backend + 'static, @@ -227,51 +271,9 @@ where let aux_eid = dfns_cggmp21::ExecutionId::new(&aux_eid_bytes); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - fn create_party( - protocol_message_channel: CloneableUnboundedReceiver, - associated_block_id: ::Clock, - associated_retry_id: ::RetryID, - associated_session_id: ::SessionID, - associated_task_id: ::TaskID, - mapping: Arc>, - id: ecdsa::Public, - network: N, - ) -> MpcParty< - Msg, - ( - futures::channel::mpsc::UnboundedReceiver< - Result>, TryRecvError>, - >, - UnboundedSender>>, - ), - > { - let ( - keygen_tx_to_outbound, - keygen_rx_async_proto, - _broadcast_tx_to_outbound, - _broadcast_rx_from_gadget, - ) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< - _, - (), - Outgoing>, - Incoming>, - >( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping, - id, - network, - ); - let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); - MpcParty::connected(delivery) - } - let incomplete_key_share: Vec = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - let party = create_party::( + let party = create_party::>( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -284,7 +286,7 @@ where run_and_serialize_keygen(&mut tracer, eid, i, n, t, party, rng.clone()).await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - let party = create_party::( + let party = create_party::>( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -297,7 +299,7 @@ where run_and_serialize_keygen(&mut tracer, eid, i, n, t, party, rng.clone()).await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - let party = create_party::( + let party = create_party::>( protocol_message_channel.clone(), associated_block_id, associated_retry_id, diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index 89cfdab27..a5812692b 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -1,7 +1,14 @@ +use dfns_cggmp21::generic_ec::coords::HasAffineX; +use dfns_cggmp21::generic_ec::{Curve, Point}; +use dfns_cggmp21::round_based::{Delivery, MpcParty}; +use dfns_cggmp21::security_level::{SecurityLevel, SecurityLevel128}; use dfns_cggmp21::signing::msg::Msg; -use dfns_cggmp21::supported_curves::Secp256k1; -use dfns_cggmp21::KeyShare; + +use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; +use dfns_cggmp21::{DataToSign, KeyShare}; +use digest::KeyInit; use gadget_common::client::{ClientWithApi, JobsApiForGadget}; +use gadget_common::config::DebugLogger; use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; @@ -11,9 +18,10 @@ use gadget_common::utils::CloneableUnboundedReceiver; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; -use rand::SeedableRng; -use round_based_21::{Incoming, Outgoing}; +use rand::{CryptoRng, RngCore, SeedableRng}; + use sc_client_api::Backend; + use sha2::Sha256; use sp_api::ProvideRuntimeApi; use sp_core::{ecdsa, keccak_256, Pair}; @@ -22,9 +30,11 @@ use std::sync::Arc; use tangle_primitives::jobs::{ DKGTSSSignatureResult, DigitalSignatureScheme, JobId, JobResult, JobType, }; -use tangle_primitives::roles::RoleType; +use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; +use super::keygen::create_party; + pub async fn create_next_job< B: Block, BE: Backend + 'static, @@ -92,11 +102,50 @@ pub struct DfnsCGGMP21SigningExtraParams { signers: Vec, job_id: JobId, role_type: RoleType, - key: KeyShare, + key: Vec, input_data_to_sign: Vec, user_id_to_account_id_mapping: Arc>, } +pub async fn run_and_serialize_signing<'r, E, L, R, D>( + logger: &DebugLogger, + tracer: &mut dfns_cggmp21::progress::PerfProfiler, + eid: dfns_cggmp21::ExecutionId<'r>, + i: u16, + signers: Vec, + msg: DataToSign, + key: Vec, + party: MpcParty, D>, + rng: &mut R, +) -> Result, JobError> +where + E: Curve, + Point: HasAffineX, + L: SecurityLevel, + R: RngCore + CryptoRng, + D: Delivery>, +{ + let key: KeyShare = bincode2::deserialize(&key).map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })?; + let signature = dfns_cggmp21::signing(eid, i, &signers, &key) + .set_progress_tracer(tracer) + .sign(rng, party, msg) + .await + .map_err(|err| JobError { + reason: format!("Signing protocol error: {err:?}"), + })?; + + let perf_report = tracer.get_report().map_err(|err| JobError { + reason: format!("Signing protocol error: {err:?}"), + })?; + logger.trace(format!("Signing protocol report: {perf_report}")); + // Normalize the signature + bincode2::serialize(&signature.normalize_s()).map_err(|err| JobError { + reason: format!("Signing protocol error: {err:?}"), + }) +} + pub async fn generate_protocol_from< B: Block, BE: Backend + 'static, @@ -123,17 +172,17 @@ where let my_role_id = config.key_store.pair().public(); let network = config.clone(); - let (i, signers, t, key, input_data_to_sign, mapping) = ( + let (i, signers, t, key, role_type, input_data_to_sign, mapping) = ( additional_params.i, additional_params.signers, additional_params.t, additional_params.key, + additional_params.role_type, additional_params.input_data_to_sign.clone(), additional_params.user_id_to_account_id_mapping.clone(), ); - let public_key_bytes = key.shared_public_key().to_bytes(true).to_vec(); - let input_data_to_sign2 = input_data_to_sign.clone(); + let key2 = key.clone(); Ok(JobBuilder::new() .protocol(async move { @@ -149,48 +198,94 @@ where let mix = keccak_256(b"dnfs-cggmp21-signing"); let eid_bytes = [&job_id_bytes[..], &mix[..]].concat(); let eid = dfns_cggmp21::ExecutionId::new(&eid_bytes); - let ( - signing_tx_to_outbound, - signing_rx_async_proto, - _broadcast_tx_to_outbound, - _broadcast_rx_from_gadget, - ) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< - _, - (), - Outgoing>, - Incoming>, - >( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - ); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - let delivery = (signing_rx_async_proto, signing_tx_to_outbound); - let party = round_based_21::MpcParty::connected(delivery); let data_hash = keccak_256(&input_data_to_sign); let data_to_sign = dfns_cggmp21::DataToSign::from_scalar( dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(data_hash), ); - let signature = dfns_cggmp21::signing(eid, i, &signers, &key) - .set_progress_tracer(&mut tracer) - .sign(&mut rng, party, data_to_sign) - .await - .map_err(|err| JobError { - reason: format!("Signing protocol error: {err:?}"), - })?; + let signature = match role_type { + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { + let party = + create_party::>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + my_role_id, + network.clone(), + ); + run_and_serialize_signing::<_, SecurityLevel128, _, _>( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + key, + party, + &mut rng, + ) + .await? + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { + let party = + create_party::>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + my_role_id, + network.clone(), + ); + run_and_serialize_signing::<_, SecurityLevel128, _, _>( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + key, + party, + &mut rng, + ) + .await? + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { + let party = create_party::>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + my_role_id, + network.clone(), + ); + run_and_serialize_signing::<_, SecurityLevel128, _, _>( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + key, + party, + &mut rng, + ) + .await? + } + _ => { + return Err(JobError { + reason: format!("Invalid role type: {role_type:?}"), + }); + } + }; - let perf_report = tracer.get_report().map_err(|err| JobError { - reason: format!("Signing protocol error: {err:?}"), - })?; - logger.trace(format!("Signing protocol report: {perf_report}")); - // Normalize the signature - let signature = signature.normalize_s(); logger.debug("Finished AsyncProtocol - Signing"); *protocol_output.lock().await = Some(signature); Ok(()) @@ -198,47 +293,11 @@ where .post(async move { // Submit the protocol output to the blockchain if let Some(signature) = protocol_output_clone.lock().await.take() { - let mut signature_bytes = [0u8; 65]; - signature.write_to_slice(&mut signature_bytes[0..64]); - // To figure out the recovery ID, we need to try all possible values of v - // in our case, v can be 0 or 1 - let mut v = 0u8; - loop { - let mut signature_bytes = signature_bytes; - let data_hash = keccak_256(&input_data_to_sign2); - signature_bytes[64] = v; - let res = sp_io::crypto::secp256k1_ecdsa_recover(&signature_bytes, &data_hash); - match res { - Ok(key) if key[..32] == public_key_bytes[1..] => { - // Found the correct v - break; - } - Ok(_) => { - // Found a key, but not the correct one - // Try the other v value - v = 1; - continue; - } - Err(_) if v == 1 => { - // We tried both v values, but no key was found - // This should never happen, but if it does, we will just - // leave v as 1 and break - break; - } - Err(_) => { - // No key was found, try the other v value - v = 1; - continue; - } - } - } - signature_bytes[64] = v + 27; - let job_result = JobResult::DKGPhaseTwo(DKGTSSSignatureResult { signature_scheme: DigitalSignatureScheme::Ecdsa, data: additional_params.input_data_to_sign.try_into().unwrap(), - signature: signature_bytes.to_vec().try_into().unwrap(), - verifying_key: public_key_bytes.try_into().unwrap(), + signature: signature.try_into().unwrap(), + verifying_key: key2.try_into().unwrap(), }); client diff --git a/test-utils/src/mock.rs b/test-utils/src/mock.rs index 3aa9edc4d..90772da1e 100644 --- a/test-utils/src/mock.rs +++ b/test-utils/src/mock.rs @@ -316,7 +316,7 @@ sp_api::mock_impl_runtime_apis! { }) } - fn query_restaker_role_key(address: AccountId) -> Option> { + fn query_restaker_role_key(address: AccountId) -> Option> { TEST_EXTERNALITIES.lock().as_ref().unwrap().execute_with(move || { MockRolesHandler::get_validator_role_key(address) }) From 428962c7219ca4fdbc802774af9f4fec4f8b9036 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 28 Feb 2024 10:30:03 -0500 Subject: [PATCH 53/66] Get zcash tests working --- protocols/zcash-frost/src/protocol/keygen.rs | 19 +++++++------------ protocols/zcash-frost/src/protocol/sign.rs | 13 ++++--------- protocols/zcash-frost/src/protocol/util.rs | 11 ----------- test-utils/src/mock.rs | 2 +- 4 files changed, 12 insertions(+), 33 deletions(-) diff --git a/protocols/zcash-frost/src/protocol/keygen.rs b/protocols/zcash-frost/src/protocol/keygen.rs index 7196e1206..0f532e176 100644 --- a/protocols/zcash-frost/src/protocol/keygen.rs +++ b/protocols/zcash-frost/src/protocol/keygen.rs @@ -25,7 +25,7 @@ use rand::SeedableRng; use round_based_21::{Incoming, Outgoing}; use sc_client_api::Backend; use sp_application_crypto::sp_core::keccak_256; -use sp_core::{ecdsa, ByteArray, Pair}; +use sp_core::{ecdsa, Pair}; use std::collections::{BTreeMap, HashMap}; use std::sync::Arc; use tangle_primitives::jobs::{DKGTSSKeySubmissionResult, DigitalSignatureScheme, JobId, JobType}; @@ -34,8 +34,6 @@ use tokio::sync::mpsc::UnboundedReceiver; use crate::rounds; use crate::rounds::keygen::Msg; - -use crate::protocol::util::account_id_32_to_public; use gadget_common::channels::PublicKeyGossipMessage; #[derive(Clone)] @@ -70,7 +68,7 @@ where panic!("Should be valid type") }; - let participants = p1_job.participants; + let participants = job.participants_role_ids; let threshold = p1_job.threshold; let user_id_to_account_id_mapping = Arc::new( @@ -78,19 +76,16 @@ where .clone() .into_iter() .enumerate() - .map(|r| { - ( - r.0 as UserID, - account_id_32_to_public(r.1.as_slice()).expect("Should convert"), - ) - }) + .map(|r| (r.0 as UserID, r.1)) .collect(), ); + let id = config.key_store.pair().public(); + let params = ZcashFrostKeygenExtraParams { i: participants .iter() - .position(|p| p == &config.account_id) + .position(|p| p == &id) .expect("Should exist") as u16, t: threshold as u16, n: participants.len() as u16, @@ -144,7 +139,7 @@ where let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); let protocol_output_clone = protocol_output.clone(); let pallet_tx = config.pallet_tx.clone(); - let id = account_id_32_to_public(config.account_id.as_slice()).expect("Should convert"); + let id = config.key_store.pair().public(); let logger = config.logger.clone(); let network = config.clone(); diff --git a/protocols/zcash-frost/src/protocol/sign.rs b/protocols/zcash-frost/src/protocol/sign.rs index 444de41ef..2d3928ef6 100644 --- a/protocols/zcash-frost/src/protocol/sign.rs +++ b/protocols/zcash-frost/src/protocol/sign.rs @@ -15,14 +15,13 @@ use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; -use crate::protocol::util::account_id_32_to_public; use gadget_common::{channels, Block}; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use rand::SeedableRng; use round_based_21::{Incoming, MpcParty, Outgoing}; use sc_client_api::Backend; -use sp_core::{ecdsa, keccak_256, ByteArray}; +use sp_core::{ecdsa, keccak_256, Pair}; use std::collections::HashMap; use std::sync::Arc; use tangle_primitives::jobs::{DKGTSSSignatureResult, DigitalSignatureScheme, JobId, JobType}; @@ -68,16 +67,12 @@ where let previous_job_id = p2_job.phase_one_id; let phase1_job = job.phase1_job.expect("Should exist for a phase 2 job"); - let participants = phase1_job.clone().get_participants().expect("Should exist"); - let participants = participants - .iter() - .map(|p| account_id_32_to_public(p.as_slice()).expect("Should convert")) - .collect::>(); + let participants = job.participants_role_ids; let t = phase1_job.get_threshold().expect("Should exist") as u16; let seed = keccak_256(&[&job_id.to_be_bytes()[..], &job.retry_id.to_be_bytes()[..]].concat()); let mut rng = rand_chacha::ChaChaRng::from_seed(seed); - let id = account_id_32_to_public(config.account_id.as_slice()).expect("Should convert"); + let id = config.key_store.pair().public(); let (i, signers, mapping) = super::util::choose_signers(&mut rng, &id, &participants, t)?; let key = config @@ -162,7 +157,7 @@ where let protocol_output = Arc::new(tokio::sync::Mutex::new(None)); let protocol_output_clone = protocol_output.clone(); let pallet_tx = config.pallet_tx.clone(); - let id = account_id_32_to_public(config.account_id.as_slice()).expect("Should convert"); + let id = config.key_store.pair().public(); let network = config.clone(); let (i, signers, t, keyshare, role_type, input_data_to_sign, mapping) = ( diff --git a/protocols/zcash-frost/src/protocol/util.rs b/protocols/zcash-frost/src/protocol/util.rs index ddea73883..5318f1019 100644 --- a/protocols/zcash-frost/src/protocol/util.rs +++ b/protocols/zcash-frost/src/protocol/util.rs @@ -6,17 +6,6 @@ use rand::seq::SliceRandom; use sp_core::ecdsa::Public; use std::collections::HashMap; -/// Converts an ECDSA key in 32-byte format to 33-byte format with the metadata 0th byte set to 0x00 -pub fn account_id_32_to_public(account_id: &[u8]) -> Option { - if account_id.len() != 32 { - return None; - } - - let mut bytes = [0u8; 33]; - bytes[1..].copy_from_slice(account_id); - Some(Public::from_raw(bytes)) -} - /// Given a list of participants, choose `t` of them and return the index of the current participant /// and the indices of the chosen participants, as well as a mapping from the index to the account /// id. diff --git a/test-utils/src/mock.rs b/test-utils/src/mock.rs index 3aa9edc4d..90772da1e 100644 --- a/test-utils/src/mock.rs +++ b/test-utils/src/mock.rs @@ -316,7 +316,7 @@ sp_api::mock_impl_runtime_apis! { }) } - fn query_restaker_role_key(address: AccountId) -> Option> { + fn query_restaker_role_key(address: AccountId) -> Option> { TEST_EXTERNALITIES.lock().as_ref().unwrap().execute_with(move || { MockRolesHandler::get_validator_role_key(address) }) From 691f9be772fc10973dd33d92d11584a63b21530c Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 28 Feb 2024 10:32:30 -0500 Subject: [PATCH 54/66] pull in origin/HEAD --- protocols/dfns-cggmp21/src/protocols/sign.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index a5812692b..c7f32aeec 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -6,7 +6,6 @@ use dfns_cggmp21::signing::msg::Msg; use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; use dfns_cggmp21::{DataToSign, KeyShare}; -use digest::KeyInit; use gadget_common::client::{ClientWithApi, JobsApiForGadget}; use gadget_common::config::DebugLogger; use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; From cbbd25027275299ab92e6effabb2d73fec13d0cc Mon Sep 17 00:00:00 2001 From: drewstone Date: Wed, 28 Feb 2024 10:58:47 -0500 Subject: [PATCH 55/66] Update README.md Co-authored-by: shekohex --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 4f2bb7fc1..f4c1a9080 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,7 @@ These protocols are endowed with the same functionalities as the `gadget-common` For more information on how to create a new protocol, see the README.md in the `protocols/stub` directory [here](protocols/stub/README.md). ## Testing -`SKIP_WASM_BUILD=true RUST_LOG=debug cargo nextest run` is required to run tests, since 1-program per-program space is required for tests due to the nature of the use of static variables in test-only contexts. There is currently an issue with the WASM build so the `SKIP_WASM_BUILD` flag is required. The `RUST_LOG=debug` flag is optional but useful for debugging. - +`RUST_LOG=debug cargo nextest run` is required to run tests, since 1-program per-program space is required for tests due to the nature of the use of static variables in test-only contexts. The `RUST_LOG=debug` flag is optional but useful for debugging. ## Troubleshooting #### GMP Issues The linking phase may fail due to not finding libgmp (i.e., "could not find library -lgmp") when building on a mac M1. To fix this problem, run: From 9a3b5727bc2a3c197fdebb72b8d926110ce9be46 Mon Sep 17 00:00:00 2001 From: drewstone Date: Wed, 28 Feb 2024 10:58:54 -0500 Subject: [PATCH 56/66] Update gadget-common/src/utils.rs Co-authored-by: shekohex --- gadget-common/src/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gadget-common/src/utils.rs b/gadget-common/src/utils.rs index bfae4c289..acf9feb1a 100644 --- a/gadget-common/src/utils.rs +++ b/gadget-common/src/utils.rs @@ -5,8 +5,8 @@ use tokio::sync::mpsc::UnboundedReceiver; /// A Channel Receiver that can be cloned. /// -/// On the second clone, the original channel will stop sending messages -/// and the new channel will start sending messages. +/// On the second clone, the original channel will stop receiving new messages +/// and the new channel will start receiving any new messages after the clone. pub struct CloneableUnboundedReceiver { rx: Arc>>, is_in_use: Arc, From 11c276d9369316f85abe3b0cdce4ea30c5cb5a4e Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 28 Feb 2024 11:49:54 -0500 Subject: [PATCH 57/66] Remove create party refresh and reuse --- .../dfns-cggmp21/src/protocols/key_rotate.rs | 25 +-- .../dfns-cggmp21/src/protocols/keygen.rs | 200 ++++++++---------- protocols/dfns-cggmp21/src/protocols/sign.rs | 25 +-- 3 files changed, 119 insertions(+), 131 deletions(-) diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index 08d5cef65..ed0648f4f 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -187,7 +187,7 @@ where ); let signature = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - let party = + let (_, _, party) = create_party::>( protocol_message_channel.clone(), associated_block_id, @@ -212,7 +212,7 @@ where .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - let party = + let (_, _, party) = create_party::>( protocol_message_channel.clone(), associated_block_id, @@ -237,16 +237,17 @@ where .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - let party = create_party::>( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - role_id, - network.clone(), - ); + let (_, _, party) = + create_party::>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + role_id, + network.clone(), + ); run_and_serialize_signing::<_, SecurityLevel128, _, _>( &logger, &mut tracer, diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index b2e9e6a1d..05fb67d4f 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -27,7 +27,7 @@ use rand::rngs::{OsRng, StdRng}; use rand::{CryptoRng, RngCore, SeedableRng}; use round_based_21::{Delivery, Incoming, MpcParty, Outgoing}; use sc_client_api::Backend; -use serde::{Serialize}; +use serde::Serialize; use sha2::Sha256; use sp_api::ProvideRuntimeApi; use sp_application_crypto::sp_core::keccak_256; @@ -169,6 +169,7 @@ where .map_err(|err| JobError { reason: format!("Key share error: {err:?}"), })?; + // Serialize the key share and the public key bincode2::serialize(&key_share) .map(|ks| (ks, key_share.shared_public_key().to_bytes(true).to_vec())) .map_err(|err| JobError { @@ -185,23 +186,27 @@ pub fn create_party( mapping: Arc>, id: ecdsa::Public, network: N, -) -> MpcParty< - M, - ( - futures::channel::mpsc::UnboundedReceiver, TryRecvError>>, - UnboundedSender>, - ), -> +) -> ( + UnboundedSender, + futures::channel::mpsc::UnboundedReceiver, + MpcParty< + M, + ( + futures::channel::mpsc::UnboundedReceiver, TryRecvError>>, + UnboundedSender>, + ), + >, +) where N: Network, L: SecurityLevel, E: Curve, M: Serialize + DeserializeOwned + Send + Sync + 'static, { - let (tx_to_outbound, rx_async_proto, _broadcast_tx_to_outbound, _broadcast_rx_from_gadget) = + let (tx_to_outbound, rx_async_proto, broadcast_tx_to_outbound, broadcast_rx_from_gadget) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< _, - (), + PublicKeyGossipMessage, Outgoing, Incoming, >( @@ -215,7 +220,11 @@ where network, ); let delivery = (rx_async_proto, tx_to_outbound); - MpcParty::connected(delivery) + ( + broadcast_tx_to_outbound, + broadcast_rx_from_gadget, + MpcParty::connected(delivery), + ) } pub async fn generate_protocol_from< @@ -273,7 +282,12 @@ where let incomplete_key_share: Vec = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - let party = create_party::>( + let (_, _, party) = create_party::< + Secp256k1, + _, + SecurityLevel128, + Msg, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -286,7 +300,12 @@ where run_and_serialize_keygen(&mut tracer, eid, i, n, t, party, rng.clone()).await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - let party = create_party::>( + let (_, _, party) = create_party::< + Secp256r1, + _, + SecurityLevel128, + Msg, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -299,7 +318,12 @@ where run_and_serialize_keygen(&mut tracer, eid, i, n, t, party, rng.clone()).await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - let party = create_party::>( + let (_, _, party) = create_party::< + Stark, + _, + SecurityLevel128, + Msg, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -343,75 +367,16 @@ where reason: format!("Failed to store pregenerated primes: {err:?}"), })?; - fn create_party_refresh( - protocol_message_channel: CloneableUnboundedReceiver, - associated_block_id: ::Clock, - associated_retry_id: ::RetryID, - associated_session_id: ::SessionID, - associated_task_id: ::TaskID, - mapping: Arc>, - id: ecdsa::Public, - network: N, - ) -> ( - UnboundedSender, - futures::channel::mpsc::UnboundedReceiver, - MpcParty< - dfns_cggmp21::key_refresh::msg::aux_only::Msg, - ( - futures::channel::mpsc::UnboundedReceiver< - Result< - Incoming< - dfns_cggmp21::key_refresh::msg::aux_only::Msg< - Sha256, - SecurityLevel128, - >, - >, - TryRecvError, - >, - >, - UnboundedSender< - Outgoing< - dfns_cggmp21::key_refresh::msg::aux_only::Msg< - Sha256, - SecurityLevel128, - >, - >, - >, - ), - >, - ) { - let ( - keyrefresh_tx_to_outbound, - keyrefresh_rx_async_proto, - broadcast_tx_to_outbound, - broadcast_rx_from_gadget, - ) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io::< - _, - PublicKeyGossipMessage, - Outgoing>, - Incoming>, - >( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping, - id, - network, - ); - let delivery = (keyrefresh_rx_async_proto, keyrefresh_tx_to_outbound); - ( - broadcast_tx_to_outbound, - broadcast_rx_from_gadget, - MpcParty::connected(delivery), - ) - } - logger.info(format!("Will now run Keygen protocol: {role_type:?}")); - let (tx, rx, key_share, serialized_public_key) = match role_type { + let (mut pubkey_gossip_tx, mut pubkey_gossip_rx) = (None, None); + let (key_share, serialized_public_key) = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - let (tx, rx, party) = create_party_refresh( + let (tx, rx, party) = create_party::< + Secp256k1, + _, + SecurityLevel128, + aux_only::Msg, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -421,7 +386,9 @@ where my_role_id, network.clone(), ); - let (ks, pk) = run_and_serialize_keyrefresh::( + pubkey_gossip_tx = Some(tx); + pubkey_gossip_rx = Some(rx); + run_and_serialize_keyrefresh::( &logger, incomplete_key_share, pregenerated_primes, @@ -432,11 +399,15 @@ where party, rng, ) - .await?; - (tx, rx, ks, pk) + .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - let (tx, rx, party) = create_party_refresh( + let (tx, rx, party) = create_party::< + Secp256r1, + _, + SecurityLevel128, + aux_only::Msg, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -446,7 +417,9 @@ where my_role_id, network.clone(), ); - let (kx, pk) = run_and_serialize_keyrefresh::( + pubkey_gossip_tx = Some(tx); + pubkey_gossip_rx = Some(rx); + run_and_serialize_keyrefresh::( &logger, incomplete_key_share, pregenerated_primes, @@ -457,11 +430,15 @@ where party, rng, ) - .await?; - (tx, rx, kx, pk) + .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - let (tx, rx, party) = create_party_refresh( + let (tx, rx, party) = create_party::< + Stark, + _, + SecurityLevel128, + aux_only::Msg, + >( protocol_message_channel.clone(), associated_block_id, associated_retry_id, @@ -471,7 +448,9 @@ where my_role_id, network.clone(), ); - let (ks, pk) = run_and_serialize_keyrefresh::( + pubkey_gossip_tx = Some(tx); + pubkey_gossip_rx = Some(rx); + run_and_serialize_keyrefresh::( &logger, incomplete_key_share, pregenerated_primes, @@ -482,28 +461,35 @@ where party, rng, ) - .await?; - (tx, rx, ks, pk) + .await? } - _ => unreachable!("Invalid role type"), + _ => Err(JobError { + reason: "Invalid role type".to_string(), + })?, }; logger.debug("Finished AsyncProtocol - Keygen"); - let job_result = handle_public_key_gossip( - key_store2, - &logger, - &key_share, - &serialized_public_key, - t, - i, - tx, - rx, - ) - .await?; - - *protocol_output.lock().await = Some((key_share, job_result)); - Ok(()) + if let (Some(tx), Some(rx)) = (pubkey_gossip_tx, pubkey_gossip_rx) { + let job_result = handle_public_key_gossip( + key_store2, + &logger, + &key_share, + &serialized_public_key, + t, + i, + tx, + rx, + ) + .await?; + + *protocol_output.lock().await = Some((key_share, job_result)); + Ok(()) + } else { + Err(JobError { + reason: "Failed to create gossip channels".to_string(), + })? + } }) .post(async move { // TODO: handle protocol blames diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index c7f32aeec..20cdceab0 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -205,7 +205,7 @@ where ); let signature = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - let party = + let (_, _, party) = create_party::>( protocol_message_channel.clone(), associated_block_id, @@ -230,7 +230,7 @@ where .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - let party = + let (_, _, party) = create_party::>( protocol_message_channel.clone(), associated_block_id, @@ -255,16 +255,17 @@ where .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - let party = create_party::>( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - ); + let (_, _, party) = + create_party::>( + protocol_message_channel.clone(), + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + my_role_id, + network.clone(), + ); run_and_serialize_signing::<_, SecurityLevel128, _, _>( &logger, &mut tracer, From b4fc80ff87ad1b79c2f100d59f639174c04f63a0 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 28 Feb 2024 14:47:48 -0500 Subject: [PATCH 58/66] Get DFNS keygen working --- gadget-common/src/channels.rs | 403 +++++++++++++----- protocols/bls/src/protocol/keygen.rs | 4 +- protocols/bls/src/protocol/signing.rs | 4 +- .../dfns-cggmp21/src/protocols/key_refresh.rs | 5 +- .../dfns-cggmp21/src/protocols/key_rotate.rs | 9 +- .../dfns-cggmp21/src/protocols/keygen.rs | 242 +++++------ protocols/dfns-cggmp21/src/protocols/sign.rs | 10 +- protocols/zcash-frost/src/protocol/keygen.rs | 4 +- protocols/zcash-frost/src/protocol/sign.rs | 5 +- 9 files changed, 418 insertions(+), 268 deletions(-) diff --git a/gadget-common/src/channels.rs b/gadget-common/src/channels.rs index 15b3bc33e..bac839825 100644 --- a/gadget-common/src/channels.rs +++ b/gadget-common/src/channels.rs @@ -3,7 +3,6 @@ use crate::gadget::message::{GadgetProtocolMessage, UserID}; use crate::gadget::network::Network; use crate::gadget::work_manager::WorkManager; -use crate::utils::CloneableUnboundedReceiver; use futures::StreamExt; use gadget_core::job_manager::WorkManagerInterface; use round_based::Msg; @@ -17,8 +16,8 @@ use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; pub fn create_job_manager_to_async_protocol_channel_split< N: Network + 'static, - C1: Serialize + DeserializeOwned + HasSenderAndReceiver + Send + 'static, - C2: Serialize + DeserializeOwned + HasSenderAndReceiver + Send + 'static, + C1: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, + C2: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, >( mut rx_gadget: UnboundedReceiver, associated_block_id: ::Clock, @@ -26,6 +25,7 @@ pub fn create_job_manager_to_async_protocol_channel_split< associated_session_id: ::SessionID, associated_task_id: ::TaskID, user_id_mapping: Arc>, + my_account_id: ecdsa::Public, network: N, ) -> ( futures::channel::mpsc::UnboundedSender, @@ -39,18 +39,22 @@ pub fn create_job_manager_to_async_protocol_channel_split< // Take the messages from the gadget and send them to the async protocol tokio::task::spawn(async move { while let Some(msg) = rx_gadget.recv().await { - match bincode2::deserialize::>(&msg.payload) { + match bincode2::deserialize::>(&msg.payload) { Ok(msg) => match msg { - SplitChannelMessage::Channel1(msg) => { + MultiplexedChannelMessage::Channel1(msg) => { if tx_to_async_proto_1.unbounded_send(Ok(msg)).is_err() { log::error!(target: "gadget", "Failed to send message to protocol"); } } - SplitChannelMessage::Channel2(msg) => { + MultiplexedChannelMessage::Channel2(msg) => { if tx_to_async_proto_2.send(msg).is_err() { log::error!(target: "gadget", "Failed to send message to protocol"); } } + + _ => { + unreachable!("We only have two channels") + } }, Err(err) => { log::error!(target: "gadget", "Failed to deserialize message: {err:?}"); @@ -63,28 +67,34 @@ pub fn create_job_manager_to_async_protocol_channel_split< let (tx_to_outbound_2, mut rx_to_outbound_2) = tokio::sync::mpsc::unbounded_channel::(); let network_clone = network.clone(); let user_id_mapping_clone = user_id_mapping.clone(); + let my_user_id = user_id_mapping + .iter() + .find_map(|(user_id, account_id)| { + if *account_id == my_account_id { + Some(*user_id) + } else { + None + } + }) + .expect("Failed to find my user id"); + // Take the messages the async protocol sends to the outbound channel and send them to the gadget tokio::task::spawn(async move { let offline_task = async move { while let Some(msg) = rx_to_outbound_1.next().await { - let from = msg.sender(); - let to = msg.receiver(); - let (to_account_id, from_account_id) = - get_to_and_from_account_id(&user_id_mapping_clone, from, to); - let msg = SplitChannelMessage::::Channel1(msg); - let msg = GadgetProtocolMessage { + if let Err(err) = wrap_message_and_forward_to_network::<_, C1, C2, (), _>( + msg, + &network, + &*user_id_mapping, + my_user_id, associated_block_id, associated_session_id, associated_retry_id, - task_hash: associated_task_id, - from, - to, - payload: bincode2::serialize(&msg).expect("Failed to serialize message"), - from_network_id: from_account_id, - to_network_id: to_account_id, - }; - - if let Err(err) = network.send_message(msg).await { + associated_task_id, + MultiplexedChannelMessage::Channel1, + ) + .await + { log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); } } @@ -92,24 +102,19 @@ pub fn create_job_manager_to_async_protocol_channel_split< let voting_task = async move { while let Some(msg) = rx_to_outbound_2.recv().await { - let from = msg.sender(); - let to = msg.receiver(); - let (to_account_id, from_account_id) = - get_to_and_from_account_id(&user_id_mapping, from, to); - let msg = SplitChannelMessage::::Channel2(msg); - let msg = GadgetProtocolMessage { + if let Err(err) = wrap_message_and_forward_to_network::<_, C1, C2, (), _>( + msg, + &network_clone, + &*user_id_mapping_clone, + my_user_id, associated_block_id, associated_session_id, associated_retry_id, - task_hash: associated_task_id, - from, - to, - payload: bincode2::serialize(&msg).expect("Failed to serialize message"), - from_network_id: from_account_id, - to_network_id: to_account_id, - }; - - if let Err(err) = network_clone.send_message(msg).await { + associated_task_id, + MultiplexedChannelMessage::Channel2, + ) + .await + { log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); } } @@ -141,34 +146,24 @@ pub fn get_to_and_from_account_id( (to_account_id, from_account_id) } -pub trait HasSenderAndReceiver { - fn sender(&self) -> UserID; - fn receiver(&self) -> Option; -} - -impl HasSenderAndReceiver for Msg { - fn sender(&self) -> UserID { - self.sender as UserID - } - fn receiver(&self) -> Option { - self.receiver.map(|r| r as UserID) - } -} - -impl HasSenderAndReceiver for () { - fn sender(&self) -> UserID { - unimplemented!("Stub implementation") +impl MaybeSenderReceiver for Msg { + fn maybe_sender(&self) -> MaybeSender { + MaybeSender::SomeoneElse(self.sender as UserID) } - fn receiver(&self) -> Option { - unimplemented!("Stub implementation") + fn maybe_receiver(&self) -> MaybeReceiver { + match self.receiver { + None => MaybeReceiver::Broadcast, + Some(i) => MaybeReceiver::P2P(i as UserID), + } } } #[derive(Serialize, Deserialize, Debug)] -pub enum SplitChannelMessage { +pub enum MultiplexedChannelMessage { Channel1(C1), Channel2(C2), + Channel3(C3), } #[derive(Debug, Serialize, Deserialize)] @@ -439,7 +434,7 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< O: InnerMessage + MaybeSenderReceiver + Send + 'static, I: InnerMessage + InnerMessageFromInbound + MaybeSenderReceiver + Send + 'static, >( - mut rx_gadget: CloneableUnboundedReceiver, + mut rx_gadget: UnboundedReceiver, associated_block_id: ::Clock, associated_retry_id: ::RetryID, associated_session_id: ::SessionID, @@ -459,14 +454,16 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< // Take the messages from the gadget and send them to the async protocol tokio::task::spawn(async move { let mut id = 0; - while let Some(msg_orig) = rx_gadget.next().await { + while let Some(msg_orig) = rx_gadget.recv().await { if msg_orig.payload.is_empty() { log::warn!(target: "gadget", "Received empty message from Peer {}", msg_orig.from); continue; } - match bincode2::deserialize::>(&msg_orig.payload) { + match bincode2::deserialize::>( + &msg_orig.payload, + ) { Ok(msg) => match msg { - SplitChannelMessage::Channel1(msg) => { + MultiplexedChannelMessage::Channel1(msg) => { let msg_type = if msg_orig.to.is_some() { MessageType::P2P } else { @@ -482,11 +479,14 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< id += 1; } - SplitChannelMessage::Channel2(msg) => { + MultiplexedChannelMessage::Channel2(msg) => { if tx_to_async_proto_2.unbounded_send(msg).is_err() { log::error!(target: "gadget", "Failed to send C2 message to protocol"); } } + _ => { + unreachable!("We only have two channels") + } }, Err(err) => { log::error!(target: "gadget", "Failed to deserialize message: {err:?}"); @@ -513,27 +513,19 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< tokio::task::spawn(async move { let offline_task = async move { while let Some(msg) = rx_to_outbound_1.next().await { - let from = msg.maybe_sender(); - let to = msg.maybe_receiver(); - let (to_account_id, from_account_id) = get_to_and_from_account_id( - &user_id_mapping_clone, - from.as_user_id().unwrap_or(my_user_id), - to.as_user_id(), - ); - let msg = SplitChannelMessage::::Channel1(msg.inner_message()); - let msg = GadgetProtocolMessage { + if let Err(err) = wrap_message_and_forward_to_network::<_, O::Inner, C2, (), _>( + msg, + &network, + &user_id_mapping, + my_user_id, associated_block_id, associated_session_id, associated_retry_id, - task_hash: associated_task_id, - from: from.as_user_id().unwrap_or(my_user_id), - to: to.as_user_id(), - payload: bincode2::serialize(&msg).expect("Failed to serialize message"), - from_network_id: from_account_id, - to_network_id: to_account_id, - }; - - if let Err(err) = network.send_message(msg).await { + associated_task_id, + |m| MultiplexedChannelMessage::Channel1(m.inner_message()), + ) + .await + { log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); } } @@ -541,27 +533,19 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< let voting_task = async move { while let Some(msg) = rx_to_outbound_2.next().await { - let from = msg.maybe_sender(); - let to = msg.maybe_receiver(); - let (to_account_id, from_account_id) = get_to_and_from_account_id( - &user_id_mapping, - from.as_user_id().unwrap_or(my_user_id), - to.as_user_id(), - ); - let msg = SplitChannelMessage::::Channel2(msg); - let msg = GadgetProtocolMessage { + if let Err(err) = wrap_message_and_forward_to_network::<_, O::Inner, C2, (), _>( + msg, + &network_clone, + &user_id_mapping_clone, + my_user_id, associated_block_id, associated_session_id, associated_retry_id, - task_hash: associated_task_id, - from: from.as_user_id().unwrap_or(my_user_id), - to: to.as_user_id(), - payload: bincode2::serialize(&msg).expect("Failed to serialize message"), - from_network_id: from_account_id, - to_network_id: to_account_id, - }; - - if let Err(err) = network_clone.send_message(msg).await { + associated_task_id, + |m| MultiplexedChannelMessage::Channel2(m), + ) + .await + { log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); } } @@ -577,3 +561,228 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< rx_for_async_proto_2, ) } + +pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< + N: Network + 'static, + C2: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, + O1: InnerMessage + MaybeSenderReceiver + Send + 'static, + I1: InnerMessage + InnerMessageFromInbound + MaybeSenderReceiver + Send + 'static, + O2: InnerMessage + MaybeSenderReceiver + Send + 'static, + I2: InnerMessage + InnerMessageFromInbound + MaybeSenderReceiver + Send + 'static, +>( + mut rx_gadget: UnboundedReceiver, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + user_id_mapping: Arc>, + my_account_id: sp_core::ecdsa::Public, + network: N, +) -> ( + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver>, + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver>, + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver, +) { + let (tx_to_async_proto_1, rx_for_async_proto_1) = futures::channel::mpsc::unbounded(); + let (tx_to_async_proto_2, rx_for_async_proto_2) = futures::channel::mpsc::unbounded(); + let (tx_to_async_proto_3, rx_for_async_proto_3) = futures::channel::mpsc::unbounded(); + + // Take the messages from the gadget and send them to the async protocol + tokio::task::spawn(async move { + let mut id = 0; + while let Some(msg_orig) = rx_gadget.recv().await { + if msg_orig.payload.is_empty() { + log::warn!(target: "gadget", "Received empty message from Peer {}", msg_orig.from); + continue; + } + match bincode2::deserialize::>( + &msg_orig.payload, + ) { + Ok(msg) => match msg { + MultiplexedChannelMessage::Channel1(msg) => { + let msg_type = if msg_orig.to.is_some() { + MessageType::P2P + } else { + MessageType::Broadcast + }; + + let incoming = + I1::from_inbound(id, msg_orig.from as PartyIndex, msg_type, msg); + + if tx_to_async_proto_1.unbounded_send(Ok(incoming)).is_err() { + log::error!(target: "gadget", "Failed to send Incoming message to protocol"); + } + + id += 1; + } + MultiplexedChannelMessage::Channel2(msg) => { + let msg_type = if msg_orig.to.is_some() { + MessageType::P2P + } else { + MessageType::Broadcast + }; + + let incoming = + I2::from_inbound(id, msg_orig.from as PartyIndex, msg_type, msg); + + if tx_to_async_proto_2.unbounded_send(Ok(incoming)).is_err() { + log::error!(target: "gadget", "Failed to send Incoming message to protocol"); + } + + id += 1; + } + MultiplexedChannelMessage::Channel3(msg) => { + if tx_to_async_proto_3.unbounded_send(msg).is_err() { + log::error!(target: "gadget", "Failed to send C2 message to protocol"); + } + } + }, + + Err(err) => { + log::error!(target: "gadget", "Failed to deserialize message: {err:?}"); + } + } + } + }); + + let (tx_to_outbound_1, mut rx_to_outbound_1) = futures::channel::mpsc::unbounded::(); + let (tx_to_outbound_2, mut rx_to_outbound_2) = futures::channel::mpsc::unbounded::(); + let (tx_to_outbound_3, mut rx_to_outbound_3) = futures::channel::mpsc::unbounded::(); + + let my_user_id = user_id_mapping + .iter() + .find_map(|(user_id, account_id)| { + if *account_id == my_account_id { + Some(*user_id) + } else { + None + } + }) + .expect("Failed to find my user id"); + // Take the messages from the async protocol and send them to the gadget + tokio::task::spawn(async move { + let ref user_id_mapping = user_id_mapping; + let ref network = network; + let task0 = async move { + while let Some(msg) = rx_to_outbound_1.next().await { + if let Err(err) = + wrap_message_and_forward_to_network::<_, O1::Inner, O2::Inner, C2, _>( + msg, + network, + user_id_mapping, + my_user_id, + associated_block_id, + associated_session_id, + associated_retry_id, + associated_task_id, + |m| MultiplexedChannelMessage::Channel1(m.inner_message()), + ) + .await + { + log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + } + } + }; + + let task1 = async move { + while let Some(msg) = rx_to_outbound_2.next().await { + if let Err(err) = + wrap_message_and_forward_to_network::<_, O1::Inner, O2::Inner, C2, _>( + msg, + network, + user_id_mapping, + my_user_id, + associated_block_id, + associated_session_id, + associated_retry_id, + associated_task_id, + |m| MultiplexedChannelMessage::Channel2(m.inner_message()), + ) + .await + { + log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + } + } + }; + + let task2 = async move { + while let Some(msg) = rx_to_outbound_3.next().await { + if let Err(err) = + wrap_message_and_forward_to_network::<_, O1::Inner, O2::Inner, C2, _>( + msg, + network, + user_id_mapping, + my_user_id, + associated_block_id, + associated_session_id, + associated_retry_id, + associated_task_id, + |m| MultiplexedChannelMessage::Channel3(m), + ) + .await + { + log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + } + } + }; + + tokio::join!(task0, task1, task2); + }); + + ( + tx_to_outbound_1, + rx_for_async_proto_1, + tx_to_outbound_2, + rx_for_async_proto_2, + tx_to_outbound_3, + rx_for_async_proto_3, + ) +} + +async fn wrap_message_and_forward_to_network< + N: Network, + C1: Serialize, + C2: Serialize, + C3: Serialize, + M, +>( + msg: M, + network: &N, + user_id_mapping: &HashMap, + my_user_id: UserID, + associated_block_id: ::Clock, + associated_session_id: ::SessionID, + associated_retry_id: ::RetryID, + associated_task_id: ::TaskID, + splitter: impl FnOnce(M) -> MultiplexedChannelMessage, +) -> Result<(), crate::Error> +where + M: MaybeSenderReceiver + Send + 'static, +{ + let from = msg.maybe_sender(); + let to = msg.maybe_receiver(); + let (to_account_id, from_account_id) = get_to_and_from_account_id( + user_id_mapping, + from.as_user_id().unwrap_or(my_user_id), + to.as_user_id(), + ); + + // let message_multiplexed = MultiplexedChannelMessage::::Channel1(msg.inner_message()); + let message_multiplexed = splitter(msg); + + let msg = GadgetProtocolMessage { + associated_block_id, + associated_session_id, + associated_retry_id, + task_hash: associated_task_id, + from: from.as_user_id().unwrap_or(my_user_id), + to: to.as_user_id(), + payload: bincode2::serialize(&message_multiplexed).expect("Failed to serialize message"), + from_network_id: from_account_id, + to_network_id: to_account_id, + }; + network.send_message(msg).await +} diff --git a/protocols/bls/src/protocol/keygen.rs b/protocols/bls/src/protocol/keygen.rs index 380f1d7d1..708b4b958 100644 --- a/protocols/bls/src/protocol/keygen.rs +++ b/protocols/bls/src/protocol/keygen.rs @@ -2,7 +2,7 @@ use crate::protocol::state_machine::payloads::RoundPayload; use crate::protocol::state_machine::BlsStateMachine; use gadget_common::gadget::message::UserID; use gadget_common::prelude::*; -use gadget_common::sp_core::{ecdsa, keccak_256, ByteArray}; +use gadget_common::sp_core::{ecdsa, keccak_256, ByteArray, Pair}; use itertools::Itertools; use round_based::Msg; use std::collections::{BTreeMap, HashMap}; @@ -87,6 +87,7 @@ where let job_id = additional_params.job_id; let pallet_tx = config.pallet_tx.clone(); let role_type = additional_params.role_type; + let id = keystore.pair().public(); let (i, t, n) = ( additional_params.i, additional_params.t, @@ -115,6 +116,7 @@ where associated_session_id, associated_task_id, user_id_to_account_id.clone(), + id, network.clone(), ); diff --git a/protocols/bls/src/protocol/signing.rs b/protocols/bls/src/protocol/signing.rs index ab07a4c45..5aa11b09d 100644 --- a/protocols/bls/src/protocol/signing.rs +++ b/protocols/bls/src/protocol/signing.rs @@ -6,7 +6,7 @@ use gadget_common::gadget::message::{GadgetProtocolMessage, UserID}; use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; -use gadget_common::sp_core::{ecdsa, keccak_256}; +use gadget_common::sp_core::{ecdsa, keccak_256, Pair}; use gadget_common::{ Backend, Block, BuiltExecutableJobWrapper, Error, JobBuilder, JobError, ProtocolWorkManager, WorkManagerInterface, @@ -120,6 +120,7 @@ where let role_type = additional_params.role_type; let job_id = additional_params.job_id; let logger = config.logger.clone(); + let id = config.key_store.pair().public(); Ok(JobBuilder::new() .protocol(async move { @@ -136,6 +137,7 @@ where associated_session_id, associated_task_id, additional_params.user_id_to_account_id_mapping.clone(), + id, network, ); diff --git a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs index aa2ecec2c..008c3724c 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs @@ -9,7 +9,6 @@ use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; use gadget_common::prelude::FullProtocolConfig; -use gadget_common::utils::CloneableUnboundedReceiver; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; @@ -144,8 +143,6 @@ where Ok(JobBuilder::new() .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); - let protocol_message_channel = - CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( "Starting KeyRefresh Protocol with params: i={i}, t={t}, n={n}" )); @@ -166,7 +163,7 @@ where Outgoing>, Incoming>, >( - protocol_message_channel.clone(), + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index ed0648f4f..5c610dd82 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -11,7 +11,6 @@ use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; use gadget_common::prelude::FullProtocolConfig; use gadget_common::prelude::*; -use gadget_common::utils::CloneableUnboundedReceiver; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; @@ -169,8 +168,6 @@ where Ok(JobBuilder::new() .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); - let protocol_message_channel = - CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( "Starting Key Rotation Protocol with params: i={i}, t={t}" @@ -189,7 +186,7 @@ where RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { let (_, _, party) = create_party::>( - protocol_message_channel.clone(), + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, @@ -214,7 +211,7 @@ where RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { let (_, _, party) = create_party::>( - protocol_message_channel.clone(), + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, @@ -239,7 +236,7 @@ where RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { let (_, _, party) = create_party::>( - protocol_message_channel.clone(), + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 05fb67d4f..221d3a72e 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -2,8 +2,10 @@ use dfns_cggmp21::generic_ec::Curve; use dfns_cggmp21::key_refresh::msg::aux_only; use dfns_cggmp21::keygen::msg::threshold::Msg; +use dfns_cggmp21::progress::PerfProfiler; use dfns_cggmp21::security_level::{SecurityLevel, SecurityLevel128}; use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; +use dfns_cggmp21::PregeneratedPrimes; use futures::channel::mpsc::{TryRecvError, UnboundedSender}; use futures::StreamExt; use gadget_common::client::{ @@ -16,7 +18,6 @@ use gadget_common::gadget::network::Network; use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::{ECDSAKeyStore, KeystoreBackend}; -use gadget_common::utils::CloneableUnboundedReceiver; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; @@ -178,7 +179,7 @@ where } pub fn create_party( - protocol_message_channel: CloneableUnboundedReceiver, + protocol_message_channel: UnboundedReceiver, associated_block_id: ::Clock, associated_retry_id: ::RetryID, associated_session_id: ::SessionID, @@ -265,8 +266,6 @@ where Ok(JobBuilder::new() .protocol(async move { let rng = rand::rngs::StdRng::from_entropy(); - let protocol_message_channel = - CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( "Starting Keygen Protocol with params: i={i}, t={t}, n={n}" )); @@ -280,51 +279,10 @@ where let aux_eid = dfns_cggmp21::ExecutionId::new(&aux_eid_bytes); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - let incomplete_key_share: Vec = match role_type { + let (key_share, serialized_public_key, tx2, rx2) = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - let (_, _, party) = create_party::< - Secp256k1, - _, - SecurityLevel128, - Msg, - >( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - ); - run_and_serialize_keygen(&mut tracer, eid, i, n, t, party, rng.clone()).await? - } - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - let (_, _, party) = create_party::< - Secp256r1, - _, - SecurityLevel128, - Msg, - >( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - ); - run_and_serialize_keygen(&mut tracer, eid, i, n, t, party, rng.clone()).await? - } - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - let (_, _, party) = create_party::< - Stark, - _, - SecurityLevel128, - Msg, - >( - protocol_message_channel.clone(), + let (tx0, rx0, tx1, rx1, tx2, rx2) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io_triplex( + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, @@ -333,62 +291,17 @@ where my_role_id, network.clone(), ); - run_and_serialize_keygen(&mut tracer, eid, i, n, t, party, rng.clone()).await? - } - _ => unreachable!("Invalid role type"), - }; - let perf_report = tracer.get_report().map_err(|err| JobError { - reason: format!("Keygen protocol error: {err:?}"), - })?; - logger.trace(format!("Incomplete Keygen protocol report: {perf_report}")); - logger.debug("Finished AsyncProtocol - Incomplete Keygen"); - let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - - let pregenerated_primes_key = - keccak_256(&[&b"dfns-cggmp21-keygen-primes"[..], &job_id_bytes[..]].concat()); - let now = tokio::time::Instant::now(); - let pregenerated_primes = tokio::task::spawn_blocking(|| { - let mut rng = OsRng; - dfns_cggmp21::PregeneratedPrimes::::generate(&mut rng) - }) - .await - .map_err(|err| JobError { - reason: format!("Failed to generate pregenerated primes: {err:?}"), - })?; + let delivery = (rx0, tx0); + let party = MpcParty::, _, _>::connected(delivery); + let incomplete_key_share = run_and_serialize_keygen::(&mut tracer, eid, i, n, t, party, rng.clone()).await?; + let (mut tracer, pregenerated_primes) = handle_post_incomplete_keygen(&mut tracer, &logger, &job_id_bytes, &key_store2).await?; - let elapsed = now.elapsed(); - logger.debug(format!("Pregenerated primes took {elapsed:?}")); + logger.info(format!("Will now run Keygen protocol: {role_type:?}")); - key_store2 - .set(&pregenerated_primes_key, pregenerated_primes.clone()) - .await - .map_err(|err| JobError { - reason: format!("Failed to store pregenerated primes: {err:?}"), - })?; - - logger.info(format!("Will now run Keygen protocol: {role_type:?}")); - let (mut pubkey_gossip_tx, mut pubkey_gossip_rx) = (None, None); - let (key_share, serialized_public_key) = match role_type { - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - let (tx, rx, party) = create_party::< - Secp256k1, - _, - SecurityLevel128, - aux_only::Msg, - >( - protocol_message_channel.clone(), - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - ); - pubkey_gossip_tx = Some(tx); - pubkey_gossip_rx = Some(rx); - run_and_serialize_keyrefresh::( + let delivery = (rx1, tx1); + let party = MpcParty::, _, _>::connected(delivery); + let (key_share, serialized_public_key) = run_and_serialize_keyrefresh::( &logger, incomplete_key_share, pregenerated_primes, @@ -399,16 +312,13 @@ where party, rng, ) - .await? + .await?; + + (key_share, serialized_public_key, tx2, rx2) } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - let (tx, rx, party) = create_party::< - Secp256r1, - _, - SecurityLevel128, - aux_only::Msg, - >( - protocol_message_channel.clone(), + let (tx0, rx0, tx1, rx1, tx2, rx2) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io_triplex( + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, @@ -417,9 +327,16 @@ where my_role_id, network.clone(), ); - pubkey_gossip_tx = Some(tx); - pubkey_gossip_rx = Some(rx); - run_and_serialize_keyrefresh::( + let delivery = (rx0, tx0); + let party = MpcParty::, _, _>::connected(delivery); + let incomplete_key_share = run_and_serialize_keygen::(&mut tracer, eid, i, n, t, party, rng.clone()).await?; + let (mut tracer, pregenerated_primes) = handle_post_incomplete_keygen(&mut tracer, &logger, &job_id_bytes, &key_store2).await?; + + logger.info(format!("Will now run Keygen protocol: {role_type:?}")); + + let delivery = (rx1, tx1); + let party = MpcParty::, _, _>::connected(delivery); + let (key_share, serialized_public_key) = run_and_serialize_keyrefresh::( &logger, incomplete_key_share, pregenerated_primes, @@ -430,16 +347,13 @@ where party, rng, ) - .await? + .await?; + + (key_share, serialized_public_key, tx2, rx2) } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - let (tx, rx, party) = create_party::< - Stark, - _, - SecurityLevel128, - aux_only::Msg, - >( - protocol_message_channel.clone(), + let (tx0, rx0, tx1, rx1, tx2, rx2) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io_triplex( + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, @@ -448,9 +362,16 @@ where my_role_id, network.clone(), ); - pubkey_gossip_tx = Some(tx); - pubkey_gossip_rx = Some(rx); - run_and_serialize_keyrefresh::( + let delivery = (rx0, tx0); + let party = MpcParty::, _, _>::connected(delivery); + let incomplete_key_share = run_and_serialize_keygen::(&mut tracer, eid, i, n, t, party, rng.clone()).await?; + let (mut tracer, pregenerated_primes) = handle_post_incomplete_keygen(&mut tracer, &logger, &job_id_bytes, &key_store2).await?; + + logger.info(format!("Will now run Keygen protocol: {role_type:?}")); + + let delivery = (rx1, tx1); + let party = MpcParty::, _, _>::connected(delivery); + let (key_share, serialized_public_key) = run_and_serialize_keyrefresh::( &logger, incomplete_key_share, pregenerated_primes, @@ -461,35 +382,29 @@ where party, rng, ) - .await? + .await?; + + (key_share, serialized_public_key, tx2, rx2) } - _ => Err(JobError { - reason: "Invalid role type".to_string(), - })?, + _ => unreachable!("Invalid role type"), }; logger.debug("Finished AsyncProtocol - Keygen"); - if let (Some(tx), Some(rx)) = (pubkey_gossip_tx, pubkey_gossip_rx) { - let job_result = handle_public_key_gossip( - key_store2, - &logger, - &key_share, - &serialized_public_key, - t, - i, - tx, - rx, - ) + let job_result = handle_public_key_gossip( + key_store2, + &logger, + &key_share, + &serialized_public_key, + t, + i, + tx2, + rx2, + ) .await?; - *protocol_output.lock().await = Some((key_share, job_result)); - Ok(()) - } else { - Err(JobError { - reason: "Failed to create gossip channels".to_string(), - })? - } + *protocol_output.lock().await = Some((key_share, job_result)); + Ok(()) }) .post(async move { // TODO: handle protocol blames @@ -678,3 +593,40 @@ fn verify_generated_dkg_key_ecdsa( data.threshold + 1 )); } + +async fn handle_post_incomplete_keygen( + tracer: &mut PerfProfiler, + logger: &DebugLogger, + job_id_bytes: &[u8], + key_store: &ECDSAKeyStore, +) -> Result<(PerfProfiler, PregeneratedPrimes), JobError> { + let perf_report = tracer.get_report().map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })?; + logger.trace(format!("Incomplete Keygen protocol report: {perf_report}")); + logger.debug("Finished AsyncProtocol - Incomplete Keygen"); + let tracer = PerfProfiler::new(); + + let pregenerated_primes_key = + keccak_256(&[&b"dfns-cggmp21-keygen-primes"[..], &job_id_bytes[..]].concat()); + let now = tokio::time::Instant::now(); + let pregenerated_primes = tokio::task::spawn_blocking(|| { + let mut rng = OsRng; + dfns_cggmp21::PregeneratedPrimes::::generate(&mut rng) + }) + .await + .map_err(|err| JobError { + reason: format!("Failed to generate pregenerated primes: {err:?}"), + })?; + + let elapsed = now.elapsed(); + logger.debug(format!("Pregenerated primes took {elapsed:?}")); + + key_store + .set(&pregenerated_primes_key, pregenerated_primes.clone()) + .await + .map_err(|err| JobError { + reason: format!("Failed to store pregenerated primes: {err:?}"), + })?; + Ok((tracer, pregenerated_primes)) +} diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index 20cdceab0..7e3715ed8 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -13,7 +13,6 @@ use gadget_common::gadget::work_manager::WorkManager; use gadget_common::gadget::JobInitMetadata; use gadget_common::keystore::KeystoreBackend; use gadget_common::prelude::{FullProtocolConfig, Network}; -use gadget_common::utils::CloneableUnboundedReceiver; use gadget_common::Block; use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; @@ -186,9 +185,6 @@ where Ok(JobBuilder::new() .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); - let protocol_message_channel = - CloneableUnboundedReceiver::from(protocol_message_channel); - logger.info(format!( "Starting Signing Protocol with params: i={i}, t={t}" )); @@ -207,7 +203,7 @@ where RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { let (_, _, party) = create_party::>( - protocol_message_channel.clone(), + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, @@ -232,7 +228,7 @@ where RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { let (_, _, party) = create_party::>( - protocol_message_channel.clone(), + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, @@ -257,7 +253,7 @@ where RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { let (_, _, party) = create_party::>( - protocol_message_channel.clone(), + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, diff --git a/protocols/zcash-frost/src/protocol/keygen.rs b/protocols/zcash-frost/src/protocol/keygen.rs index 0f532e176..cdcc0aac3 100644 --- a/protocols/zcash-frost/src/protocol/keygen.rs +++ b/protocols/zcash-frost/src/protocol/keygen.rs @@ -163,8 +163,6 @@ where Ok(JobBuilder::new() .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); - let protocol_message_channel = - gadget_common::utils::CloneableUnboundedReceiver::from(protocol_message_channel); logger.info(format!( "Starting Keygen Protocol with params: i={i}, t={t}, n={n}" )); @@ -180,7 +178,7 @@ where Outgoing, Incoming, >( - protocol_message_channel.clone(), + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, diff --git a/protocols/zcash-frost/src/protocol/sign.rs b/protocols/zcash-frost/src/protocol/sign.rs index 2d3928ef6..ae00aae33 100644 --- a/protocols/zcash-frost/src/protocol/sign.rs +++ b/protocols/zcash-frost/src/protocol/sign.rs @@ -182,9 +182,6 @@ where Ok(JobBuilder::new() .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); - let protocol_message_channel = - gadget_common::utils::CloneableUnboundedReceiver::from(protocol_message_channel); - logger.info(format!( "Starting Signing Protocol with params: i={i}, t={t}" )); @@ -200,7 +197,7 @@ where Outgoing, Incoming, >( - protocol_message_channel.clone(), + protocol_message_channel, associated_block_id, associated_retry_id, associated_session_id, From d51dc72d89b9bbe2ab370765d5a9093af1554819 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 28 Feb 2024 16:04:35 -0500 Subject: [PATCH 59/66] Refactor DFNS keygen --- .../dfns-cggmp21/src/protocols/keygen.rs | 164 +++++++++++------- 1 file changed, 99 insertions(+), 65 deletions(-) diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 221d3a72e..28747e2b5 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -277,11 +277,11 @@ where let mix = keccak_256(b"dnfs-cggmp21-keygen-aux"); let aux_eid_bytes = [&job_id_bytes[..], &mix[..]].concat(); let aux_eid = dfns_cggmp21::ExecutionId::new(&aux_eid_bytes); - let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); + let tracer = dfns_cggmp21::progress::PerfProfiler::new(); let (key_share, serialized_public_key, tx2, rx2) = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - let (tx0, rx0, tx1, rx1, tx2, rx2) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io_triplex( + run_full_keygen_protocol::( protocol_message_channel, associated_block_id, associated_retry_id, @@ -290,34 +290,22 @@ where mapping.clone(), my_role_id, network.clone(), - ); - - let delivery = (rx0, tx0); - let party = MpcParty::, _, _>::connected(delivery); - let incomplete_key_share = run_and_serialize_keygen::(&mut tracer, eid, i, n, t, party, rng.clone()).await?; - let (mut tracer, pregenerated_primes) = handle_post_incomplete_keygen(&mut tracer, &logger, &job_id_bytes, &key_store2).await?; - - logger.info(format!("Will now run Keygen protocol: {role_type:?}")); - - let delivery = (rx1, tx1); - let party = MpcParty::, _, _>::connected(delivery); - let (key_share, serialized_public_key) = run_and_serialize_keyrefresh::( - &logger, - incomplete_key_share, - pregenerated_primes, - &mut tracer, + tracer, + eid, aux_eid, i, n, - party, + t, rng, + &logger, + &job_id_bytes, + &key_store, + role_type, ) - .await?; - - (key_share, serialized_public_key, tx2, rx2) + .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - let (tx0, rx0, tx1, rx1, tx2, rx2) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io_triplex( + run_full_keygen_protocol::( protocol_message_channel, associated_block_id, associated_retry_id, @@ -326,33 +314,22 @@ where mapping.clone(), my_role_id, network.clone(), - ); - let delivery = (rx0, tx0); - let party = MpcParty::, _, _>::connected(delivery); - let incomplete_key_share = run_and_serialize_keygen::(&mut tracer, eid, i, n, t, party, rng.clone()).await?; - let (mut tracer, pregenerated_primes) = handle_post_incomplete_keygen(&mut tracer, &logger, &job_id_bytes, &key_store2).await?; - - logger.info(format!("Will now run Keygen protocol: {role_type:?}")); - - let delivery = (rx1, tx1); - let party = MpcParty::, _, _>::connected(delivery); - let (key_share, serialized_public_key) = run_and_serialize_keyrefresh::( - &logger, - incomplete_key_share, - pregenerated_primes, - &mut tracer, + tracer, + eid, aux_eid, i, n, - party, + t, rng, + &logger, + &job_id_bytes, + &key_store, + role_type, ) - .await?; - - (key_share, serialized_public_key, tx2, rx2) + .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - let (tx0, rx0, tx1, rx1, tx2, rx2) = gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io_triplex( + run_full_keygen_protocol::( protocol_message_channel, associated_block_id, associated_retry_id, @@ -361,30 +338,19 @@ where mapping.clone(), my_role_id, network.clone(), - ); - let delivery = (rx0, tx0); - let party = MpcParty::, _, _>::connected(delivery); - let incomplete_key_share = run_and_serialize_keygen::(&mut tracer, eid, i, n, t, party, rng.clone()).await?; - let (mut tracer, pregenerated_primes) = handle_post_incomplete_keygen(&mut tracer, &logger, &job_id_bytes, &key_store2).await?; - - logger.info(format!("Will now run Keygen protocol: {role_type:?}")); - - let delivery = (rx1, tx1); - let party = MpcParty::, _, _>::connected(delivery); - let (key_share, serialized_public_key) = run_and_serialize_keyrefresh::( - &logger, - incomplete_key_share, - pregenerated_primes, - &mut tracer, + tracer, + eid, aux_eid, i, n, - party, + t, rng, + &logger, + &job_id_bytes, + &key_store, + role_type, ) - .await?; - - (key_share, serialized_public_key, tx2, rx2) + .await? } _ => unreachable!("Invalid role type"), }; @@ -392,7 +358,7 @@ where logger.debug("Finished AsyncProtocol - Keygen"); let job_result = handle_public_key_gossip( - key_store2, + key_store, &logger, &key_share, &serialized_public_key, @@ -401,7 +367,7 @@ where tx2, rx2, ) - .await?; + .await?; *protocol_output.lock().await = Some((key_share, job_result)); Ok(()) @@ -410,7 +376,7 @@ where // TODO: handle protocol blames // Store the keys locally, as well as submitting them to the blockchain if let Some((local_key, job_result)) = protocol_output_clone.lock().await.take() { - key_store + key_store2 .set_job_result(additional_params.job_id, local_key) .await .map_err(|err| JobError { @@ -630,3 +596,71 @@ async fn handle_post_incomplete_keygen( })?; Ok((tracer, pregenerated_primes)) } + +async fn run_full_keygen_protocol<'a, E: Curve, KBE: KeystoreBackend, N: Network>( + protocol_message_channel: UnboundedReceiver, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + mapping: Arc>, + my_role_id: ecdsa::Public, + network: N, + mut tracer: PerfProfiler, + eid: dfns_cggmp21::ExecutionId<'a>, + aux_eid: dfns_cggmp21::ExecutionId<'a>, + i: u16, + n: u16, + t: u16, + rng: StdRng, + logger: &DebugLogger, + job_id_bytes: &[u8], + key_store: &ECDSAKeyStore, + role_type: RoleType, +) -> Result< + ( + Vec, + Vec, + UnboundedSender, + futures::channel::mpsc::UnboundedReceiver, + ), + JobError, +> { + let (tx0, rx0, tx1, rx1, tx2, rx2) = + gadget_common::channels::create_job_manager_to_async_protocol_channel_split_io_triplex( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping, + my_role_id, + network, + ); + let delivery = (rx0, tx0); + let party = MpcParty::, _, _>::connected(delivery); + let incomplete_key_share = + run_and_serialize_keygen::(&mut tracer, eid, i, n, t, party, rng.clone()).await?; + let (mut tracer, pregenerated_primes) = + handle_post_incomplete_keygen::(&mut tracer, &logger, &job_id_bytes, &key_store) + .await?; + + logger.info(format!("Will now run Keygen protocol: {role_type:?}")); + + let delivery = (rx1, tx1); + let party = MpcParty::, _, _>::connected(delivery); + let (key_share, serialized_public_key) = run_and_serialize_keyrefresh::( + &logger, + incomplete_key_share, + pregenerated_primes, + &mut tracer, + aux_eid, + i, + n, + party, + rng, + ) + .await?; + + Ok((key_share, serialized_public_key, tx2, rx2)) +} From 7e4f5698eb15254445d6a3c830462558200c0f69 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 28 Feb 2024 16:44:10 -0500 Subject: [PATCH 60/66] Allow generalization of SecurityLevel and Digest --- .../dfns-cggmp21/src/protocols/keygen.rs | 262 +++++++++++------- 1 file changed, 157 insertions(+), 105 deletions(-) diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 28747e2b5..e7b62e14f 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -1,11 +1,15 @@ use dfns_cggmp21::generic_ec::Curve; use dfns_cggmp21::key_refresh::msg::aux_only; +use dfns_cggmp21::key_refresh::AuxInfoGenerationBuilder; use dfns_cggmp21::keygen::msg::threshold::Msg; +use dfns_cggmp21::keygen::KeygenBuilder; use dfns_cggmp21::progress::PerfProfiler; use dfns_cggmp21::security_level::{SecurityLevel, SecurityLevel128}; use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; use dfns_cggmp21::PregeneratedPrimes; +use digest::typenum::U32; +use digest::Digest; use futures::channel::mpsc::{TryRecvError, UnboundedSender}; use futures::StreamExt; use gadget_common::client::{ @@ -44,6 +48,9 @@ use tokio::sync::mpsc::UnboundedReceiver; use gadget_common::channels::PublicKeyGossipMessage; +type DefaultSecurityLevel = SecurityLevel128; +type DefaultCryptoHasher = Sha256; + pub async fn create_next_job< B: Block, BE: Backend + 'static, @@ -106,20 +113,28 @@ pub struct DfnsCGGMP21KeygenExtraParams { user_id_to_account_id_mapping: Arc>, } -pub async fn run_and_serialize_keygen<'r, E: Curve, D, R>( - tracer: &mut dfns_cggmp21::progress::PerfProfiler, +pub async fn run_and_serialize_keygen< + 'r, + E: Curve, + S: SecurityLevel, + H: Digest + Clone + Send + 'static, + D, + R, +>( + tracer: &mut PerfProfiler, eid: dfns_cggmp21::ExecutionId<'r>, i: u16, n: u16, t: u16, - party: MpcParty, D>, + party: MpcParty, D>, mut rng: R, ) -> Result, JobError> where - D: Delivery>, + D: Delivery>, R: RngCore + CryptoRng, { - let incomplete_key_share = dfns_cggmp21::keygen::(eid, i, n) + let builder = KeygenBuilder::::new(eid, i, n); + let incomplete_key_share = builder .set_progress_tracer(tracer) .set_threshold(t) .start(&mut rng, party) @@ -132,33 +147,42 @@ where }) } -pub async fn run_and_serialize_keyrefresh<'r, E: Curve, D>( +pub async fn run_and_serialize_keyrefresh< + 'r, + E: Curve, + S: SecurityLevel, + H: Digest + Clone + Send + 'static, + D, +>( logger: &DebugLogger, incomplete_key_share: Vec, - pregenerated_primes: dfns_cggmp21::PregeneratedPrimes, - tracer: &mut dfns_cggmp21::progress::PerfProfiler, + pregenerated_primes: PregeneratedPrimes, + tracer: &mut PerfProfiler, aux_eid: dfns_cggmp21::ExecutionId<'r>, i: u16, n: u16, - party: MpcParty, D>, + party: MpcParty, D>, mut rng: StdRng, ) -> Result<(Vec, Vec), JobError> where - D: Delivery>, + D: Delivery>, { let incomplete_key_share: dfns_cggmp21::key_share::Valid< dfns_cggmp21::key_share::DirtyIncompleteKeyShare<_>, > = bincode2::deserialize(&incomplete_key_share).map_err(|err| JobError { reason: format!("Keygen protocol error: {err:?}"), })?; - let aux_info = - dfns_cggmp21::aux_info_gen::(aux_eid, i, n, pregenerated_primes) - .set_progress_tracer(tracer) - .start(&mut rng, party) - .await - .map_err(|err| JobError { - reason: format!("Aux info protocol error: {err:?}"), - })?; + + let aux_info_builder = + AuxInfoGenerationBuilder::::new_aux_gen(aux_eid, i, n, pregenerated_primes); + + let aux_info = aux_info_builder + .set_progress_tracer(tracer) + .start(&mut rng, party) + .await + .map_err(|err| JobError { + reason: format!("Aux info protocol error: {err:?}"), + })?; let perf_report = tracer.get_report().map_err(|err| JobError { reason: format!("Aux info protocol error: {err:?}"), })?; @@ -166,10 +190,11 @@ where logger.debug("Finished AsyncProtocol - Aux Info"); let key_share = - dfns_cggmp21::KeyShare::::make(incomplete_key_share, aux_info) - .map_err(|err| JobError { + dfns_cggmp21::KeyShare::::make(incomplete_key_share, aux_info).map_err(|err| { + JobError { reason: format!("Key share error: {err:?}"), - })?; + } + })?; // Serialize the key share and the public key bincode2::serialize(&key_share) .map(|ks| (ks, key_share.shared_public_key().to_bytes(true).to_vec())) @@ -279,81 +304,100 @@ where let aux_eid = dfns_cggmp21::ExecutionId::new(&aux_eid_bytes); let tracer = dfns_cggmp21::progress::PerfProfiler::new(); - let (key_share, serialized_public_key, tx2, rx2) = match role_type { - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - run_full_keygen_protocol::( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - tracer, - eid, - aux_eid, - i, - n, - t, - rng, - &logger, - &job_id_bytes, - &key_store, - role_type, - ) - .await? - } - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - run_full_keygen_protocol::( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - tracer, - eid, - aux_eid, - i, - n, - t, - rng, - &logger, - &job_id_bytes, - &key_store, - role_type, - ) - .await? - } - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - run_full_keygen_protocol::( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - tracer, - eid, - aux_eid, - i, - n, - t, - rng, - &logger, - &job_id_bytes, - &key_store, - role_type, - ) - .await? - } - _ => unreachable!("Invalid role type"), - }; + let (key_share, serialized_public_key, tx2, rx2) = + match role_type { + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { + run_full_keygen_protocol::< + Secp256k1, + DefaultSecurityLevel, + DefaultCryptoHasher, + _, + _, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + my_role_id, + network.clone(), + tracer, + eid, + aux_eid, + i, + n, + t, + rng, + &logger, + &job_id_bytes, + &key_store, + role_type, + ) + .await? + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { + run_full_keygen_protocol::< + Secp256r1, + DefaultSecurityLevel, + DefaultCryptoHasher, + _, + _, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + my_role_id, + network.clone(), + tracer, + eid, + aux_eid, + i, + n, + t, + rng, + &logger, + &job_id_bytes, + &key_store, + role_type, + ) + .await? + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { + run_full_keygen_protocol::< + Stark, + DefaultSecurityLevel, + DefaultCryptoHasher, + _, + _, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + my_role_id, + network.clone(), + tracer, + eid, + aux_eid, + i, + n, + t, + rng, + &logger, + &job_id_bytes, + &key_store, + role_type, + ) + .await? + } + _ => unreachable!("Invalid role type"), + }; logger.debug("Finished AsyncProtocol - Keygen"); @@ -560,12 +604,12 @@ fn verify_generated_dkg_key_ecdsa( )); } -async fn handle_post_incomplete_keygen( +async fn handle_post_incomplete_keygen( tracer: &mut PerfProfiler, logger: &DebugLogger, job_id_bytes: &[u8], key_store: &ECDSAKeyStore, -) -> Result<(PerfProfiler, PregeneratedPrimes), JobError> { +) -> Result<(PerfProfiler, PregeneratedPrimes), JobError> { let perf_report = tracer.get_report().map_err(|err| JobError { reason: format!("Keygen protocol error: {err:?}"), })?; @@ -578,7 +622,7 @@ async fn handle_post_incomplete_keygen( let now = tokio::time::Instant::now(); let pregenerated_primes = tokio::task::spawn_blocking(|| { let mut rng = OsRng; - dfns_cggmp21::PregeneratedPrimes::::generate(&mut rng) + dfns_cggmp21::PregeneratedPrimes::::generate(&mut rng) }) .await .map_err(|err| JobError { @@ -597,7 +641,14 @@ async fn handle_post_incomplete_keygen( Ok((tracer, pregenerated_primes)) } -async fn run_full_keygen_protocol<'a, E: Curve, KBE: KeystoreBackend, N: Network>( +async fn run_full_keygen_protocol< + 'a, + E: Curve, + S: SecurityLevel, + H: Digest + Clone + Send + 'static, + KBE: KeystoreBackend, + N: Network, +>( protocol_message_channel: UnboundedReceiver, associated_block_id: ::Clock, associated_retry_id: ::RetryID, @@ -638,18 +689,19 @@ async fn run_full_keygen_protocol<'a, E: Curve, KBE: KeystoreBackend, N: Network network, ); let delivery = (rx0, tx0); - let party = MpcParty::, _, _>::connected(delivery); + let party = MpcParty::, _, _>::connected(delivery); let incomplete_key_share = - run_and_serialize_keygen::(&mut tracer, eid, i, n, t, party, rng.clone()).await?; + run_and_serialize_keygen::(&mut tracer, eid, i, n, t, party, rng.clone()) + .await?; let (mut tracer, pregenerated_primes) = - handle_post_incomplete_keygen::(&mut tracer, &logger, &job_id_bytes, &key_store) + handle_post_incomplete_keygen::(&mut tracer, &logger, &job_id_bytes, &key_store) .await?; logger.info(format!("Will now run Keygen protocol: {role_type:?}")); let delivery = (rx1, tx1); - let party = MpcParty::, _, _>::connected(delivery); - let (key_share, serialized_public_key) = run_and_serialize_keyrefresh::( + let party = MpcParty::, _, _>::connected(delivery); + let (key_share, serialized_public_key) = run_and_serialize_keyrefresh::( &logger, incomplete_key_share, pregenerated_primes, From 71231c04a154658488ffec403e977e9741ec887a Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Thu, 29 Feb 2024 11:11:42 -0500 Subject: [PATCH 61/66] clippy lints --- gadget-common/src/channels.rs | 64 ++++---- gadget-common/src/lib.rs | 1 + .../dfns-cggmp21/src/protocols/key_rotate.rs | 87 ++++++----- .../dfns-cggmp21/src/protocols/keygen.rs | 49 +++--- protocols/dfns-cggmp21/src/protocols/mod.rs | 6 + protocols/dfns-cggmp21/src/protocols/sign.rs | 141 ++++++++++++------ protocols/dfns-cggmp21/src/protocols/util.rs | 4 +- 7 files changed, 213 insertions(+), 139 deletions(-) diff --git a/gadget-common/src/channels.rs b/gadget-common/src/channels.rs index bac839825..87a6a1f5d 100644 --- a/gadget-common/src/channels.rs +++ b/gadget-common/src/channels.rs @@ -14,6 +14,7 @@ use std::collections::HashMap; use std::sync::Arc; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; +#[allow(clippy::too_many_arguments)] pub fn create_job_manager_to_async_protocol_channel_split< N: Network + 'static, C1: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, @@ -85,7 +86,7 @@ pub fn create_job_manager_to_async_protocol_channel_split< if let Err(err) = wrap_message_and_forward_to_network::<_, C1, C2, (), _>( msg, &network, - &*user_id_mapping, + &user_id_mapping, my_user_id, associated_block_id, associated_session_id, @@ -105,7 +106,7 @@ pub fn create_job_manager_to_async_protocol_channel_split< if let Err(err) = wrap_message_and_forward_to_network::<_, C1, C2, (), _>( msg, &network_clone, - &*user_id_mapping_clone, + &user_id_mapping_clone, my_user_id, associated_block_id, associated_session_id, @@ -428,6 +429,14 @@ impl MaybeSenderReceiver for () { } } +pub type DuplexedChannel = ( + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver>, + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver, +); + +#[allow(clippy::too_many_arguments)] pub fn create_job_manager_to_async_protocol_channel_split_io< N: Network + 'static, C2: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, @@ -439,15 +448,10 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< associated_retry_id: ::RetryID, associated_session_id: ::SessionID, associated_task_id: ::TaskID, - user_id_mapping: Arc>, - my_account_id: sp_core::ecdsa::Public, + user_id_mapping: Arc>, + my_account_id: ecdsa::Public, network: N, -) -> ( - futures::channel::mpsc::UnboundedSender, - futures::channel::mpsc::UnboundedReceiver>, - futures::channel::mpsc::UnboundedSender, - futures::channel::mpsc::UnboundedReceiver, -) { +) -> DuplexedChannel { let (tx_to_async_proto_1, rx_for_async_proto_1) = futures::channel::mpsc::unbounded(); let (tx_to_async_proto_2, rx_for_async_proto_2) = futures::channel::mpsc::unbounded(); @@ -562,9 +566,19 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< ) } +pub type TriplexedChannel = ( + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver>, + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver>, + futures::channel::mpsc::UnboundedSender, + futures::channel::mpsc::UnboundedReceiver, +); + +#[allow(clippy::too_many_arguments)] pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< N: Network + 'static, - C2: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, + C3: Serialize + DeserializeOwned + MaybeSenderReceiver + Send + 'static, O1: InnerMessage + MaybeSenderReceiver + Send + 'static, I1: InnerMessage + InnerMessageFromInbound + MaybeSenderReceiver + Send + 'static, O2: InnerMessage + MaybeSenderReceiver + Send + 'static, @@ -575,17 +589,10 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< associated_retry_id: ::RetryID, associated_session_id: ::SessionID, associated_task_id: ::TaskID, - user_id_mapping: Arc>, - my_account_id: sp_core::ecdsa::Public, + user_id_mapping: Arc>, + my_account_id: ecdsa::Public, network: N, -) -> ( - futures::channel::mpsc::UnboundedSender, - futures::channel::mpsc::UnboundedReceiver>, - futures::channel::mpsc::UnboundedSender, - futures::channel::mpsc::UnboundedReceiver>, - futures::channel::mpsc::UnboundedSender, - futures::channel::mpsc::UnboundedReceiver, -) { +) -> TriplexedChannel { let (tx_to_async_proto_1, rx_for_async_proto_1) = futures::channel::mpsc::unbounded(); let (tx_to_async_proto_2, rx_for_async_proto_2) = futures::channel::mpsc::unbounded(); let (tx_to_async_proto_3, rx_for_async_proto_3) = futures::channel::mpsc::unbounded(); @@ -598,7 +605,7 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< log::warn!(target: "gadget", "Received empty message from Peer {}", msg_orig.from); continue; } - match bincode2::deserialize::>( + match bincode2::deserialize::>( &msg_orig.payload, ) { Ok(msg) => match msg { @@ -650,7 +657,7 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< let (tx_to_outbound_1, mut rx_to_outbound_1) = futures::channel::mpsc::unbounded::(); let (tx_to_outbound_2, mut rx_to_outbound_2) = futures::channel::mpsc::unbounded::(); - let (tx_to_outbound_3, mut rx_to_outbound_3) = futures::channel::mpsc::unbounded::(); + let (tx_to_outbound_3, mut rx_to_outbound_3) = futures::channel::mpsc::unbounded::(); let my_user_id = user_id_mapping .iter() @@ -664,12 +671,12 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< .expect("Failed to find my user id"); // Take the messages from the async protocol and send them to the gadget tokio::task::spawn(async move { - let ref user_id_mapping = user_id_mapping; - let ref network = network; + let user_id_mapping = &user_id_mapping; + let network = &network; let task0 = async move { while let Some(msg) = rx_to_outbound_1.next().await { if let Err(err) = - wrap_message_and_forward_to_network::<_, O1::Inner, O2::Inner, C2, _>( + wrap_message_and_forward_to_network::<_, O1::Inner, O2::Inner, C3, _>( msg, network, user_id_mapping, @@ -690,7 +697,7 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< let task1 = async move { while let Some(msg) = rx_to_outbound_2.next().await { if let Err(err) = - wrap_message_and_forward_to_network::<_, O1::Inner, O2::Inner, C2, _>( + wrap_message_and_forward_to_network::<_, O1::Inner, O2::Inner, C3, _>( msg, network, user_id_mapping, @@ -711,7 +718,7 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< let task2 = async move { while let Some(msg) = rx_to_outbound_3.next().await { if let Err(err) = - wrap_message_and_forward_to_network::<_, O1::Inner, O2::Inner, C2, _>( + wrap_message_and_forward_to_network::<_, O1::Inner, O2::Inner, C3, _>( msg, network, user_id_mapping, @@ -742,6 +749,7 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< ) } +#[allow(clippy::too_many_arguments)] async fn wrap_message_and_forward_to_network< N: Network, C1: Serialize, diff --git a/gadget-common/src/lib.rs b/gadget-common/src/lib.rs index 59a4198df..59ffb8b26 100644 --- a/gadget-common/src/lib.rs +++ b/gadget-common/src/lib.rs @@ -24,6 +24,7 @@ pub use subxt_signer; use tokio::task::JoinError; pub use webb; +#[allow(ambiguous_glob_reexports)] pub mod prelude { pub use crate::client::*; pub use crate::config::*; diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index 5c610dd82..a1b870456 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -1,5 +1,4 @@ use crate::protocols::sign::run_and_serialize_signing; -use dfns_cggmp21::security_level::SecurityLevel128; use dfns_cggmp21::signing::msg::Msg; use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; @@ -16,8 +15,8 @@ use gadget_core::job::{BuiltExecutableJobWrapper, JobBuilder, JobError}; use gadget_core::job_manager::{ProtocolWorkManager, WorkManagerInterface}; use rand::SeedableRng; +use crate::protocols::{DefaultCryptoHasher, DefaultSecurityLevel}; use sc_client_api::Backend; -use sha2::Sha256; use sp_api::ProvideRuntimeApi; use sp_core::{ecdsa, keccak_256, Pair}; use std::collections::HashMap; @@ -184,18 +183,22 @@ where ); let signature = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - let (_, _, party) = - create_party::>( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - role_id, - network.clone(), - ); - run_and_serialize_signing::<_, SecurityLevel128, _, _>( + let (_, _, party) = create_party::< + Secp256k1, + _, + DefaultSecurityLevel, + Msg, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + role_id, + network.clone(), + ); + run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( &logger, &mut tracer, eid, @@ -209,18 +212,22 @@ where .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - let (_, _, party) = - create_party::>( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - role_id, - network.clone(), - ); - run_and_serialize_signing::<_, SecurityLevel128, _, _>( + let (_, _, party) = create_party::< + Secp256r1, + _, + DefaultSecurityLevel, + Msg, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + role_id, + network.clone(), + ); + run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( &logger, &mut tracer, eid, @@ -234,18 +241,22 @@ where .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - let (_, _, party) = - create_party::>( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - role_id, - network.clone(), - ); - run_and_serialize_signing::<_, SecurityLevel128, _, _>( + let (_, _, party) = create_party::< + Stark, + _, + DefaultSecurityLevel, + Msg, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + role_id, + network.clone(), + ); + run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( &logger, &mut tracer, eid, diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index e7b62e14f..7cf15efa6 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -5,7 +5,7 @@ use dfns_cggmp21::key_refresh::AuxInfoGenerationBuilder; use dfns_cggmp21::keygen::msg::threshold::Msg; use dfns_cggmp21::keygen::KeygenBuilder; use dfns_cggmp21::progress::PerfProfiler; -use dfns_cggmp21::security_level::{SecurityLevel, SecurityLevel128}; +use dfns_cggmp21::security_level::SecurityLevel; use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; use dfns_cggmp21::PregeneratedPrimes; use digest::typenum::U32; @@ -33,7 +33,6 @@ use rand::{CryptoRng, RngCore, SeedableRng}; use round_based_21::{Delivery, Incoming, MpcParty, Outgoing}; use sc_client_api::Backend; use serde::Serialize; -use sha2::Sha256; use sp_api::ProvideRuntimeApi; use sp_application_crypto::sp_core::keccak_256; use sp_core::{ecdsa, Pair}; @@ -46,11 +45,9 @@ use tangle_primitives::jobs::{ use tangle_primitives::roles::{RoleType, ThresholdSignatureRoleType}; use tokio::sync::mpsc::UnboundedReceiver; +use crate::protocols::{DefaultCryptoHasher, DefaultSecurityLevel}; use gadget_common::channels::PublicKeyGossipMessage; -type DefaultSecurityLevel = SecurityLevel128; -type DefaultCryptoHasher = Sha256; - pub async fn create_next_job< B: Block, BE: Backend + 'static, @@ -147,6 +144,7 @@ where }) } +#[allow(clippy::too_many_arguments)] pub async fn run_and_serialize_keyrefresh< 'r, E: Curve, @@ -203,16 +201,7 @@ where }) } -pub fn create_party( - protocol_message_channel: UnboundedReceiver, - associated_block_id: ::Clock, - associated_retry_id: ::RetryID, - associated_session_id: ::SessionID, - associated_task_id: ::TaskID, - mapping: Arc>, - id: ecdsa::Public, - network: N, -) -> ( +pub type CreatePartyResult = ( UnboundedSender, futures::channel::mpsc::UnboundedReceiver, MpcParty< @@ -222,7 +211,19 @@ pub fn create_party( UnboundedSender>, ), >, -) +); + +#[allow(clippy::too_many_arguments)] +pub fn create_party( + protocol_message_channel: UnboundedReceiver, + associated_block_id: ::Clock, + associated_retry_id: ::RetryID, + associated_session_id: ::SessionID, + associated_task_id: ::TaskID, + mapping: Arc>, + id: ecdsa::Public, + network: N, +) -> CreatePartyResult where N: Network, L: SecurityLevel, @@ -302,7 +303,7 @@ where let mix = keccak_256(b"dnfs-cggmp21-keygen-aux"); let aux_eid_bytes = [&job_id_bytes[..], &mix[..]].concat(); let aux_eid = dfns_cggmp21::ExecutionId::new(&aux_eid_bytes); - let tracer = dfns_cggmp21::progress::PerfProfiler::new(); + let tracer = PerfProfiler::new(); let (key_share, serialized_public_key, tx2, rx2) = match role_type { @@ -452,7 +453,7 @@ async fn handle_public_key_gossip( serialized_public_key: &[u8], t: u16, i: u16, - broadcast_tx_to_outbound: futures::channel::mpsc::UnboundedSender, + broadcast_tx_to_outbound: UnboundedSender, mut broadcast_rx_from_gadget: futures::channel::mpsc::UnboundedReceiver, ) -> Result { let key_hashed = keccak_256(serialized_public_key); @@ -490,7 +491,7 @@ async fn handle_public_key_gossip( continue; } // verify signature - let maybe_signature = sp_core::ecdsa::Signature::from_slice(&message.signature); + let maybe_signature = ecdsa::Signature::from_slice(&message.signature); match maybe_signature.and_then(|s| s.recover_prehashed(&key_hashed)) { Some(p) if p != message.id => { logger.warn(format!( @@ -605,7 +606,7 @@ fn verify_generated_dkg_key_ecdsa( } async fn handle_post_incomplete_keygen( - tracer: &mut PerfProfiler, + tracer: &PerfProfiler, logger: &DebugLogger, job_id_bytes: &[u8], key_store: &ECDSAKeyStore, @@ -618,7 +619,7 @@ async fn handle_post_incomplete_keygen( let tracer = PerfProfiler::new(); let pregenerated_primes_key = - keccak_256(&[&b"dfns-cggmp21-keygen-primes"[..], &job_id_bytes[..]].concat()); + keccak_256(&[&b"dfns-cggmp21-keygen-primes"[..], job_id_bytes].concat()); let now = tokio::time::Instant::now(); let pregenerated_primes = tokio::task::spawn_blocking(|| { let mut rng = OsRng; @@ -641,6 +642,7 @@ async fn handle_post_incomplete_keygen( Ok((tracer, pregenerated_primes)) } +#[allow(clippy::too_many_arguments)] async fn run_full_keygen_protocol< 'a, E: Curve, @@ -694,15 +696,14 @@ async fn run_full_keygen_protocol< run_and_serialize_keygen::(&mut tracer, eid, i, n, t, party, rng.clone()) .await?; let (mut tracer, pregenerated_primes) = - handle_post_incomplete_keygen::(&mut tracer, &logger, &job_id_bytes, &key_store) - .await?; + handle_post_incomplete_keygen::(&tracer, logger, job_id_bytes, key_store).await?; logger.info(format!("Will now run Keygen protocol: {role_type:?}")); let delivery = (rx1, tx1); let party = MpcParty::, _, _>::connected(delivery); let (key_share, serialized_public_key) = run_and_serialize_keyrefresh::( - &logger, + logger, incomplete_key_share, pregenerated_primes, &mut tracer, diff --git a/protocols/dfns-cggmp21/src/protocols/mod.rs b/protocols/dfns-cggmp21/src/protocols/mod.rs index 76127e8f4..82ff2039f 100644 --- a/protocols/dfns-cggmp21/src/protocols/mod.rs +++ b/protocols/dfns-cggmp21/src/protocols/mod.rs @@ -1,5 +1,11 @@ +use dfns_cggmp21::security_level::SecurityLevel128; +use sha2::Sha256; + pub mod key_refresh; pub mod key_rotate; pub mod keygen; pub mod sign; pub mod util; + +pub type DefaultSecurityLevel = SecurityLevel128; +pub type DefaultCryptoHasher = Sha256; diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index 7e3715ed8..ebe9997fc 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -1,7 +1,7 @@ use dfns_cggmp21::generic_ec::coords::HasAffineX; use dfns_cggmp21::generic_ec::{Curve, Point}; use dfns_cggmp21::round_based::{Delivery, MpcParty}; -use dfns_cggmp21::security_level::{SecurityLevel, SecurityLevel128}; +use dfns_cggmp21::security_level::SecurityLevel; use dfns_cggmp21::signing::msg::Msg; use dfns_cggmp21::supported_curves::{Secp256k1, Secp256r1, Stark}; @@ -20,7 +20,10 @@ use rand::{CryptoRng, RngCore, SeedableRng}; use sc_client_api::Backend; -use sha2::Sha256; +use crate::protocols::{DefaultCryptoHasher, DefaultSecurityLevel}; +use dfns_cggmp21::signing::SigningBuilder; +use digest::typenum::U32; +use digest::Digest; use sp_api::ProvideRuntimeApi; use sp_core::{ecdsa, keccak_256, Pair}; use std::collections::HashMap; @@ -105,7 +108,8 @@ pub struct DfnsCGGMP21SigningExtraParams { user_id_to_account_id_mapping: Arc>, } -pub async fn run_and_serialize_signing<'r, E, L, R, D>( +#[allow(clippy::too_many_arguments)] +pub async fn run_and_serialize_signing<'r, E, L, R, D, H>( logger: &DebugLogger, tracer: &mut dfns_cggmp21::progress::PerfProfiler, eid: dfns_cggmp21::ExecutionId<'r>, @@ -113,7 +117,7 @@ pub async fn run_and_serialize_signing<'r, E, L, R, D>( signers: Vec, msg: DataToSign, key: Vec, - party: MpcParty, D>, + party: MpcParty, D>, rng: &mut R, ) -> Result, JobError> where @@ -121,12 +125,14 @@ where Point: HasAffineX, L: SecurityLevel, R: RngCore + CryptoRng, - D: Delivery>, + D: Delivery>, + H: Digest + Clone + Send + 'static, { let key: KeyShare = bincode2::deserialize(&key).map_err(|err| JobError { reason: format!("Keygen protocol error: {err:?}"), })?; - let signature = dfns_cggmp21::signing(eid, i, &signers, &key) + let signing_builder = SigningBuilder::::new(eid, i, &signers, &key); + let signature = signing_builder .set_progress_tracer(tracer) .sign(rng, party, msg) .await @@ -170,7 +176,7 @@ where let my_role_id = config.key_store.pair().public(); let network = config.clone(); - let (i, signers, t, key, role_type, input_data_to_sign, mapping) = ( + let (i, signers, t, local_key_serialized, role_type, input_data_to_sign, mapping) = ( additional_params.i, additional_params.signers, additional_params.t, @@ -180,7 +186,22 @@ where additional_params.user_id_to_account_id_mapping.clone(), ); - let key2 = key.clone(); + let public_key = match role_type { + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { + get_public_key_from_serialized_local_key_bytes::(&local_key_serialized)? + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { + get_public_key_from_serialized_local_key_bytes::(&local_key_serialized)? + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { + get_public_key_from_serialized_local_key_bytes::(&local_key_serialized)? + } + _ => { + return Err(JobError { + reason: format!("Invalid role type: {role_type:?}"), + }); + } + }; Ok(JobBuilder::new() .protocol(async move { @@ -201,75 +222,87 @@ where ); let signature = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - let (_, _, party) = - create_party::>( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - ); - run_and_serialize_signing::<_, SecurityLevel128, _, _>( + let (_, _, party) = create_party::< + Secp256k1, + _, + DefaultSecurityLevel, + Msg, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + my_role_id, + network.clone(), + ); + run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( &logger, &mut tracer, eid, i, signers, data_to_sign, - key, + local_key_serialized, party, &mut rng, ) .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - let (_, _, party) = - create_party::>( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - ); - run_and_serialize_signing::<_, SecurityLevel128, _, _>( + let (_, _, party) = create_party::< + Secp256r1, + _, + DefaultSecurityLevel, + Msg, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + my_role_id, + network.clone(), + ); + run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( &logger, &mut tracer, eid, i, signers, data_to_sign, - key, + local_key_serialized, party, &mut rng, ) .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - let (_, _, party) = - create_party::>( - protocol_message_channel, - associated_block_id, - associated_retry_id, - associated_session_id, - associated_task_id, - mapping.clone(), - my_role_id, - network.clone(), - ); - run_and_serialize_signing::<_, SecurityLevel128, _, _>( + let (_, _, party) = create_party::< + Stark, + _, + DefaultSecurityLevel, + Msg, + >( + protocol_message_channel, + associated_block_id, + associated_retry_id, + associated_session_id, + associated_task_id, + mapping.clone(), + my_role_id, + network.clone(), + ); + run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( &logger, &mut tracer, eid, i, signers, data_to_sign, - key, + local_key_serialized, party, &mut rng, ) @@ -293,7 +326,7 @@ where signature_scheme: DigitalSignatureScheme::Ecdsa, data: additional_params.input_data_to_sign.try_into().unwrap(), signature: signature.try_into().unwrap(), - verifying_key: key2.try_into().unwrap(), + verifying_key: public_key.try_into().unwrap(), }); client @@ -312,3 +345,15 @@ where }) .build()) } + +fn get_public_key_from_serialized_local_key_bytes( + local_key_serialized: &[u8], +) -> Result, JobError> { + let key_share = bincode2::deserialize::>( + local_key_serialized, + ) + .map_err(|err| JobError { + reason: format!("Keygen protocol error: {err:?}"), + })?; + Ok(key_share.shared_public_key().to_bytes(true).to_vec()) +} diff --git a/protocols/dfns-cggmp21/src/protocols/util.rs b/protocols/dfns-cggmp21/src/protocols/util.rs index bec7f4d45..f9083bc74 100644 --- a/protocols/dfns-cggmp21/src/protocols/util.rs +++ b/protocols/dfns-cggmp21/src/protocols/util.rs @@ -3,6 +3,8 @@ use rand::prelude::SliceRandom; use sp_core::ecdsa::Public; use std::collections::HashMap; +pub type ChosenSigners = (u16, Vec, HashMap); + /// Given a list of participants, choose `t` of them and return the index of the current participant /// and the indices of the chosen participants, as well as a mapping from the index to the account /// id. @@ -18,7 +20,7 @@ pub fn choose_signers( my_account_id: &Public, participants: &[Public], t: u16, -) -> Result<(u16, Vec, HashMap), gadget_common::Error> { +) -> Result { let selected_participants = participants .choose_multiple(rng, t as usize) .cloned() From 9bab079af5b4b44bde2b392ee74ead3babf39e8c Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Thu, 29 Feb 2024 14:43:32 -0500 Subject: [PATCH 62/66] Get signing test passing --- .../dfns-cggmp21/src/protocols/key_rotate.rs | 39 ++++-- protocols/dfns-cggmp21/src/protocols/sign.rs | 114 +++++++++++++----- 2 files changed, 111 insertions(+), 42 deletions(-) diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index a1b870456..0c33febfa 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -150,7 +150,7 @@ where let phase_one_id = additional_params.phase_one_id; let network = config.clone(); - let (i, signers, t, new_phase_one_id, key, role_type, new_key, mapping) = ( + let (i, signers, t, new_phase_one_id, serialized_key_share, role_type, new_key, mapping) = ( additional_params.i, additional_params.signers, additional_params.t, @@ -161,8 +161,20 @@ where additional_params.user_id_to_account_id_mapping.clone(), ); - let key2 = key.clone(); - let new_key2 = new_key.clone(); + let public_key = super::sign::get_public_key_from_serialized_key_share_bytes( + &role_type, + &serialized_key_share, + )?; + let new_public_key = + super::sign::get_public_key_from_serialized_key_share_bytes(&role_type, &new_key)?; + + // We're signing over the hash of the new key + let data_hash = keccak_256(&new_key); + let data_to_sign = dfns_cggmp21::DataToSign::from_scalar( + dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(data_hash), + ); + + let data_to_sign_bytes = data_hash.to_vec(); Ok(JobBuilder::new() .protocol(async move { @@ -177,10 +189,6 @@ where let eid_bytes = [&job_id_bytes[..], &mix[..]].concat(); let eid = dfns_cggmp21::ExecutionId::new(&eid_bytes); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - let data_hash = keccak_256(&new_key); - let data_to_sign = dfns_cggmp21::DataToSign::from_scalar( - dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(data_hash), - ); let signature = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { let (_, _, party) = create_party::< @@ -205,7 +213,7 @@ where i, signers, data_to_sign, - key, + serialized_key_share, party, &mut rng, ) @@ -234,7 +242,7 @@ where i, signers, data_to_sign, - key, + serialized_key_share, party, &mut rng, ) @@ -263,7 +271,7 @@ where i, signers, data_to_sign, - key, + serialized_key_share, party, &mut rng, ) @@ -282,13 +290,18 @@ where .post(async move { // Submit the protocol output to the blockchain if let Some(signature) = protocol_output_clone.lock().await.take() { + let signature = super::sign::convert_dfns_signature( + signature, + &data_to_sign_bytes, + &new_public_key, + ); let job_result = JobResult::DKGPhaseFour(DKGTSSKeyRotationResult { signature_scheme: DigitalSignatureScheme::Ecdsa, - signature: signature.try_into().unwrap(), + signature: signature.to_vec().try_into().unwrap(), phase_one_id, new_phase_one_id, - new_key: new_key2.try_into().unwrap(), - key: key2.try_into().unwrap(), + new_key: new_public_key.try_into().unwrap(), + key: public_key.try_into().unwrap(), }); client diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index ebe9997fc..f8c1837ba 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -89,7 +89,7 @@ where signers, job_id, role_type: job.role_type, - key, + serialized_key_share: key, input_data_to_sign, user_id_to_account_id_mapping, }; @@ -103,7 +103,7 @@ pub struct DfnsCGGMP21SigningExtraParams { signers: Vec, job_id: JobId, role_type: RoleType, - key: Vec, + serialized_key_share: Vec, input_data_to_sign: Vec, user_id_to_account_id_mapping: Arc>, } @@ -145,9 +145,9 @@ where })?; logger.trace(format!("Signing protocol report: {perf_report}")); // Normalize the signature - bincode2::serialize(&signature.normalize_s()).map_err(|err| JobError { - reason: format!("Signing protocol error: {err:?}"), - }) + let mut ret = [0u8; 65]; + signature.write_to_slice(&mut ret); + Ok(ret.to_vec()) } pub async fn generate_protocol_from< @@ -176,32 +176,18 @@ where let my_role_id = config.key_store.pair().public(); let network = config.clone(); - let (i, signers, t, local_key_serialized, role_type, input_data_to_sign, mapping) = ( + let (i, signers, t, serialized_key_share, role_type, input_data_to_sign, mapping) = ( additional_params.i, additional_params.signers, additional_params.t, - additional_params.key, + additional_params.serialized_key_share, additional_params.role_type, additional_params.input_data_to_sign.clone(), additional_params.user_id_to_account_id_mapping.clone(), ); - let public_key = match role_type { - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { - get_public_key_from_serialized_local_key_bytes::(&local_key_serialized)? - } - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { - get_public_key_from_serialized_local_key_bytes::(&local_key_serialized)? - } - RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { - get_public_key_from_serialized_local_key_bytes::(&local_key_serialized)? - } - _ => { - return Err(JobError { - reason: format!("Invalid role type: {role_type:?}"), - }); - } - }; + let public_key = + get_public_key_from_serialized_key_share_bytes(&role_type, &serialized_key_share)?; Ok(JobBuilder::new() .protocol(async move { @@ -217,9 +203,10 @@ where let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let data_hash = keccak_256(&input_data_to_sign); - let data_to_sign = dfns_cggmp21::DataToSign::from_scalar( + let data_to_sign = DataToSign::from_scalar( dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(data_hash), ); + let signature = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { let (_, _, party) = create_party::< @@ -244,7 +231,7 @@ where i, signers, data_to_sign, - local_key_serialized, + serialized_key_share, party, &mut rng, ) @@ -273,7 +260,7 @@ where i, signers, data_to_sign, - local_key_serialized, + serialized_key_share, party, &mut rng, ) @@ -302,7 +289,7 @@ where i, signers, data_to_sign, - local_key_serialized, + serialized_key_share, party, &mut rng, ) @@ -322,10 +309,16 @@ where .post(async move { // Submit the protocol output to the blockchain if let Some(signature) = protocol_output_clone.lock().await.take() { + let signature = convert_dfns_signature( + signature, + &additional_params.input_data_to_sign, + &public_key, + ); + let job_result = JobResult::DKGPhaseTwo(DKGTSSSignatureResult { signature_scheme: DigitalSignatureScheme::Ecdsa, data: additional_params.input_data_to_sign.try_into().unwrap(), - signature: signature.try_into().unwrap(), + signature: signature.to_vec().try_into().unwrap(), verifying_key: public_key.try_into().unwrap(), }); @@ -346,7 +339,27 @@ where .build()) } -fn get_public_key_from_serialized_local_key_bytes( +pub fn get_public_key_from_serialized_key_share_bytes( + role_type: &RoleType, + serialized_key_share: &[u8], +) -> Result, JobError> { + match role_type { + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { + get_public_key_from_serialized_local_key_bytes_inner::(serialized_key_share) + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { + get_public_key_from_serialized_local_key_bytes_inner::(serialized_key_share) + } + RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { + get_public_key_from_serialized_local_key_bytes_inner::(serialized_key_share) + } + _ => Err(JobError { + reason: format!("Invalid role type: {role_type:?}"), + }), + } +} + +fn get_public_key_from_serialized_local_key_bytes_inner( local_key_serialized: &[u8], ) -> Result, JobError> { let key_share = bincode2::deserialize::>( @@ -357,3 +370,46 @@ fn get_public_key_from_serialized_local_key_bytes( })?; Ok(key_share.shared_public_key().to_bytes(true).to_vec()) } + +pub fn convert_dfns_signature( + signature: Vec, + input_data_to_sign: &[u8], + public_key_bytes: &[u8], +) -> [u8; 65] { + let mut signature_bytes = [0u8; 65]; + (signature_bytes[..64]).copy_from_slice(&signature[..64]); + let data_hash = keccak_256(input_data_to_sign); + // To figure out the recovery ID, we need to try all possible values of v + // in our case, v can be 0 or 1 + let mut v = 0u8; + loop { + let mut signature_bytes = signature_bytes; + signature_bytes[64] = v; + let res = sp_io::crypto::secp256k1_ecdsa_recover(&signature_bytes, &data_hash); + match res { + Ok(key) if key[..32] == public_key_bytes[1..] => { + // Found the correct v + break; + } + Ok(_) => { + // Found a key, but not the correct one + // Try the other v value + v = 1; + continue; + } + Err(_) if v == 1 => { + // We tried both v values, but no key was found + // This should never happen, but if it does, we will just + // leave v as 1 and break + break; + } + Err(_) => { + // No key was found, try the other v value + v = 1; + continue; + } + } + } + signature_bytes[64] = v + 27; + signature_bytes +} From 06225fa39bca3028ccfe7b391086d42678840a9f Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Fri, 1 Mar 2024 09:39:05 -0500 Subject: [PATCH 63/66] Improve logging --- gadget-common/src/gadget/mod.rs | 19 +-- gadget-common/src/lib.rs | 3 + protocols/dfns-cggmp21/src/lib.rs | 27 +++- .../dfns-cggmp21/src/protocols/key_rotate.rs | 147 +++++++++++------- 4 files changed, 133 insertions(+), 63 deletions(-) diff --git a/gadget-common/src/gadget/mod.rs b/gadget-common/src/gadget/mod.rs index c7d8f8e16..b36949214 100644 --- a/gadget-common/src/gadget/mod.rs +++ b/gadget-common/src/gadget/mod.rs @@ -118,8 +118,7 @@ where let now: u64 = now_header.saturated_into(); *self.clock.write() = Some(now); self.protocol.logger().info(format!( - "[{}] Processing finality notification at block number {now}", - self.protocol.name() + "Processing finality notification at block number {now}", )); let jobs = self @@ -129,8 +128,7 @@ where .await?; self.protocol.logger().trace(format!( - "[{}] Found {} potential job(s) for initialization", - self.protocol.name(), + "Found {} potential job(s) for initialization", jobs.len() )); let mut relevant_jobs = Vec::new(); @@ -146,12 +144,12 @@ where } // Job is not for this role if !self.protocol.role_filter(job.job_type.get_role_type()) { - self.protocol.logger().trace(format!("[{}] The job {} requested for initialization is not for this role {:?}, skipping submission", self.protocol.name(), job.job_id, job.job_type.get_role_type())); + // self.protocol.logger().trace(format!("[{}] The job {} requested for initialization is not for this role {:?}, skipping submission", self.protocol.name(), job.job_id, job.job_type.get_role_type())); continue; } // Job is not for this phase if !self.protocol.phase_filter(job.job_type.clone()) { - self.protocol.logger().trace(format!("[{}] The job {} requested for initialization is not for this phase {:?}, skipping submission", self.protocol.name(), job.job_id, job.job_type)); + // self.protocol.logger().trace(format!("[{}] The job {} requested for initialization is not for this phase {:?}, skipping submission", self.protocol.name(), job.job_id, job.job_type)); continue; } @@ -208,6 +206,10 @@ where .await?; if let Some(role_key) = maybe_role_key { out.push(role_key); + } else { + self.protocol.logger().warn(format!( + "Participant {p} not found in the restaker registry", + )); } } out @@ -229,8 +231,7 @@ where let task_id = relevant_job.task_id; let retry_id = relevant_job.retry_id; self.protocol.logger().trace(format!( - "[{}] Creating job for task {task_id} with retry id {retry_id}", - self.protocol.name(), + "Creating job for task {task_id} with retry id {retry_id}", task_id = hex::encode(task_id), retry_id = retry_id )); @@ -271,7 +272,7 @@ where } Err(Error::ParticipantNotSelected { id, reason }) => { - self.protocol.logger().debug(format!("[{}] Participant {id} not selected for job {task_id} with retry id {retry_id} because {reason}", self.protocol.name(), id = id, task_id = hex::encode(task_id), retry_id = retry_id, reason = reason)); + self.protocol.logger().debug(format!("Participant {id} not selected for job {task_id} with retry id {retry_id} because {reason}", id = id, task_id = hex::encode(task_id), retry_id = retry_id, reason = reason)); } Err(err) => { diff --git a/gadget-common/src/lib.rs b/gadget-common/src/lib.rs index 59ffb8b26..4104bbb24 100644 --- a/gadget-common/src/lib.rs +++ b/gadget-common/src/lib.rs @@ -302,6 +302,9 @@ macro_rules! generate_protocol { key_store: ECDSAKeyStore, prometheus_config: $crate::prometheus::PrometheusConfig, ) -> Result { + let logger = DebugLogger { + peer_id: (logger.peer_id + " | " + stringify!($name)).replace("\"", "") + }; Ok(Self { pallet_tx, logger, diff --git a/protocols/dfns-cggmp21/src/lib.rs b/protocols/dfns-cggmp21/src/lib.rs index cddbfcb09..4dda5bd51 100644 --- a/protocols/dfns-cggmp21/src/lib.rs +++ b/protocols/dfns-cggmp21/src/lib.rs @@ -58,4 +58,29 @@ generate_setup_and_run_command!( DfnsKeyRotateProtocol ); -generate_signing_and_keygen_tss_tests!(2, 3, 4, ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1); +mod secp256k1 { + super::generate_signing_and_keygen_tss_tests!( + 2, + 3, + 4, + ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1 + ); +} + +mod secp256r1 { + super::generate_signing_and_keygen_tss_tests!( + 2, + 3, + 4, + ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1 + ); +} + +mod stark { + super::generate_signing_and_keygen_tss_tests!( + 2, + 3, + 4, + ThresholdSignatureRoleType::DfnsCGGMP21Stark + ); +} diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index 7e0f944cc..48aa09a75 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -43,6 +43,7 @@ pub async fn create_next_job< where >::Api: JobsApiForGadget, { + config.logger.info("[KEY-ROTATE] Creating next job"); let job_id = job.job_id; let JobType::DKGTSSPhaseFour(p4_job) = job.job_type else { @@ -56,13 +57,13 @@ where let seed = keccak_256(&[&job_id.to_be_bytes()[..], &job.retry_id.to_be_bytes()[..]].concat()); let mut rng = rand_chacha::ChaChaRng::from_seed(seed); - - let (i, signers, mapping) = super::util::choose_signers( - &mut rng, - &config.key_store.pair().public(), - &job.participants_role_ids, - t, - )?; + let my_id = config.key_store.pair().public(); + config.logger.info(format!( + "My ID: {my_id:?} | signers: {:?}", + job.participants_role_ids + )); + let (i, signers, mapping) = + super::util::choose_signers(&mut rng, &my_id, &job.participants_role_ids, t)?; let new_phase_one_result = config .get_jobs_client() @@ -168,14 +169,8 @@ where DefaultSecurityLevel, >(&role_type, &new_key)?; - // We're signing over the hash of the new key - let data_hash = keccak_256(&new_key); - let data_to_sign = dfns_cggmp21::DataToSign::from_scalar( - dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(data_hash), - ); - - let data_to_sign_bytes = data_hash.to_vec(); - + // We're signing over the hash of the new public key using the old public key + let data_hash = keccak_256(&new_public_key); Ok(JobBuilder::new() .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); @@ -189,8 +184,14 @@ where let eid_bytes = [&job_id_bytes[..], &mix[..]].concat(); let eid = dfns_cggmp21::ExecutionId::new(&eid_bytes); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - let signature = match role_type { + let (signature, data_to_sign_bytes) = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { + let data_to_sign = dfns_cggmp21::DataToSign::::from_scalar( + dfns_cggmp21::generic_ec::Scalar::::from_be_bytes_mod_order( + data_hash, + ), + ); + let data_to_sign_bytes = data_hash.to_vec(); let (_, _, party) = create_party::< Secp256k1, _, @@ -206,25 +207,40 @@ where role_id, network.clone(), ); - run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( - &logger, - &mut tracer, - eid, - i, - signers, - data_to_sign, - serialized_key_share, - party, - &mut rng, + ( + run_and_serialize_signing::< + _, + DefaultSecurityLevel, + _, + _, + DefaultCryptoHasher, + >( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + serialized_key_share, + party, + &mut rng, + ) + .await?, + data_to_sign_bytes, ) - .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { + let data_to_sign = dfns_cggmp21::DataToSign::::from_scalar( + dfns_cggmp21::generic_ec::Scalar::::from_be_bytes_mod_order( + data_hash, + ), + ); + let data_to_sign_bytes = data_hash.to_vec(); let (_, _, party) = create_party::< Secp256r1, _, DefaultSecurityLevel, - Msg, + Msg, >( protocol_message_channel, associated_block_id, @@ -235,25 +251,40 @@ where role_id, network.clone(), ); - run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( - &logger, - &mut tracer, - eid, - i, - signers, - data_to_sign, - serialized_key_share, - party, - &mut rng, + ( + run_and_serialize_signing::< + Secp256r1, + DefaultSecurityLevel, + _, + _, + DefaultCryptoHasher, + >( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + serialized_key_share, + party, + &mut rng, + ) + .await?, + data_to_sign_bytes, ) - .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { + let data_to_sign = dfns_cggmp21::DataToSign::::from_scalar( + dfns_cggmp21::generic_ec::Scalar::::from_be_bytes_mod_order( + data_hash, + ), + ); + let data_to_sign_bytes = data_hash.to_vec(); let (_, _, party) = create_party::< Stark, _, DefaultSecurityLevel, - Msg, + Msg, >( protocol_message_channel, associated_block_id, @@ -264,18 +295,27 @@ where role_id, network.clone(), ); - run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( - &logger, - &mut tracer, - eid, - i, - signers, - data_to_sign, - serialized_key_share, - party, - &mut rng, + ( + run_and_serialize_signing::< + Stark, + DefaultSecurityLevel, + _, + _, + DefaultCryptoHasher, + >( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + serialized_key_share, + party, + &mut rng, + ) + .await?, + data_to_sign_bytes, ) - .await? } _ => { return Err(JobError { @@ -284,12 +324,13 @@ where } }; logger.debug("Finished AsyncProtocol - Key Rotation"); - *protocol_output.lock().await = Some(signature); + *protocol_output.lock().await = Some((signature, data_to_sign_bytes)); Ok(()) }) .post(async move { // Submit the protocol output to the blockchain - if let Some(signature) = protocol_output_clone.lock().await.take() { + if let Some((signature, data_to_sign_bytes)) = protocol_output_clone.lock().await.take() + { let signature = super::sign::convert_dfns_signature( signature, &data_to_sign_bytes, From ca99def46691bceeeb5edb9870f6743b3583dab0 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Fri, 1 Mar 2024 11:04:47 -0500 Subject: [PATCH 64/66] debugging --- .../dfns-cggmp21/src/protocols/key_rotate.rs | 171 +++++++++--------- protocols/dfns-cggmp21/src/protocols/sign.rs | 2 + protocols/dfns-cggmp21/src/protocols/util.rs | 2 +- 3 files changed, 84 insertions(+), 91 deletions(-) diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index 48aa09a75..02e097ea9 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -43,7 +43,6 @@ pub async fn create_next_job< where >::Api: JobsApiForGadget, { - config.logger.info("[KEY-ROTATE] Creating next job"); let job_id = job.job_id; let JobType::DKGTSSPhaseFour(p4_job) = job.job_type else { @@ -58,30 +57,25 @@ where let seed = keccak_256(&[&job_id.to_be_bytes()[..], &job.retry_id.to_be_bytes()[..]].concat()); let mut rng = rand_chacha::ChaChaRng::from_seed(seed); let my_id = config.key_store.pair().public(); - config.logger.info(format!( - "My ID: {my_id:?} | signers: {:?}", - job.participants_role_ids - )); + let (i, signers, mapping) = super::util::choose_signers(&mut rng, &my_id, &job.participants_role_ids, t)?; + config.logger.info(format!( + "We are selected to sign: i={i}, signers={signers:?} | signers len: {}", + signers.len() + )); - let new_phase_one_result = config - .get_jobs_client() - .query_job_result(job.at, job.role_type, new_phase_one_id) - .await? - .ok_or_else(|| gadget_common::Error::ClientError { - err: format!("No key found for job ID: {new_phase_one_id}"), + let new_key = config + .key_store + .get_job_result(new_phase_one_id) + .await + .map_err(|err| Error::ClientError { + err: err.to_string(), + })? + .ok_or_else(|| Error::ClientError { + err: format!("No new key found for job ID: {new_phase_one_id:?}"), })?; - let new_key = match new_phase_one_result.result { - JobResult::DKGPhaseOne(r) => r.key, - _ => { - return Err(gadget_common::Error::ClientError { - err: format!("Wrong job result type for job ID: {new_phase_one_id}"), - }) - } - }; - let key = config .key_store .get_job_result(phase_one_id) @@ -93,8 +87,12 @@ where err: format!("No key found for job ID: {job_id:?}"), })?; + config.logger.info("RB4"); + let user_id_to_account_id_mapping = Arc::new(mapping); + config.logger.info("RB5"); + let params = DfnsCGGMP21KeyRotateExtraParams { i, t, @@ -104,9 +102,10 @@ where new_phase_one_id, role_type: job.role_type, key, - new_key: new_key.into(), + new_key, user_id_to_account_id_mapping, }; + Ok(params) } @@ -151,7 +150,16 @@ where let phase_one_id = additional_params.phase_one_id; let network = config.clone(); - let (i, signers, t, new_phase_one_id, serialized_key_share, role_type, new_key, mapping) = ( + let ( + i, + signers, + t, + new_phase_one_id, + serialized_key_share, + role_type, + new_serialized_key_share, + mapping, + ) = ( additional_params.i, additional_params.signers, additional_params.t, @@ -165,12 +173,14 @@ where let public_key = super::sign::get_public_key_from_serialized_key_share_bytes::< DefaultSecurityLevel, >(&role_type, &serialized_key_share)?; + let new_public_key = super::sign::get_public_key_from_serialized_key_share_bytes::< DefaultSecurityLevel, - >(&role_type, &new_key)?; + >(&role_type, &new_serialized_key_share)?; // We're signing over the hash of the new public key using the old public key let data_hash = keccak_256(&new_public_key); + let data_to_sign_bytes = data_hash.to_vec(); Ok(JobBuilder::new() .protocol(async move { let mut rng = rand::rngs::StdRng::from_entropy(); @@ -184,14 +194,13 @@ where let eid_bytes = [&job_id_bytes[..], &mix[..]].concat(); let eid = dfns_cggmp21::ExecutionId::new(&eid_bytes); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); - let (signature, data_to_sign_bytes) = match role_type { + let signature = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { let data_to_sign = dfns_cggmp21::DataToSign::::from_scalar( dfns_cggmp21::generic_ec::Scalar::::from_be_bytes_mod_order( data_hash, ), ); - let data_to_sign_bytes = data_hash.to_vec(); let (_, _, party) = create_party::< Secp256k1, _, @@ -207,27 +216,18 @@ where role_id, network.clone(), ); - ( - run_and_serialize_signing::< - _, - DefaultSecurityLevel, - _, - _, - DefaultCryptoHasher, - >( - &logger, - &mut tracer, - eid, - i, - signers, - data_to_sign, - serialized_key_share, - party, - &mut rng, - ) - .await?, - data_to_sign_bytes, + run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + serialized_key_share, + party, + &mut rng, ) + .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { let data_to_sign = dfns_cggmp21::DataToSign::::from_scalar( @@ -235,7 +235,6 @@ where data_hash, ), ); - let data_to_sign_bytes = data_hash.to_vec(); let (_, _, party) = create_party::< Secp256r1, _, @@ -251,27 +250,24 @@ where role_id, network.clone(), ); - ( - run_and_serialize_signing::< - Secp256r1, - DefaultSecurityLevel, - _, - _, - DefaultCryptoHasher, - >( - &logger, - &mut tracer, - eid, - i, - signers, - data_to_sign, - serialized_key_share, - party, - &mut rng, - ) - .await?, - data_to_sign_bytes, + run_and_serialize_signing::< + Secp256r1, + DefaultSecurityLevel, + _, + _, + DefaultCryptoHasher, + >( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + serialized_key_share, + party, + &mut rng, ) + .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { let data_to_sign = dfns_cggmp21::DataToSign::::from_scalar( @@ -279,7 +275,6 @@ where data_hash, ), ); - let data_to_sign_bytes = data_hash.to_vec(); let (_, _, party) = create_party::< Stark, _, @@ -295,27 +290,24 @@ where role_id, network.clone(), ); - ( - run_and_serialize_signing::< - Stark, - DefaultSecurityLevel, - _, - _, - DefaultCryptoHasher, - >( - &logger, - &mut tracer, - eid, - i, - signers, - data_to_sign, - serialized_key_share, - party, - &mut rng, - ) - .await?, - data_to_sign_bytes, + run_and_serialize_signing::< + Stark, + DefaultSecurityLevel, + _, + _, + DefaultCryptoHasher, + >( + &logger, + &mut tracer, + eid, + i, + signers, + data_to_sign, + serialized_key_share, + party, + &mut rng, ) + .await? } _ => { return Err(JobError { @@ -324,13 +316,12 @@ where } }; logger.debug("Finished AsyncProtocol - Key Rotation"); - *protocol_output.lock().await = Some((signature, data_to_sign_bytes)); + *protocol_output.lock().await = Some(signature); Ok(()) }) .post(async move { // Submit the protocol output to the blockchain - if let Some((signature, data_to_sign_bytes)) = protocol_output_clone.lock().await.take() - { + if let Some(signature) = protocol_output_clone.lock().await.take() { let signature = super::sign::convert_dfns_signature( signature, &data_to_sign_bytes, diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index 938623833..75f820606 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -140,6 +140,8 @@ where reason: format!("Signing protocol error: {err:?}"), })?; + logger.info("Done signing"); + let perf_report = tracer.get_report().map_err(|err| JobError { reason: format!("Signing protocol error: {err:?}"), })?; diff --git a/protocols/dfns-cggmp21/src/protocols/util.rs b/protocols/dfns-cggmp21/src/protocols/util.rs index f9083bc74..6dbb07fa7 100644 --- a/protocols/dfns-cggmp21/src/protocols/util.rs +++ b/protocols/dfns-cggmp21/src/protocols/util.rs @@ -38,7 +38,7 @@ pub fn choose_signers( let i = selected_participants_indices .iter() - .position(|p| p == &j) + .position(|p| *p == j) .map(|i| i as u16) .ok_or_else(|| gadget_common::Error::ParticipantNotSelected { id: *my_account_id, From b0b6c5b45cbae4210781ea5412d37354bc5c647a Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Fri, 1 Mar 2024 15:00:20 -0500 Subject: [PATCH 65/66] improve logging --- gadget-common/src/channels.rs | 87 +++++++++++++------ protocols/bls/src/protocol/keygen.rs | 1 + protocols/bls/src/protocol/signing.rs | 1 + .../dfns-cggmp21/src/protocols/key_refresh.rs | 1 + .../dfns-cggmp21/src/protocols/key_rotate.rs | 6 ++ .../dfns-cggmp21/src/protocols/keygen.rs | 3 + protocols/dfns-cggmp21/src/protocols/sign.rs | 25 ++++-- protocols/dfns-cggmp21/src/protocols/util.rs | 47 +++++----- protocols/zcash-frost/src/protocol/keygen.rs | 1 + protocols/zcash-frost/src/protocol/sign.rs | 1 + 10 files changed, 120 insertions(+), 53 deletions(-) diff --git a/gadget-common/src/channels.rs b/gadget-common/src/channels.rs index 87a6a1f5d..9db6ab554 100644 --- a/gadget-common/src/channels.rs +++ b/gadget-common/src/channels.rs @@ -3,6 +3,7 @@ use crate::gadget::message::{GadgetProtocolMessage, UserID}; use crate::gadget::network::Network; use crate::gadget::work_manager::WorkManager; +use crate::prelude::DebugLogger; use futures::StreamExt; use gadget_core::job_manager::WorkManagerInterface; use round_based::Msg; @@ -28,6 +29,7 @@ pub fn create_job_manager_to_async_protocol_channel_split< user_id_mapping: Arc>, my_account_id: ecdsa::Public, network: N, + logger: DebugLogger, ) -> ( futures::channel::mpsc::UnboundedSender, futures::channel::mpsc::UnboundedReceiver>, @@ -36,7 +38,7 @@ pub fn create_job_manager_to_async_protocol_channel_split< ) { let (tx_to_async_proto_1, rx_for_async_proto_1) = futures::channel::mpsc::unbounded(); let (tx_to_async_proto_2, rx_for_async_proto_2) = tokio::sync::mpsc::unbounded_channel(); - + let logger_outgoing = logger.clone(); // Take the messages from the gadget and send them to the async protocol tokio::task::spawn(async move { while let Some(msg) = rx_gadget.recv().await { @@ -44,12 +46,12 @@ pub fn create_job_manager_to_async_protocol_channel_split< Ok(msg) => match msg { MultiplexedChannelMessage::Channel1(msg) => { if tx_to_async_proto_1.unbounded_send(Ok(msg)).is_err() { - log::error!(target: "gadget", "Failed to send message to protocol"); + logger.error("Failed to send message to C1 protocol"); } } MultiplexedChannelMessage::Channel2(msg) => { if tx_to_async_proto_2.send(msg).is_err() { - log::error!(target: "gadget", "Failed to send message to protocol"); + logger.error("Failed to send message to C2 protocol"); } } @@ -58,7 +60,7 @@ pub fn create_job_manager_to_async_protocol_channel_split< } }, Err(err) => { - log::error!(target: "gadget", "Failed to deserialize message: {err:?}"); + logger.error(format!("Failed to deserialize message: {err:?}")); } } } @@ -81,7 +83,8 @@ pub fn create_job_manager_to_async_protocol_channel_split< // Take the messages the async protocol sends to the outbound channel and send them to the gadget tokio::task::spawn(async move { - let offline_task = async move { + let logger = &logger_outgoing; + let channel_1_task = async move { while let Some(msg) = rx_to_outbound_1.next().await { if let Err(err) = wrap_message_and_forward_to_network::<_, C1, C2, (), _>( msg, @@ -93,15 +96,16 @@ pub fn create_job_manager_to_async_protocol_channel_split< associated_retry_id, associated_task_id, MultiplexedChannelMessage::Channel1, + logger, ) .await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + logger.error(format!("Failed to send message to outbound: {err:?}")); } } }; - let voting_task = async move { + let channel_2_task = async move { while let Some(msg) = rx_to_outbound_2.recv().await { if let Err(err) = wrap_message_and_forward_to_network::<_, C1, C2, (), _>( msg, @@ -113,15 +117,16 @@ pub fn create_job_manager_to_async_protocol_channel_split< associated_retry_id, associated_task_id, MultiplexedChannelMessage::Channel2, + logger, ) .await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + logger.error(format!("Failed to send message to outbound: {err:?}")); } } }; - tokio::join!(offline_task, voting_task); + tokio::join!(channel_1_task, channel_2_task); }); ( @@ -136,6 +141,7 @@ pub fn get_to_and_from_account_id( mapping: &HashMap, from: UserID, to: Option, + logger: &DebugLogger, ) -> (Option, Option) { let from_account_id = mapping.get(&from).cloned(); let to_account_id = if let Some(to) = to { @@ -144,6 +150,11 @@ pub fn get_to_and_from_account_id( None }; + logger.trace(format!( + "From (mapped): {:?}, To: {:?}", + from_account_id, to_account_id + )); + (to_account_id, from_account_id) } @@ -451,16 +462,21 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< user_id_mapping: Arc>, my_account_id: ecdsa::Public, network: N, + logger: DebugLogger, ) -> DuplexedChannel { let (tx_to_async_proto_1, rx_for_async_proto_1) = futures::channel::mpsc::unbounded(); let (tx_to_async_proto_2, rx_for_async_proto_2) = futures::channel::mpsc::unbounded(); + let logger_outgoing = logger.clone(); // Take the messages from the gadget and send them to the async protocol tokio::task::spawn(async move { let mut id = 0; while let Some(msg_orig) = rx_gadget.recv().await { if msg_orig.payload.is_empty() { - log::warn!(target: "gadget", "Received empty message from Peer {}", msg_orig.from); + logger.warn(format!( + "Received empty message from Peer {}", + msg_orig.from + )); continue; } match bincode2::deserialize::>( @@ -468,6 +484,10 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< ) { Ok(msg) => match msg { MultiplexedChannelMessage::Channel1(msg) => { + logger.info(format!( + "Received message from {} as {:?}", + msg_orig.from, msg_orig.to + )); let msg_type = if msg_orig.to.is_some() { MessageType::P2P } else { @@ -478,14 +498,14 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< I::from_inbound(id, msg_orig.from as PartyIndex, msg_type, msg); if tx_to_async_proto_1.unbounded_send(Ok(incoming)).is_err() { - log::error!(target: "gadget", "Failed to send Incoming message to protocol"); + logger.error("Failed to send Incoming message to protocol"); } id += 1; } MultiplexedChannelMessage::Channel2(msg) => { if tx_to_async_proto_2.unbounded_send(msg).is_err() { - log::error!(target: "gadget", "Failed to send C2 message to protocol"); + logger.error("Failed to send C2 message to protocol"); } } _ => { @@ -493,7 +513,7 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< } }, Err(err) => { - log::error!(target: "gadget", "Failed to deserialize message: {err:?}"); + logger.error(format!("Failed to deserialize message: {err:?}")); } } } @@ -515,7 +535,8 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< .expect("Failed to find my user id"); // Take the messages from the async protocol and send them to the gadget tokio::task::spawn(async move { - let offline_task = async move { + let logger = &logger_outgoing; + let channel_1_task = async move { while let Some(msg) = rx_to_outbound_1.next().await { if let Err(err) = wrap_message_and_forward_to_network::<_, O::Inner, C2, (), _>( msg, @@ -527,15 +548,16 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< associated_retry_id, associated_task_id, |m| MultiplexedChannelMessage::Channel1(m.inner_message()), + logger, ) .await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + logger.error(format!("Failed to send message to outbound: {err:?}")); } } }; - let voting_task = async move { + let channel_2_task = async move { while let Some(msg) = rx_to_outbound_2.next().await { if let Err(err) = wrap_message_and_forward_to_network::<_, O::Inner, C2, (), _>( msg, @@ -547,15 +569,16 @@ pub fn create_job_manager_to_async_protocol_channel_split_io< associated_retry_id, associated_task_id, |m| MultiplexedChannelMessage::Channel2(m), + logger, ) .await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + logger.error(format!("Failed to send message to outbound: {err:?}")); } } }; - tokio::join!(offline_task, voting_task); + tokio::join!(channel_1_task, channel_2_task); }); ( @@ -592,17 +615,22 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< user_id_mapping: Arc>, my_account_id: ecdsa::Public, network: N, + logger: DebugLogger, ) -> TriplexedChannel { let (tx_to_async_proto_1, rx_for_async_proto_1) = futures::channel::mpsc::unbounded(); let (tx_to_async_proto_2, rx_for_async_proto_2) = futures::channel::mpsc::unbounded(); let (tx_to_async_proto_3, rx_for_async_proto_3) = futures::channel::mpsc::unbounded(); + let logger_outgoing = logger.clone(); // Take the messages from the gadget and send them to the async protocol tokio::task::spawn(async move { let mut id = 0; while let Some(msg_orig) = rx_gadget.recv().await { if msg_orig.payload.is_empty() { - log::warn!(target: "gadget", "Received empty message from Peer {}", msg_orig.from); + logger.warn(format!( + "Received empty message from Peer {}", + msg_orig.from + )); continue; } match bincode2::deserialize::>( @@ -620,7 +648,7 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< I1::from_inbound(id, msg_orig.from as PartyIndex, msg_type, msg); if tx_to_async_proto_1.unbounded_send(Ok(incoming)).is_err() { - log::error!(target: "gadget", "Failed to send Incoming message to protocol"); + logger.error("Failed to send Incoming message to protocol"); } id += 1; @@ -636,20 +664,20 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< I2::from_inbound(id, msg_orig.from as PartyIndex, msg_type, msg); if tx_to_async_proto_2.unbounded_send(Ok(incoming)).is_err() { - log::error!(target: "gadget", "Failed to send Incoming message to protocol"); + logger.error("Failed to send Incoming message to protocol"); } id += 1; } MultiplexedChannelMessage::Channel3(msg) => { if tx_to_async_proto_3.unbounded_send(msg).is_err() { - log::error!(target: "gadget", "Failed to send C2 message to protocol"); + logger.error("Failed to send C2 message to protocol"); } } }, Err(err) => { - log::error!(target: "gadget", "Failed to deserialize message: {err:?}"); + logger.error(format!("Failed to deserialize message: {err:?}")); } } } @@ -673,6 +701,7 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< tokio::task::spawn(async move { let user_id_mapping = &user_id_mapping; let network = &network; + let logger = &logger_outgoing; let task0 = async move { while let Some(msg) = rx_to_outbound_1.next().await { if let Err(err) = @@ -686,10 +715,11 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< associated_retry_id, associated_task_id, |m| MultiplexedChannelMessage::Channel1(m.inner_message()), + logger, ) .await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + logger.error(format!("Failed to send message to outbound: {err:?}")); } } }; @@ -707,10 +737,11 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< associated_retry_id, associated_task_id, |m| MultiplexedChannelMessage::Channel2(m.inner_message()), + logger, ) .await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + logger.error(format!("Failed to send message to outbound: {err:?}")); } } }; @@ -728,10 +759,11 @@ pub fn create_job_manager_to_async_protocol_channel_split_io_triplex< associated_retry_id, associated_task_id, |m| MultiplexedChannelMessage::Channel3(m), + logger, ) .await { - log::error!(target:"gadget", "Failed to send message to outbound: {err:?}"); + logger.error(format!("Failed to send message to outbound: {err:?}")); } } }; @@ -766,16 +798,19 @@ async fn wrap_message_and_forward_to_network< associated_retry_id: ::RetryID, associated_task_id: ::TaskID, splitter: impl FnOnce(M) -> MultiplexedChannelMessage, + logger: &DebugLogger, ) -> Result<(), crate::Error> where M: MaybeSenderReceiver + Send + 'static, { let from = msg.maybe_sender(); let to = msg.maybe_receiver(); + logger.trace(format!("Sending message from {:?} to {:?}", from, to)); let (to_account_id, from_account_id) = get_to_and_from_account_id( user_id_mapping, from.as_user_id().unwrap_or(my_user_id), to.as_user_id(), + logger, ); // let message_multiplexed = MultiplexedChannelMessage::::Channel1(msg.inner_message()); diff --git a/protocols/bls/src/protocol/keygen.rs b/protocols/bls/src/protocol/keygen.rs index 708b4b958..35f033e76 100644 --- a/protocols/bls/src/protocol/keygen.rs +++ b/protocols/bls/src/protocol/keygen.rs @@ -118,6 +118,7 @@ where user_id_to_account_id.clone(), id, network.clone(), + logger.clone(), ); let me = round_based::AsyncProtocol::new(state_machine, rx0, tx0) diff --git a/protocols/bls/src/protocol/signing.rs b/protocols/bls/src/protocol/signing.rs index 5aa11b09d..d1782d93a 100644 --- a/protocols/bls/src/protocol/signing.rs +++ b/protocols/bls/src/protocol/signing.rs @@ -139,6 +139,7 @@ where additional_params.user_id_to_account_id_mapping.clone(), id, network, + logger.clone(), ); // Step 1: Generate shares diff --git a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs index 8b20f56d9..1925ee3c2 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_refresh.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_refresh.rs @@ -303,6 +303,7 @@ async fn handle_key_refresh< mapping.clone(), role_id, network.clone(), + logger.clone(), ); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); diff --git a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs index 02e097ea9..46c8d0488 100644 --- a/protocols/dfns-cggmp21/src/protocols/key_rotate.rs +++ b/protocols/dfns-cggmp21/src/protocols/key_rotate.rs @@ -64,6 +64,9 @@ where "We are selected to sign: i={i}, signers={signers:?} | signers len: {}", signers.len() )); + config + .logger + .info(format!("Mapping for network: {mapping:?}")); let new_key = config .key_store @@ -215,6 +218,7 @@ where mapping.clone(), role_id, network.clone(), + logger.clone(), ); run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( &logger, @@ -249,6 +253,7 @@ where mapping.clone(), role_id, network.clone(), + logger.clone(), ); run_and_serialize_signing::< Secp256r1, @@ -289,6 +294,7 @@ where mapping.clone(), role_id, network.clone(), + logger.clone(), ); run_and_serialize_signing::< Stark, diff --git a/protocols/dfns-cggmp21/src/protocols/keygen.rs b/protocols/dfns-cggmp21/src/protocols/keygen.rs index 7cf15efa6..87d31e425 100644 --- a/protocols/dfns-cggmp21/src/protocols/keygen.rs +++ b/protocols/dfns-cggmp21/src/protocols/keygen.rs @@ -223,6 +223,7 @@ pub fn create_party( mapping: Arc>, id: ecdsa::Public, network: N, + logger: DebugLogger, ) -> CreatePartyResult where N: Network, @@ -245,6 +246,7 @@ where mapping, id, network, + logger, ); let delivery = (rx_async_proto, tx_to_outbound); ( @@ -689,6 +691,7 @@ async fn run_full_keygen_protocol< mapping, my_role_id, network, + logger.clone(), ); let delivery = (rx0, tx0); let party = MpcParty::, _, _>::connected(delivery); diff --git a/protocols/dfns-cggmp21/src/protocols/sign.rs b/protocols/dfns-cggmp21/src/protocols/sign.rs index 75f820606..224d8b833 100644 --- a/protocols/dfns-cggmp21/src/protocols/sign.rs +++ b/protocols/dfns-cggmp21/src/protocols/sign.rs @@ -207,12 +207,14 @@ where let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let data_hash = keccak_256(&input_data_to_sign); - let data_to_sign = DataToSign::from_scalar( - dfns_cggmp21::generic_ec::Scalar::from_be_bytes_mod_order(data_hash), - ); let signature = match role_type { RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256k1) => { + let data_to_sign = DataToSign::from_scalar(dfns_cggmp21::generic_ec::Scalar::< + Secp256k1, + >::from_be_bytes_mod_order( + data_hash + )); let (_, _, party) = create_party::< Secp256k1, _, @@ -227,6 +229,7 @@ where mapping.clone(), my_role_id, network.clone(), + logger.clone(), ); run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( &logger, @@ -242,11 +245,16 @@ where .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Secp256r1) => { + let data_to_sign = DataToSign::from_scalar(dfns_cggmp21::generic_ec::Scalar::< + Secp256r1, + >::from_be_bytes_mod_order( + data_hash + )); let (_, _, party) = create_party::< Secp256r1, _, DefaultSecurityLevel, - Msg, + Msg, >( protocol_message_channel, associated_block_id, @@ -256,6 +264,7 @@ where mapping.clone(), my_role_id, network.clone(), + logger.clone(), ); run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( &logger, @@ -271,11 +280,16 @@ where .await? } RoleType::Tss(ThresholdSignatureRoleType::DfnsCGGMP21Stark) => { + let data_to_sign = DataToSign::from_scalar(dfns_cggmp21::generic_ec::Scalar::< + Stark, + >::from_be_bytes_mod_order( + data_hash + )); let (_, _, party) = create_party::< Stark, _, DefaultSecurityLevel, - Msg, + Msg, >( protocol_message_channel, associated_block_id, @@ -285,6 +299,7 @@ where mapping.clone(), my_role_id, network.clone(), + logger.clone(), ); run_and_serialize_signing::<_, DefaultSecurityLevel, _, _, DefaultCryptoHasher>( &logger, diff --git a/protocols/dfns-cggmp21/src/protocols/util.rs b/protocols/dfns-cggmp21/src/protocols/util.rs index 6dbb07fa7..9a97474e7 100644 --- a/protocols/dfns-cggmp21/src/protocols/util.rs +++ b/protocols/dfns-cggmp21/src/protocols/util.rs @@ -1,5 +1,5 @@ use gadget_common::gadget::message::UserID; -use rand::prelude::SliceRandom; +use itertools::Itertools; use sp_core::ecdsa::Public; use std::collections::HashMap; @@ -16,44 +16,47 @@ pub type ChosenSigners = (u16, Vec, HashMap); /// # Panics /// If the current participant is not in the list of participants it will panic. pub fn choose_signers( - rng: &mut R, + _rng: &mut R, my_account_id: &Public, participants: &[Public], t: u16, ) -> Result { let selected_participants = participants - .choose_multiple(rng, t as usize) - .cloned() - .collect::>(); + .iter() + .take(t as usize) + .copied() + .enumerate() + .map(|(i, p)| (i as UserID, p)) + .sorted_by_key(|k| k.0) + .collect::>(); let selected_participants_indices = selected_participants .iter() - .map(|p| participants.iter().position(|x| x == p).unwrap() as u16) + .map(|p| participants.iter().position(|x| x == p.1).unwrap() as u16) + .sorted() .collect::>(); - let j = participants + // Generate a new mapping of part indexes starting from 0 and incrementing to t (e.g., [0, 1, 2, ...]) + let _user_id_to_account_id_mapping = selected_participants_indices .iter() - .position(|p| p == my_account_id) - .expect("Should exist") as u16; + .map(|idx| participants[*idx as usize]) + .enumerate() + .map(|(i, p)| (i as UserID, p)) + .collect::>(); - let i = selected_participants_indices + // Find our position in the NEW mapping + let my_position = *selected_participants .iter() - .position(|p| *p == j) - .map(|i| i as u16) + .find(|(_id, pk)| pk == &my_account_id) .ok_or_else(|| gadget_common::Error::ParticipantNotSelected { id: *my_account_id, - reason: String::from("we are not selected to sign"), - })?; + reason: "We are not signing this round".to_string(), + })? + .0; - let user_id_to_account_id_mapping = selected_participants - .clone() - .into_iter() - .enumerate() - .map(|(i, p)| (i as UserID, p)) - .collect(); Ok(( - i, + my_position as u16, selected_participants_indices, - user_id_to_account_id_mapping, + selected_participants, )) } diff --git a/protocols/zcash-frost/src/protocol/keygen.rs b/protocols/zcash-frost/src/protocol/keygen.rs index cdcc0aac3..48c4985ba 100644 --- a/protocols/zcash-frost/src/protocol/keygen.rs +++ b/protocols/zcash-frost/src/protocol/keygen.rs @@ -186,6 +186,7 @@ where mapping.clone(), id, network.clone(), + logger.clone(), ); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); let delivery = (keygen_rx_async_proto, keygen_tx_to_outbound); diff --git a/protocols/zcash-frost/src/protocol/sign.rs b/protocols/zcash-frost/src/protocol/sign.rs index ae00aae33..8ffea0b8d 100644 --- a/protocols/zcash-frost/src/protocol/sign.rs +++ b/protocols/zcash-frost/src/protocol/sign.rs @@ -205,6 +205,7 @@ where mapping.clone(), id, network.clone(), + logger.clone(), ); let mut tracer = dfns_cggmp21::progress::PerfProfiler::new(); From 6c5d90061abab52c9f4a936f37f44b2ab7fbd3ef Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Fri, 1 Mar 2024 15:02:32 -0500 Subject: [PATCH 66/66] revert util.rs --- protocols/dfns-cggmp21/src/protocols/util.rs | 54 ++++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/protocols/dfns-cggmp21/src/protocols/util.rs b/protocols/dfns-cggmp21/src/protocols/util.rs index 9a97474e7..49d4a2932 100644 --- a/protocols/dfns-cggmp21/src/protocols/util.rs +++ b/protocols/dfns-cggmp21/src/protocols/util.rs @@ -1,5 +1,6 @@ use gadget_common::gadget::message::UserID; -use itertools::Itertools; +use rand::prelude::SliceRandom; +use sp_core::ecdsa; use sp_core::ecdsa::Public; use std::collections::HashMap; @@ -16,47 +17,44 @@ pub type ChosenSigners = (u16, Vec, HashMap); /// # Panics /// If the current participant is not in the list of participants it will panic. pub fn choose_signers( - _rng: &mut R, - my_account_id: &Public, - participants: &[Public], + rng: &mut R, + my_role_key: &ecdsa::Public, + participants: &[ecdsa::Public], t: u16, ) -> Result { let selected_participants = participants - .iter() - .take(t as usize) - .copied() - .enumerate() - .map(|(i, p)| (i as UserID, p)) - .sorted_by_key(|k| k.0) - .collect::>(); + .choose_multiple(rng, t as usize) + .cloned() + .collect::>(); let selected_participants_indices = selected_participants .iter() - .map(|p| participants.iter().position(|x| x == p.1).unwrap() as u16) - .sorted() + .map(|p| participants.iter().position(|x| x == p).unwrap() as u16) .collect::>(); - // Generate a new mapping of part indexes starting from 0 and incrementing to t (e.g., [0, 1, 2, ...]) - let _user_id_to_account_id_mapping = selected_participants_indices + let j = participants .iter() - .map(|idx| participants[*idx as usize]) - .enumerate() - .map(|(i, p)| (i as UserID, p)) - .collect::>(); + .position(|p| p == my_role_key) + .expect("Should exist") as u16; - // Find our position in the NEW mapping - let my_position = *selected_participants + let i = selected_participants_indices .iter() - .find(|(_id, pk)| pk == &my_account_id) + .position(|p| p == &j) + .map(|i| i as u16) .ok_or_else(|| gadget_common::Error::ParticipantNotSelected { - id: *my_account_id, - reason: "We are not signing this round".to_string(), - })? - .0; + id: *my_role_key, + reason: String::from("we are not selected to sign"), + })?; + let user_id_to_account_id_mapping = selected_participants + .clone() + .into_iter() + .enumerate() + .map(|(i, p)| (i as UserID, p)) + .collect(); Ok(( - my_position as u16, + i, selected_participants_indices, - selected_participants, + user_id_to_account_id_mapping, )) }