diff --git a/Cargo.lock b/Cargo.lock index 818d3bf..bfcaefa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,21 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +version = 4 [[package]] name = "anyhow" @@ -35,21 +20,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "backtrace" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - [[package]] name = "base16ct" version = "0.2.0" @@ -141,12 +111,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" - [[package]] name = "cc" version = "1.0.83" @@ -164,9 +128,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cggmp21-keygen" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "035c720da632d7303d2286f9ba4923dfba646f99465695ef21fc72b9e330476f" +checksum = "aaa8c850290c494f951abe0350e56c31e4f5664863490197490ff48cb825447d" dependencies = [ "digest", "displaydoc", @@ -180,7 +144,7 @@ dependencies = [ "serde", "serde_with", "sha2", - "thiserror", + "thiserror 1.0.57", "udigest", ] @@ -258,7 +222,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -282,7 +246,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -293,7 +257,7 @@ checksum = "c5a91391accf613803c2a9bf9abccdbaa07c54b4244a5b64883f9c3c137c86be" dependencies = [ "darling_core", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -334,7 +298,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -401,7 +365,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -482,7 +446,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -614,15 +578,9 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - [[package]] name = "givre" -version = "0.1.0" +version = "0.2.0" dependencies = [ "cggmp21-keygen", "digest", @@ -645,7 +603,6 @@ dependencies = [ "anyhow", "bitcoin", "ed25519-dalek", - "futures", "generic-tests", "givre", "hex", @@ -655,9 +612,7 @@ dependencies = [ "rand_dev", "round-based", "secp256k1", - "slip-10", "test-case", - "tokio", ] [[package]] @@ -673,9 +628,9 @@ dependencies = [ [[package]] name = "hd-wallet" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4111172d55e2217d689df0fc9038cbd65826dd842ac5df9a04363accfa0769a3" +checksum = "6d1e8b25f89c813ea3f4317b86c1e89ecc86843601ca8657448e47e4f68f69af" dependencies = [ "generic-array", "generic-ec", @@ -747,9 +702,9 @@ dependencies = [ [[package]] name = "key-share" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea364cb2397405d8c79afd3de173ca7e2e1d83a4ddd94d359263480ad96f06f" +checksum = "3ee8e510bb9f738ac400b7dedd98aeb23677c6b48cd3b1b682651ea5091f4282" dependencies = [ "displaydoc", "generic-ec", @@ -759,7 +714,7 @@ dependencies = [ "rand_core", "serde", "serde_with", - "thiserror", + "thiserror 1.0.57", ] [[package]] @@ -774,15 +729,6 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" -[[package]] -name = "miniz_oxide" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" -dependencies = [ - "adler", -] - [[package]] name = "num-bigint" version = "0.4.4" @@ -818,15 +764,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "memchr", -] - [[package]] name = "phantom-type" version = "0.3.1" @@ -887,9 +824,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -957,37 +894,28 @@ dependencies = [ [[package]] name = "round-based" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55f473f56ecfa6457a75c0922c4e51ad036d4a1d27b0a697ac3a9b26f74acc3b" +checksum = "079e623c882b5ec9c1a4140cb077179ea89f5352f85a7ebd879428c33ce66399" dependencies = [ - "displaydoc", "futures-util", "phantom-type 0.3.1", "round-based-derive", - "thiserror", - "tokio", - "tokio-stream", + "thiserror 2.0.6", "tracing", ] [[package]] name = "round-based-derive" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0397bf224fdbcb3b286926e43bba90a96f81a82cc630ebfc9290d18e8b6331bd" +checksum = "4afa4d5b318bcafae8a7ebc57c1cb7d4b2db7358293e34d71bfd605fd327cc13" dependencies = [ "proc-macro2", "quote", "syn 1.0.109", ] -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - [[package]] name = "rustc_version" version = "0.4.0" @@ -1058,7 +986,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -1096,7 +1024,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -1128,19 +1056,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "slip-10" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10c50b6de806a216bce1d98e9107e03f60b54abcfbe6be3935a528ab57c19f6a" -dependencies = [ - "generic-array", - "generic-ec", - "hmac", - "sha2", - "subtle", -] - [[package]] name = "spki" version = "0.7.3" @@ -1182,9 +1097,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -1209,7 +1124,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -1220,7 +1135,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", "test-case-core", ] @@ -1230,7 +1145,16 @@ version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.57", +] + +[[package]] +name = "thiserror" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47" +dependencies = [ + "thiserror-impl 2.0.6", ] [[package]] @@ -1241,7 +1165,18 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] @@ -1263,53 +1198,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" -[[package]] -name = "tokio" -version = "1.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" -dependencies = [ - "backtrace", - "pin-project-lite", - "tokio-macros", -] - -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "tokio-stream" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", - "tokio-util", -] - -[[package]] -name = "tokio-util" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", -] - [[package]] name = "tracing" version = "0.1.40" @@ -1350,7 +1238,7 @@ checksum = "603329303137e0d59238ee4d6b9c085eada8e2a9d20666f3abd9dadf8f8543f4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -1388,5 +1276,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] diff --git a/Cargo.toml b/Cargo.toml index e3ca791..e2d3cfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,3 +9,7 @@ exclude = [ "wasm/no_std", ] +[workspace.dependencies] +givre = { path = "./givre" } + +round-based = { version = "0.4", default-features = false } diff --git a/givre/CHANGELOG.md b/givre/CHANGELOG.md index b7a3502..c737b3b 100644 --- a/givre/CHANGELOG.md +++ b/givre/CHANGELOG.md @@ -1,3 +1,12 @@ +## v0.2.0 +* Update dependencies: [#15] + * `hd-wallet` to v0.6 + * `round-based` to v0.4 + * `key-share` to v0.6 + * `cggmp21-keygen` to v0.5 + +[#15]: https://github.com/LFDT-Lockness/givre/pull/15 + ## v0.1.2 * Fix issue with double header menu displayed on docs.rs [#16] diff --git a/givre/Cargo.toml b/givre/Cargo.toml index e9bd179..3d24607 100644 --- a/givre/Cargo.toml +++ b/givre/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "givre" -version = "0.1.2" +version = "0.2.0" edition = "2021" license = "MIT OR Apache-2.0" description = "TSS Schnorr/EdDSA implementation based on FROST" @@ -12,15 +12,15 @@ readme = "../README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cggmp21-keygen = { version = "0.4", default-features = false, optional = true } -key-share = { version = "0.5", default-features = false } +cggmp21-keygen = { version = "0.5", default-features = false, optional = true } +key-share = { version = "0.6", default-features = false } generic-ec = { version = "0.4", default-features = false, features = ["alloc"] } rand_core = { version = "0.6", default-features = false } digest = { version = "0.10", default-features = false } -round-based = { version = "0.3", default-features = false, features = ["derive"], optional = true } +round-based = { workspace = true, features = ["derive"], optional = true } k256 = { version = "0.13", default-features = false, features = ["hash2curve"], optional = true } static_assertions = { version = "1.1", optional = true } @@ -28,7 +28,7 @@ sha2 = { version = "0.10", default-features = false, optional = true } serde = { version = "1", default-features = false, features = ["derive"], optional = true } -hd-wallet = { version = "0.5", default-features = false, optional = true } +hd-wallet = { version = "0.6", default-features = false, optional = true } [dev-dependencies] rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } @@ -40,9 +40,7 @@ default = ["std"] std = [ "key-share/std", "cggmp21-keygen?/std", - "round-based?/std", "serde?/std", - "hd-wallet?/std" ] cggmp21-keygen = ["dep:cggmp21-keygen"] diff --git a/givre/src/ciphersuite.rs b/givre/src/ciphersuite.rs index 340d71c..e1ca167 100644 --- a/givre/src/ciphersuite.rs +++ b/givre/src/ciphersuite.rs @@ -33,7 +33,7 @@ pub use secp256k1::Secp256k1; /// For the details, refer to [Section 6] of the draft /// /// [Section 6]: https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-15.html#name-ciphersuites -pub trait Ciphersuite: Sized + Clone + Copy + core::fmt::Debug { +pub trait Ciphersuite: Sized + Clone + Copy + Eq + core::fmt::Debug { /// Name of the ciphersuite, also known as `contextString` in the draft const NAME: &'static str; @@ -204,7 +204,10 @@ impl, E: Curve> AdditionalEntropy for generic_ec::S } } impl> AdditionalEntropy for generic_ec::NonZero { - type Bytes<'b> = >::Bytes<'b> where Self: 'b; + type Bytes<'b> + = >::Bytes<'b> + where + Self: 'b; fn to_bytes(&self) -> Self::Bytes<'_> { AdditionalEntropy::::to_bytes(self.as_ref()) } @@ -222,7 +225,10 @@ impl AdditionalEntropy for [u8; N] { } } impl> AdditionalEntropy for &T { - type Bytes<'b> = >::Bytes<'b> where Self: 'b; + type Bytes<'b> + = >::Bytes<'b> + where + Self: 'b; fn to_bytes(&self) -> Self::Bytes<'_> { (*self).to_bytes() } @@ -232,7 +238,7 @@ impl> AdditionalEntropy for &T { /// /// Point that satisfies [`Ciphersuite::is_normalized`]. Can wrap both `Point` and /// `NonZero>`. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct NormalizedPoint(P, core::marker::PhantomData); impl>> NormalizedPoint { @@ -281,12 +287,6 @@ where self.0.as_ref() } } -impl core::cmp::PartialEq for NormalizedPoint { - fn eq(&self, other: &Self) -> bool { - self.0 == other.0 - } -} -impl core::cmp::Eq for NormalizedPoint {} #[cfg(feature = "serde")] impl serde::Serialize for NormalizedPoint { diff --git a/givre/src/ciphersuite/bitcoin.rs b/givre/src/ciphersuite/bitcoin.rs index d493cec..6925a0b 100644 --- a/givre/src/ciphersuite/bitcoin.rs +++ b/givre/src/ciphersuite/bitcoin.rs @@ -6,7 +6,7 @@ use super::{Ciphersuite, Secp256k1}; /// FROST ciphersuite that outputs [BIP-340] compliant signatures /// /// [BIP-340]: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Bitcoin; impl Ciphersuite for Bitcoin { diff --git a/givre/src/ciphersuite/ed25519.rs b/givre/src/ciphersuite/ed25519.rs index dbec0e4..9da8a13 100644 --- a/givre/src/ciphersuite/ed25519.rs +++ b/givre/src/ciphersuite/ed25519.rs @@ -4,7 +4,7 @@ use generic_ec::{NonZero, Point}; use crate::Ciphersuite; /// FROST(Ed25519, SHA-512) ciphersuite that produces Ed25519-compliant signatures -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Ed25519; impl Ciphersuite for Ed25519 { diff --git a/givre/src/ciphersuite/secp256k1.rs b/givre/src/ciphersuite/secp256k1.rs index 81a4ee3..0879197 100644 --- a/givre/src/ciphersuite/secp256k1.rs +++ b/givre/src/ciphersuite/secp256k1.rs @@ -4,7 +4,7 @@ use generic_ec::{NonZero, Point}; use crate::Ciphersuite; /// FROST(secp256k1, SHA-256) ciphersuite -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Secp256k1; impl Ciphersuite for Secp256k1 { diff --git a/givre/src/signing/aggregate.rs b/givre/src/signing/aggregate.rs index 53145c5..991f6ba 100644 --- a/givre/src/signing/aggregate.rs +++ b/givre/src/signing/aggregate.rs @@ -15,7 +15,7 @@ use crate::{ciphersuite::NormalizedPoint, Ciphersuite, SignerIndex}; use super::{round1::PublicCommitments, round2::SigShare, utils}; -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[cfg_attr( feature = "serde", derive(serde::Serialize, serde::Deserialize), diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 112020d..d4a6678 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -7,25 +7,22 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -givre = { path = "../givre", features = ["all-ciphersuites", "cggmp21-keygen", "spof", "hd-wallet", "full-signing"] } +givre = { workspace = true, features = ["all-ciphersuites", "cggmp21-keygen", "spof", "hd-wallet", "full-signing"] } generic-tests = "0.1" test-case = "3.3" -rand_dev = "0.1" rand = "0.8" rand_core = "0.6" +rand_dev = "0.1" hex = "0.4" hex-literal = "0.4" -tokio = { version = "1", features = ["macros", "rt"]} -futures = "0.3" -round-based = { version = "0.3", features = ["dev"] } +round-based = { workspace = true, features = ["sim"] } ed25519 = { package = "ed25519-dalek", version = "2.1" } secp256k1 = { version = "0.29", features = ["global-context"] } bitcoin = "0.32" -slip-10 = { version = "0.4", default-features = false } anyhow = "1" diff --git a/tests/tests/it/interactive.rs b/tests/tests/it/interactive.rs index 0465865..6b498e0 100644 --- a/tests/tests/it/interactive.rs +++ b/tests/tests/it/interactive.rs @@ -1,7 +1,5 @@ -#[generic_tests::define(attrs(test_case::case, tokio::test))] +#[generic_tests::define(attrs(test_case::case))] mod generic { - use std::iter; - use anyhow::Context; use givre::Ciphersuite; use givre_tests::ExternalVerifier; @@ -13,45 +11,41 @@ mod generic { #[test_case::case(Some(3), 5; "t3n5")] #[test_case::case(Some(5), 5; "t5n5")] #[test_case::case(None, 5; "n5")] - #[tokio::test] - async fn keygen_sign(t: Option, n: u16) { + fn keygen_sign(t: Option, n: u16) { let mut rng = rand_dev::DevRng::new(); // --- Keygen let eid: [u8; 32] = rng.gen(); let eid = givre::keygen::ExecutionId::new(&eid); - let mut simulation_threshold = round_based::simulation::Simulation::new(); - let mut simulation_nonthreshold = round_based::simulation::Simulation::new(); - let keygen_executions = (0..n) - .zip(iter::repeat_with(|| { - ( - rng.fork(), - simulation_threshold.add_party(), - simulation_nonthreshold.add_party(), - ) - })) - .map( - move |(j, (mut rng, party_threshold, party_nonthreshold))| async move { - if let Some(t) = t { - givre::keygen::(eid, j, n) - .set_threshold(t) - .hd_wallet(true) - .start(&mut rng, party_threshold) - .await - } else { - givre::keygen(eid, j, n) - .hd_wallet(true) - .start(&mut rng, party_nonthreshold) - .await - } - }, - ); + let mut sim_threshold = round_based::sim::Simulation::with_capacity(n); + let mut sim_nonthreshold = round_based::sim::Simulation::with_capacity(n); + for j in 0..n { + let mut rng = rng.fork(); + if let Some(t) = t { + sim_threshold.add_async_party(|party| async move { + givre::keygen::(eid, j, n) + .set_threshold(t) + .hd_wallet(true) + .start(&mut rng, party) + .await + }) + } else { + sim_nonthreshold.add_async_party(|party| async move { + givre::keygen(eid, j, n) + .hd_wallet(true) + .start(&mut rng, party) + .await + }) + } + } - let key_shares: Vec> = - futures::future::try_join_all(keygen_executions) - .await - .unwrap(); + let key_shares = if t.is_some() { + sim_threshold.run() + } else { + sim_nonthreshold.run() + }; + let key_shares = key_shares.unwrap().expect_ok().into_vec(); let pk = key_shares[0].shared_public_key; // --- Signing @@ -87,32 +81,27 @@ mod generic { .collect::>(); let signers = signers.as_slice(); - let mut simulation = round_based::simulation::Simulation::new(); - let signing_executions = (0..t) - .zip(signers) - .zip(iter::repeat_with(|| (rng.fork(), simulation.add_party()))) - .map(|((j, &index_at_keygen), (mut rng, party))| { - let key_share = &key_shares[usize::from(index_at_keygen)]; - let derivation_path = &derivation_path; - async move { - let mut signing = givre::signing::(j, key_share, signers, msg); - if !derivation_path.is_empty() { - signing = signing - .set_derivation_path(derivation_path.iter().copied()) - .context("set derivation path")?; - } - if let Some(root) = taproot_merkle_root { - signing = signing.set_taproot_tweak(root).context("set merkle root")? - } - - signing.sign(&mut rng, party).await.context("sign") + let sig = round_based::sim::run_with_setup(signers, |j, party, &index_at_keygen| { + let key_share = &key_shares[usize::from(index_at_keygen)]; + let derivation_path = &derivation_path; + let mut rng = rng.fork(); + async move { + let mut signing = givre::signing::(j, key_share, signers, msg); + if !derivation_path.is_empty() { + signing = signing + .set_derivation_path(derivation_path.iter().copied()) + .context("set derivation path")?; + } + if let Some(root) = taproot_merkle_root { + signing = signing.set_taproot_tweak(root).context("set merkle root")? } - }); - let sigs: Vec> = - futures::future::try_join_all(signing_executions) - .await - .unwrap(); + signing.sign(&mut rng, party).await.context("sign") + } + }) + .unwrap() + .expect_ok() + .expect_eq(); // Verify signature using external library C::verify_sig( @@ -120,15 +109,10 @@ mod generic { key_shares[0].chain_code, &derivation_path, taproot_merkle_root, - &sigs[0], + &sig, msg, ) .unwrap(); - - for sig in &sigs[1..] { - assert_eq!(sigs[0].r, sig.r); - assert_eq!(sigs[0].z, sig.z); - } } #[instantiate_tests()] diff --git a/tests/tests/it/test_vectors.rs b/tests/tests/it/test_vectors.rs index e4888ba..c84f304 100644 --- a/tests/tests/it/test_vectors.rs +++ b/tests/tests/it/test_vectors.rs @@ -290,7 +290,7 @@ fn ed25519() { fn mocked_randomness(bytes: &[u8]) -> impl RngCore + CryptoRng + '_ { struct MockedRng<'b>(&'b [u8]); - impl<'b> RngCore for MockedRng<'b> { + impl RngCore for MockedRng<'_> { fn fill_bytes(&mut self, dest: &mut [u8]) { let len = dest.len(); let (randomness, leftover) = self.0.split_at(len); @@ -309,7 +309,7 @@ fn mocked_randomness(bytes: &[u8]) -> impl RngCore + CryptoRng + '_ { Ok(()) } } - impl<'b> CryptoRng for MockedRng<'b> {} + impl CryptoRng for MockedRng<'_> {} MockedRng(bytes) }