From 8ecdb48c83ead0ddbb57a295c7732893b5a566fb Mon Sep 17 00:00:00 2001 From: Georgios Gkitsas Date: Tue, 10 Aug 2021 10:33:29 +0100 Subject: [PATCH 01/16] initial work on #55 --- Cargo.lock | 1 + Cargo.toml | 1 + src/dkg/pv.rs | 258 +++++++++++++++++++++++++++++++++++++ src/primitives.rs | 1 - src/vss/pvss.rs | 19 ++- tpke/benches/benchmarks.rs | 4 +- tpke/src/context.rs | 3 +- tpke/src/decryption.rs | 2 +- tpke/src/key_share.rs | 8 +- tpke/src/lib.rs | 2 - 10 files changed, 287 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc6fb4d7..9487946f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -708,6 +708,7 @@ dependencies = [ "rand 0.7.3", "rand 0.8.4", "rand_chacha 0.3.1", + "rand_core 0.6.3", "redjubjub", "serde", "serde_bytes", diff --git a/Cargo.toml b/Cargo.toml index 2a220d2d..ef43499c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ measure_time = "0.7" redjubjub = "0.4.0" ark-ed-on-bls12-381 = "0.3.0" group-threshold-cryptography = {path = "./tpke/"} +rand_core = "0.6" [dependencies.digest] version = "0.9.0" diff --git a/src/dkg/pv.rs b/src/dkg/pv.rs index c8364a92..a8a63bef 100644 --- a/src/dkg/pv.rs +++ b/src/dkg/pv.rs @@ -212,3 +212,261 @@ pub struct PubliclyVerifiableAnnouncement { pub session_key: PubliclyVerifiablePublicKey, pub stake: u64, } + +#[cfg(test)] +mod tests { + + use crate::dkg::PubliclyVerifiableDKG; + use crate::*; + use ark_bls12_381::G1Affine; + use ark_ec::{bls12::Bls12, PairingEngine}; + use ark_std::{end_timer, start_timer}; + use group_threshold_cryptography::{ + decrypt_with_shared_secret, encrypt, setup, Ciphertext, + DecryptionShare, PrivateDecryptionContext, PrivateKeyShare, + PublicDecryptionContext, PublicKeyShares, + }; + use itertools::izip; + + // #[test] + // pub fn test_pv() { + // extern crate rand_old; + // use rand_old::rngs::OsRng; + // use ark_bls12_381::Bls12_381; + + // let mut rng = &mut ark_std::test_rng(); + // let mut csprng = OsRng{}; + + // let shares_num = 8192; + // let threshold = shares_num*2/3; + // let num_entities = 150; + + // let dkg_params = Params { + // tau: 0, + // security_threshold: threshold, + // total_weight: shares_num + // }; + + // let ed_key: ed25519::Keypair = ed25519::Keypair::generate(&mut csprng); + // let mut dkg: PubliclyVerifiableDKG = PubliclyVerifiableDKG::new(ed_key, dkg_params, rng).unwrap(); + // let pubkey = dkg.final_key(); + // let share_msg = dkg.share(rng).unwrap(); + + // } + + #[test] + pub fn test_pvdkg_tpke() { + use ark_ec::{AffineCurve, ProjectiveCurve}; + let rng = &mut ark_std::test_rng(); + use rand_old::SeedableRng; + let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); + + let params = Params { + tau: 0u64, + security_threshold: 300 / 3, + total_weight: 300, + }; + + // for _ in 0..1 { + let mut contexts = vec![]; + for _ in 0..10 { + contexts.push( + PubliclyVerifiableDKG::::new( + ed25519_dalek::Keypair::generate(ed_rng), + params.clone(), + rng, + ) + .unwrap(), + ); + } + use std::collections::VecDeque; + let mut messages = VecDeque::new(); + + let stake = (0..150u64).map(|i| i).collect::>(); + + for (participant, stake) in contexts.iter_mut().zip(stake.iter()) { + let announce = participant.announce(*stake); + messages.push_back(announce); + } + + let msg_loop = + |contexts: &mut Vec< + PubliclyVerifiableDKG, + >, + messages: &mut VecDeque| loop { + if messages.is_empty() { + break; + } + let signed_message = messages.pop_front().unwrap(); + for node in contexts.iter_mut() { + let (_, message) = signed_message.verify().unwrap(); + let new_msg = node + .handle_message(&signed_message.signer, message) + .unwrap(); + if let Some(new_msg) = new_msg { + messages.push_back(new_msg); + } + } + }; + + msg_loop(&mut contexts, &mut messages); + + for participant in contexts.iter_mut() { + participant.finish_announce().unwrap(); + } + + msg_loop(&mut contexts, &mut messages); + + let mut dealt_weight = 0u32; + let mut pvss = vec![]; + for participant in contexts.iter_mut() { + if dealt_weight < params.total_weight - params.security_threshold { + let msg = participant.share(rng).unwrap(); + let msg: PubliclyVerifiableMessage = + msg; //.verify().unwrap().1; + pvss.push((participant.ed_key.public.clone(), msg)); + //messages.push_back(msg); + dealt_weight += participant.participants[participant.me].weight; + } + } + for msg in pvss.iter() { + for node in contexts.iter_mut() { + node.handle_message(&msg.0, msg.1.clone()).unwrap(); + } + } + msg_loop(&mut contexts, &mut messages); + + let tpke_pubkey = contexts[0].final_key(); + + ///////////////////////////////////////// TPKE ///////////////////////////////////////// + let threshold = contexts[0].params.security_threshold as usize; //16 * 2 / 3; + let shares_num = contexts[0].params.total_weight as usize; //16; + let num_entities = contexts.len(); + let msg: &[u8] = "abc".as_bytes(); + + // let (_, privkey, tpke_contexts) = setup::( + // threshold, + // shares_num, + // num_entities, + // ); + + use ark_std::UniformRand; + let rng = &mut ark_std::test_rng(); + + let window_size = FixedBaseMSM::get_mul_window_size(100); + let scalar_bits = as PairingEngine>::Fr::size_in_bits(); + let g = as PairingEngine>::G1Affine::prime_subgroup_generator(); + let h = as PairingEngine>::G2Affine::prime_subgroup_generator(); + + let mut private_contexts = vec![]; + let mut public_contexts = vec![]; + + // pub struct PubliclyVerifiableDKG + // { + // pub ed_key: ed25519::Keypair, + // pub params: Params, + // pub pvss_params: PubliclyVerifiableParams, + // pub session_keypair: PubliclyVerifiableKeypair, + // pub participants: Vec>, + // pub vss: BTreeMap>, + // pub domain: ark_poly::Radix2EvaluationDomain, + // pub state: DKGState, + // pub me: usize, + // pub local_shares: Vec, + // } + + let fft_domain = ark_poly::Radix2EvaluationDomain::< + as PairingEngine>::Fr, + >::new(shares_num) + .unwrap(); + let mut domain_points = Vec::with_capacity(shares_num); + let mut point = + as PairingEngine>::Fr::one(); + let mut domain_points_inv = Vec::with_capacity(shares_num); + let mut point_inv = + as PairingEngine>::Fr::one(); + + for _ in 0..shares_num { + domain_points.push(point); + point *= fft_domain.group_gen; + domain_points_inv.push(point_inv); + point_inv *= fft_domain.group_gen_inv; + } + + // let pubkey_shares: Vec< + // as PairingEngine>::G1Affine, + // > = vec![]; + + // for context in contexts { + for (_, (context, domain, domain_inv, public)) in izip!( + contexts, + domain_points.chunks(shares_num / num_entities), + domain_points_inv.chunks(shares_num / num_entities), + pubkey_shares.chunks(shares_num / num_entities), + ) + .enumerate() + { + let b = + as PairingEngine>::Fr::rand( + rng, + ); + let private_key_share = PrivateKeyShare:: { + private_key_shares: context.local_shares, + }; + let mut blinded_key_shares = private_key_share.blind(b.clone()); + blinded_key_shares.multiply_by_omega_inv(domain_inv); + + private_contexts.push(PrivateDecryptionContext:: { + index: context.me, + b, + b_inv: b.inverse().unwrap(), + private_key_share, + public_decryption_contexts: vec![], + g, + g_inv: as PairingEngine>::G1Prepared::from(-g), + h_inv: as PairingEngine>::G2Prepared::from(-h), + scalar_bits, + window_size, + }); + let mut lagrange_N_0 = domain.iter().product::< as PairingEngine>::Fr>(); + if domain.len() % 2 == 1 { + lagrange_N_0 = -lagrange_N_0; + } + public_contexts.push(PublicDecryptionContext::< + ark_bls12_381::Bls12_381, + > { + domain: domain.to_vec(), + public_key_shares: PublicKeyShares:: { + public_key_shares: public.to_vec(), + }, + blinded_key_shares, + lagrange_N_0, + }); + } + for private in private_contexts.iter_mut() { + private.public_decryption_contexts = public_contexts.clone(); + } + + let ciphertext = + encrypt::<_, ark_bls12_381::Bls12_381>(msg, tpke_pubkey, rng); + + // create Decryption Shares + let mut shares: Vec> = vec![]; + for context in private_contexts.iter() { + shares.push(context.create_decryption_share(&ciphertext)); + } + + let prepared_blinded_key_shares = + private_contexts[0].prepare_combine(&shares); + let s = private_contexts[0].share_combine( + &ciphertext, + &shares, + &prepared_blinded_key_shares, + ); + + let plaintext = decrypt_with_shared_secret(&ciphertext, &s); + assert!(plaintext == msg) + + // } + } +} diff --git a/src/primitives.rs b/src/primitives.rs index 935a9f2b..7b4ab1bf 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -6,7 +6,6 @@ pub use keypair::*; pub mod subproductdomain; pub use subproductdomain::*; - /// Compute a fast multiexp of many scalars times the same base /// Only convenient for when called once with given base; if called /// more than once, it's faster to save the generated window table diff --git a/src/vss/pvss.rs b/src/vss/pvss.rs index e34867f7..862c0cb5 100644 --- a/src/vss/pvss.rs +++ b/src/vss/pvss.rs @@ -278,13 +278,13 @@ fn test_pvss() { #[test] fn test_pvss() { - let rng = &mut ark_std::test_rng(); + let mut rng = &mut ark_std::test_rng(); use ark_bls12_381::Bls12_381; type Fr = ::Fr; type G1 = ::G1Affine; type G2 = ::G2Affine; - let mut phi = DensePolynomial::::rand(8192 / 3, rng); + let mut phi = DensePolynomial::::rand(8192 / 3, &mut rng); use ark_std::UniformRand; let domain = ark_poly::Radix2EvaluationDomain::::new(8192) .ok_or_else(|| anyhow!("unable to construct domain")) @@ -310,4 +310,19 @@ fn test_pvss() { ) }) .collect::>(); + + // use group_threshold_cryptography::*; + // // let mut rng = test_rng + // let shares_num = 8192;(); + // let threshold = shares_num*2/3; + // let num_entities = 150; + + // let msg: &[u8] = "abc".as_bytes(); + + // // let (pubkey, privkey, _) = setup::(threshold, shares_num, num_entities); + + // let ciphertext = encrypt::(msg, pubkey, &mut rng); + // let plaintext = decrypt(&ciphertext, privkey); + + // assert!(msg == plaintext) } diff --git a/tpke/benches/benchmarks.rs b/tpke/benches/benchmarks.rs index d428951b..36b67e30 100644 --- a/tpke/benches/benchmarks.rs +++ b/tpke/benches/benchmarks.rs @@ -32,7 +32,7 @@ pub fn bench_decryption(c: &mut Criterion) { dec_shares.push(Vec::with_capacity(threshold)); for i in 0..num_entities { - dec_shares[j].push(contexts[i].create_share(&ciphertexts[j])); + dec_shares[j].push(contexts[i].create_decryption_share(&ciphertexts[j])); } } let prepared_blinded_key_shares = contexts[0].prepare_combine(&dec_shares[0]); @@ -78,7 +78,7 @@ pub fn bench_decryption(c: &mut Criterion) { dec_shares.push(Vec::with_capacity(threshold)); for i in 0..num_entities { - dec_shares[j].push(contexts[i].create_share(&ciphertexts[j])); + dec_shares[j].push(contexts[i].create_decryption_share(&ciphertexts[j])); } } diff --git a/tpke/src/context.rs b/tpke/src/context.rs index 299993fd..80fb4d8f 100644 --- a/tpke/src/context.rs +++ b/tpke/src/context.rs @@ -1,6 +1,6 @@ use crate::*; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct PublicDecryptionContext { pub domain: Vec, pub public_key_shares: PublicKeyShares, @@ -9,6 +9,7 @@ pub struct PublicDecryptionContext { pub lagrange_N_0: E::Fr, } +#[derive(Debug)] pub struct PrivateDecryptionContext { pub index: usize, pub b: E::Fr, diff --git a/tpke/src/decryption.rs b/tpke/src/decryption.rs index 2bb33ca2..ff1bfec6 100644 --- a/tpke/src/decryption.rs +++ b/tpke/src/decryption.rs @@ -8,7 +8,7 @@ pub struct DecryptionShare { } impl PrivateDecryptionContext { - pub fn create_share(&self, ciphertext: &Ciphertext) -> DecryptionShare { + pub fn create_decryption_share(&self, ciphertext: &Ciphertext) -> DecryptionShare { let decryption_share = ciphertext.nonce.mul(self.b_inv).into_affine(); DecryptionShare { diff --git a/tpke/src/key_share.rs b/tpke/src/key_share.rs index fa092649..ce280868 100644 --- a/tpke/src/key_share.rs +++ b/tpke/src/key_share.rs @@ -2,12 +2,12 @@ use crate::*; use ark_ec::ProjectiveCurve; use itertools::Itertools; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct PublicKeyShares { pub public_key_shares: Vec, // A_{i, \omega_i} } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct BlindedKeyShares { pub blinding_key: E::G2Affine, // [b] H pub blinding_key_prepared: E::G2Prepared, // [b] H @@ -51,6 +51,7 @@ impl BlindedKeyShares { (alpha_A_i, E::G2Prepared::from(self.blinding_key)), ]) == E::Fqk::one() } + pub fn get_window_table( &self, window_size: usize, @@ -67,12 +68,13 @@ impl BlindedKeyShares { }) .collect::>() } + pub fn multiply_by_omega_inv(&mut self, domain_inv: &[E::Fr]) { izip!(self.blinded_key_shares.iter_mut(), domain_inv.iter()) .for_each(|(key, omega_inv)| *key = key.mul(-*omega_inv).into_affine()) } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct BlindedKeyShareWindowTable { pub window_table: Vec>, } diff --git a/tpke/src/lib.rs b/tpke/src/lib.rs index adeb9c05..826c065a 100644 --- a/tpke/src/lib.rs +++ b/tpke/src/lib.rs @@ -69,8 +69,6 @@ pub fn setup( let rng = &mut ark_std::test_rng(); let g = E::G1Affine::prime_subgroup_generator(); let h = E::G2Affine::prime_subgroup_generator(); - let g_inv = E::G1Prepared::from(-g); - let h_inv = E::G2Prepared::from(-h); assert!(shares_num >= threshold); let threshold_poly = DensePolynomial::::rand(threshold - 1, rng); From d81a36b0f4c1ed6266d3b1a3ce0360c90d2ea46a Mon Sep 17 00:00:00 2001 From: Georgios Gkitsas Date: Thu, 12 Aug 2021 14:51:16 +0100 Subject: [PATCH 02/16] refactor --- tpke/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tpke/src/lib.rs b/tpke/src/lib.rs index 826c065a..f721d8fd 100644 --- a/tpke/src/lib.rs +++ b/tpke/src/lib.rs @@ -71,10 +71,11 @@ pub fn setup( let h = E::G2Affine::prime_subgroup_generator(); assert!(shares_num >= threshold); - let threshold_poly = DensePolynomial::::rand(threshold - 1, rng); + let threshold_poly = DensePolynomial::::rand(threshold - 1, rng); let fft_domain = ark_poly::Radix2EvaluationDomain::::new(shares_num).unwrap(); let evals = threshold_poly.evaluate_over_domain_by_ref(fft_domain); + let mut domain_points = Vec::with_capacity(shares_num); let mut point = E::Fr::one(); let mut domain_points_inv = Vec::with_capacity(shares_num); @@ -189,7 +190,7 @@ mod tests { let mut shares: Vec> = vec![]; for context in contexts.iter() { - shares.push(context.create_share(&ciphertext)); + shares.push(context.create_decryption_share(&ciphertext)); } /*for pub_context in contexts[0].public_decryption_contexts.iter() { assert!(pub_context From 3611f99996d6599f6821dd53cda22b5c488d6a8b Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Tue, 17 Aug 2021 11:55:57 -0400 Subject: [PATCH 03/16] Add more detail on tx encryption --- book/src/tpke.md | 3 +-- book/src/tx.md | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/book/src/tpke.md b/book/src/tpke.md index 88f63430..519838d4 100644 --- a/book/src/tpke.md +++ b/book/src/tpke.md @@ -4,7 +4,7 @@ Based on [A Simple and Efficient Threshold Cryptosystem from the Gap Diffie-Hell ## Overview -The threshold encryption scheme allows the encrypter to derive a **shared secret** \\(s\\) from the threshold public key \\(Y\\), such that sufficient threshold of validators holding private key shares \\(Z_i\\) associated with \\(Y\\) can also derive the shared secret. Both encrypter and decrypter can use the shared secret to derive a ChaCha20 symmetric key via HKDF. +The threshold encryption scheme allows the encrypter to derive a **shared secret** \\(s\\) from the threshold public key \\(Y\\), such that sufficient threshold of validators holding private key shares \\(Z_i\\) associated with \\(Y\\) can also derive the shared secret. Both encrypter and decrypter use the shared secret to derive a symmetric key for a key-committing AEAD via HKDF. ### To encrypt @@ -31,7 +31,6 @@ Check that \\(e(U, H_{\mathbb{G}_2} (U))= e(G, W)\\) for ciphertext validity. 2. Each decryption share is \\(C_i = e(U, Z_i)\\). 3. To combine decryption shares, s = \\(\prod C_i^{\lambda_i(0)}\\) where \\(\lambda_i(0)\\) is the lagrange coefficient over the appropriate size domain. - ### Threshold Decryption (fast method) Thanks to Kobi Gurkan for this approach. diff --git a/book/src/tx.md b/book/src/tx.md index 7db391c0..ca91c1b8 100644 --- a/book/src/tx.md +++ b/book/src/tx.md @@ -7,26 +7,36 @@ Transactions sent to the mempool should be encrypted to this public key, and blo An encrypted transaction consists of: - The public key ciphertext \\(U, W\\) associated with this transaction -- The ChaCha20 encrypted payload of the transaction, with symmetric key derived from \\(U, W\\) -- A BLAKE2b hash of the transaction payload +- The key-committing AEAD encrypted payload of the transaction, with symmetric key derived from \\(U, W\\) - Transaction fee payment details +- The epoch number that the tx is being encrypted to. The inclusion of fee payment outside of the payload ensures that the network is not saturated with invalid transactions. +The encryption method is then ran roughly as: +1. Sample private key `k`. +2. Compute Ciphertext as `CT = KC_AEAD.Encrypt(key=Hash(k * threshold_pubkey), msg={state machine tx}, additional_data={empty})` +3. Run Threshold Encryption as `TE.Encrypt(private_key=k, threshold_pubkey, ciphertext=ct, additional_data={tx fee details, epoch number})` + ## Block proposal A block proposal, therefore, consists of: 1. Validator-selected encrypted transactions (likely ordered by fee) -2. Combined decryption shares for all transactions in the previous block -3. Decryptions of transactions from the previous block. - -Availability of decryption shares for those transactions is guaranteed by new block finalization rules, and it is the block proposer's responsibility to combine the decryption shares to derive each transaction's symmetric key, and to compute the ChaCha20 decryption of each encrypted transaction's payload. +2. Decryption data for all transactions in the previous block + +Availability of decryption shares for those transactions is guaranteed by new block finalization rules, and it is the block proposer's responsibility to combine the decryption shares to derive each transaction's symmetric key, and to compute the AEAD decryption of each encrypted transaction's payload. + +The decryption data for a tx is oneof (`encryption_private_key`, `list of decryption shares`). For a validly constructed transaction, the decryption shares can be combined to get the symmetric key. The combined share can then be included within the block, and every node can check its validity by correctness of the key-committing AEAD. + +If the tx was invalidly constructed, then all of the constituent decryption shares must get posted on-chain for verifyability.** Constructing a valid block proposal therefore executes 1 `TPKE.CombineDecryptionShares` operation per transaction per block signer in the previous block. Verifying the validity of a block proposal therefore executes 1 `TPKE.VerifyCombination` operation per block signer in the previous block. +** There is an optimization where we only need one list of 'cross-tx combined' decryption shares, for all invalid txs per block. + ## Block finalization In addition to the standard 2/3 weight requirements for block finalization, Ferveo adds an additional requirement: every validator signature on a block must include valid, signed decryption shares corresponsing to that validator, for every encrypted transaction committed to in that block, totaling at least 2/3 weight of decryption shares. From 2b6590e3b02fd4e051e90242aa5c21085ca069b0 Mon Sep 17 00:00:00 2001 From: joe bebel <55120843+joebebel@users.noreply.github.com> Date: Wed, 18 Aug 2021 01:04:20 -0700 Subject: [PATCH 04/16] book --- book/src/dkg.md | 19 +++---- book/src/tpke-concrete.md | 104 ++++++++++++++++++++------------------ 2 files changed, 66 insertions(+), 57 deletions(-) diff --git a/book/src/dkg.md b/book/src/dkg.md index 6f3b62bf..e8e92ea9 100644 --- a/book/src/dkg.md +++ b/book/src/dkg.md @@ -14,21 +14,22 @@ Some Publicly Verifiable DKG schemes, such as Groth21, produce field private key In addition to the two independent generators \\(G \in \mathbb{G}_1\\) and \\(H \in \mathbb{G}_2\\), a third independent generator \\(\hat{u}_1 \in \mathbb{G}_2\\) is selected. -## Session keys +## Epoch keys -Each validator \\(i\\) generates a **session keypair** for the lifetime of the DKG: a decryption key \\(dk_i \in \mathbb{F}_r\\), and a signing key \\(sk_i\in \mathbb{F}_r \\). - -The signing key is used for a signature of knowledge in the DKG and is independent of the Ed25519 identity used for signing messages in the protocol. - -The public session keypair consists of an **encryption key** \\(ek_i \in \mathbb{G}_2\\) and a verification key \\(sk_i \in \mathbb{G}_1\\): +Each validator \\(i\\) generates a **epoch keypair**: a private decryption key \\(dk_i \in \mathbb{F}_r\\), and a public encryption key \\(ek_i\in \mathbb{G}_2 \\). The encryption key is derived from the decryption key: \\[ek_i = [dk_i] H \\] -\\[vk_i = [sk_i] G \\] + +Each validator is required to generate an epoch keypair at genesis, or upon joining the validator set. Each validator should generate and announce a new epoch public key once per epoch, but in the event that a validator does not announce a new epoch public key during an epoch, the last announced epoch public key should be used in the DKG. For this reason, each validator should persist their latest epoch private key on disk. ## Publicly Verifiable Secret Sharing -The validators, in decreasing order of number of key shares, each act as a dealer for exactly one PVSS instance until at least 2/3 by weight of key shares have successfully posted a verified correct PVSS instance to the blockchain. In case a dealer's PVSS instance does not verify as correct, that instance is discarded (and penalties may be imposed) and additional validators act as dealers until the 2/3 threshold is reached. +The validators should each generate exactly one PVSS instance as a dealer, and include that instance as a VoteExtension to a specially designated DKG block. The next block proposer is responsible for verifying and aggregating at least 2/3 by weight of PVSS instances, and including the aggregation in the next block. + +For performance reasons, the aggregating validator may sort the PVSS instances by decreasing validator weight, and only include sufficient instances to reach the necessary 2/3 total weight. PVSS instances above the 2/3 weight threshold are ignored. + +In case a dealer's PVSS instance does not verify as correct, that instance is discarded (and penalties may be imposed). ## Output -Once 2/3 by weight of dealers have posted correct PVSS instances, all of the correct instances are aggregated into a single PVSS instance. The commitment to the constant term of the aggregated PVSS instance, \\(F_0\\), is the public key output \\(Y\\) from the PVDKG, and each validators aggregated private key shares \\(Z_{i,\omega_j} \\) are the private key shares associated with \\(Y\\) \ No newline at end of file +Once 2/3 by weight of correct PVSS instances have been aggregated into a single PVSS instance, the commitment to the constant term of the aggregated PVSS instance, \\(F_0\\), is the public key output \\(Y\\) from the PVDKG, and each validators aggregated private key shares \\(Z_{i,\omega_j} \\) are the private key shares associated with \\(Y\\) \ No newline at end of file diff --git a/book/src/tpke-concrete.md b/book/src/tpke-concrete.md index d8cadf5a..215c1b4b 100644 --- a/book/src/tpke-concrete.md +++ b/book/src/tpke-concrete.md @@ -6,31 +6,64 @@ There are optimizations that can be done to increase decryption throughput when The DKG and TPKE schemes support the following key operations: -* `DKG.KeyGen(tau, total_weight, {(s_i, ek_i)})` -* `DKG.Announce() -> (ek, dk)` +* `DKG.GenerateEpochKeypair() -> (ek, dk)` * `DKG.PartitionDomain() ` -* `DKG.Share` -* `TPKE.Blind(Z_i)` inputs a validators private key shares and outputs a -* `TPKE.VerifyBlinding()` +* `DKG.GeneratePVSS(tau, total_weight, {(s_i, ek_i)})` +* `DKG.VerifyPVSS` +* `DKG.AggregatePVSS` And supports the following ciphertext operations: * `TPKE.Encrypt(Y)` inputs a public threshold key \\(Y\\) and outputs a random ciphertext \\((U,W)\\) encrypted to that public key +* `TPKE.Blind` * `TPKE.CiphertextValidity(U,W)` tests if $\\((U,W)\\) is a valid ciphertext -* `TPKE.CreateDecryptionShare()` +* `TPKE.CreateDecryptionShare(dk_j, U_i,W_i) -> D_{i,j}` * `TPKE.VerifyDecryptionShares` * `TPKE.BatchVerifyDecryptionShares` * `TPKE.CombineDecryptionShares` combines decryption shares * `TPKE.VerifyCombination` verifies a combination for many * `TPKE.DeriveSymmetricKey` +## `DKG.GenerateEpochKeypair() -> (ek, dk)` + +Choose a uniformly random scalar \\(dk \in \mathbb{F}_r \\) and compute \\( ek = [dk] H \\) + +## `DKG.PartitionDomain() -> {(Omega_i, ek_i)}` + +## `DKG.GeneratePVSS(tau, total_weight, {(Omega_i, ek_i)}) -> ` + +2. Choose a uniformly random polynomial \\(f(x) = \sum^p_i a_i x^i \\) of degree \\(t\\). +3. Let \\(F_0, \ldots, F_p \leftarrow = [a_0] G, \ldots, [a_t] G \\) +5. For each validator \\(i\\), for each \\(\omega_j \in \Omega_i\\), encrypt the evaluation \\( \hat{Y}_{i, \omega_j} \leftarrow [f(\omega_j)] ek_i \\) + + +## `DKG.VerifyPVSS` + +## `DKG.AggregatePVSS` + +4. +4. Post the signed message \\(\tau, (F_0, \ldots, F_t), \hat{u}_2, (\hat{Y}_{i,\omega_j})\\) to the blockchain + +## `DKG.VerifyAggregatedPVSS` + +## Public verification + +1. Check \\(e(F_0, \hat{u}_1)= e(G_1, \hat{u_2})\\) +2. Compute by FFT \\(A_1, \ldots, A_W \leftarrow [f(\omega_0)]G_1, \ldots, [f(\omega_W)]G_1 \\) +3. Partition \\(A_1, \ldots, A_W\\) into \\(A_{i,\omega_j} \\) for validator \\(i\\)'s shares \\(\omega_j\\) +4. For each encrypted share \\(\hat{Y}_{i,\omega_i} \\), check \\(e(G_1, \hat{Y}_{i,\omega_j}) = e(A_{i,\omega_j}, ek_i) \\) + ## Lagrange Coefficients Given a validator subset \\(\{i\}\\), the Lagrange coefficients \\(\lambda_{\omega}(0)\\) for the domain \\(\cup \Omega_i \\) can be computed efficiently using the Subproduct Domain technique. Total cost: \\( O(p \log p) \\) -## `TPKE.Encrypt(Y)` +## `DKG.GenerateEpochKeypair() -> (ek, dk)` + +The validator generates a random scalar \\(dk \in \mathbb{F}_r \\) and computes the public key \\( ek = [dk] H \\) + +## `TPKE.Encrypt(Y, aad) -> (U,W)` `TPKE.Encrypt(Y, aad)` creates a new, random ciphertext \\((U,W)\\) encrypted to the public key \\(Y\\), and a corresponding ephemeral shared secret \\(S\\) such that the private key associated with \\(Y\\) can efficiently compute \\(S\\) from the ciphertext \\((U,W)\\). Additional authenticated data `aad` may be attached to the ciphertext. @@ -43,29 +76,7 @@ The ephemeral shared secret \\(S\\) can be used to derive a shared symmetric enc Then \\((U,W)\\) is the ciphertext and \\(S\\) is the ephemeral shared secret. -## `TPKE.Blind` - -On input private key shares \\( Z_{i, \omega_j} \\), generate a random scalar \\(b\\) and output - -\\[ B_{i, \omega_j} = [b] Z_{i, \omega_j} \\] - -\\[ P_i = [b] H \\] - -Total cost: -* 1 \\(\mathbb{G}_1\\) multiply per key share -* 1 \\(\mathbb{G}_1\\) multiply - -## `TPKE.VerifyBlinding()` - -On input \\([b_i] Z_{i_\omega}\\) and \\([b_i] H \\) - -\\[ e(A_i + [\alpha] G, [b_i] H) = e(G, [b_i]Z_i + [\alpha * b] H) \\] - -Total cost: -* 1 `G2Prepared` per key share -* 1 `G2Prepared` per validator - -## `TPKE.CiphertextValidity(U,W)` +## `TPKE.CiphertextValidity(U,W) -> bool` To provide chosen ciphertext security, ciphertext validity must be checked for each ciphertext \\((U,W)\\) separately. The ciphertext can be checked by: @@ -75,7 +86,7 @@ Total cost: * 1 \\(\mathbb{G}_1\\) and 1 \\(\mathbb{G}_2\\) deserialize per ciphertext * 1 product of pairings * -## `TPKE.BatchCiphertextValidity( {U,W} )` +## `TPKE.BatchCiphertextValidity( {U,W} ) -> bool` Once a block proposer has verified ciphertext validity, the entire block can be optimistically verified: @@ -85,37 +96,35 @@ Total cost: * 1 \\(\mathbb{G}_1\\) and 1 \\(\mathbb{G}_2\\) deserialize per ciphertext * 1 product of pairings -## `TPKE.CreateDecryptionShare` - -\\[D_{i,j} = [b_i^{-1}] U_j\\] +## `TPKE.CreateDecryptionShare(dk_i, U_j) -> D_{i,j}` +\\[D_{i,j} = [dk_i^{-1}] U_j\\] -## `TPKE.VerifyDecryptionShares` +## `TPKE.VerifyDecryptionShares(ek_i, { U_j }, { D_{i,j} }) -> bool` -Given many valid ciphertexts \\((U_j,W_j)\\), on input potential decryption shares for each ciphertext \\(\{D_{i,j}\}\\) from a single validator \\(i\\) with blinded public key \\(B_i\\), the validity of those shares can be checked by: +Given many valid ciphertexts \\((U_j,W_j)\\), on input potential decryption shares for each ciphertext \\(\{D_{i,j}\}\\) from a single validator \\(i\\) with epoch public key \\(ek_i\\), the validity of those shares can be checked by: -\\[D_{i,j} = [b_i^{-1}] U_j\\] -\\[P_i = [b_i] H \\] +\\[D_{i,j} = [dk_i^{-1}] U_j\\] -\\[ e(\sum_j [\alpha_j] D_{i,j}, P_i) = e(\sum_j [\alpha_j] U_j, H) \\] +\\[ e(\sum_j [\alpha_j] D_{i,j}, ek_i) = e(\sum_j [\alpha_j] U_j, H) \\] Total cost: * 1 \\(\mathbb{G}_1\\) deserialize per validator per ciphertext * 2 pairings per validator * 1 \\(\mathbb{G}_1\\) multiply and 1 \\(\mathbb{G}_2\\) multiply per ciphertext. -## `TPKE.BatchVerifyDecryptionShares` +## `TPKE.BatchVerifyDecryptionShares({ek_i}, { U_j }, { D_{i,j} }) -> bool` -Given many valid ciphertexts \\((U_j,W_j)\\), on input 2/3 weight of potential decryption shares for each ciphertext \\(\{D_{i,j}\}\\), corresponding to validator set \\(\{i\}\\) with blinded public keys \\(B_i\\), the validity of those shares can be checked: +Given many valid ciphertexts \\((U_j,W_j)\\), on input 2/3 weight of potential decryption shares for each ciphertext \\(\{D_{i,j}\}\\), corresponding to validator set \\(\{i\}\\) with epoch public keys \\(ek_i\\), the validity of those shares can be checked: -\\[ \prod_i e(\sum_{j} [\alpha_{i,j}] D_{i,j}, P_i) = e([\sum_{i,j} \alpha_{i,j}] U_j, H) \\] +\\[ \prod_i e(\sum_{j} [\alpha_{i,j}] D_{i,j}, ek_i) = e([\sum_{i,j} \alpha_{i,j}] U_j, H) \\] Total cost: * 1 G1 deserialize per validator * V+1 pairings * 1 \\(\mathbb{G}_1\\) multiply and 1 \\(\mathbb{G}_2\\) multiply, per ciphertext. -## `TPKE.AggregateDecryptionShares` +## `TPKE.AggregateDecryptionShares( {U_j}, {D_{i,j}} ) -> {\hat{D}_i} ` Given many valid ciphertexts \\((U_j,W_j)\\), on input 2/3 weight of potential decryption shares for each ciphertext \\(\{D_{i,j}\}\\) sharing the same validator set, if decryption shares are only needed to check the validity of the decryption process, the decryption shares of many ciphertexts can be aggregated into one decryption share set. @@ -128,7 +137,7 @@ which can be used to compute the aggregated decryption share for validator \\(i\ \\[\hat{D}_i = \sum_j \rho_j D_{i,j} \\] -## `TPKE.VerifyAggregatedDecryptionShares` +## `TPKE.VerifyAggregatedDecryptionShares({U_j}, {\hat{D}_i}) -> bool` Given many valid ciphertexts \\((U_j,W_j)\\) and an aggregated decryption share set for those ciphertexts, the validity of the aggregation can be checked by computing the publicly known coefficients: \\[ \rho_j = H(U_1, \ldots, U_k, j) \\] @@ -137,14 +146,13 @@ and checking the pairing equation: \\[ \prod_i e(\sum_{j} [\rho_i] \hat{D}_{i}, P_i) = e([\sum_{i,j} \rho_i] U_j, H) \\] - -## `TPKE.CombineDecryptionShares()` +## `TPKE.CombineDecryptionShares( {U_j}, {D_{i,j}) -> {S_j}` For a given ciphertext \\((U_j,W_j)\\), on input 2/3 weight of valid decryption shares \\(\{D_{i,j}\}\\) as checked by ``TPKE.VerifyDecryptionShares`, corresponding to validator set \\(\{i\}\\). Then a partial combined share \\(S_{i,j}\\) for that ciphertext can be computed with one pairing: -\\[ S_{i,j} = e( D_{i,j}, [\sum_{\omega_j \in \Omega_i} \lambda_{\omega_j}(0)] [b] Z_{i,\omega_j} ) \\] +\\[ S_{i,j} = e( D_{i,j}, [\sum_{\omega_j \in \Omega_i} \lambda_{\omega_j}(0)] Z_{i,\omega_j} ) \\] and combined to get the final combined share \\(S_j = \prod_i S_{i,j}\\). @@ -163,7 +171,7 @@ computed using unknown \\(D_{i,j}\\) but with the publicly known coefficients: can be used to compute an aggregated partial combined share \\(\hat{S}_i \\): -\\[ \hat{S}_i = e( \hat{D}_i, [\sum_{\omega_j \in \Omega_i} \lambda_{\omega_j}(0)] [b] Z_{i,\omega_j} ) \\] +\\[ \hat{S}_i = e( \hat{D}_i, [\sum_{\omega_j \in \Omega_i} \lambda_{\omega_j}(0)] Z_{i,\omega_j} ) \\] and combined to get an aggregated final combined share \\( \hat{S} = \prod_i \hat{S}_i\\) which can be checked against the computed \\(\{S_j\}\\) by: From 0b75038e233aaab85344d649ab1e68a846fe2fff Mon Sep 17 00:00:00 2001 From: joe bebel <55120843+joebebel@users.noreply.github.com> Date: Wed, 18 Aug 2021 01:44:04 -0700 Subject: [PATCH 05/16] remove u_hat --- Cargo.toml | 12 ++++----- book/src/tpke-concrete.md | 56 ++++++++++++++++++++------------------- src/dkg/common.rs | 1 - src/vss/pvss.rs | 18 ------------- 4 files changed, 35 insertions(+), 52 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4ce27500..3905ef5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ authors = ["Heliax AG "] [dependencies] ark-poly-commit = "0.3" ark-std = "0.3" -ark-pallas = "0.3" +#ark-pallas = "0.3" ark-bls12-381 = "0.3" ark-ec = "0.3" ark-ff = "0.3" @@ -30,8 +30,8 @@ miracl_core = "2.3.0" num = "0.4" sha2 = "0.9.1" ed25519-dalek = { version = "1", features = ["serde", "batch"] } -x25519-dalek = { version = "1.1", features = ["serde"] } -curve25519-dalek = { version = "3.0", features = ["serde"] } +#x25519-dalek = { version = "1.1", features = ["serde"] } +#curve25519-dalek = { version = "3.0", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } blake2 = "0.9.1" rand_chacha = "0.3.0" @@ -46,9 +46,9 @@ borsh = "0.9" subtle = "2.4" itertools = "0.10.1" measure_time = "0.7" -redjubjub = "0.4.0" -ark-ed-on-bls12-381 = "0.3.0" -group-threshold-cryptography = {path = "./tpke/"} +#redjubjub = "0.4.0" +#ark-ed-on-bls12-381 = "0.3.0" +#group-threshold-cryptography = {path = "./tpke/"} rand_core = "0.6" [dependencies.digest] diff --git a/book/src/tpke-concrete.md b/book/src/tpke-concrete.md index 215c1b4b..cc48bb8d 100644 --- a/book/src/tpke-concrete.md +++ b/book/src/tpke-concrete.md @@ -7,51 +7,48 @@ There are optimizations that can be done to increase decryption throughput when The DKG and TPKE schemes support the following key operations: * `DKG.GenerateEpochKeypair() -> (ek, dk)` -* `DKG.PartitionDomain() ` +* `DKG.PartitionDomain({ek_i, s_i}) -> {(ek_i, Omega_i)} ` * `DKG.GeneratePVSS(tau, total_weight, {(s_i, ek_i)})` -* `DKG.VerifyPVSS` -* `DKG.AggregatePVSS` +* `DKG.VerifyPVSS(tau, PVSS) -> bool` +* `DKG.AggregatePVSS({PVSS_i}) -> PVSS` +* `DKG.VerifyAggregatedPVSS({PVSS_i}, PVSS) -> bool` And supports the following ciphertext operations: -* `TPKE.Encrypt(Y)` inputs a public threshold key \\(Y\\) and outputs a random ciphertext \\((U,W)\\) encrypted to that public key -* `TPKE.Blind` +* `TPKE.Encrypt(Y, aad)` inputs a public threshold key \\(Y\\) and outputs a random ciphertext \\((U,W)\\) encrypted to that public key * `TPKE.CiphertextValidity(U,W)` tests if $\\((U,W)\\) is a valid ciphertext * `TPKE.CreateDecryptionShare(dk_j, U_i,W_i) -> D_{i,j}` -* `TPKE.VerifyDecryptionShares` -* `TPKE.BatchVerifyDecryptionShares` -* `TPKE.CombineDecryptionShares` combines decryption shares +* `TPKE.VerifyDecryptionShares(ek_i, { U_j }, { D_{i,j} }) -> bool` +* `TPKE.BatchVerifyDecryptionShares({ek_i}, { U_j }, { D_{i,j} }) -> bool` +* `TPKE.CombineDecryptionShares( {U_j}, {D_{i,j}) -> {S_j}` combines decryption shares * `TPKE.VerifyCombination` verifies a combination for many -* `TPKE.DeriveSymmetricKey` +* `TPKE.DeriveSymmetricKey(S_j) -> k_j` ## `DKG.GenerateEpochKeypair() -> (ek, dk)` Choose a uniformly random scalar \\(dk \in \mathbb{F}_r \\) and compute \\( ek = [dk] H \\) -## `DKG.PartitionDomain() -> {(Omega_i, ek_i)}` +## `DKG.PartitionDomain({ek_i, s_i}) -> {(ek_i, Omega_i)}` -## `DKG.GeneratePVSS(tau, total_weight, {(Omega_i, ek_i)}) -> ` +## `DKG.GeneratePVSS(tau, total_weight, {(ek_i, Omega_i)}) -> PVSS` -2. Choose a uniformly random polynomial \\(f(x) = \sum^p_i a_i x^i \\) of degree \\(t\\). -3. Let \\(F_0, \ldots, F_p \leftarrow = [a_0] G, \ldots, [a_t] G \\) -5. For each validator \\(i\\), for each \\(\omega_j \in \Omega_i\\), encrypt the evaluation \\( \hat{Y}_{i, \omega_j} \leftarrow [f(\omega_j)] ek_i \\) +1. Choose a uniformly random polynomial \\(f(x) = \sum^p_i a_i x^i \\) of degree \\(t\\). +2. Let \\(F_0, \ldots, F_t \leftarrow = [a_0] G, \ldots, [a_t] G \\) +3. For each validator \\(i\\), for each \\(\omega_j \in \Omega_i\\), encrypt the evaluation \\( Z_{i, \omega_j} \leftarrow [f(\omega_j)] ek_i \\) +4. \\(\sigma = [a_0] H_{\mathbb{G}_2}(tau,F_0) \\) +Output PVSS = \\( ((F_0, sigma), (F_1, ldots, F_t), {Z_{i,\omega_j}}) \\) -## `DKG.VerifyPVSS` +## `DKG.VerifyPVSS(tau, PVSS) -> bool` -## `DKG.AggregatePVSS` +0. Decode \\( ((F_0, sigma), (F_1, ldots, F_t), {Z_{i,\omega_j}}) \leftarrow \\) PVSS +1. Compute by FFT \\(A_1, \ldots, A_W \leftarrow \operatorname{FFT}(F_0, \ldots, F_t) \\) +2. Compute \\(W\\) random scalars \\(\alpha_i \\) +3. Check \\(\mathcal{O} = \prod_i e(-G_1, Z_{i,\omega_j})e(A_{i,\omega_j}, ek_i) \\) -4. -4. Post the signed message \\(\tau, (F_0, \ldots, F_t), \hat{u}_2, (\hat{Y}_{i,\omega_j})\\) to the blockchain +## `DKG.AggregatePVSS({PVSS_i}) -> PVSS` -## `DKG.VerifyAggregatedPVSS` - -## Public verification - -1. Check \\(e(F_0, \hat{u}_1)= e(G_1, \hat{u_2})\\) -2. Compute by FFT \\(A_1, \ldots, A_W \leftarrow [f(\omega_0)]G_1, \ldots, [f(\omega_W)]G_1 \\) -3. Partition \\(A_1, \ldots, A_W\\) into \\(A_{i,\omega_j} \\) for validator \\(i\\)'s shares \\(\omega_j\\) -4. For each encrypted share \\(\hat{Y}_{i,\omega_i} \\), check \\(e(G_1, \hat{Y}_{i,\omega_j}) = e(A_{i,\omega_j}, ek_i) \\) +## `DKG.VerifyAggregatedPVSS({PVSS_i}, PVSS) -> bool` ## Lagrange Coefficients @@ -85,7 +82,8 @@ To provide chosen ciphertext security, ciphertext validity must be checked for e Total cost: * 1 \\(\mathbb{G}_1\\) and 1 \\(\mathbb{G}_2\\) deserialize per ciphertext * 1 product of pairings -* + + ## `TPKE.BatchCiphertextValidity( {U,W} ) -> bool` Once a block proposer has verified ciphertext validity, the entire block can be optimistically verified: @@ -180,3 +178,7 @@ and combined to get an aggregated final combined share \\( \hat{S} = \prod_i \ha Total cost: * 1 pairing and 1 \\(\mathbb{G}_T\\) multiply per validator * 1 \\(\mathbb{G}_1\\) multiply and 1 \\(\mathbb{G}_T\\) multiply per ciphertext. + +## `TPKE.DeriveSymmetricKey(S_j) -> k_j` + +Use HKDF(S_j) \ No newline at end of file diff --git a/src/dkg/common.rs b/src/dkg/common.rs index 5ac9f6f2..c9d26030 100644 --- a/src/dkg/common.rs +++ b/src/dkg/common.rs @@ -34,7 +34,6 @@ where .floor() as u32 }) .collect::>(); - //dbg!(&weights); // Add any excess weight to the largest weight participants let adjust_weight = params .total_weight diff --git a/src/vss/pvss.rs b/src/vss/pvss.rs index 862c0cb5..e9dd233c 100644 --- a/src/vss/pvss.rs +++ b/src/vss/pvss.rs @@ -12,9 +12,6 @@ pub struct PubliclyVerifiableSS { /// Feldman commitment to the VSS polynomial, F = g^{\phi} pub coeffs: Vec, - // \hat{u}_2 = \hat{u}_1^{a_0} - pub u_hat_2: E::G2Affine, - // ek_i^{f(\omega_j)} pub shares: Vec>, @@ -80,8 +77,6 @@ where let (_, first_pvss) = pvss_iter.next().unwrap(); //TODO: unwrap? let mut coeffs = batch_to_projective(&first_pvss.coeffs); - let mut u_hat_2 = first_pvss.u_hat_2.into_projective(); - let mut shares = first_pvss .shares .iter() @@ -91,7 +86,6 @@ where for (a, b) in coeffs.iter_mut().zip_eq(next.coeffs.iter()) { *a += b.into_projective(); } - u_hat_2 += next.u_hat_2.into_projective(); for (a, b) in shares.iter_mut().zip_eq(next.shares.iter()) { for (c, d) in a.iter_mut().zip_eq(b.iter()) { *c += d.into_projective(); @@ -112,7 +106,6 @@ where } Self { coeffs: E::G1Projective::batch_normalization_into_affine(&coeffs), - u_hat_2: u_hat_2.into_affine(), shares, sigma, commitment: E::G1Projective::batch_normalization_into_affine( @@ -155,13 +148,10 @@ where //phi.zeroize(); // TODO zeroize? - let u_hat_2 = dkg.pvss_params.u_hat_1.mul(*s).into_affine(); //TODO: new base - let sigma = E::G2Affine::prime_subgroup_generator().mul(*s).into(); //todo hash to curve let vss = Self { coeffs, - u_hat_2, shares, sigma, commitment: vec![], // Optimistically avoid computing the commitment @@ -183,14 +173,6 @@ where return Err(anyhow!("wrong vss length")); } - //let pairings = vec![]; - //let random_coefficients = vec![]; - // check e(F_0, u_hat_1) == e(g_1, u_hat_2) - if E::pairing(self.coeffs[0], dkg.pvss_params.u_hat_1) - != E::pairing(dkg.pvss_params.g_1, self.u_hat_2) - { - return Err(anyhow!("invalid")); - } { print_time!("check encryptions"); //check e() From d38bfeae5e49723443bb1b31e46b7f69347e68cd Mon Sep 17 00:00:00 2001 From: Alberto Centelles Date: Wed, 18 Aug 2021 13:12:02 +0100 Subject: [PATCH 06/16] Initial changes matching desired Ferveo API --- src/dkg.rs | 25 ++++++++++---- src/dkg/pv.rs | 93 +++++++++++++++++++++++++-------------------------- 2 files changed, 64 insertions(+), 54 deletions(-) diff --git a/src/dkg.rs b/src/dkg.rs index 16248c88..066a8b1b 100644 --- a/src/dkg.rs +++ b/src/dkg.rs @@ -30,13 +30,24 @@ pub struct Params { } #[derive(Debug, Clone)] -pub enum DKGState { - Init { - announce_messages: Vec>, - }, - Sharing { - finalized_weight: u32, +pub enum DKGState { + Init, + Dealt, + Shared, + Aggregated { + finalized_weight: u32 }, Success, - Failure, + Invalid } +// pub enum DKGState { +// Init { +// announce_messages: Vec>, +// }, +// Sharing { +// finalized_weight: u32, +// }, +// Success, +// Failure, +// } + diff --git a/src/dkg/pv.rs b/src/dkg/pv.rs index c8364a92..0ec168d7 100644 --- a/src/dkg/pv.rs +++ b/src/dkg/pv.rs @@ -14,9 +14,10 @@ where pub participants: Vec>, pub vss: BTreeMap>, pub domain: ark_poly::Radix2EvaluationDomain, - pub state: DKGState, + pub state: DKGState, pub me: usize, pub local_shares: Vec, + pub announce_messages: Vec>, } impl PubliclyVerifiableDKG @@ -50,17 +51,17 @@ where participants: vec![], vss: BTreeMap::new(), domain, - state: DKGState::::Init { - announce_messages: vec![], - }, + state: DKGState::Init, me: 0, // TODO: invalid value //final_state: None, local_shares: vec![], + // TODO: Read from storage + announce_messages: vec![], }) } /// Create a new PVSS instance within this DKG session, contributing to the final key /// `rng` is a cryptographic random number generator - /// Returns a PVSS sharing message to post on-chain + /// Returns a PVSS dealing message to post on-chain pub fn share( &mut self, rng: &mut R, @@ -74,7 +75,7 @@ where let sharing = vss.clone(); self.vss.insert(self.me as u32, vss); - Ok(PubliclyVerifiableMessage::Sharing(sharing)) + Ok(PubliclyVerifiableMessage::Deal(sharing)) } /// Aggregate all received PVSS messages into a single message, prepared to post on-chain pub fn aggregate(&mut self) -> PubliclyVerifiableMessage { @@ -91,17 +92,13 @@ where /// Call `finish_announce` once the Announcement phase is complete /// Partitions the share domain among the announced participants /// and begins the sharing phase of the DKG + /// TODO: Since announce is no longer a phase, do we still need this? pub fn finish_announce(&mut self) -> Result<()> { - if let DKGState::Init { announce_messages } = &mut self.state { - self.participants = - partition_domain(&self.params, announce_messages)?; - self.me = self - .find_by_key(&self.ed_key.public) - .ok_or_else(|| anyhow!("self not found"))?; - self.state = DKGState::Sharing { - finalized_weight: 0u32, - }; - } + self.participants = + partition_domain(&self.params, &mut self.announce_messages)?; + self.me = self + .find_by_key(&self.ed_key.public) + .ok_or_else(|| anyhow!("self not found"))?; Ok(()) } /// Returns the public key generated by the DKG @@ -116,16 +113,16 @@ where /// Create an `Announce` message /// `stake`: the amount staked by this participant in the DKG /// Returns an Announcement nessage to post on chain - pub fn announce(&mut self, stake: u64) -> SignedMessage { - SignedMessage::sign( - self.params.tau, - &PubliclyVerifiableMessage::Announce { - stake, - session_key: self.session_keypair.public(), - }, - &self.ed_key, - ) - } + // pub fn announce(&mut self, stake: u64) -> SignedMessage { + // SignedMessage::sign( + // self.params.tau, + // &PubliclyVerifiableMessage::Announce { + // stake, + // session_key: self.session_keypair.public(), + // }, + // &self.ed_key, + // ) + // } /// Handle a DKG related message posted on chain /// `signer` is the ed25519 public key of the sender of the message @@ -136,20 +133,22 @@ where payload: PubliclyVerifiableMessage, ) -> Result> { match payload { - PubliclyVerifiableMessage::Announce { stake, session_key } => { - if let DKGState::Init { announce_messages } = &mut self.state { - announce_messages.push( - PubliclyVerifiableAnnouncement:: { - stake, - session_key, - signer: *signer, - }, - ); - } - Ok(None) - } - PubliclyVerifiableMessage::Sharing(sharing) => { - if let DKGState::Sharing { finalized_weight } = self.state { + // TODO: Validators don't announce themselves through DKG + // TODO: Instead, we read stakes from storage + // PubliclyVerifiableMessage::Announce { stake, session_key } => { + // if let DKGState::Init { announce_messages } = &mut self.state { + // announce_messages.push( + // PubliclyVerifiableAnnouncement:: { + // stake, + // session_key, + // signer: *signer, + // }, + // ); + // } + // Ok(None) + // } + PubliclyVerifiableMessage::Deal(sharing) => { + if let DKGState::Init = self.state { let dealer = self.find_by_key(signer).ok_or_else(|| { anyhow!("received dealing from unknown dealer") })? as u32; @@ -163,7 +162,7 @@ where Ok(None) } PubliclyVerifiableMessage::Aggregate(vss) => { - if let DKGState::Sharing { finalized_weight } = self.state { + if let DKGState::Shared = self.state { let minimum_weight = self.params.total_weight //- self.params.failure_threshold - self.params.security_threshold; @@ -173,7 +172,7 @@ where self.local_shares = local_shares; self.state = DKGState::Success; } else { - self.state = DKGState::Sharing { + self.state = DKGState::Aggregated { finalized_weight: verified_weight, }; } @@ -188,12 +187,12 @@ where #[derive(Serialize, Deserialize, Clone, Debug)] #[serde(bound = "")] pub enum PubliclyVerifiableMessage { - Announce { - stake: u64, - session_key: PubliclyVerifiablePublicKey, - }, + // Announce { + // stake: u64, + // session_key: PubliclyVerifiablePublicKey, + // }, #[serde(with = "ark_serde")] - Sharing(PubliclyVerifiableSS), + Deal(PubliclyVerifiableSS), #[serde(with = "ark_serde")] Aggregate(PubliclyVerifiableSS), } From e6b350cea4e36d9c583868f3df991efa980bef45 Mon Sep 17 00:00:00 2001 From: Alberto Centelles Date: Wed, 18 Aug 2021 13:19:47 +0100 Subject: [PATCH 07/16] Add comment --- src/dkg/pv.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dkg/pv.rs b/src/dkg/pv.rs index 0ec168d7..04181112 100644 --- a/src/dkg/pv.rs +++ b/src/dkg/pv.rs @@ -158,6 +158,8 @@ where } self.vss.insert(dealer, sharing); } + // TODO: Shall we add here a check whether enough dealers (> 66%) have shared their PVSS? If so, we'd move to a Dealt state. + // Once we are in a dealt state, we'd trigger the generation of the transcript and share the decryption keys } Ok(None) } From 8c103ca6377216cda5ba542e8b78cfdfe48d257f Mon Sep 17 00:00:00 2001 From: Alberto Centelles Date: Wed, 18 Aug 2021 13:20:57 +0100 Subject: [PATCH 08/16] Remove dead code --- src/dkg/pv.rs | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/src/dkg/pv.rs b/src/dkg/pv.rs index 04181112..e2308974 100644 --- a/src/dkg/pv.rs +++ b/src/dkg/pv.rs @@ -55,7 +55,8 @@ where me: 0, // TODO: invalid value //final_state: None, local_shares: vec![], - // TODO: Read from storage + // TODO: Validators don't announce themselves through DKG + // TODO: Instead, we read stakes from storage announce_messages: vec![], }) } @@ -110,20 +111,6 @@ where .into_affine() } - /// Create an `Announce` message - /// `stake`: the amount staked by this participant in the DKG - /// Returns an Announcement nessage to post on chain - // pub fn announce(&mut self, stake: u64) -> SignedMessage { - // SignedMessage::sign( - // self.params.tau, - // &PubliclyVerifiableMessage::Announce { - // stake, - // session_key: self.session_keypair.public(), - // }, - // &self.ed_key, - // ) - // } - /// Handle a DKG related message posted on chain /// `signer` is the ed25519 public key of the sender of the message /// `payload` is the content of the message @@ -133,20 +120,6 @@ where payload: PubliclyVerifiableMessage, ) -> Result> { match payload { - // TODO: Validators don't announce themselves through DKG - // TODO: Instead, we read stakes from storage - // PubliclyVerifiableMessage::Announce { stake, session_key } => { - // if let DKGState::Init { announce_messages } = &mut self.state { - // announce_messages.push( - // PubliclyVerifiableAnnouncement:: { - // stake, - // session_key, - // signer: *signer, - // }, - // ); - // } - // Ok(None) - // } PubliclyVerifiableMessage::Deal(sharing) => { if let DKGState::Init = self.state { let dealer = self.find_by_key(signer).ok_or_else(|| { @@ -189,10 +162,6 @@ where #[derive(Serialize, Deserialize, Clone, Debug)] #[serde(bound = "")] pub enum PubliclyVerifiableMessage { - // Announce { - // stake: u64, - // session_key: PubliclyVerifiablePublicKey, - // }, #[serde(with = "ark_serde")] Deal(PubliclyVerifiableSS), #[serde(with = "ark_serde")] From fe964f30570ce0725c841d10fb9361026506b4e4 Mon Sep 17 00:00:00 2001 From: Alberto Centelles Date: Wed, 18 Aug 2021 13:21:29 +0100 Subject: [PATCH 09/16] Remove dead code --- src/dkg.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/dkg.rs b/src/dkg.rs index 066a8b1b..8bddc819 100644 --- a/src/dkg.rs +++ b/src/dkg.rs @@ -40,14 +40,3 @@ pub enum DKGState { Success, Invalid } -// pub enum DKGState { -// Init { -// announce_messages: Vec>, -// }, -// Sharing { -// finalized_weight: u32, -// }, -// Success, -// Failure, -// } - From 1eee37e39c0bc832364aae22b3a16e992d77204b Mon Sep 17 00:00:00 2001 From: R2D2 Date: Thu, 26 Aug 2021 16:46:41 +0200 Subject: [PATCH 10/16] [chore]: Made tpke and ferveo subcrates and made a top level workspace Cargo file. Applied lints and formatting where it was unobtrusive --- Cargo.lock | 617 +++-- Cargo.toml | 101 +- benches/benchmarks/pvdkg.rs | 17 +- examples/noserialize.rs | 2 +- examples/pvdkg.rs | 15 +- ferveo/Cargo.lock | 2121 +++++++++++++++++ ferveo/Cargo.toml | 98 + {src => ferveo/src}/dkg.rs | 2 +- {src => ferveo/src}/dkg/common.rs | 3 +- {src => ferveo/src}/dkg/pv.rs | 31 +- {src => ferveo/src}/lib.rs | 9 +- {src => ferveo/src}/main.rs | 0 {src => ferveo/src}/msg.rs | 1 - {src => ferveo/src}/primitives.rs | 1 - {src => ferveo/src}/primitives/keypair.rs | 5 +- .../src}/primitives/subproductdomain.rs | 2 +- {src => ferveo/src}/vss.rs | 2 +- {src => ferveo/src}/vss/pvss.rs | 40 +- tpke/benches/benchmarks.rs | 63 +- tpke/src/ciphertext.rs | 17 +- tpke/src/combine.rs | 46 +- tpke/src/context.rs | 2 +- tpke/src/decryption.rs | 28 +- tpke/src/hash_to_curve.rs | 14 +- tpke/src/key_share.rs | 29 +- tpke/src/lib.rs | 49 +- tpke/src/subproductdomain.rs | 37 +- 27 files changed, 2931 insertions(+), 421 deletions(-) create mode 100644 ferveo/Cargo.lock create mode 100644 ferveo/Cargo.toml rename {src => ferveo/src}/dkg.rs (95%) rename {src => ferveo/src}/dkg/common.rs (98%) rename {src => ferveo/src}/dkg/pv.rs (90%) rename {src => ferveo/src}/lib.rs (75%) rename {src => ferveo/src}/main.rs (100%) rename {src => ferveo/src}/msg.rs (98%) rename {src => ferveo/src}/primitives.rs (99%) rename {src => ferveo/src}/primitives/keypair.rs (93%) rename {src => ferveo/src}/primitives/subproductdomain.rs (99%) rename {src => ferveo/src}/vss.rs (92%) rename {src => ferveo/src}/vss/pvss.rs (90%) diff --git a/Cargo.lock b/Cargo.lock index dc6fb4d7..9eaefe1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,12 +1,25 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +[[package]] +name = "addr2line" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61f2b7f93d2c7d2b08263acaa4a363b3e276806c68af6134c44f523bf1aacd" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aead" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "922b33332f54fc0ad13fa3e514601e8d30fb54e1f3eadc36643f6526db645621" +checksum = "6e3e798aa0c8239776f54415bc06f3d74b1850f3f830b45c35cfc80556973f70" dependencies = [ "generic-array", ] @@ -19,20 +32,31 @@ checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" [[package]] name = "ahash" -version = "0.7.2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "796540673305a66d127804eef19ad696f1f204b8c1025aaca4958c17eab32877" +dependencies = [ + "getrandom 0.2.3", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f200cbb1e856866d9eade941cf3aa0c5d7dd36f74311c4273b494f4ef036957" +checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98" dependencies = [ - "getrandom 0.2.2", + "getrandom 0.2.3", "once_cell", "version_check", ] [[package]] name = "anyhow" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" +checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf" [[package]] name = "ark-bls12-381" @@ -242,6 +266,15 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + [[package]] name = "arrayvec" version = "0.5.2" @@ -265,6 +298,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a905d892734eea339e896738c14b9afce22b5318f64b951e70bf3844419b01" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "bincode" version = "1.3.3" @@ -305,9 +353,9 @@ dependencies = [ [[package]] name = "blake2" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a5720225ef5daecf08657f23791354e1685a8c91a4c60c7f3d3b2892f978f4" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" dependencies = [ "crypto-mac", "digest", @@ -321,7 +369,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" dependencies = [ "arrayref", - "arrayvec", + "arrayvec 0.5.2", "constant_time_eq", ] @@ -347,9 +395,9 @@ dependencies = [ [[package]] name = "borsh" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fcabb02816fdadf90866dc9a7824491ccb63d69f55375a266dc03509ac68d36" +checksum = "18dda7dc709193c0d86a1a51050a926dc3df1cf262ec46a23a25dba421ea1924" dependencies = [ "borsh-derive", "hashbrown 0.9.1", @@ -357,9 +405,9 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd16f0729b89f0a212b0e2e1d19cc6593df63f771161a11863967780e2d033d" +checksum = "684155372435f578c0fa1acd13ebbb182cc19d6b38b64ae7901da4393217d264" dependencies = [ "borsh-derive-internal", "borsh-schema-derive-internal", @@ -370,9 +418,9 @@ dependencies = [ [[package]] name = "borsh-derive-internal" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e321a130a3ac4b88eb59a6d670bde11eec9721a397b77e0f2079060e2a1b785" +checksum = "2102f62f8b6d3edeab871830782285b64cc1830168094db05c8e458f209bc5c3" dependencies = [ "proc-macro2", "quote", @@ -381,9 +429,9 @@ dependencies = [ [[package]] name = "borsh-schema-derive-internal" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15151a485164b319cc7a5160fe4316dc469a27993f71b73d7617dc9032ff0fd7" +checksum = "196c978c4c9b0b142d446ef3240690bf5a8a33497074a113ff9a337ccb750483" dependencies = [ "proc-macro2", "quote", @@ -392,9 +440,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" +checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" dependencies = [ "lazy_static", "memchr", @@ -404,9 +452,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.6.1" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" + +[[package]] +name = "bytemuck" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" +checksum = "72957246c41db82b8ef88a5486143830adeb8227ef9837740bdec67724cf2c5b" [[package]] name = "byteorder" @@ -416,13 +470,19 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cast" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc38c385bfd7e444464011bb24820f40dd1c76bcdfa1b78611cb7c2e5cafab75" +checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" dependencies = [ - "rustc_version 0.2.3", + "rustc_version 0.4.0", ] +[[package]] +name = "cc" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" + [[package]] name = "cfg-if" version = "1.0.0" @@ -431,9 +491,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" +checksum = "ea8756167ea0aca10e066cdbe7813bd71d2f24e69b0bc7b50509590cef2ce0b9" dependencies = [ "cfg-if", "cipher", @@ -443,9 +503,9 @@ dependencies = [ [[package]] name = "chacha20poly1305" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" +checksum = "175a11316f33592cf2b71416ee65283730b5b7849813c4891d02a12906ed9acc" dependencies = [ "aead", "chacha20", @@ -480,6 +540,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "cpp_demangle" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea47428dc9d2237f3c6bc134472edfd63ebba0af932e783506dcfd66f10d18a" +dependencies = [ + "cfg-if", +] + [[package]] name = "cpufeatures" version = "0.1.5" @@ -489,12 +558,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cpuid-bool" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" - [[package]] name = "criterion" version = "0.3.4" @@ -506,7 +569,7 @@ dependencies = [ "clap", "criterion-plot", "csv", - "itertools 0.10.1", + "itertools", "lazy_static", "num-traits", "oorandom", @@ -523,12 +586,12 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" +checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" dependencies = [ "cast", - "itertools 0.9.0", + "itertools", ] [[package]] @@ -543,9 +606,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -554,9 +617,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ "cfg-if", "crossbeam-utils", @@ -567,11 +630,10 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "autocfg", "cfg-if", "lazy_static", ] @@ -610,9 +672,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ "byteorder", "digest", @@ -622,6 +684,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "debugid" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91cf5a8c2f2097e2a32627123508635d47ce10563d999ec1a95addf08b502ba" +dependencies = [ + "uuid", +] + [[package]] name = "derivative" version = "2.2.0" @@ -644,9 +715,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d0860415b12243916284c67a9be413e044ee6668247b99ba26d94b2bc06c8f6" +checksum = "4620d40f6d2601794401d6dd95a5cf69b6c157852539470eeda433a99b3c0efc" dependencies = [ "serde", "signature", @@ -701,10 +772,11 @@ dependencies = [ "ff 0.8.0", "group-threshold-cryptography", "hex", - "itertools 0.10.1", + "itertools", "measure_time", "miracl_core", "num", + "pprof", "rand 0.7.3", "rand 0.8.4", "rand_chacha 0.3.1", @@ -769,15 +841,21 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] +[[package]] +name = "gimli" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" + [[package]] name = "group" version = "0.9.0" @@ -803,8 +881,9 @@ dependencies = [ "ark-std", "blake2b_simd", "chacha20", + "criterion", "hex", - "itertools 0.10.1", + "itertools", "miracl_core", "rand 0.8.4", "rand_core 0.6.3", @@ -833,14 +912,14 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.2", + "ahash 0.7.4", ] [[package]] name = "hermit-abi" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] @@ -852,12 +931,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] -name = "itertools" -version = "0.9.0" +name = "indexmap" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" dependencies = [ - "either", + "autocfg", + "hashbrown 0.11.2", +] + +[[package]] +name = "inferno" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3cbcc228d2ad2e99328c2b19f38d80ec387ca6a29f778e40e32ca9f25448c3" +dependencies = [ + "ahash 0.6.3", + "atty", + "indexmap", + "itoa", + "lazy_static", + "log", + "num-format", + "quick-xml", + "rgb", + "str_stack", +] + +[[package]] +name = "instant" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +dependencies = [ + "cfg-if", ] [[package]] @@ -871,15 +978,15 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "js-sys" -version = "0.3.50" +version = "0.3.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c" +checksum = "e4bf49d50e2961077d9c99f4b7997d770a1114f087c3c2e0069b36c13fc2979d" dependencies = [ "wasm-bindgen", ] @@ -912,9 +1019,18 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.98" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" + +[[package]] +name = "lock_api" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +dependencies = [ + "scopeguard", +] [[package]] name = "log" @@ -936,15 +1052,25 @@ dependencies = [ [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +dependencies = [ + "libc", + "winapi", +] [[package]] name = "memoffset" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -961,12 +1087,41 @@ dependencies = [ "zeroize", ] +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + [[package]] name = "miracl_core" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94c7128ba23c81f6471141b90f17654f89ef44a56e14b8a4dd0fddfccd655277" +[[package]] +name = "nix" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8e5e343312e7fbeb2a52139114e9e702991ef9c2aea6817ff2440b35647d56" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + [[package]] name = "num" version = "0.4.0" @@ -1001,6 +1156,16 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-format" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" +dependencies = [ + "arrayvec 0.4.12", + "itoa", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -1053,11 +1218,20 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2766204889d09937d00bfbb7fec56bb2a199e2ade963cab19185d8a6104c7c" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" +checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" [[package]] name = "oorandom" @@ -1071,6 +1245,31 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + [[package]] name = "paste" version = "1.0.5" @@ -1094,9 +1293,9 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "plotters" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" +checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" dependencies = [ "num-traits", "plotters-backend", @@ -1107,30 +1306,49 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" +checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" [[package]] name = "plotters-svg" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" dependencies = [ "plotters-backend", ] [[package]] name = "poly1305" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe800695325da85083cd23b56826fccb2e2dc29b218e7811a6f33bc93f414be" +checksum = "9fcffab1f78ebbdf4b93b68c1ffebc24037eedf271edaca795732b24e5e4e349" dependencies = [ "cpufeatures", "opaque-debug", "universal-hash", ] +[[package]] +name = "pprof" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c7600124d694d855283caf9f333befe2abce090833bb638009aeddd9e156dee" +dependencies = [ + "backtrace", + "criterion", + "inferno", + "lazy_static", + "libc", + "log", + "nix", + "parking_lot", + "symbolic-demangle", + "tempfile", + "thiserror", +] + [[package]] name = "ppv-lite86" version = "0.2.10" @@ -1148,13 +1366,22 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.26" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" dependencies = [ "unicode-xid", ] +[[package]] +name = "quick-xml" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26aab6b48e2590e4a64d1ed808749ba06257882b461d01ca71baeb747074a6dd" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.9" @@ -1236,7 +1463,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.2", + "getrandom 0.2.3", ] [[package]] @@ -1271,9 +1498,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -1299,39 +1526,60 @@ dependencies = [ "zeroize", ] +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] + [[package]] name = "regex" -version = "1.4.5" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -dependencies = [ - "byteorder", -] +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" -version = "0.6.23" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] -name = "rustc_version" -version = "0.2.3" +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "rgb" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "8fddb3b23626145d1776addfc307e1a1851f60ef6ca64f376bcb889697144cf0" dependencies = [ - "semver 0.9.0", + "bytemuck", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc_version" version = "0.3.3" @@ -1341,6 +1589,15 @@ dependencies = [ "semver 0.11.0", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.4", +] + [[package]] name = "ryu" version = "1.0.5" @@ -1362,29 +1619,20 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser 0.7.0", -] - [[package]] name = "semver" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ - "semver-parser 0.10.2", + "semver-parser", ] [[package]] -name = "semver-parser" -version = "0.7.0" +name = "semver" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "semver-parser" @@ -1397,9 +1645,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.125" +version = "1.0.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +checksum = "d1f72836d2aa753853178eda473a3b9d8e4eefdaf20523b919677e6de489f8f1" dependencies = [ "serde_derive", ] @@ -1415,9 +1663,9 @@ dependencies = [ [[package]] name = "serde_cbor" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ "half", "serde", @@ -1425,9 +1673,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.125" +version = "1.0.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +checksum = "e57ae87ad533d9a56427558b516d0adac283614e347abf85b0dc0cbbf0a249f3" dependencies = [ "proc-macro2", "quote", @@ -1436,9 +1684,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" dependencies = [ "itoa", "ryu", @@ -1447,13 +1695,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" dependencies = [ "block-buffer", "cfg-if", - "cpuid-bool", + "cpufeatures", "digest", "opaque-debug", ] @@ -1464,17 +1712,58 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c19772be3c4dd2ceaacf03cb41d5885f2a02c4d8804884918e3a258480803335" +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "str_stack" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" + [[package]] name = "subtle" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "symbolic-common" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348885c332e7d0784d661844b13b198464144a5ebcd3bfc047a6c441867ea467" +dependencies = [ + "debugid", + "memmap", + "stable_deref_trait", + "uuid", +] + +[[package]] +name = "symbolic-demangle" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6780c62bfbd609bffaa13d6959715850578aa43caaae7aee14f1f24ceb64f433" +dependencies = [ + "cpp_demangle", + "rustc-demangle", + "symbolic-common", +] [[package]] name = "syn" -version = "1.0.69" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" +checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7" dependencies = [ "proc-macro2", "quote", @@ -1483,9 +1772,9 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +checksum = "474aaa926faa1603c40b7885a9eaea29b444d1cb2850cb7c0e37bb1a4182f4fa" dependencies = [ "proc-macro2", "quote", @@ -1499,6 +1788,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tempfile" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if", + "libc", + "rand 0.8.4", + "redox_syscall", + "remove_dir_all", + "winapi", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -1572,18 +1875,18 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +checksum = "2ca517f43f0fb96e0c3072ed5c275fe5eece87e8cb52f4a77b69226d3b1c9df8" dependencies = [ "lazy_static", ] [[package]] name = "tracing-subscriber" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab69019741fca4d98be3c62d2b75254528b5432233fd8a4d2739fec20278de48" +checksum = "b9cbe87a2fa7e35900ce5de20220a582a9483a7063811defce79d7cbd59d4cfe" dependencies = [ "tracing-core", ] @@ -1608,20 +1911,26 @@ checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "universal-hash" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" +checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" dependencies = [ "generic-array", "subtle", ] +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + [[package]] name = "version_check" version = "0.9.3" @@ -1653,9 +1962,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.73" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" +checksum = "8ce9b1b516211d33767048e5d47fa2a381ed8b76fc48d2ce4aa39877f9f183e0" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1663,9 +1972,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.73" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae" +checksum = "cfe8dc78e2326ba5f845f4b5bf548401604fa20b1dd1d365fb73b6c1d6364041" dependencies = [ "bumpalo", "lazy_static", @@ -1678,9 +1987,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.73" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" +checksum = "44468aa53335841d9d6b6c023eaab07c0cd4bddbcfdee3e2bb1e8d2cb8069fef" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1688,9 +1997,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.73" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" +checksum = "0195807922713af1e67dc66132c7328206ed9766af3858164fb583eedc25fbad" dependencies = [ "proc-macro2", "quote", @@ -1701,15 +2010,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.73" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" +checksum = "acdb075a845574a1fa5f09fd77e43f7747599301ea3417a9fbffdeedfc1f4a29" [[package]] name = "web-sys" -version = "0.3.50" +version = "0.3.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" +checksum = "224b2f6b67919060055ef1a67807367c2066ed520c3862cc013d26cf893a783c" dependencies = [ "js-sys", "wasm-bindgen", @@ -1766,18 +2075,18 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16" +checksum = "a2c1e130bebaeab2f23886bf9acbaca14b092408c452543c857f66399cd6dab1" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 0247a2e9..4368307c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,97 +1,6 @@ -[package] -name = "ferveo" -version = "0.1.0" -edition = "2018" -license = "AGPL-3.0" -repository = "https://gitlab.com/metastatedev/ferveo" -readme = "README.md" -description = "An implementation of a DKG protocol for front-running protection on public blockchains." -keywords = ["DKG"] -categories = ["cryptography"] -authors = ["Heliax AG "] +[workspace] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -ark-poly-commit = "0.3" -ark-std = "0.3" -ark-pallas = "0.3" -ark-bls12-381 = "0.3" -ark-ec = "0.3" -ark-ff = "0.3" -ark-serialize = "0.3" -ark-poly = "0.3" -rand = "0.8" -rand_old = { package = "rand", version = "0.7" } -either = "1.6.1" -ff = "0.8" -hex = "0.4.2" -miracl_core = "2.3.0" -num = "0.4" -sha2 = "0.9.1" -ed25519-dalek = { version = "1", features = ["serde", "batch"] } -x25519-dalek = { version = "1.1", features = ["serde"] } -curve25519-dalek = { version = "3.0", features = ["serde"] } -serde = { version = "1.0", features = ["derive"] } -blake2 = "0.9.1" -rand_chacha = "0.3.0" -blake2b_simd = "0.5.11" -zeroize = { version = "1", default-features = false, features = ["zeroize_derive"] } -chacha20poly1305 = "0.8" -serde_bytes = { version = "0.11" } -bincode = "1.3" -anyhow = "1.0" -serde_json = "1.0" -borsh = "0.9" -subtle = "2.4" -itertools = "0.10.1" -measure_time = "0.7" -redjubjub = "0.4.0" -ark-ed-on-bls12-381 = "0.3.0" -group-threshold-cryptography = {path = "./tpke/"} - -[dependencies.digest] -version = "0.9.0" -features = ["alloc"] - -[dev-dependencies] -criterion = "=0.3.4" -pprof = { version = "0.4", features = ["flamegraph", "criterion"] } - -# local override for bls12-381 -#[patch.crates-io] -#bls12_381 = { git = 'https://github.com/A-Manning/bls12_381.git', branch = "ash/scalar-traits" } - -[profile.bench] -opt-level = 3 -debug = true - -# Optimizations are needed such that the tests run in a reasonable timeframe -#[profile.test] -#opt-level = 3 - -[profile.release] -debug = true - -#[[bench]] -#name = "benchmarks" -#harness = false -#debug = true - -[[example]] -name = "pvdkg" -debug = true - -#[[bench]] -#name = "pairing" -#harness = false -#debug = false - -#[[bench]] -#name = "bench_main" -#harness = false - -[[bench]] -name = "pvdkg" -path = "benches/benchmarks/pvdkg.rs" -harness = false +members = [ + "ferveo", + "tpke" +] \ No newline at end of file diff --git a/benches/benchmarks/pvdkg.rs b/benches/benchmarks/pvdkg.rs index 7782b2b6..e5e50d73 100644 --- a/benches/benchmarks/pvdkg.rs +++ b/benches/benchmarks/pvdkg.rs @@ -4,7 +4,7 @@ use ferveo::*; pub fn dkgs(c: &mut Criterion) { // use a fixed seed for reproducability use rand::SeedableRng; - let mut rng = rand::rngs::StdRng::seed_from_u64(0); + let _rng = rand::rngs::StdRng::seed_from_u64(0); let mut group = c.benchmark_group("compare DKGs with 8192 shares"); group.sample_size(10); @@ -23,13 +23,13 @@ pub fn dkgs(c: &mut Criterion) { // 2130.7 seconds per iteration to verify pairwise group.measurement_time(core::time::Duration::new(60, 0)); group.bench_function("PVDKG BLS12-381", |b| { - b.iter(|| pvdkg::()) + b.iter(pvdkg::) }); } use pprof::criterion::{Output, PProfProfiler}; -criterion_group!{ +criterion_group! { name = pvdkg_bls; config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); targets = dkgs @@ -38,7 +38,6 @@ criterion_group!{ criterion_main!(pvdkg_bls); pub fn pvdkg() { - use ark_ec::{AffineCurve, ProjectiveCurve}; let rng = &mut ark_std::test_rng(); use rand_old::SeedableRng; let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); @@ -53,9 +52,9 @@ pub fn pvdkg() { let mut contexts = vec![]; for _ in 0..10 { contexts.push( - PubliclyVerifiableDKG::::new( + PubliclyVerifiableDkg::::new( ed25519_dalek::Keypair::generate(ed_rng), - params.clone(), + params, rng, ) .unwrap(), @@ -64,7 +63,7 @@ pub fn pvdkg() { use std::collections::VecDeque; let mut messages = VecDeque::new(); - let stake = (0..150u64).map(|i| i).collect::>(); + let stake = (0..150u64).collect::>(); for (participant, stake) in contexts.iter_mut().zip(stake.iter()) { let announce = participant.announce(*stake); @@ -72,7 +71,7 @@ pub fn pvdkg() { } let msg_loop = - |contexts: &mut Vec>, + |contexts: &mut Vec>, messages: &mut VecDeque| loop { if messages.is_empty() { break; @@ -103,7 +102,7 @@ pub fn pvdkg() { if dealt_weight < params.total_weight - params.security_threshold { let msg = participant.share(rng).unwrap(); let msg: PubliclyVerifiableMessage = msg; //.verify().unwrap().1; - pvss.push((participant.ed_key.public.clone(), msg)); + pvss.push((participant.ed_key.public, msg)); //messages.push_back(msg); dealt_weight += participant.participants[participant.me].weight; } diff --git a/examples/noserialize.rs b/examples/noserialize.rs index 676b4807..e05cb915 100644 --- a/examples/noserialize.rs +++ b/examples/noserialize.rs @@ -85,7 +85,7 @@ pub fn pvdkg() { participant .handle_message(&agg_signer, agg.clone()) .unwrap(); - //assert_eq!(participant.state, DKGState::Success); + //assert_eq!(participant.state, DkgState::Success); } contexts[0].final_key(); } diff --git a/examples/pvdkg.rs b/examples/pvdkg.rs index 7bfd3112..a1144943 100644 --- a/examples/pvdkg.rs +++ b/examples/pvdkg.rs @@ -5,7 +5,6 @@ pub fn main() { } pub fn pvdkg() { - use ark_ec::{AffineCurve, ProjectiveCurve}; let rng = &mut ark_std::test_rng(); use rand_old::SeedableRng; let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); @@ -20,9 +19,9 @@ pub fn pvdkg() { let mut contexts = vec![]; for _ in 0..10 { contexts.push( - PubliclyVerifiableDKG::::new( + PubliclyVerifiableDkg::::new( ed25519_dalek::Keypair::generate(ed_rng), - params.clone(), + params, rng, ) .unwrap(), @@ -31,7 +30,7 @@ pub fn pvdkg() { use std::collections::VecDeque; let mut messages = VecDeque::new(); - let stake = (0..150u64).map(|i| i).collect::>(); + let stake = (0..150u64).collect::>(); for (participant, stake) in contexts.iter_mut().zip(stake.iter()) { let announce = participant.announce(*stake); @@ -39,7 +38,7 @@ pub fn pvdkg() { } let msg_loop = - |contexts: &mut Vec>, + |contexts: &mut Vec>, messages: &mut VecDeque| loop { if messages.is_empty() { break; @@ -69,7 +68,7 @@ pub fn pvdkg() { for participant in contexts.iter_mut() { if dealt_weight < params.total_weight - params.security_threshold { let msg = participant.share(rng).unwrap(); - pvss.push((participant.ed_key.public.clone(), msg)); + pvss.push((participant.ed_key.public, msg)); dealt_weight += participant.participants[participant.me].weight; } } @@ -80,12 +79,12 @@ pub fn pvdkg() { } msg_loop(&mut contexts, &mut messages); let agg = contexts[0].aggregate(); - let agg_signer = contexts[0].ed_key.public.clone(); + let agg_signer = contexts[0].ed_key.public; for participant in contexts.iter_mut() { participant .handle_message(&agg_signer, agg.clone()) .unwrap(); - //assert_eq!(participant.state, DKGState::Success); + //assert_eq!(participant.state, DkgState::Success); } contexts[0].final_key(); diff --git a/ferveo/Cargo.lock b/ferveo/Cargo.lock new file mode 100644 index 00000000..6838c84f --- /dev/null +++ b/ferveo/Cargo.lock @@ -0,0 +1,2121 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aead" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "922b33332f54fc0ad13fa3e514601e8d30fb54e1f3eadc36643f6526db645621" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ahash" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" + +[[package]] +name = "ahash" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "796540673305a66d127804eef19ad696f1f204b8c1025aaca4958c17eab32877" +dependencies = [ + "getrandom 0.2.2", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f200cbb1e856866d9eade941cf3aa0c5d7dd36f74311c4273b494f4ef036957" +dependencies = [ + "getrandom 0.2.2", + "once_cell", + "version_check", +] + +[[package]] +name = "anyhow" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" + +[[package]] +name = "ark-bls12-381" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65be532f9dd1e98ad0150b037276cde464c6f371059e6dd02c0222395761f6aa" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea978406c4b1ca13c2db2373b05cc55429c3575b8b21f1b9ee859aa5b03dd42" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "num-traits", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ed-on-bls12-381" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b7ada17db3854f5994e74e60b18e10e818594935ee7e1d329800c117b32970" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rayon", + "rustc_version 0.3.3", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote", + "syn", +] + +[[package]] +name = "ark-nonnative-field" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "440ad4569974910adbeb84422b7e622b79e08d27142afd113785b7fcfb446186" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-r1cs-std", + "ark-relations", + "ark-std", + "derivative", + "num-bigint", + "num-integer", + "num-traits", + "tracing", +] + +[[package]] +name = "ark-pallas" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e945e1c8d86aa869853944ce6ecf072c2dac623b88c94e68792901b06190e53" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-poly" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0f78f47537c2f15706db7e98fe64cc1711dbf9def81218194e17239e53e5aa" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.11.2", + "rayon", +] + +[[package]] +name = "ark-poly-commit" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a71ddfa72bad1446cab7bbecb6018dbbdc9abcbc3a0065483ae5186ad2a64dcd" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-nonnative-field", + "ark-poly", + "ark-relations", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "rayon", + "tracing", +] + +[[package]] +name = "ark-r1cs-std" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e8fdacb1931f238a0d866ced1e916a49d36de832fd8b83dc916b718ae72893" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-relations", + "ark-std", + "derivative", + "num-bigint", + "num-traits", + "tracing", +] + +[[package]] +name = "ark-relations" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cba4c1c99792a6834bd97f7fd76578ec2cd58d2afc5139a17e1d1bec65b38f6" +dependencies = [ + "ark-ff", + "ark-std", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd4e5f0bf8285d5ed538d27fab7411f3e297908fd93c62195de8bee3f199e82" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand 0.8.4", + "rayon", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "backtrace" +version = "0.3.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bitvec" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" +dependencies = [ + "funty", + "radium 0.3.0", + "wyz", +] + +[[package]] +name = "bitvec" +version = "0.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" +dependencies = [ + "funty", + "radium 0.6.2", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a5720225ef5daecf08657f23791354e1685a8c91a4c60c7f3d3b2892f978f4" +dependencies = [ + "crypto-mac", + "digest", + "opaque-debug", +] + +[[package]] +name = "blake2b_simd" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bls12_381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c56609cc42c628848e7b18e0baf42a4ef626b8c50442dc08b8094bd21d8ad32" +dependencies = [ + "ff 0.9.0", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "borsh" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fcabb02816fdadf90866dc9a7824491ccb63d69f55375a266dc03509ac68d36" +dependencies = [ + "borsh-derive", + "hashbrown 0.9.1", +] + +[[package]] +name = "borsh-derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bd16f0729b89f0a212b0e2e1d19cc6593df63f771161a11863967780e2d033d" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate", + "proc-macro2", + "syn", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e321a130a3ac4b88eb59a6d670bde11eec9721a397b77e0f2079060e2a1b785" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15151a485164b319cc7a5160fe4316dc469a27993f71b73d7617dc9032ff0fd7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "bstr" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" + +[[package]] +name = "bytemuck" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72957246c41db82b8ef88a5486143830adeb8227ef9837740bdec67724cf2c5b" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cast" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc38c385bfd7e444464011bb24820f40dd1c76bcdfa1b78611cb7c2e5cafab75" +dependencies = [ + "rustc_version 0.2.3", +] + +[[package]] +name = "cc" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chacha20" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", + "zeroize", +] + +[[package]] +name = "chacha20poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "bitflags", + "textwrap", + "unicode-width", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "cpp_demangle" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea47428dc9d2237f3c6bc134472edfd63ebba0af932e783506dcfd66f10d18a" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cpufeatures" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +dependencies = [ + "libc", +] + +[[package]] +name = "cpuid-bool" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" + +[[package]] +name = "criterion" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" +dependencies = [ + "atty", + "cast", + "clap", + "criterion-plot", + "csv", + "itertools 0.10.1", + "lazy_static", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_cbor", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" +dependencies = [ + "cast", + "itertools 0.9.0", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +dependencies = [ + "autocfg", + "cfg-if", + "lazy_static", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + +[[package]] +name = "curve25519-dalek" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" +dependencies = [ + "byteorder", + "digest", + "rand_core 0.5.1", + "serde", + "subtle", + "zeroize", +] + +[[package]] +name = "debugid" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91cf5a8c2f2097e2a32627123508635d47ce10563d999ec1a95addf08b502ba" +dependencies = [ + "uuid", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ed25519" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d0860415b12243916284c67a9be413e044ee6668247b99ba26d94b2bc06c8f6" +dependencies = [ + "serde", + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek", + "ed25519", + "merlin", + "rand 0.7.3", + "serde", + "serde_bytes", + "sha2", + "zeroize", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "ferveo" +version = "0.1.0" +dependencies = [ + "anyhow", + "ark-bls12-381", + "ark-ec", + "ark-ed-on-bls12-381", + "ark-ff", + "ark-pallas", + "ark-poly", + "ark-poly-commit", + "ark-serialize", + "ark-std", + "bincode", + "blake2", + "blake2b_simd", + "borsh", + "chacha20poly1305", + "criterion", + "curve25519-dalek", + "digest", + "ed25519-dalek", + "either", + "ff 0.8.0", + "group-threshold-cryptography", + "hex", + "itertools 0.10.1", + "measure_time", + "miracl_core", + "num", + "pprof", + "rand 0.7.3", + "rand 0.8.4", + "rand_chacha 0.3.1", + "redjubjub", + "serde", + "serde_bytes", + "serde_json", + "sha2", + "subtle", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "ff" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" +dependencies = [ + "bitvec 0.18.5", + "rand_core 0.5.1", + "subtle", +] + +[[package]] +name = "ff" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72a4d941a5b7c2a75222e2d44fcdf634a67133d9db31e177ae5ff6ecda852bfe" +dependencies = [ + "bitvec 0.20.4", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" + +[[package]] +name = "group" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b3c1e8b4f1ca07e6605ea1be903a5f6956aec5c8a67fd44d56076631675ed8" +dependencies = [ + "byteorder", + "ff 0.9.0", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "group-threshold-cryptography" +version = "0.1.0" +dependencies = [ + "anyhow", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "blake2b_simd", + "chacha20", + "hex", + "itertools 0.10.1", + "miracl_core", + "rand 0.8.4", + "rand_core 0.6.3", + "rayon", + "thiserror", +] + +[[package]] +name = "half" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +dependencies = [ + "ahash 0.4.7", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash 0.7.2", +] + +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown 0.11.2", +] + +[[package]] +name = "inferno" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3cbcc228d2ad2e99328c2b19f38d80ec387ca6a29f778e40e32ca9f25448c3" +dependencies = [ + "ahash 0.6.3", + "atty", + "indexmap", + "itoa", + "lazy_static", + "log", + "num-format", + "quick-xml", + "rgb", + "str_stack", +] + +[[package]] +name = "instant" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "js-sys" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jubjub" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d7e7fef85ae7b26dd89f34175b7f3c5ace64067a110c2ac86cf92407a6666ca" +dependencies = [ + "bitvec 0.20.4", + "bls12_381", + "ff 0.9.0", + "group", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "keccak" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" + +[[package]] +name = "lock_api" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "measure_time" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68c8a1703dd54ab3307c03401e8b6c42121b67501dd6c6deb5077914ccb8085" +dependencies = [ + "log", +] + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "memoffset" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "merlin" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + +[[package]] +name = "miracl_core" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94c7128ba23c81f6471141b90f17654f89ef44a56e14b8a4dd0fddfccd655277" + +[[package]] +name = "nix" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8e5e343312e7fbeb2a52139114e9e702991ef9c2aea6817ff2440b35647d56" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "num" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d047c1062aa51e256408c560894e5251f08925980e53cf1aa5bd00eec6512" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-format" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" +dependencies = [ + "arrayvec 0.4.12", + "itoa", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" + +[[package]] +name = "once_cell" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" + +[[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.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "paste" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" + +[[package]] +name = "plotters" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" + +[[package]] +name = "plotters-svg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "poly1305" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fe800695325da85083cd23b56826fccb2e2dc29b218e7811a6f33bc93f414be" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "pprof" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c7600124d694d855283caf9f333befe2abce090833bb638009aeddd9e156dee" +dependencies = [ + "backtrace", + "criterion", + "inferno", + "lazy_static", + "libc", + "log", + "nix", + "parking_lot", + "symbolic-demangle", + "tempfile", + "thiserror", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quick-xml" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26aab6b48e2590e4a64d1ed808749ba06257882b461d01ca71baeb747074a6dd" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + +[[package]] +name = "radium" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.3", + "rand_hc 0.3.1", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.3", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom 0.2.2", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +dependencies = [ + "rand_core 0.6.3", +] + +[[package]] +name = "rayon" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + +[[package]] +name = "redjubjub" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcf30702f15c157e348b4ccef28b1224fc7da8f8430d553bdc47b2d6599107b" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest", + "funty", + "jubjub", + "rand_core 0.6.3", + "serde", + "thiserror", + "zeroize", +] + +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", +] + +[[package]] +name = "regex-syntax" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "rgb" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fddb3b23626145d1776addfc307e1a1851f60ef6ca64f376bcb889697144cf0" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + +[[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.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser 0.7.0", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser 0.10.2", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_bytes" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_cbor" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" +dependencies = [ + "half", + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" +dependencies = [ + "block-buffer", + "cfg-if", + "cpuid-bool", + "digest", + "opaque-debug", +] + +[[package]] +name = "signature" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19772be3c4dd2ceaacf03cb41d5885f2a02c4d8804884918e3a258480803335" + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "str_stack" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" + +[[package]] +name = "subtle" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" + +[[package]] +name = "symbolic-common" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348885c332e7d0784d661844b13b198464144a5ebcd3bfc047a6c441867ea467" +dependencies = [ + "debugid", + "memmap", + "stable_deref_trait", + "uuid", +] + +[[package]] +name = "symbolic-demangle" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6780c62bfbd609bffaa13d6959715850578aa43caaae7aee14f1f24ceb64f433" +dependencies = [ + "cpp_demangle", + "rustc-demangle", + "symbolic-common", +] + +[[package]] +name = "syn" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "synstructure" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if", + "libc", + "rand 0.8.4", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab69019741fca4d98be3c62d2b75254528b5432233fd8a4d2739fec20278de48" +dependencies = [ + "tracing-core", +] + +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "universal-hash" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" + +[[package]] +name = "web-sys" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + +[[package]] +name = "x25519-dalek" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +dependencies = [ + "curve25519-dalek", + "rand_core 0.5.1", + "serde", + "zeroize", +] + +[[package]] +name = "zeroize" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] diff --git a/ferveo/Cargo.toml b/ferveo/Cargo.toml new file mode 100644 index 00000000..e96167a5 --- /dev/null +++ b/ferveo/Cargo.toml @@ -0,0 +1,98 @@ +[package] +name = "ferveo" +version = "0.1.0" +edition = "2018" +license = "AGPL-3.0" +repository = "https://gitlab.com/metastatedev/ferveo" +readme = "README.md" +description = "An implementation of a DKG protocol for front-running protection on public blockchains." +keywords = ["DKG"] +categories = ["cryptography"] +authors = ["Heliax AG "] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ark-poly-commit = "0.3" +ark-std = "0.3" +ark-pallas = "0.3" +ark-bls12-381 = "0.3" +ark-ec = "0.3" +ark-ff = "0.3" +ark-serialize = "0.3" +ark-poly = "0.3" +rand = "0.8" +rand_old = { package = "rand", version = "0.7" } +either = "1.6.1" +ff = "0.8" +hex = "0.4.2" +miracl_core = "2.3.0" +num = "0.4" +sha2 = "0.9.1" +ed25519-dalek = { version = "1", features = ["serde", "batch"] } +x25519-dalek = { version = "1.1", features = ["serde"] } +curve25519-dalek = { version = "3.0", features = ["serde"] } +serde = { version = "1.0", features = ["derive"] } +blake2 = "0.9.1" +rand_chacha = "0.3.0" +blake2b_simd = "0.5.11" +zeroize = { version = "1", default-features = false, features = ["zeroize_derive"] } +chacha20poly1305 = "0.8" +serde_bytes = { version = "0.11" } +bincode = "1.3" +anyhow = "1.0" +serde_json = "1.0" +borsh = "0.9" +subtle = "2.4" +itertools = "0.10.1" +measure_time = "0.7" +redjubjub = "0.4.0" +ark-ed-on-bls12-381 = "0.3.0" +group-threshold-cryptography = {path = "../tpke"} + +[dependencies.digest] +version = "0.9.0" +features = ["alloc"] + +[dev-dependencies] +criterion = "=0.3.4" +pprof = { version = "0.4", features = ["flamegraph", "criterion"] } + +# local override for bls12-381 +#[patch.crates-io] +#bls12_381 = { git = 'https://github.com/A-Manning/bls12_381.git', branch = "ash/scalar-traits" } + +[profile.bench] +opt-level = 3 +debug = true + +# Optimizations are needed such that the tests run in a reasonable timeframe +#[profile.test] +#opt-level = 3 + +[profile.release] +debug = true + +#[[bench]] +#name = "benchmarks" +#harness = false +#debug = true + +[[example]] +name = "pvdkg" +path = "../examples/pvdkg.rs" +debug = true + +#[[bench]] +#name = "pairing" +#harness = false +#debug = false + +#[[bench]] +#name = "bench_main" +#harness = false + +[[bench]] +name = "pvdkg" +path = "../benches/benchmarks/pvdkg.rs" +harness = false diff --git a/src/dkg.rs b/ferveo/src/dkg.rs similarity index 95% rename from src/dkg.rs rename to ferveo/src/dkg.rs index 16248c88..7eda3c28 100644 --- a/src/dkg.rs +++ b/ferveo/src/dkg.rs @@ -30,7 +30,7 @@ pub struct Params { } #[derive(Debug, Clone)] -pub enum DKGState { +pub enum DkgState { Init { announce_messages: Vec>, }, diff --git a/src/dkg/common.rs b/ferveo/src/dkg/common.rs similarity index 98% rename from src/dkg/common.rs rename to ferveo/src/dkg/common.rs index 5ac9f6f2..b2c3105d 100644 --- a/src/dkg/common.rs +++ b/ferveo/src/dkg/common.rs @@ -23,8 +23,7 @@ where let total_stake: f64 = announce_messages .iter() .map(|p| p.stake as f64) - .sum::() - .into(); + .sum::(); // Compute the weight of each participant rounded down let mut weights = announce_messages diff --git a/src/dkg/pv.rs b/ferveo/src/dkg/pv.rs similarity index 90% rename from src/dkg/pv.rs rename to ferveo/src/dkg/pv.rs index c8364a92..67700b18 100644 --- a/src/dkg/pv.rs +++ b/ferveo/src/dkg/pv.rs @@ -3,7 +3,7 @@ use ark_ec::PairingEngine; use ark_std::{end_timer, start_timer}; /// The DKG context that holds all of the local state for participating in the DKG -pub struct PubliclyVerifiableDKG +pub struct PubliclyVerifiableDkg where E: PairingEngine, { @@ -14,12 +14,12 @@ where pub participants: Vec>, pub vss: BTreeMap>, pub domain: ark_poly::Radix2EvaluationDomain, - pub state: DKGState, + pub state: DkgState, pub me: usize, pub local_shares: Vec, } -impl PubliclyVerifiableDKG +impl PubliclyVerifiableDkg where E: PairingEngine, { @@ -50,7 +50,7 @@ where participants: vec![], vss: BTreeMap::new(), domain, - state: DKGState::::Init { + state: DkgState::::Init { announce_messages: vec![], }, me: 0, // TODO: invalid value @@ -92,13 +92,13 @@ where /// Partitions the share domain among the announced participants /// and begins the sharing phase of the DKG pub fn finish_announce(&mut self) -> Result<()> { - if let DKGState::Init { announce_messages } = &mut self.state { + if let DkgState::Init { announce_messages } = &mut self.state { self.participants = partition_domain(&self.params, announce_messages)?; self.me = self .find_by_key(&self.ed_key.public) .ok_or_else(|| anyhow!("self not found"))?; - self.state = DKGState::Sharing { + self.state = DkgState::Sharing { finalized_weight: 0u32, }; } @@ -137,7 +137,7 @@ where ) -> Result> { match payload { PubliclyVerifiableMessage::Announce { stake, session_key } => { - if let DKGState::Init { announce_messages } = &mut self.state { + if let DkgState::Init { announce_messages } = &mut self.state { announce_messages.push( PubliclyVerifiableAnnouncement:: { stake, @@ -149,7 +149,10 @@ where Ok(None) } PubliclyVerifiableMessage::Sharing(sharing) => { - if let DKGState::Sharing { finalized_weight } = self.state { + if let DkgState::Sharing { + finalized_weight: _, + } = self.state + { let dealer = self.find_by_key(signer).ok_or_else(|| { anyhow!("received dealing from unknown dealer") })? as u32; @@ -163,7 +166,10 @@ where Ok(None) } PubliclyVerifiableMessage::Aggregate(vss) => { - if let DKGState::Sharing { finalized_weight } = self.state { + if let DkgState::Sharing { + finalized_weight: _, + } = self.state + { let minimum_weight = self.params.total_weight //- self.params.failure_threshold - self.params.security_threshold; @@ -171,16 +177,15 @@ where vss.verify_aggregation(&self)?; if verified_weight >= minimum_weight { self.local_shares = local_shares; - self.state = DKGState::Success; + self.state = DkgState::Success; } else { - self.state = DKGState::Sharing { + self.state = DkgState::Sharing { finalized_weight: verified_weight, }; } } Ok(None) - } - _ => Err(anyhow!("Unknown message type for this DKG engine")), + } //_ => Err(anyhow!("Unknown message type for this DKG engine")), } } } diff --git a/src/lib.rs b/ferveo/src/lib.rs similarity index 75% rename from src/lib.rs rename to ferveo/src/lib.rs index 6d4efad0..37dd2b9b 100644 --- a/src/lib.rs +++ b/ferveo/src/lib.rs @@ -16,21 +16,18 @@ use crate::msg::*; use ark_ec::AffineCurve; use ark_ec::ProjectiveCurve; +use ark_ff::One; use ark_ff::Zero; -use ark_ff::{FftField, Field, One}; use ark_poly::{ polynomial::univariate::DensePolynomial, polynomial::UVPolynomial, - EvaluationDomain, Polynomial, + EvaluationDomain, }; use ed25519_dalek as ed25519; use serde::*; -use num::integer::div_ceil; -use std::collections::{BTreeMap, BTreeSet, HashMap}; -use std::rc::Rc; +use std::collections::BTreeMap; use anyhow::{anyhow, Result}; -use chacha20poly1305::aead::Aead; pub use dkg::*; pub use msg::*; pub use vss::*; diff --git a/src/main.rs b/ferveo/src/main.rs similarity index 100% rename from src/main.rs rename to ferveo/src/main.rs diff --git a/src/msg.rs b/ferveo/src/msg.rs similarity index 98% rename from src/msg.rs rename to ferveo/src/msg.rs index 91876c44..63b082d6 100644 --- a/src/msg.rs +++ b/ferveo/src/msg.rs @@ -2,7 +2,6 @@ use ed25519_dalek as ed25519; use ed25519_dalek::Signer; use crate::*; -use ark_std::{end_timer, start_timer}; use serde::{Deserialize, Serialize}; pub mod ark_serde { diff --git a/src/primitives.rs b/ferveo/src/primitives.rs similarity index 99% rename from src/primitives.rs rename to ferveo/src/primitives.rs index 935a9f2b..7b4ab1bf 100644 --- a/src/primitives.rs +++ b/ferveo/src/primitives.rs @@ -6,7 +6,6 @@ pub use keypair::*; pub mod subproductdomain; pub use subproductdomain::*; - /// Compute a fast multiexp of many scalars times the same base /// Only convenient for when called once with given base; if called /// more than once, it's faster to save the generated window table diff --git a/src/primitives/keypair.rs b/ferveo/src/primitives/keypair.rs similarity index 93% rename from src/primitives/keypair.rs rename to ferveo/src/primitives/keypair.rs index 8a7ede30..0d679ce4 100644 --- a/src/primitives/keypair.rs +++ b/ferveo/src/primitives/keypair.rs @@ -1,8 +1,7 @@ -use crate::*; -use chacha20poly1305::aead::{generic_array::GenericArray, Aead, NewAead}; - use ark_ec::PairingEngine; +use crate::*; + #[derive(Serialize, Deserialize, Copy, Clone, Debug)] pub struct PubliclyVerifiablePublicKey where diff --git a/src/primitives/subproductdomain.rs b/ferveo/src/primitives/subproductdomain.rs similarity index 99% rename from src/primitives/subproductdomain.rs rename to ferveo/src/primitives/subproductdomain.rs index 6d1a9f80..ca454a5e 100644 --- a/src/primitives/subproductdomain.rs +++ b/ferveo/src/primitives/subproductdomain.rs @@ -283,7 +283,7 @@ pub fn build_circulant( circulant } /// Computes the Toeplitz matrix of polynomial times the vector v -pub fn toeplitz_mul( +pub fn toeplitz_mul( polynomial: &Poly, v: &[E::G1Affine], size: usize, diff --git a/src/vss.rs b/ferveo/src/vss.rs similarity index 92% rename from src/vss.rs rename to ferveo/src/vss.rs index 7589df5c..1584d140 100644 --- a/src/vss.rs +++ b/ferveo/src/vss.rs @@ -7,7 +7,7 @@ pub use pvss::*; /// The possible States of a VSS instance #[derive(Clone, Debug)] -pub enum VSSState { +pub enum VssState { /// The VSS is currently in a Sharing state with weight_ready /// of participants signaling Ready for this VSS Sharing { weight_ready: u32 }, diff --git a/src/vss/pvss.rs b/ferveo/src/vss/pvss.rs similarity index 90% rename from src/vss/pvss.rs rename to ferveo/src/vss/pvss.rs index e34867f7..504a60ae 100644 --- a/src/vss/pvss.rs +++ b/ferveo/src/vss/pvss.rs @@ -2,9 +2,8 @@ use crate::*; use ark_ec::PairingEngine; use ark_serialize::*; use itertools::Itertools; -use serde::*; -pub type ShareEncryptions = Vec; +pub type ShareEncryptions = Vec<::G2Affine>; /// The dealer posts the Dealing to the blockchain to initiate the VSS #[derive(CanonicalSerialize, CanonicalDeserialize, Clone, Debug)] @@ -42,11 +41,11 @@ where /// and the local private keyshares pub fn verify_aggregation( &self, - dkg: &PubliclyVerifiableDKG, + dkg: &PubliclyVerifiableDkg, ) -> Result<(u32, Vec)> { print_time!("PVSS verify_aggregation"); let local_shares = self.verify(dkg)?; - let mut Y = E::G1Projective::zero(); + let mut y = E::G1Projective::zero(); let mut weight = 0u32; for (dealer, pvss) in dkg.vss.iter() { let c = pvss.coeffs[0].into_projective(); @@ -58,10 +57,10 @@ where { return Err(anyhow!("PVSS sigma verification")); } - Y += c; + y += c; weight += dkg.participants[*dealer as usize].weight; } - if Y.into_affine() == self.coeffs[0] { + if y.into_affine() == self.coeffs[0] { Ok((weight, local_shares)) } else { Err(anyhow!( @@ -73,7 +72,7 @@ where /// Aggregate the PVSS instances in `pvss` from DKG session `dkg` ] /// into a new PVSS instance pub fn aggregate( - dkg: &PubliclyVerifiableDKG, + dkg: &PubliclyVerifiableDkg, pvss: &BTreeMap>, ) -> Self { let mut pvss_iter = pvss.iter(); @@ -126,7 +125,7 @@ where /// `rng` a cryptographic random number generator pub fn new( s: &E::Fr, - dkg: &PubliclyVerifiableDKG, + dkg: &PubliclyVerifiableDkg, rng: &mut R, ) -> Result { let mut phi = DensePolynomial::::rand( @@ -173,11 +172,11 @@ where /// Verify the PVSS instance `self` is a valid PVSS instance for the DKG context `dkg` pub fn verify( &self, - dkg: &PubliclyVerifiableDKG, + dkg: &PubliclyVerifiableDkg, ) -> Result> { print_time!("PVSS verify"); - let me = &dkg.participants[dkg.me as usize]; + let _me = &dkg.participants[dkg.me as usize]; if self.shares.len() != dkg.participants.len() { return Err(anyhow!("wrong vss length")); @@ -200,18 +199,18 @@ where let ek = participant.session_key.encryption_key; let alpha = E::Fr::one(); //TODO: random number! let mut powers_of_alpha = alpha; - let mut Y = E::G2Projective::zero(); - let mut A = E::G1Projective::zero(); - for (Y_i, A_i) in shares + let mut y = E::G2Projective::zero(); + let mut a = E::G1Projective::zero(); + for (y_i, a_i) in shares .iter() .zip_eq(self.commitment[share_range].iter()) { - Y += Y_i.mul(powers_of_alpha); - A += A_i.mul(powers_of_alpha); + y += y_i.mul(powers_of_alpha); + a += a_i.mul(powers_of_alpha); powers_of_alpha *= alpha; } - E::pairing(dkg.pvss_params.g_1, Y) == E::pairing(A, ek) + E::pairing(dkg.pvss_params.g_1, y) == E::pairing(a, ek) }, ); } @@ -284,8 +283,7 @@ fn test_pvss() { type G1 = ::G1Affine; type G2 = ::G2Affine; - let mut phi = DensePolynomial::::rand(8192 / 3, rng); - use ark_std::UniformRand; + let phi = DensePolynomial::::rand(8192 / 3, rng); let domain = ark_poly::Radix2EvaluationDomain::::new(8192) .ok_or_else(|| anyhow!("unable to construct domain")) .unwrap(); @@ -294,12 +292,10 @@ fn test_pvss() { let g_1 = G1::prime_subgroup_generator(); // commitment to coeffs - let coeffs = fast_multiexp(&phi.coeffs, g_1.into_projective()); - - use itertools::Itertools; + let _coeffs = fast_multiexp(&phi.coeffs, g_1.into_projective()); let weight = 8192 / 150; - let shares = (0..150) + let _shares = (0..150) .map(|participant| { let share_range = (participant * weight)..((participant + 1) * weight); diff --git a/tpke/benches/benchmarks.rs b/tpke/benches/benchmarks.rs index d428951b..c78bcda2 100644 --- a/tpke/benches/benchmarks.rs +++ b/tpke/benches/benchmarks.rs @@ -5,39 +5,45 @@ pub fn bench_decryption(c: &mut Criterion) { use rand::SeedableRng; use rand_core::RngCore; + #[allow(dead_code)] const NUM_OF_TX: usize = 1000; - fn share_combine_bench(num_msg: usize, num_shares: usize, num_entities: usize, msg_size: usize) -> impl Fn() { + fn share_combine_bench( + num_msg: usize, + num_shares: usize, + num_entities: usize, + msg_size: usize, + ) -> impl Fn() { let rng = &mut rand::rngs::StdRng::seed_from_u64(0); type E = ark_bls12_381::Bls12_381; let threshold = num_shares * 2 / 3; - let (pubkey, _, contexts) = setup::(threshold, num_shares, num_entities); + let (pubkey, _, contexts) = + setup::(threshold, num_shares, num_entities); // let mut messages: Vec<[u8; NUM_OF_TX]> = vec![]; let mut messages: Vec> = vec![]; let mut ciphertexts: Vec> = vec![]; - let mut dec_shares: Vec>> = Vec::with_capacity(ciphertexts.len()); + let mut dec_shares: Vec>> = + Vec::with_capacity(ciphertexts.len()); for j in 0..num_msg { // let mut msg: [u8; NUM_OF_TX] = [0u8; NUM_OF_TX]; - let mut msg: Vec = vec![]; - for _ in 0..msg_size { - msg.push(0u8); - } + let mut msg: Vec = vec![0u8; msg_size]; rng.fill_bytes(&mut msg[..]); messages.push(msg.clone()); ciphertexts.push(encrypt::<_, E>(&messages[j], pubkey, rng)); dec_shares.push(Vec::with_capacity(threshold)); - for i in 0..num_entities { - dec_shares[j].push(contexts[i].create_share(&ciphertexts[j])); + for ctx in contexts.iter().take(num_entities) { + dec_shares[j].push(ctx.create_share(&ciphertexts[j])); } } - let prepared_blinded_key_shares = contexts[0].prepare_combine(&dec_shares[0]); + let prepared_blinded_key_shares = + contexts[0].prepare_combine(&dec_shares[0]); - let share_combine_prepared = move || { + move || { let c: Vec> = ciphertexts.clone(); let shares: Vec>> = dec_shares.clone(); @@ -48,47 +54,50 @@ pub fn bench_decryption(c: &mut Criterion) { &prepared_blinded_key_shares, )); } - }; - - share_combine_prepared + } } - fn block_propose_bench(num_msg: usize, num_shares: usize, num_entities: usize, msg_size: usize) -> impl Fn() { + fn block_propose_bench( + num_msg: usize, + num_shares: usize, + num_entities: usize, + msg_size: usize, + ) -> impl Fn() { let rng = &mut rand::rngs::StdRng::seed_from_u64(0); type E = ark_bls12_381::Bls12_381; let threshold = num_shares * 2 / 3; - let (pubkey, _, contexts) = setup::(threshold, num_shares, num_entities); + let (pubkey, _, contexts) = + setup::(threshold, num_shares, num_entities); // let mut messages: Vec<[u8; NUM_OF_TX]> = vec![]; let mut messages: Vec> = vec![]; let mut ciphertexts: Vec> = vec![]; - let mut dec_shares: Vec>> = Vec::with_capacity(ciphertexts.len()); + let mut dec_shares: Vec>> = + Vec::with_capacity(ciphertexts.len()); for j in 0..num_msg { // let mut msg: [u8; NUM_OF_TX] = [0u8; NUM_OF_TX]; - let mut msg: Vec = vec![]; - for _ in 0..msg_size { - msg.push(0u8); - } + let mut msg: Vec = vec![0u8; msg_size]; rng.fill_bytes(&mut msg); messages.push(msg.clone()); ciphertexts.push(encrypt::<_, E>(&messages[j], pubkey, rng)); dec_shares.push(Vec::with_capacity(threshold)); - for i in 0..num_entities { - dec_shares[j].push(contexts[i].create_share(&ciphertexts[j])); + for ctx in contexts.iter().take(num_entities) { + dec_shares[j].push(ctx.create_share(&ciphertexts[j])); } } - let block_proposer_prepared = move || { + move || { let rng = &mut ark_std::test_rng(); let c: Vec> = ciphertexts.clone(); let shares: Vec>> = dec_shares.clone(); contexts[0].batch_verify_decryption_shares(&c, &shares, rng); - let prepared_blinded_key_shares = contexts[0].prepare_combine(&dec_shares[0]); + let prepared_blinded_key_shares = + contexts[0].prepare_combine(&dec_shares[0]); for i in 0..ciphertexts.len() { black_box(contexts[0].share_combine( @@ -97,9 +106,7 @@ pub fn bench_decryption(c: &mut Criterion) { &prepared_blinded_key_shares, )); } - }; - - block_proposer_prepared + } } let mut group = c.benchmark_group("TPKE"); diff --git a/tpke/src/ciphertext.rs b/tpke/src/ciphertext.rs index ace4abda..72b806a5 100644 --- a/tpke/src/ciphertext.rs +++ b/tpke/src/ciphertext.rs @@ -1,6 +1,10 @@ -use crate::*; +use ark_ec::{AffineCurve, PairingEngine}; +use ark_ff::{One, ToBytes, UniformRand}; use chacha20::cipher::{NewCipher, StreamCipher}; use chacha20::{ChaCha20, Key, Nonce}; +use rand_core::RngCore; + +use crate::{construct_tag_hash, hash_to_g2}; #[derive(Clone, Debug)] pub struct Ciphertext { @@ -19,7 +23,6 @@ impl Ciphertext { ]) == E::Fqk::one() } fn construct_tag_hash(&self) -> E::G2Affine { - use ark_ff::ToBytes; let mut hash_input = Vec::::new(); self.nonce.write(&mut hash_input).unwrap(); hash_input.extend_from_slice(&self.ciphertext); @@ -57,7 +60,10 @@ pub fn encrypt( pub fn check_ciphertext_validity(c: &Ciphertext) -> bool { let g_inv = E::G1Prepared::from(-E::G1Affine::prime_subgroup_generator()); - let hash_g2 = E::G2Prepared::from(construct_tag_hash::(c.nonce, &c.ciphertext[..])); + let hash_g2 = E::G2Prepared::from(construct_tag_hash::( + c.nonce, + &c.ciphertext[..], + )); E::product_of_pairings(&[ (E::G1Prepared::from(c.nonce), hash_g2), @@ -65,7 +71,10 @@ pub fn check_ciphertext_validity(c: &Ciphertext) -> bool { ]) == E::Fqk::one() } -pub fn decrypt(ciphertext: &Ciphertext, privkey: E::G2Affine) -> Vec { +pub fn decrypt( + ciphertext: &Ciphertext, + privkey: E::G2Affine, +) -> Vec { let s = E::product_of_pairings(&[( E::G1Prepared::from(ciphertext.nonce), E::G2Prepared::from(privkey), diff --git a/tpke/src/combine.rs b/tpke/src/combine.rs index 84ed2cc2..d9d53e55 100644 --- a/tpke/src/combine.rs +++ b/tpke/src/combine.rs @@ -2,25 +2,30 @@ use crate::*; use ark_ec::ProjectiveCurve; impl PrivateDecryptionContext { - pub fn prepare_combine(&self, shares: &[DecryptionShare]) -> Vec { + pub fn prepare_combine( + &self, + shares: &[DecryptionShare], + ) -> Vec { let mut domain = vec![]; - let mut N_0 = E::Fr::one(); - for D_i in shares.iter() { + let mut n_0 = E::Fr::one(); + for d_i in shares.iter() { domain.extend( - self.public_decryption_contexts[D_i.decryptor_index] + self.public_decryption_contexts[d_i.decryptor_index] .domain .iter(), ); - N_0 *= self.public_decryption_contexts[D_i.decryptor_index].lagrange_N_0; + n_0 *= self.public_decryption_contexts[d_i.decryptor_index] + .lagrange_n_0; } let s = SubproductDomain::::new(domain); let mut lagrange = s.inverse_lagrange_coefficients(); - ark_ff::batch_inversion_and_mul(&mut lagrange, &N_0); + ark_ff::batch_inversion_and_mul(&mut lagrange, &n_0); let mut start = 0usize; shares .iter() - .map(|D_i| { - let decryptor = &self.public_decryption_contexts[D_i.decryptor_index]; + .map(|d_i| { + let decryptor = + &self.public_decryption_contexts[d_i.decryptor_index]; let end = start + decryptor.domain.len(); let lagrange_slice = &lagrange[start..end]; start = end; @@ -29,7 +34,9 @@ impl PrivateDecryptionContext { lagrange_slice.iter(), decryptor.blinded_key_shares.blinded_key_shares.iter() //decryptor.blinded_key_shares.window_tables.iter() ) - .map(|(lambda, blinded_key_share)| blinded_key_share.mul(*lambda)) + .map(|(lambda, blinded_key_share)| { + blinded_key_share.mul(*lambda) + }) /*.map(|(lambda, base_table)| { FixedBaseMSM::multi_scalar_mul::( self.scalar_bits, @@ -46,16 +53,18 @@ impl PrivateDecryptionContext { } pub fn share_combine( &self, - ciphertext: &Ciphertext, + _ciphertext: &Ciphertext, shares: &[DecryptionShare], prepared_key_shares: &[E::G2Prepared], ) -> E::Fqk { let mut pairing_product: Vec<(E::G1Prepared, E::G2Prepared)> = vec![]; - for (D_i, blinded_key_share) in izip!(shares, prepared_key_shares.iter()) { + for (d_i, blinded_key_share) in + izip!(shares, prepared_key_shares.iter()) + { // e(D_i, [b*omega_i^-1] Z_{i,omega_i}) pairing_product.push(( - E::G1Prepared::from(D_i.decryption_share), + E::G1Prepared::from(d_i.decryption_share), blinded_key_share.clone(), )); } @@ -66,15 +75,14 @@ impl PrivateDecryptionContext { #[cfg(test)] mod tests { - type E = ark_bls12_381::Bls12_381; type Fr = ::Fr; #[test] fn test_lagrange() { - use ark_ff; use ark_poly::EvaluationDomain; use ark_std::One; - let fft_domain = ark_poly::Radix2EvaluationDomain::::new(500).unwrap(); + let fft_domain = + ark_poly::Radix2EvaluationDomain::::new(500).unwrap(); let mut domain = Vec::with_capacity(500); let mut point = Fr::one(); @@ -82,13 +90,13 @@ mod tests { domain.push(point); point *= fft_domain.group_gen; } - let mut N_0 = Fr::one(); - let mut lagrange_N_0 = domain.iter().product::(); + + let mut lagrange_n_0 = domain.iter().product::(); if domain.len() % 2 == 1 { - lagrange_N_0 = -lagrange_N_0; + lagrange_n_0 = -lagrange_n_0; } let s = crate::subproductdomain::SubproductDomain::::new(domain); let mut lagrange = s.inverse_lagrange_coefficients(); - ark_ff::batch_inversion_and_mul(&mut lagrange, &lagrange_N_0); + ark_ff::batch_inversion_and_mul(&mut lagrange, &lagrange_n_0); } } diff --git a/tpke/src/context.rs b/tpke/src/context.rs index 299993fd..a05f077b 100644 --- a/tpke/src/context.rs +++ b/tpke/src/context.rs @@ -6,7 +6,7 @@ pub struct PublicDecryptionContext { pub public_key_shares: PublicKeyShares, pub blinded_key_shares: BlindedKeyShares, // This decrypter's contribution to N(0), namely (-1)^|domain| * \prod_i omega_i - pub lagrange_N_0: E::Fr, + pub lagrange_n_0: E::Fr, } pub struct PrivateDecryptionContext { diff --git a/tpke/src/decryption.rs b/tpke/src/decryption.rs index 2bb33ca2..c44b2e56 100644 --- a/tpke/src/decryption.rs +++ b/tpke/src/decryption.rs @@ -8,7 +8,10 @@ pub struct DecryptionShare { } impl PrivateDecryptionContext { - pub fn create_share(&self, ciphertext: &Ciphertext) -> DecryptionShare { + pub fn create_share( + &self, + ciphertext: &Ciphertext, + ) -> DecryptionShare { let decryption_share = ciphertext.nonce.mul(self.b_inv).into_affine(); DecryptionShare { @@ -29,8 +32,8 @@ impl PrivateDecryptionContext { // Get [b_i] H for each of the decryption shares let blinding_keys = shares[0] .iter() - .map(|D| { - self.public_decryption_contexts[D.decryptor_index] + .map(|d| { + self.public_decryption_contexts[d.decryptor_index] .blinded_key_shares .blinding_key_prepared .clone() @@ -51,7 +54,7 @@ impl PrivateDecryptionContext { .collect::>(); // Compute \sum_j [ \sum_i \alpha_{i,j} ] U_j - let sum_U_j = E::G1Prepared::from( + let sum_u_j = E::G1Prepared::from( izip!(ciphertexts.iter(), sum_alpha_i.iter()) .map(|(c, alpha_j)| c.nonce.mul(*alpha_j)) .sum::() @@ -59,20 +62,23 @@ impl PrivateDecryptionContext { ); // e(\sum_j [ \sum_i \alpha_{i,j} ] U_j, -H) - pairings.push((sum_U_j, self.h_inv.clone())); + pairings.push((sum_u_j, self.h_inv.clone())); - let mut sum_D_j = vec![E::G1Projective::zero(); num_shares]; + let mut sum_d_j = vec![E::G1Projective::zero(); num_shares]; // sum_D_j = { [\sum_j \alpha_{i,j} ] D_i } - for (D, alpha_j) in izip!(shares.iter(), alpha_ij.iter()) { - for (sum_alpha_D_i, Dij, alpha) in izip!(sum_D_j.iter_mut(), D.iter(), alpha_j.iter()) { - *sum_alpha_D_i += Dij.decryption_share.mul(*alpha); + for (d, alpha_j) in izip!(shares.iter(), alpha_ij.iter()) { + for (sum_alpha_d_i, d_ij, alpha) in + izip!(sum_d_j.iter_mut(), d.iter(), alpha_j.iter()) + { + *sum_alpha_d_i += d_ij.decryption_share.mul(*alpha); } } // e([\sum_j \alpha_{i,j} ] D_i, B_i) - for (D_i, B_i) in izip!(sum_D_j.iter(), blinding_keys.iter()) { - pairings.push((E::G1Prepared::from(D_i.into_affine()), B_i.clone())); + for (d_i, b_i) in izip!(sum_d_j.iter(), blinding_keys.iter()) { + pairings + .push((E::G1Prepared::from(d_i.into_affine()), b_i.clone())); } E::product_of_pairings(&pairings) == E::Fqk::one() diff --git a/tpke/src/hash_to_curve.rs b/tpke/src/hash_to_curve.rs index ecdbfad1..73d4b82b 100644 --- a/tpke/src/hash_to_curve.rs +++ b/tpke/src/hash_to_curve.rs @@ -17,6 +17,7 @@ fn ceil(a: usize, b: usize) -> usize { (a - 1) / b + 1 } +#[allow(dead_code)] fn hash_to_field_bls12381( hash: usize, hlen: usize, @@ -80,6 +81,7 @@ fn hash_to_field2_bls12381( u } +#[allow(dead_code)] pub fn htp_bls12381_g1(msg: &[u8]) -> ark_bls12_381::G1Affine { let dst = "QUUX-V01-CS02-with-BLS12381G1_XMD:SHA-256_SSWU_RO_".as_bytes(); let u = hash_to_field_bls12381(hmac::MC_SHA2, ecp::HASH_TYPE, dst, msg, 2); @@ -136,11 +138,13 @@ mod tests { hex::decode_to_slice(expected_hex_string, &mut expected_compressed) .expect("Failed to decode hex"); - let mut expected_compressed_rev = expected_compressed.clone(); + let mut expected_compressed_rev = expected_compressed; expected_compressed_rev[0] &= (1 << 5) - 1; expected_compressed_rev.reverse(); - let expected = ark_bls12_381::G1Affine::deserialize(&expected_compressed_rev[..]).unwrap(); + let expected = + ark_bls12_381::G1Affine::deserialize(&expected_compressed_rev[..]) + .unwrap(); let res = htp_bls12381_g1(msg); @@ -152,11 +156,13 @@ mod tests { hex::decode_to_slice(expected_hex_string, &mut expected_compressed) .expect("Failed to decode hex"); - let mut expected_compressed_rev = expected_compressed.clone(); + let mut expected_compressed_rev = expected_compressed; expected_compressed_rev[0] &= (1 << 5) - 1; expected_compressed_rev.reverse(); - let expected = ark_bls12_381::G2Affine::deserialize(&expected_compressed_rev[..]).unwrap(); + let expected = + ark_bls12_381::G2Affine::deserialize(&expected_compressed_rev[..]) + .unwrap(); let res = htp_bls12381_g2(msg); diff --git a/tpke/src/key_share.rs b/tpke/src/key_share.rs index fa092649..d799d99e 100644 --- a/tpke/src/key_share.rs +++ b/tpke/src/key_share.rs @@ -9,9 +9,9 @@ pub struct PublicKeyShares { #[derive(Clone)] pub struct BlindedKeyShares { - pub blinding_key: E::G2Affine, // [b] H - pub blinding_key_prepared: E::G2Prepared, // [b] H - pub blinded_key_shares: Vec, // [b] Z_{i, \omega_i} + pub blinding_key: E::G2Affine, // [b] H + pub blinding_key_prepared: E::G2Prepared, // [b] H + pub blinded_key_shares: Vec, // [b] Z_{i, \omega_i} pub window_tables: Vec>, // [b*omega_i^-1] Z_{i, \omega_i} } @@ -22,10 +22,13 @@ impl BlindedKeyShares { rng: &mut R, ) -> bool { let g = E::G1Affine::prime_subgroup_generator(); - let alpha = E::Fr::rand(rng); - let alpha_i = generate_random::<_, E>(public_key_shares.public_key_shares.len(), rng); + let _alpha = E::Fr::rand(rng); + let alpha_i = generate_random::<_, E>( + public_key_shares.public_key_shares.len(), + rng, + ); - let alpha_A_i = E::G1Prepared::from( + let alpha_a_i = E::G1Prepared::from( g + public_key_shares .public_key_shares .iter() @@ -35,7 +38,7 @@ impl BlindedKeyShares { .into_affine(), ); - let alpha_Z_i = E::G2Prepared::from( + let alpha_z_i = E::G2Prepared::from( self.blinding_key + self .blinded_key_shares @@ -47,8 +50,8 @@ impl BlindedKeyShares { ); E::product_of_pairings(&[ - (E::G1Prepared::from(-g), alpha_Z_i), - (alpha_A_i, E::G2Prepared::from(self.blinding_key)), + (E::G1Prepared::from(-g), alpha_z_i), + (alpha_a_i, E::G2Prepared::from(self.blinding_key)), ]) == E::Fqk::one() } pub fn get_window_table( @@ -68,8 +71,9 @@ impl BlindedKeyShares { .collect::>() } pub fn multiply_by_omega_inv(&mut self, domain_inv: &[E::Fr]) { - izip!(self.blinded_key_shares.iter_mut(), domain_inv.iter()) - .for_each(|(key, omega_inv)| *key = key.mul(-*omega_inv).into_affine()) + izip!(self.blinded_key_shares.iter_mut(), domain_inv.iter()).for_each( + |(key, omega_inv)| *key = key.mul(-*omega_inv).into_affine(), + ) } } #[derive(Clone)] @@ -84,7 +88,8 @@ pub struct PrivateKeyShare { impl PrivateKeyShare { pub fn blind(&self, b: E::Fr) -> BlindedKeyShares { - let blinding_key = E::G2Affine::prime_subgroup_generator().mul(b).into_affine(); + let blinding_key = + E::G2Affine::prime_subgroup_generator().mul(b).into_affine(); BlindedKeyShares:: { blinding_key, blinding_key_prepared: E::G2Prepared::from(blinding_key), diff --git a/tpke/src/lib.rs b/tpke/src/lib.rs index adeb9c05..cbfaf9c6 100644 --- a/tpke/src/lib.rs +++ b/tpke/src/lib.rs @@ -3,12 +3,11 @@ use crate::subproductdomain::SubproductDomain; use ark_ec::{msm::FixedBaseMSM, AffineCurve, PairingEngine}; use ark_ff::{Field, One, PrimeField, ToBytes, UniformRand, Zero}; use ark_poly::EvaluationDomain; -use ark_poly::{univariate::DensePolynomial, Polynomial, UVPolynomial}; +use ark_poly::{univariate::DensePolynomial, UVPolynomial}; use ark_serialize::CanonicalSerialize; use itertools::izip; use rand_core::RngCore; -use rayon::prelude::*; use std::usize; use thiserror::Error; @@ -53,7 +52,10 @@ fn hash_to_g2(message: &[u8]) -> T { T::deserialize(&point_ser[..]).unwrap() } -fn construct_tag_hash(u: E::G1Affine, stream_ciphertext: &[u8]) -> E::G2Affine { +fn construct_tag_hash( + u: E::G1Affine, + stream_ciphertext: &[u8], +) -> E::G2Affine { let mut hash_input = Vec::::new(); u.write(&mut hash_input).unwrap(); hash_input.extend_from_slice(stream_ciphertext); @@ -69,13 +71,14 @@ pub fn setup( let rng = &mut ark_std::test_rng(); let g = E::G1Affine::prime_subgroup_generator(); let h = E::G2Affine::prime_subgroup_generator(); - let g_inv = E::G1Prepared::from(-g); - let h_inv = E::G2Prepared::from(-h); + let _g_inv = E::G1Prepared::from(-g); + let _h_inv = E::G2Prepared::from(-h); assert!(shares_num >= threshold); let threshold_poly = DensePolynomial::::rand(threshold - 1, rng); - let fft_domain = ark_poly::Radix2EvaluationDomain::::new(shares_num).unwrap(); + let fft_domain = + ark_poly::Radix2EvaluationDomain::::new(shares_num).unwrap(); let evals = threshold_poly.evaluate_over_domain_by_ref(fft_domain); let mut domain_points = Vec::with_capacity(shares_num); let mut point = E::Fr::one(); @@ -92,8 +95,10 @@ pub fn setup( let window_size = FixedBaseMSM::get_mul_window_size(100); let scalar_bits = E::Fr::size_in_bits(); - let pubkey_shares = subproductdomain::fast_multiexp(&evals.evals, g.into_projective()); - let privkey_shares = subproductdomain::fast_multiexp(&evals.evals, h.into_projective()); + let pubkey_shares = + subproductdomain::fast_multiexp(&evals.evals, g.into_projective()); + let privkey_shares = + subproductdomain::fast_multiexp(&evals.evals, h.into_projective()); let x = threshold_poly.coeffs[0]; let pubkey = g.mul(x); @@ -114,7 +119,7 @@ pub fn setup( private_key_shares: private.to_vec(), }; let b = E::Fr::rand(rng); - let mut blinded_key_shares = private_key_share.blind(b.clone()); + let mut blinded_key_shares = private_key_share.blind(b); blinded_key_shares.multiply_by_omega_inv(domain_inv); /*blinded_key_shares.window_tables = blinded_key_shares.get_window_table(window_size, scalar_bits, domain_inv);*/ @@ -130,9 +135,9 @@ pub fn setup( scalar_bits, window_size, }); - let mut lagrange_N_0 = domain.iter().product::(); + let mut lagrange_n_0 = domain.iter().product::(); if domain.len() % 2 == 1 { - lagrange_N_0 = -lagrange_N_0; + lagrange_n_0 = -lagrange_n_0; } public_contexts.push(PublicDecryptionContext:: { domain: domain.to_vec(), @@ -140,7 +145,7 @@ pub fn setup( public_key_shares: public.to_vec(), }, blinded_key_shares, - lagrange_N_0, + lagrange_n_0, }); } for private in private_contexts.iter_mut() { @@ -150,7 +155,10 @@ pub fn setup( (pubkey.into(), privkey.into(), private_contexts) } -pub fn generate_random(n: usize, rng: &mut R) -> Vec { +pub fn generate_random( + n: usize, + rng: &mut R, +) -> Vec { (0..n).map(|_| E::Fr::rand(rng)).collect::>() } @@ -170,9 +178,11 @@ mod tests { let msg: &[u8] = "abc".as_bytes(); - let (pubkey, privkey, _) = setup::(threshold, shares_num, num_entities); + let (pubkey, privkey, _) = + setup::(threshold, shares_num, num_entities); - let ciphertext = encrypt::(msg, pubkey, &mut rng); + let ciphertext = + encrypt::(msg, pubkey, &mut rng); let plaintext = decrypt(&ciphertext, privkey); assert!(msg == plaintext) @@ -186,7 +196,8 @@ mod tests { let num_entities = 5; let msg: &[u8] = "abc".as_bytes(); - let (pubkey, privkey, contexts) = setup::(threshold, shares_num, num_entities); + let (pubkey, _privkey, contexts) = + setup::(threshold, shares_num, num_entities); let ciphertext = encrypt::<_, E>(msg, pubkey, rng); let mut shares: Vec> = vec![]; @@ -199,7 +210,11 @@ mod tests { .verify_blinding(&pub_context.public_key_shares, rng)); }*/ let prepared_blinded_key_shares = contexts[0].prepare_combine(&shares); - let s = contexts[0].share_combine(&ciphertext, &shares, &prepared_blinded_key_shares); + let s = contexts[0].share_combine( + &ciphertext, + &shares, + &prepared_blinded_key_shares, + ); let plaintext = decrypt_with_shared_secret(&ciphertext, &s); assert!(plaintext == msg) diff --git a/tpke/src/subproductdomain.rs b/tpke/src/subproductdomain.rs index 95fedd8e..4ade602d 100644 --- a/tpke/src/subproductdomain.rs +++ b/tpke/src/subproductdomain.rs @@ -13,7 +13,8 @@ pub fn fast_multiexp( let window_size = FixedBaseMSM::get_mul_window_size(scalars.len()); let scalar_bits = Projective::ScalarField::size_in_bits(); - let base_table = FixedBaseMSM::get_window_table(scalar_bits, window_size, base); + let base_table = + FixedBaseMSM::get_window_table(scalar_bits, window_size, base); let exp = FixedBaseMSM::multi_scalar_mul::( scalar_bits, @@ -24,9 +25,12 @@ pub fn fast_multiexp( Projective::batch_normalization_into_affine(&exp) } +#[allow(dead_code)] pub fn poly_from_scalar(s: &F) -> Poly { Poly:: { coeffs: vec![*s] } } + +#[allow(dead_code)] pub fn moduli_from_scalar(s: &F) -> Poly { Poly:: { coeffs: vec![-*s, F::one()], @@ -76,7 +80,10 @@ pub fn rev(f: &mut Poly, m: usize) { /// GG Algorithm 9.5 /// Divide f by g in nearly linear time -pub fn fast_divide_monic(f: &Poly, g: &Poly) -> (Poly, Poly) { +pub fn fast_divide_monic( + f: &Poly, + g: &Poly, +) -> (Poly, Poly) { //assert_eq!(g.coeffs.last(), F::one()); //TODO: check monic condition if f.coeffs().len() < g.coeffs().len() { @@ -126,20 +133,27 @@ impl SubproductDomain { let prime = derivative::(&t.m); SubproductDomain { u, t, prime } } + + #[allow(dead_code)] /// Evaluate a polynomial f over the subproduct domain u pub fn evaluate(&self, f: &Poly) -> Vec { let mut evals = vec![F::zero(); self.u.len()]; self.t.evaluate(f, &self.u, &mut evals); evals } + + #[allow(dead_code)] /// Interpolate a polynomial f over the domain, such that f(u_i) = v_i pub fn interpolate(&self, v: &[F]) -> Poly { self.t.interpolate(&self.u, v) } + /// Compute the inverse of the lagrange coefficients necessary to interpolate over u pub fn inverse_lagrange_coefficients(&self) -> Vec { self.t.inverse_lagrange_coefficients(&self.u) } + + #[allow(dead_code)] /// Compute a linear combination of lagrange factors times c_i pub fn linear_combine(&self, c: &[F]) -> Poly { self.t.linear_combine(&self.u, &c) @@ -223,6 +237,8 @@ impl SubproductTree { left.evaluate(&r_0, u_0, t_0); right.evaluate(&r_1, u_1, t_1); } + + #[allow(dead_code)] /// Fast interpolate over this subproduct tree pub fn interpolate(&self, u: &[F], v: &[F]) -> Poly { let mut lagrange_coeff = self.inverse_lagrange_coefficients(u); @@ -233,6 +249,7 @@ impl SubproductTree { self.linear_combine(u, &lagrange_coeff) } + /// Fast compute lagrange coefficients over this subproduct tree pub fn inverse_lagrange_coefficients(&self, u: &[F]) -> Vec { //assert u.len() == degree of s.m @@ -244,6 +261,8 @@ impl SubproductTree { self.evaluate(&m_prime, u, &mut evals); evals } + + #[allow(dead_code)] /// GG Algorithm 10.9 /// Fast linear combination of moduli over this subproduct tree /// On input c = { c_0, ..., c_{n-1} } @@ -292,14 +311,18 @@ pub fn build_circulant( if n == coeffs.len() - 1 { circulant[0] = *coeffs.last().unwrap(); circulant[n] = *coeffs.last().unwrap(); - circulant[n + 1..n + 1 + coeffs.len() - 2].copy_from_slice(&coeffs[1..coeffs.len() - 1]); + circulant[n + 1..n + 1 + coeffs.len() - 2] + .copy_from_slice(&coeffs[1..coeffs.len() - 1]); } else { - circulant[n + 1..n + 1 + coeffs.len() - 1].copy_from_slice(&coeffs[1..]); + circulant[n + 1..n + 1 + coeffs.len() - 1] + .copy_from_slice(&coeffs[1..]); } circulant } + +#[allow(dead_code)] /// Computes the Toeplitz matrix of polynomial times the vector v -pub fn toeplitz_mul( +pub fn toeplitz_mul( polynomial: &Poly, v: &[E::G1Affine], size: usize, @@ -310,7 +333,9 @@ pub fn toeplitz_mul( let size = ark_std::cmp::max(size, m); let domain = ark_poly::Radix2EvaluationDomain::::new(2 * size) - .ok_or_else(|| anyhow::anyhow!("toeplitz multiplication on too large a domain"))?; + .ok_or_else(|| { + anyhow::anyhow!("toeplitz multiplication on too large a domain") + })?; let circulant_size = domain.size(); let toeplitz_size = circulant_size / 2; From cb02291b1f46fa6758cf6cf63803993c43df5154 Mon Sep 17 00:00:00 2001 From: joe bebel <55120843+joebebel@users.noreply.github.com> Date: Thu, 26 Aug 2021 22:56:40 -0700 Subject: [PATCH 11/16] cleanup --- Cargo.lock | 739 ++++++++++++++++++++++++++++------- Cargo.toml | 15 +- src/dkg.rs | 9 +- src/dkg/common.rs | 27 +- src/dkg/pv.rs | 65 ++- src/lib.rs | 7 +- src/msg.rs | 8 +- src/primitives/keypair.rs | 2 +- src/vss/pvss.rs | 39 +- tpke/src/ciphertext.rs | 1 - tpke/src/combine.rs | 4 +- tpke/src/decryption.rs | 2 + tpke/src/hash_to_curve.rs | 1 + tpke/src/key_share.rs | 3 + tpke/src/lib.rs | 8 +- tpke/src/subproductdomain.rs | 3 + 16 files changed, 678 insertions(+), 255 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9487946f..feb3af50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aead" version = "0.4.1" @@ -17,6 +32,17 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" +[[package]] +name = "ahash" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "796540673305a66d127804eef19ad696f1f204b8c1025aaca4958c17eab32877" +dependencies = [ + "getrandom 0.2.2", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.7.2" @@ -28,6 +54,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "anomaly" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "550632e31568ae1a5f47998c3aa48563030fc49b9ec91913ca337cf64fbc5ccb" +dependencies = [ + "backtrace", +] + [[package]] name = "anyhow" version = "1.0.40" @@ -60,18 +95,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "ark-ed-on-bls12-381" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b7ada17db3854f5994e74e60b18e10e818594935ee7e1d329800c117b32970" -dependencies = [ - "ark-bls12-381", - "ark-ec", - "ark-ff", - "ark-std", -] - [[package]] name = "ark-ff" version = "0.3.0" @@ -131,17 +154,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "ark-pallas" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e945e1c8d86aa869853944ce6ecf072c2dac623b88c94e68792901b06190e53" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-std", -] - [[package]] name = "ark-poly" version = "0.3.0" @@ -242,12 +254,32 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + [[package]] name = "arrayvec" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "async-trait" +version = "0.1.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atty" version = "0.2.14" @@ -265,6 +297,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "bincode" version = "1.3.3" @@ -280,29 +327,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "bitvec" -version = "0.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" -dependencies = [ - "funty", - "radium 0.3.0", - "wyz", -] - -[[package]] -name = "bitvec" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" -dependencies = [ - "funty", - "radium 0.6.2", - "tap", - "wyz", -] - [[package]] name = "blake2" version = "0.9.1" @@ -321,7 +345,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" dependencies = [ "arrayref", - "arrayvec", + "arrayvec 0.5.2", "constant_time_eq", ] @@ -334,17 +358,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bls12_381" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c56609cc42c628848e7b18e0baf42a4ef626b8c50442dc08b8094bd21d8ad32" -dependencies = [ - "ff 0.9.0", - "rand_core 0.6.3", - "subtle", -] - [[package]] name = "borsh" version = "0.9.0" @@ -408,12 +421,24 @@ version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" +[[package]] +name = "bytemuck" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72957246c41db82b8ef88a5486143830adeb8227ef9837740bdec67724cf2c5b" + [[package]] name = "byteorder" version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" + [[package]] name = "cast" version = "0.2.5" @@ -423,6 +448,12 @@ dependencies = [ "rustc_version 0.2.3", ] +[[package]] +name = "cc" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" + [[package]] name = "cfg-if" version = "1.0.0" @@ -454,6 +485,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "serde", + "time", + "winapi", +] + [[package]] name = "cipher" version = "0.3.0" @@ -480,6 +525,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "cpp_demangle" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea47428dc9d2237f3c6bc134472edfd63ebba0af932e783506dcfd66f10d18a" +dependencies = [ + "cfg-if", +] + [[package]] name = "cpufeatures" version = "0.1.5" @@ -617,11 +671,19 @@ dependencies = [ "byteorder", "digest", "rand_core 0.5.1", - "serde", "subtle", "zeroize", ] +[[package]] +name = "debugid" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91cf5a8c2f2097e2a32627123508635d47ce10563d999ec1a95addf08b502ba" +dependencies = [ + "uuid", +] + [[package]] name = "derivative" version = "2.2.0" @@ -681,9 +743,7 @@ dependencies = [ "anyhow", "ark-bls12-381", "ark-ec", - "ark-ed-on-bls12-381", "ark-ff", - "ark-pallas", "ark-poly", "ark-poly-commit", "ark-serialize", @@ -694,58 +754,122 @@ dependencies = [ "borsh", "chacha20poly1305", "criterion", - "curve25519-dalek", "digest", "ed25519-dalek", "either", - "ff 0.8.0", "group-threshold-cryptography", "hex", "itertools 0.10.1", "measure_time", "miracl_core", "num", + "pprof", "rand 0.7.3", "rand 0.8.4", "rand_chacha 0.3.1", "rand_core 0.6.3", - "redjubjub", "serde", "serde_bytes", "serde_json", "sha2", "subtle", - "x25519-dalek", + "tendermint", "zeroize", ] [[package]] -name = "ff" -version = "0.8.0" +name = "futures" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" +checksum = "1adc00f486adfc9ce99f77d717836f0c5aa84965eb0b4f051f4e83f7cab53f8b" dependencies = [ - "bitvec 0.18.5", - "rand_core 0.5.1", - "subtle", + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", ] [[package]] -name = "ff" -version = "0.9.0" +name = "futures-channel" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72a4d941a5b7c2a75222e2d44fcdf634a67133d9db31e177ae5ff6ecda852bfe" +checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9" dependencies = [ - "bitvec 0.20.4", - "rand_core 0.6.3", - "subtle", + "futures-core", + "futures-sink", ] [[package]] -name = "funty" -version = "1.1.0" +name = "futures-core" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" + +[[package]] +name = "futures-executor" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d0d535a57b87e1ae31437b892713aee90cd2d7b0ee48727cd11fc72ef54761c" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582" + +[[package]] +name = "futures-macro" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57" +dependencies = [ + "autocfg", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53" + +[[package]] +name = "futures-task" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2" + +[[package]] +name = "futures-util" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" +dependencies = [ + "autocfg", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] [[package]] name = "generic-array" @@ -780,16 +904,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.9.0" +name = "gimli" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3c1e8b4f1ca07e6605ea1be903a5f6956aec5c8a67fd44d56076631675ed8" -dependencies = [ - "byteorder", - "ff 0.9.0", - "rand_core 0.6.3", - "subtle", -] +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" [[package]] name = "group-threshold-cryptography" @@ -852,6 +970,43 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown 0.11.2", +] + +[[package]] +name = "inferno" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3cbcc228d2ad2e99328c2b19f38d80ec387ca6a29f778e40e32ca9f25448c3" +dependencies = [ + "ahash 0.6.3", + "atty", + "indexmap", + "itoa", + "lazy_static", + "log", + "num-format", + "quick-xml", + "rgb", + "str_stack", +] + +[[package]] +name = "instant" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +dependencies = [ + "cfg-if", +] + [[package]] name = "itertools" version = "0.9.0" @@ -885,20 +1040,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jubjub" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d7e7fef85ae7b26dd89f34175b7f3c5ace64067a110c2ac86cf92407a6666ca" -dependencies = [ - "bitvec 0.20.4", - "bls12_381", - "ff 0.9.0", - "group", - "rand_core 0.6.3", - "subtle", -] - [[package]] name = "keccak" version = "0.1.0" @@ -913,9 +1054,18 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.98" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" + +[[package]] +name = "lock_api" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +dependencies = [ + "scopeguard", +] [[package]] name = "log" @@ -941,6 +1091,16 @@ version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "memoffset" version = "0.6.3" @@ -962,12 +1122,41 @@ dependencies = [ "zeroize", ] +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + [[package]] name = "miracl_core" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94c7128ba23c81f6471141b90f17654f89ef44a56e14b8a4dd0fddfccd655277" +[[package]] +name = "nix" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8e5e343312e7fbeb2a52139114e9e702991ef9c2aea6817ff2440b35647d56" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + [[package]] name = "num" version = "0.4.0" @@ -1002,6 +1191,27 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num-format" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" +dependencies = [ + "arrayvec 0.4.12", + "itoa", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -1054,6 +1264,12 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" + [[package]] name = "once_cell" version = "1.7.2" @@ -1072,6 +1288,31 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + [[package]] name = "paste" version = "1.0.5" @@ -1093,6 +1334,12 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "plotters" version = "0.3.0" @@ -1132,6 +1379,25 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "pprof" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9fb4eee2f2c4f7d48fe5a33008dececbc405d0e58d2a94afe742d4f175bc401" +dependencies = [ + "backtrace", + "criterion", + "inferno", + "lazy_static", + "libc", + "log", + "nix", + "parking_lot", + "symbolic-demangle", + "tempfile", + "thiserror", +] + [[package]] name = "ppv-lite86" version = "0.2.10" @@ -1147,6 +1413,18 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + [[package]] name = "proc-macro2" version = "1.0.26" @@ -1157,25 +1435,55 @@ dependencies = [ ] [[package]] -name = "quote" -version = "1.0.9" +name = "prost" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "9e6984d2f1a23009bd270b8bb56d0926810a3d483f59c987d77969e9d8e840b2" dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "169a15f3008ecb5160cba7d37bcd690a7601b6d30cfb87a117d45e59d52af5d4" +dependencies = [ + "anyhow", + "itertools 0.9.0", "proc-macro2", + "quote", + "syn", ] [[package]] -name = "radium" -version = "0.3.0" +name = "prost-types" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" +checksum = "b518d7cdd93dab1d1122cf07fa9a60771836c668dde9d9e2a139f957f0d9f1bb" +dependencies = [ + "bytes", + "prost", +] [[package]] -name = "radium" -version = "0.6.2" +name = "quick-xml" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" +checksum = "26aab6b48e2590e4a64d1ed808749ba06257882b461d01ca71baeb747074a6dd" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] [[package]] name = "rand" @@ -1284,20 +1592,12 @@ dependencies = [ ] [[package]] -name = "redjubjub" -version = "0.4.0" +name = "redox_syscall" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcf30702f15c157e348b4ccef28b1224fc7da8f8430d553bdc47b2d6599107b" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ - "blake2b_simd", - "byteorder", - "digest", - "funty", - "jubjub", - "rand_core 0.6.3", - "serde", - "thiserror", - "zeroize", + "bitflags", ] [[package]] @@ -1324,6 +1624,30 @@ version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "rgb" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fddb3b23626145d1776addfc307e1a1851f60ef6ca64f376bcb889697144cf0" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49" + [[package]] name = "rustc_version" version = "0.2.3" @@ -1446,6 +1770,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98d0516900518c29efa217c298fa1f4e6c6ffc85ae29fd7f4ee48f176e1a9ed5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sha2" version = "0.9.3" @@ -1465,12 +1800,68 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c19772be3c4dd2ceaacf03cb41d5885f2a02c4d8804884918e3a258480803335" +[[package]] +name = "slab" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "str_stack" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" + [[package]] name = "subtle" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" +[[package]] +name = "subtle-encoding" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcb1ed7b8330c5eed5441052651dd7a12c75e2ed88f2ec024ae1fa3a5e59945" +dependencies = [ + "zeroize", +] + +[[package]] +name = "symbolic-common" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348885c332e7d0784d661844b13b198464144a5ebcd3bfc047a6c441867ea467" +dependencies = [ + "debugid", + "memmap", + "stable_deref_trait", + "uuid", +] + +[[package]] +name = "symbolic-demangle" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6780c62bfbd609bffaa13d6959715850578aa43caaae7aee14f1f24ceb64f433" +dependencies = [ + "cpp_demangle", + "rustc-demangle", + "symbolic-common", +] + [[package]] name = "syn" version = "1.0.69" @@ -1495,10 +1886,66 @@ dependencies = [ ] [[package]] -name = "tap" -version = "1.0.1" +name = "tempfile" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if", + "libc", + "rand 0.8.4", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "tendermint" +version = "0.18.0" +source = "git+https://github.com/heliaxdev/tendermint-rs#1a6629046035e5e504f3609725a93b35cf0eab1b" +dependencies = [ + "anomaly", + "async-trait", + "bytes", + "chrono", + "ed25519", + "ed25519-dalek", + "futures", + "num-traits", + "once_cell", + "prost", + "prost-types", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2", + "signature", + "subtle", + "subtle-encoding", + "tendermint-proto", + "thiserror", + "toml", + "zeroize", +] + +[[package]] +name = "tendermint-proto" +version = "0.18.0" +source = "git+https://github.com/heliaxdev/tendermint-rs#1a6629046035e5e504f3609725a93b35cf0eab1b" +dependencies = [ + "anomaly", + "bytes", + "chrono", + "num-derive", + "num-traits", + "prost", + "prost-types", + "serde", + "serde_bytes", + "subtle-encoding", + "thiserror", +] [[package]] name = "textwrap" @@ -1529,6 +1976,16 @@ dependencies = [ "syn", ] +[[package]] +name = "time" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -1623,6 +2080,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + [[package]] name = "version_check" version = "0.9.3" @@ -1747,24 +2210,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "wyz" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" - -[[package]] -name = "x25519-dalek" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" -dependencies = [ - "curve25519-dalek", - "rand_core 0.5.1", - "serde", - "zeroize", -] - [[package]] name = "zeroize" version = "1.2.0" diff --git a/Cargo.toml b/Cargo.toml index 3905ef5b..32d94c49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ authors = ["Heliax AG "] [dependencies] ark-poly-commit = "0.3" ark-std = "0.3" -#ark-pallas = "0.3" ark-bls12-381 = "0.3" ark-ec = "0.3" ark-ff = "0.3" @@ -24,14 +23,11 @@ ark-poly = "0.3" rand = "0.8" rand_old = { package = "rand", version = "0.7" } either = "1.6.1" -ff = "0.8" hex = "0.4.2" miracl_core = "2.3.0" num = "0.4" sha2 = "0.9.1" ed25519-dalek = { version = "1", features = ["serde", "batch"] } -#x25519-dalek = { version = "1.1", features = ["serde"] } -#curve25519-dalek = { version = "3.0", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } blake2 = "0.9.1" rand_chacha = "0.3.0" @@ -41,23 +37,22 @@ chacha20poly1305 = "0.8" serde_bytes = { version = "0.11" } bincode = "1.3" anyhow = "1.0" -serde_json = "1.0" borsh = "0.9" subtle = "2.4" itertools = "0.10.1" measure_time = "0.7" -#redjubjub = "0.4.0" -#ark-ed-on-bls12-381 = "0.3.0" -#group-threshold-cryptography = {path = "./tpke/"} +group-threshold-cryptography = { path = "tpke" } rand_core = "0.6" +tendermint = {git = "https://github.com/heliaxdev/tendermint-rs"} [dependencies.digest] version = "0.9.0" features = ["alloc"] [dev-dependencies] -criterion = "=0.3.4" -pprof = { version = "0.4", features = ["flamegraph", "criterion"] } +criterion = "=0.3" +pprof = { version = "0.5", features = ["flamegraph", "criterion"] } +serde_json = "1.0" # local override for bls12-381 #[patch.crates-io] diff --git a/src/dkg.rs b/src/dkg.rs index 8bddc819..83e2caf9 100644 --- a/src/dkg.rs +++ b/src/dkg.rs @@ -2,8 +2,6 @@ #![allow(non_snake_case)] #![allow(unused_imports)] -//use ark_poly_commit::kzg10::{Powers, VerifierKey}; - use crate::*; use anyhow::anyhow; use ark_ec::{AffineCurve, PairingEngine, ProjectiveCurve}; @@ -14,7 +12,6 @@ use ark_poly::{ EvaluationDomain, Polynomial, }; use ed25519_dalek as ed25519; -use serde::*; pub mod common; pub mod pv; @@ -34,9 +31,7 @@ pub enum DKGState { Init, Dealt, Shared, - Aggregated { - finalized_weight: u32 - }, + Aggregated { finalized_weight: u32 }, Success, - Invalid + Invalid, } diff --git a/src/dkg/common.rs b/src/dkg/common.rs index c9d26030..ad1798bb 100644 --- a/src/dkg/common.rs +++ b/src/dkg/common.rs @@ -12,28 +12,25 @@ use crate::*; /// partition_domain returns a vector of DKG participants pub fn partition_domain( params: &Params, - announce_messages: &mut Vec>, + validator_set: &tendermint::validator::Set, + //announce_messages: &mut Vec>, ) -> Result>> where E: ark_ec::PairingEngine, { + let validators = validator_set.validators(); // Sort participants from greatest to least stake - announce_messages.sort_by(|a, b| b.stake.cmp(&a.stake)); + // Compute the total amount staked - let total_stake: f64 = announce_messages - .iter() - .map(|p| p.stake as f64) - .sum::() - .into(); + let total_stake = params.total_weight as f64 + / validator_set.total_voting_power().value() as f64; // Compute the weight of each participant rounded down - let mut weights = announce_messages + let mut weights = validators .iter() - .map(|p| { - ((params.total_weight as f64) * p.stake as f64 / total_stake) - .floor() as u32 - }) - .collect::>(); + .map(|p| (p.power() as f64 * total_stake).floor() as u32) + .collect::>(); + // Add any excess weight to the largest weight participants let adjust_weight = params .total_weight @@ -49,11 +46,11 @@ where let mut allocated_weight = 0usize; let mut participants = vec![]; - for (announcement, weight) in announce_messages.iter().zip(weights) { + for (announcement, weight) in validators.iter().zip(weights) { let share_range = allocated_weight..allocated_weight + weight as usize; participants.push(PubliclyVerifiableParticipant:: { - ed_key: announcement.signer, + //ed_key: announcement.signer, session_key: announcement.session_key, weight, share_range, diff --git a/src/dkg/pv.rs b/src/dkg/pv.rs index 64d970d9..fa6ed57b 100644 --- a/src/dkg/pv.rs +++ b/src/dkg/pv.rs @@ -1,5 +1,6 @@ use crate::*; use ark_ec::PairingEngine; +use ark_ff::Field; use ark_std::{end_timer, start_timer}; /// The DKG context that holds all of the local state for participating in the DKG @@ -7,7 +8,7 @@ pub struct PubliclyVerifiableDKG where E: PairingEngine, { - pub ed_key: ed25519::Keypair, + //pub ed_key: ed25519::Keypair, pub params: Params, pub pvss_params: PubliclyVerifiableParams, pub session_keypair: PubliclyVerifiableKeypair, @@ -16,8 +17,8 @@ where pub domain: ark_poly::Radix2EvaluationDomain, pub state: DKGState, pub me: usize, - pub local_shares: Vec, - pub announce_messages: Vec>, + //pub local_shares: Vec, + //pub announce_messages: Vec>, } impl PubliclyVerifiableDKG @@ -30,8 +31,9 @@ where /// `params` contains the parameters of the DKG such as number of shares /// `rng` is a cryptographic random number generator pub fn new( - ed_key: ed25519::Keypair, + validator_set: &tendermint::validator::Set, params: Params, + me: usize, rng: &mut R, ) -> Result { use ark_std::UniformRand; @@ -41,23 +43,22 @@ where .ok_or_else(|| anyhow!("unable to construct domain"))?; Ok(Self { - ed_key, session_keypair: PubliclyVerifiableKeypair::::new(rng), params, pvss_params: PubliclyVerifiableParams:: { - g_1: E::G1Projective::prime_subgroup_generator(), - u_hat_1: E::G2Affine::prime_subgroup_generator(), + g: E::G1Projective::prime_subgroup_generator(), + h: E::G2Projective::prime_subgroup_generator(), }, participants: vec![], vss: BTreeMap::new(), domain, state: DKGState::Init, - me: 0, // TODO: invalid value + me, + //me: 0, // TODO: invalid value //final_state: None, - local_shares: vec![], + //local_shares: vec![], // TODO: Validators don't announce themselves through DKG // TODO: Instead, we read stakes from storage - announce_messages: vec![], }) } /// Create a new PVSS instance within this DKG session, contributing to the final key @@ -86,22 +87,10 @@ where /// Converts an ed25519 key to the index of that participant //TODO: this is not a good workaround for finding dealer from ed_key - pub fn find_by_key(&self, ed_key: &ed25519::PublicKey) -> Option { - self.participants.iter().position(|p| p.ed_key == *ed_key) - } + //pub fn find_by_key(&self, ed_key: &ed25519::PublicKey) -> Option { + // self.participants.iter().position(|p| p.ed_key == *ed_key) + //} - /// Call `finish_announce` once the Announcement phase is complete - /// Partitions the share domain among the announced participants - /// and begins the sharing phase of the DKG - /// TODO: Since announce is no longer a phase, do we still need this? - pub fn finish_announce(&mut self) -> Result<()> { - self.participants = - partition_domain(&self.params, &mut self.announce_messages)?; - self.me = self - .find_by_key(&self.ed_key.public) - .ok_or_else(|| anyhow!("self not found"))?; - Ok(()) - } /// Returns the public key generated by the DKG pub fn final_key(&self) -> E::G1Affine { self.vss @@ -116,15 +105,15 @@ where /// `payload` is the content of the message pub fn handle_message( &mut self, - signer: &ed25519::PublicKey, + dealer: u32, payload: PubliclyVerifiableMessage, ) -> Result> { match payload { PubliclyVerifiableMessage::Deal(sharing) => { if let DKGState::Init = self.state { - let dealer = self.find_by_key(signer).ok_or_else(|| { + /*let dealer = self.find_by_key(signer).ok_or_else(|| { anyhow!("received dealing from unknown dealer") - })? as u32; + })? as u32;*/ if dealer != self.me as u32 { if self.vss.contains_key(&dealer) { return Err(anyhow!("Repeat dealer {}", dealer)); @@ -139,12 +128,10 @@ where PubliclyVerifiableMessage::Aggregate(vss) => { if let DKGState::Shared = self.state { let minimum_weight = self.params.total_weight - //- self.params.failure_threshold - - self.params.security_threshold; - let (verified_weight, local_shares) = - vss.verify_aggregation(&self)?; + - self.params.security_threshold; + let verified_weight = vss.verify_aggregation(&self)?; if verified_weight >= minimum_weight { - self.local_shares = local_shares; + //self.local_shares = local_shares; self.state = DKGState::Success; } else { self.state = DKGState::Aggregated { @@ -170,7 +157,6 @@ pub enum PubliclyVerifiableMessage { #[derive(Clone, Debug)] pub struct PubliclyVerifiableParticipant { - pub ed_key: ed25519::PublicKey, pub session_key: PubliclyVerifiablePublicKey, pub weight: u32, pub share_range: std::ops::Range, @@ -178,7 +164,6 @@ pub struct PubliclyVerifiableParticipant { #[derive(Debug, Clone)] pub struct PubliclyVerifiableAnnouncement { - pub signer: ed25519::PublicKey, pub session_key: PubliclyVerifiablePublicKey, pub stake: u64, } @@ -242,7 +227,6 @@ mod tests { for _ in 0..10 { contexts.push( PubliclyVerifiableDKG::::new( - ed25519_dalek::Keypair::generate(ed_rng), params.clone(), rng, ) @@ -387,7 +371,7 @@ mod tests { blinded_key_shares.multiply_by_omega_inv(domain_inv); private_contexts.push(PrivateDecryptionContext:: { - index: context.me, + index: 0,//context.me, b, b_inv: b.inverse().unwrap(), private_key_share, @@ -428,11 +412,8 @@ mod tests { let prepared_blinded_key_shares = private_contexts[0].prepare_combine(&shares); - let s = private_contexts[0].share_combine( - &ciphertext, - &shares, - &prepared_blinded_key_shares, - ); + let s = private_contexts[0] + .share_combine(&shares, &prepared_blinded_key_shares); let plaintext = decrypt_with_shared_secret(&ciphertext, &s); assert!(plaintext == msg) diff --git a/src/lib.rs b/src/lib.rs index 6d4efad0..76c57a82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(unused_imports)] pub mod dkg; pub mod msg; pub mod vss; @@ -16,15 +17,15 @@ use crate::msg::*; use ark_ec::AffineCurve; use ark_ec::ProjectiveCurve; -use ark_ff::Zero; -use ark_ff::{FftField, Field, One}; +use ark_ff::{Field, FftField, Zero, One}; use ark_poly::{ polynomial::univariate::DensePolynomial, polynomial::UVPolynomial, - EvaluationDomain, Polynomial, + EvaluationDomain, }; use ed25519_dalek as ed25519; use serde::*; +use ark_std::{end_timer, start_timer}; use num::integer::div_ceil; use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::rc::Rc; diff --git a/src/msg.rs b/src/msg.rs index 91876c44..82bae988 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -2,7 +2,6 @@ use ed25519_dalek as ed25519; use ed25519_dalek::Signer; use crate::*; -use ark_std::{end_timer, start_timer}; use serde::{Deserialize, Serialize}; pub mod ark_serde { @@ -66,15 +65,14 @@ pub struct SignedMessage { #[test] fn test_ark_serde() { - use ark_pallas::Affine; - //use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; + use ark_bls12_381::G1Affine; #[derive(Serialize, Deserialize)] struct Test { #[serde(with = "ark_serde")] - pub p: Affine, + pub p: G1Affine, } use ark_ec::AffineCurve; - let p = Affine::prime_subgroup_generator(); + let p = G1Affine::prime_subgroup_generator(); let t = Test { p }; let m = serde_json::to_string(&t).unwrap(); let _t2: Test = serde_json::from_str(&m).unwrap(); diff --git a/src/primitives/keypair.rs b/src/primitives/keypair.rs index 8a7ede30..1107d892 100644 --- a/src/primitives/keypair.rs +++ b/src/primitives/keypair.rs @@ -3,7 +3,7 @@ use chacha20poly1305::aead::{generic_array::GenericArray, Aead, NewAead}; use ark_ec::PairingEngine; -#[derive(Serialize, Deserialize, Copy, Clone, Debug)] +#[derive(Serialize, Deserialize, Copy, Clone, Debug, std::hash::Hash)] pub struct PubliclyVerifiablePublicKey where E: PairingEngine, diff --git a/src/vss/pvss.rs b/src/vss/pvss.rs index e9dd233c..1fab70b3 100644 --- a/src/vss/pvss.rs +++ b/src/vss/pvss.rs @@ -2,7 +2,7 @@ use crate::*; use ark_ec::PairingEngine; use ark_serialize::*; use itertools::Itertools; -use serde::*; +//use serde::*; pub type ShareEncryptions = Vec; @@ -24,8 +24,8 @@ pub struct PubliclyVerifiableSS { #[derive(Clone)] pub struct PubliclyVerifiableParams { - pub g_1: E::G1Projective, - pub u_hat_1: E::G2Affine, + pub g: E::G1Projective, + pub h: E::G2Projective, } impl PubliclyVerifiableSS @@ -40,9 +40,10 @@ where pub fn verify_aggregation( &self, dkg: &PubliclyVerifiableDKG, - ) -> Result<(u32, Vec)> { + ) -> Result { print_time!("PVSS verify_aggregation"); - let local_shares = self.verify(dkg)?; + //let local_shares = self.verify(dkg)?; + self.verify(dkg); let mut Y = E::G1Projective::zero(); let mut weight = 0u32; for (dealer, pvss) in dkg.vss.iter() { @@ -59,7 +60,7 @@ where weight += dkg.participants[*dealer as usize].weight; } if Y.into_affine() == self.coeffs[0] { - Ok((weight, local_shares)) + Ok(weight) } else { Err(anyhow!( "aggregation does not match received PVSS instances" @@ -131,7 +132,7 @@ where let evals = phi.evaluate_over_domain_by_ref(dkg.domain); // commitment to coeffs - let coeffs = fast_multiexp(&phi.coeffs, dkg.pvss_params.g_1); + let coeffs = fast_multiexp(&phi.coeffs, dkg.pvss_params.g); let shares = dkg .participants @@ -161,16 +162,13 @@ where } /// Verify the PVSS instance `self` is a valid PVSS instance for the DKG context `dkg` - pub fn verify( - &self, - dkg: &PubliclyVerifiableDKG, - ) -> Result> { + pub fn verify(&self, dkg: &PubliclyVerifiableDKG) -> bool { print_time!("PVSS verify"); - let me = &dkg.participants[dkg.me as usize]; + //let me = &dkg.participants[dkg.me as usize]; if self.shares.len() != dkg.participants.len() { - return Err(anyhow!("wrong vss length")); + return false; //Err(anyhow!("wrong vss length")); } { @@ -193,12 +191,12 @@ where powers_of_alpha *= alpha; } - E::pairing(dkg.pvss_params.g_1, Y) == E::pairing(A, ek) + E::pairing(dkg.pvss_params.g, Y) == E::pairing(A, ek) }, ); } - let local_shares = { + /*let local_shares = { print_time!("decrypt shares"); self.shares[dkg.me] @@ -208,7 +206,8 @@ where }; Ok(E::G2Projective::batch_normalization_into_affine( &local_shares, - )) + ))*/ + true } } /* @@ -266,8 +265,8 @@ fn test_pvss() { type G1 = ::G1Affine; type G2 = ::G2Affine; - let mut phi = DensePolynomial::::rand(8192 / 3, &mut rng); - use ark_std::UniformRand; + let mut phi = DensePolynomial::::rand(2 * 128 / 3, &mut rng); + //use ark_std::UniformRand; let domain = ark_poly::Radix2EvaluationDomain::::new(8192) .ok_or_else(|| anyhow!("unable to construct domain")) .unwrap(); @@ -280,8 +279,8 @@ fn test_pvss() { use itertools::Itertools; - let weight = 8192 / 150; - let shares = (0..150) + let weight = 128 / 4; + let shares = (0..4) .map(|participant| { let share_range = (participant * weight)..((participant + 1) * weight); diff --git a/tpke/src/ciphertext.rs b/tpke/src/ciphertext.rs index ace4abda..4ed240b3 100644 --- a/tpke/src/ciphertext.rs +++ b/tpke/src/ciphertext.rs @@ -19,7 +19,6 @@ impl Ciphertext { ]) == E::Fqk::one() } fn construct_tag_hash(&self) -> E::G2Affine { - use ark_ff::ToBytes; let mut hash_input = Vec::::new(); self.nonce.write(&mut hash_input).unwrap(); hash_input.extend_from_slice(&self.ciphertext); diff --git a/tpke/src/combine.rs b/tpke/src/combine.rs index 84ed2cc2..12d22ed9 100644 --- a/tpke/src/combine.rs +++ b/tpke/src/combine.rs @@ -1,3 +1,5 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] use crate::*; use ark_ec::ProjectiveCurve; @@ -46,7 +48,7 @@ impl PrivateDecryptionContext { } pub fn share_combine( &self, - ciphertext: &Ciphertext, + //ciphertext: &Ciphertext, shares: &[DecryptionShare], prepared_key_shares: &[E::G2Prepared], ) -> E::Fqk { diff --git a/tpke/src/decryption.rs b/tpke/src/decryption.rs index ff1bfec6..75916ab1 100644 --- a/tpke/src/decryption.rs +++ b/tpke/src/decryption.rs @@ -1,3 +1,5 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] use crate::*; use ark_ec::ProjectiveCurve; diff --git a/tpke/src/hash_to_curve.rs b/tpke/src/hash_to_curve.rs index ecdbfad1..622afe41 100644 --- a/tpke/src/hash_to_curve.rs +++ b/tpke/src/hash_to_curve.rs @@ -1,6 +1,7 @@ #![allow(non_snake_case)] #![allow(clippy::many_single_char_names)] #![allow(clippy::zero_prefixed_literal)] +#![allow(dead_code)] use ark_serialize::CanonicalDeserialize; use miracl_core::bls12381::big::BIG; diff --git a/tpke/src/key_share.rs b/tpke/src/key_share.rs index ce280868..87bec988 100644 --- a/tpke/src/key_share.rs +++ b/tpke/src/key_share.rs @@ -1,3 +1,6 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] + use crate::*; use ark_ec::ProjectiveCurve; use itertools::Itertools; diff --git a/tpke/src/lib.rs b/tpke/src/lib.rs index f721d8fd..35cbc6cc 100644 --- a/tpke/src/lib.rs +++ b/tpke/src/lib.rs @@ -1,14 +1,16 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] use crate::hash_to_curve::htp_bls12381_g2; use crate::subproductdomain::SubproductDomain; use ark_ec::{msm::FixedBaseMSM, AffineCurve, PairingEngine}; use ark_ff::{Field, One, PrimeField, ToBytes, UniformRand, Zero}; use ark_poly::EvaluationDomain; -use ark_poly::{univariate::DensePolynomial, Polynomial, UVPolynomial}; +use ark_poly::{univariate::DensePolynomial, UVPolynomial}; use ark_serialize::CanonicalSerialize; use itertools::izip; use rand_core::RngCore; -use rayon::prelude::*; +//use rayon::prelude::*; use std::usize; use thiserror::Error; @@ -198,7 +200,7 @@ mod tests { .verify_blinding(&pub_context.public_key_shares, rng)); }*/ let prepared_blinded_key_shares = contexts[0].prepare_combine(&shares); - let s = contexts[0].share_combine(&ciphertext, &shares, &prepared_blinded_key_shares); + let s = contexts[0].share_combine(&shares, &prepared_blinded_key_shares); let plaintext = decrypt_with_shared_secret(&ciphertext, &s); assert!(plaintext == msg) diff --git a/tpke/src/subproductdomain.rs b/tpke/src/subproductdomain.rs index 95fedd8e..74c5a414 100644 --- a/tpke/src/subproductdomain.rs +++ b/tpke/src/subproductdomain.rs @@ -1,3 +1,6 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] + use ark_ec::{msm::FixedBaseMSM, PairingEngine, ProjectiveCurve}; use ark_ff::{FftField, Field, PrimeField, Zero}; use ark_poly::polynomial::univariate::DensePolynomial as Poly; From 603ac1ed8c9fd6e8f640cffd0154b27bd6d3293e Mon Sep 17 00:00:00 2001 From: joe bebel <55120843+joebebel@users.noreply.github.com> Date: Mon, 30 Aug 2021 00:24:45 -0700 Subject: [PATCH 12/16] refactor API --- ferveo/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ferveo/Cargo.toml b/ferveo/Cargo.toml index d157439f..4017d4dd 100644 --- a/ferveo/Cargo.toml +++ b/ferveo/Cargo.toml @@ -72,7 +72,7 @@ pprof = { version = "0.5", features = ["flamegraph", "criterion"] } [[example]] name = "pvdkg" -path = "../examples/pvdkg.rs" +path = "examples/pvdkg.rs" #[[bench]] #name = "pairing" @@ -85,5 +85,5 @@ path = "../examples/pvdkg.rs" [[bench]] name = "pvdkg" -path = "../benches/benchmarks/pvdkg.rs" +path = "benches/benchmarks/pvdkg.rs" harness = false \ No newline at end of file From f2b8b25d8162db4cab43762117edff570b8b529f Mon Sep 17 00:00:00 2001 From: joe bebel <55120843+joebebel@users.noreply.github.com> Date: Wed, 22 Sep 2021 00:14:51 -0700 Subject: [PATCH 13/16] examples --- ferveo/examples/noserialize.rs | 92 ------------------------ ferveo/examples/pvdkg.rs | 128 ++++++++++++++------------------- ferveo/src/dkg/pv.rs | 108 +++++++++------------------- 3 files changed, 89 insertions(+), 239 deletions(-) delete mode 100644 ferveo/examples/noserialize.rs diff --git a/ferveo/examples/noserialize.rs b/ferveo/examples/noserialize.rs deleted file mode 100644 index e05cb915..00000000 --- a/ferveo/examples/noserialize.rs +++ /dev/null @@ -1,92 +0,0 @@ -use ferveo::*; - -pub fn main() { - pvdkg::(); -} - -pub fn pvdkg() { - use ark_ec::{AffineCurve, ProjectiveCurve}; - let rng = &mut ark_std::test_rng(); - use rand_old::SeedableRng; - let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); - - let params = Params { - tau: 0u64, - security_threshold: 8192 / 3, - total_weight: 8192, - }; - - for _ in 0..1 { - let mut contexts = vec![]; - for _ in 0..25 { - contexts.push( - PubliclyVerifiableDKG::::new( - ed25519_dalek::Keypair::generate(ed_rng), - params.clone(), - rng, - ) - .unwrap(), - ); - } - use std::collections::VecDeque; - let mut messages = VecDeque::new(); - - let stake = (0..150u64).map(|i| i).collect::>(); - - for (participant, stake) in contexts.iter_mut().zip(stake.iter()) { - let announce = participant.announce(*stake); - messages.push_back(announce); - } - - let msg_loop = - |contexts: &mut Vec>, - messages: &mut VecDeque| loop { - if messages.is_empty() { - break; - } - let signed_message = messages.pop_front().unwrap(); - for node in contexts.iter_mut() { - let (_, message) = signed_message.verify().unwrap(); - let new_msg = node - .handle_message(&signed_message.signer, message) - .unwrap(); - if let Some(new_msg) = new_msg { - messages.push_back(new_msg); - } - } - }; - - msg_loop(&mut contexts, &mut messages); - - for participant in contexts.iter_mut() { - participant.finish_announce().unwrap(); - } - - msg_loop(&mut contexts, &mut messages); - - let mut dealt_weight = 0u32; - let mut pvss = vec![]; - for participant in contexts.iter_mut() { - if dealt_weight < params.total_weight - params.security_threshold { - let msg = participant.share(rng).unwrap(); - pvss.push((participant.ed_key.public.clone(), msg)); - dealt_weight += participant.participants[participant.me].weight; - } - } - for msg in pvss.iter() { - for node in contexts.iter_mut() { - node.handle_message(&msg.0, msg.1.clone()).unwrap(); - } - } - msg_loop(&mut contexts, &mut messages); - let agg = contexts[0].aggregate(); - let agg_signer = contexts[0].ed_key.public.clone(); - for participant in contexts.iter_mut() { - participant - .handle_message(&agg_signer, agg.clone()) - .unwrap(); - //assert_eq!(participant.state, DkgState::Success); - } - contexts[0].final_key(); - } -} diff --git a/ferveo/examples/pvdkg.rs b/ferveo/examples/pvdkg.rs index a1144943..e342ff78 100644 --- a/ferveo/examples/pvdkg.rs +++ b/ferveo/examples/pvdkg.rs @@ -4,89 +4,71 @@ pub fn main() { pvdkg::(); } +fn create_info(vp: u64) -> tendermint::validator::Info { + use std::convert::TryFrom; + tendermint::validator::Info::new( + tendermint::public_key::PublicKey::from_raw_ed25519(&vec![ + 48, 163, 55, 132, 231, 147, 230, 163, 56, 158, 127, 218, 179, 139, + 212, 103, 218, 89, 122, 126, 229, 88, 84, 48, 32, 0, 185, 174, 63, + 72, 203, 52, + ]) + .unwrap(), + tendermint::vote::Power::try_from(vp).unwrap(), + ) +} + pub fn pvdkg() { + use ark_ec::{AffineCurve, ProjectiveCurve}; let rng = &mut ark_std::test_rng(); - use rand_old::SeedableRng; - let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); + //use rand_old::SeedableRng; + //let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); let params = Params { tau: 0u64, - security_threshold: 512 / 3, - total_weight: 512, + security_threshold: 300 / 3, + total_weight: 300, }; + let validator_set = tendermint::validator::Set::without_proposer( + (1..11u64).map(|vp| create_info(vp)).collect::>(), + ); - for _ in 0..1 { - let mut contexts = vec![]; - for _ in 0..10 { - contexts.push( - PubliclyVerifiableDkg::::new( - ed25519_dalek::Keypair::generate(ed_rng), - params, - rng, - ) - .unwrap(), - ); - } - use std::collections::VecDeque; - let mut messages = VecDeque::new(); - - let stake = (0..150u64).collect::>(); - - for (participant, stake) in contexts.iter_mut().zip(stake.iter()) { - let announce = participant.announce(*stake); - messages.push_back(announce); - } - - let msg_loop = - |contexts: &mut Vec>, - messages: &mut VecDeque| loop { - if messages.is_empty() { - break; - } - let signed_message = messages.pop_front().unwrap(); - for node in contexts.iter_mut() { - let (_, message) = signed_message.verify().unwrap(); - let new_msg = node - .handle_message(&signed_message.signer, message) - .unwrap(); - if let Some(new_msg) = new_msg { - messages.push_back(new_msg); - } - } - }; - - msg_loop(&mut contexts, &mut messages); + let validator_keys = (0..10) + .map(|_| { + ferveo_common::PublicKey::::default() + }) + .collect::>(); - for participant in contexts.iter_mut() { - participant.finish_announce().unwrap(); - } - - msg_loop(&mut contexts, &mut messages); + // for _ in 0..1 { + let mut contexts = vec![]; + for me in 0..10 { + contexts.push( + PubliclyVerifiableDkg::::new( + &validator_set, + &validator_keys, + params.clone(), + me, + rng, + ) + .unwrap(), + ); + } + use std::collections::VecDeque; + let mut messages = VecDeque::new(); - let mut dealt_weight = 0u32; - let mut pvss = vec![]; - for participant in contexts.iter_mut() { - if dealt_weight < params.total_weight - params.security_threshold { - let msg = participant.share(rng).unwrap(); - pvss.push((participant.ed_key.public, msg)); - dealt_weight += participant.participants[participant.me].weight; - } - } - for msg in pvss.iter() { - for node in contexts.iter_mut() { - node.handle_message(&msg.0, msg.1.clone()).unwrap(); - } + let mut dealt_weight = 0u32; + for participant in contexts.iter_mut() { + if dealt_weight < params.total_weight - params.security_threshold { + let msg = participant.share(rng).unwrap(); + let msg: Message = msg; //.verify().unwrap().1; + messages.push_back((participant.me, msg)); + dealt_weight += participant.validators[participant.me].weight; } - msg_loop(&mut contexts, &mut messages); - let agg = contexts[0].aggregate(); - let agg_signer = contexts[0].ed_key.public; - for participant in contexts.iter_mut() { - participant - .handle_message(&agg_signer, agg.clone()) - .unwrap(); - //assert_eq!(participant.state, DkgState::Success); + } + for msg in messages.iter() { + for node in contexts.iter_mut() { + node.handle_message(msg.0 as u32, msg.1.clone()).unwrap(); } - - contexts[0].final_key(); } + + let tpke_pubkey = contexts[0].final_key(); } diff --git a/ferveo/src/dkg/pv.rs b/ferveo/src/dkg/pv.rs index 9747c76f..0423c0e6 100644 --- a/ferveo/src/dkg/pv.rs +++ b/ferveo/src/dkg/pv.rs @@ -175,51 +175,50 @@ mod tests { }; use itertools::izip; - // #[test] - // pub fn test_pv() { - // extern crate rand_old; - // use rand_old::rngs::OsRng; - // use ark_bls12_381::Bls12_381; - - // let mut rng = &mut ark_std::test_rng(); - // let mut csprng = OsRng{}; - - // let shares_num = 8192; - // let threshold = shares_num*2/3; - // let num_entities = 150; - - // let dkg_params = Params { - // tau: 0, - // security_threshold: threshold, - // total_weight: shares_num - // }; - - // let ed_key: ed25519::Keypair = ed25519::Keypair::generate(&mut csprng); - // let mut dkg: PubliclyVerifiableDKG = PubliclyVerifiableDKG::new(ed_key, dkg_params, rng).unwrap(); - // let pubkey = dkg.final_key(); - // let share_msg = dkg.share(rng).unwrap(); - - // } + fn create_info(vp: u64) -> tendermint::validator::Info { + use std::convert::TryFrom; + tendermint::validator::Info::new( + tendermint::public_key::PublicKey::from_raw_ed25519(&vec![ + 48, 163, 55, 132, 231, 147, 230, 163, 56, 158, 127, 218, 179, + 139, 212, 103, 218, 89, 122, 126, 229, 88, 84, 48, 32, 0, 185, + 174, 63, 72, 203, 52, + ]) + .unwrap(), + tendermint::vote::Power::try_from(vp).unwrap(), + ) + } #[test] pub fn test_pvdkg_tpke() { use ark_ec::{AffineCurve, ProjectiveCurve}; let rng = &mut ark_std::test_rng(); - use rand_old::SeedableRng; - let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); + //use rand_old::SeedableRng; + //let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); let params = Params { tau: 0u64, security_threshold: 300 / 3, total_weight: 300, }; + let validator_set = tendermint::validator::Set::without_proposer( + (1..11u64).map(|vp| create_info(vp)).collect::>(), + ); + + let validator_keys = (0..10) + .map(|_| { + ferveo_common::PublicKey::::default() + }) + .collect::>(); // for _ in 0..1 { let mut contexts = vec![]; - for _ in 0..10 { + for me in 0..10 { contexts.push( PubliclyVerifiableDkg::::new( + &validator_set, + &validator_keys, params.clone(), + me, rng, ) .unwrap(), @@ -228,62 +227,23 @@ mod tests { use std::collections::VecDeque; let mut messages = VecDeque::new(); - let stake = (0..150u64).map(|i| i).collect::>(); - - for (participant, stake) in contexts.iter_mut().zip(stake.iter()) { - let announce = participant.announce(*stake); - messages.push_back(announce); - } - - let msg_loop = - |contexts: &mut Vec< - PubliclyVerifiableDkg, - >, - messages: &mut VecDeque| loop { - if messages.is_empty() { - break; - } - let signed_message = messages.pop_front().unwrap(); - for node in contexts.iter_mut() { - let (_, message) = signed_message.verify().unwrap(); - let new_msg = node - .handle_message(&signed_message.signer, message) - .unwrap(); - if let Some(new_msg) = new_msg { - messages.push_back(new_msg); - } - } - }; - - msg_loop(&mut contexts, &mut messages); - - for participant in contexts.iter_mut() { - participant.finish_announce().unwrap(); - } - - msg_loop(&mut contexts, &mut messages); - let mut dealt_weight = 0u32; - let mut pvss = vec![]; for participant in contexts.iter_mut() { if dealt_weight < params.total_weight - params.security_threshold { let msg = participant.share(rng).unwrap(); - let msg: PubliclyVerifiableMessage = - msg; //.verify().unwrap().1; - pvss.push((participant.ed_key.public.clone(), msg)); - //messages.push_back(msg); - dealt_weight += participant.participants[participant.me].weight; + let msg: Message = msg; //.verify().unwrap().1; + messages.push_back((participant.me, msg)); + dealt_weight += participant.validators[participant.me].weight; } } - for msg in pvss.iter() { + for msg in messages.iter() { for node in contexts.iter_mut() { - node.handle_message(&msg.0, msg.1.clone()).unwrap(); + node.handle_message(msg.0 as u32, msg.1.clone()).unwrap(); } } - msg_loop(&mut contexts, &mut messages); let tpke_pubkey = contexts[0].final_key(); - + /* ///////////////////////////////////////// TPKE ///////////////////////////////////////// let threshold = contexts[0].params.security_threshold as usize; //16 * 2 / 3; let shares_num = contexts[0].params.total_weight as usize; //16; @@ -410,6 +370,6 @@ mod tests { let plaintext = decrypt_with_shared_secret(&ciphertext, &s); assert!(plaintext == msg) - // } + // }*/ } } From f2006f8c43de8a6d1936bb57ddd3ecd6c659e56e Mon Sep 17 00:00:00 2001 From: joe bebel <55120843+joebebel@users.noreply.github.com> Date: Wed, 22 Sep 2021 00:15:42 -0700 Subject: [PATCH 14/16] rayon version --- Cargo.lock | 189 +++++++++++++++++++++++------------------------- tpke/Cargo.toml | 4 +- 2 files changed, 91 insertions(+), 102 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 304bebbc..00f1e8fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,17 +23,6 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" -[[package]] -name = "ahash" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "796540673305a66d127804eef19ad696f1f204b8c1025aaca4958c17eab32877" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.7.4" @@ -56,9 +45,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf" +checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" [[package]] name = "ark-bls12-381" @@ -327,9 +316,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ "lazy_static", "memchr", @@ -339,9 +328,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.7.0" +version = "3.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" +checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" [[package]] name = "bytemuck" @@ -372,9 +361,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" +checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" [[package]] name = "cfg-if" @@ -384,9 +373,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea8756167ea0aca10e066cdbe7813bd71d2f24e69b0bc7b50509590cef2ce0b9" +checksum = "f08493fa7707effc63254c66c6ea908675912493cd67952eda23c09fae2610b1" dependencies = [ "cfg-if", "cipher", @@ -444,18 +433,18 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.1.5" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" dependencies = [ "libc", ] [[package]] name = "criterion" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" +checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" dependencies = [ "atty", "cast", @@ -690,9 +679,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adc00f486adfc9ce99f77d717836f0c5aa84965eb0b4f051f4e83f7cab53f8b" +checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" dependencies = [ "futures-channel", "futures-core", @@ -705,9 +694,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9" +checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" dependencies = [ "futures-core", "futures-sink", @@ -715,15 +704,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" +checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" [[package]] name = "futures-executor" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d0d535a57b87e1ae31437b892713aee90cd2d7b0ee48727cd11fc72ef54761c" +checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" dependencies = [ "futures-core", "futures-task", @@ -732,15 +721,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582" +checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" [[package]] name = "futures-macro" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57" +checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" dependencies = [ "autocfg", "proc-macro-hack", @@ -751,21 +740,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53" +checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" [[package]] name = "futures-task" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2" +checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" [[package]] name = "futures-util" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" +checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" dependencies = [ "autocfg", "futures-channel", @@ -894,11 +883,11 @@ dependencies = [ [[package]] name = "inferno" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3cbcc228d2ad2e99328c2b19f38d80ec387ca6a29f778e40e32ca9f25448c3" +checksum = "bfa5bd9a10b38bf5f3c670f9d75c194adbecd2b1573f737668ab8599f41edc87" dependencies = [ - "ahash 0.6.3", + "ahash 0.7.4", "atty", "indexmap", "itoa", @@ -945,9 +934,9 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "js-sys" -version = "0.3.53" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4bf49d50e2961077d9c99f4b7997d770a1114f087c3c2e0069b36c13fc2979d" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" dependencies = [ "wasm-bindgen", ] @@ -966,15 +955,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.101" +version = "0.2.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" +checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103" [[package]] name = "lock_api" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" dependencies = [ "scopeguard", ] @@ -1085,9 +1074,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d047c1062aa51e256408c560894e5251f08925980e53cf1aa5bd00eec6512" +checksum = "74e768dff5fb39a41b3bcd30bb25cf989706c90d028d1ad71971987aa309d535" dependencies = [ "autocfg", "num-integer", @@ -1178,9 +1167,9 @@ dependencies = [ [[package]] name = "object" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2766204889d09937d00bfbb7fec56bb2a199e2ade963cab19185d8a6104c7c" +checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2" dependencies = [ "memchr", ] @@ -1205,9 +1194,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "parking_lot" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", @@ -1216,9 +1205,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ "cfg-if", "instant", @@ -1331,9 +1320,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" dependencies = [ "unicode-xid", ] @@ -1373,9 +1362,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26aab6b48e2590e4a64d1ed808749ba06257882b461d01ca71baeb747074a6dd" +checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" dependencies = [ "memchr", ] @@ -1472,9 +1461,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ "autocfg", "crossbeam-deque", @@ -1614,9 +1603,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.129" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1f72836d2aa753853178eda473a3b9d8e4eefdaf20523b919677e6de489f8f1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1642,9 +1631,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.129" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e57ae87ad533d9a56427558b516d0adac283614e347abf85b0dc0cbbf0a249f3" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1653,9 +1642,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" +checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" dependencies = [ "itoa", "ryu", @@ -1675,9 +1664,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.5" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", "cfg-if", @@ -1756,9 +1745,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.75" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7" +checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84" dependencies = [ "proc-macro2", "quote", @@ -1850,18 +1839,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" dependencies = [ "proc-macro2", "quote", @@ -1899,9 +1888,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.13.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" [[package]] name = "ucd-trie" @@ -1911,9 +1900,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" @@ -1958,9 +1947,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.76" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce9b1b516211d33767048e5d47fa2a381ed8b76fc48d2ce4aa39877f9f183e0" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1968,9 +1957,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.76" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe8dc78e2326ba5f845f4b5bf548401604fa20b1dd1d365fb73b6c1d6364041" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" dependencies = [ "bumpalo", "lazy_static", @@ -1983,9 +1972,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.76" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44468aa53335841d9d6b6c023eaab07c0cd4bddbcfdee3e2bb1e8d2cb8069fef" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1993,9 +1982,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.76" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0195807922713af1e67dc66132c7328206ed9766af3858164fb583eedc25fbad" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ "proc-macro2", "quote", @@ -2006,15 +1995,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.76" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acdb075a845574a1fa5f09fd77e43f7747599301ea3417a9fbffdeedfc1f4a29" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" [[package]] name = "web-sys" -version = "0.3.53" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224b2f6b67919060055ef1a67807367c2066ed520c3862cc013d26cf893a783c" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" dependencies = [ "js-sys", "wasm-bindgen", @@ -2053,18 +2042,18 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "zeroize" -version = "1.3.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +checksum = "bf68b08513768deaa790264a7fac27a58cbf2705cfcdc9448362229217d7e970" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2c1e130bebaeab2f23886bf9acbaca14b092408c452543c857f66399cd6dab1" +checksum = "bdff2024a851a322b08f179173ae2ba620445aef1e838f0c196820eade4ae0c7" dependencies = [ "proc-macro2", "quote", diff --git a/tpke/Cargo.toml b/tpke/Cargo.toml index 6acf444b..6b71d6d5 100644 --- a/tpke/Cargo.toml +++ b/tpke/Cargo.toml @@ -12,8 +12,8 @@ readme = "README.md" hex = "=0.4.3" rand_core = "0.6" rand = "0.8" -rayon = "=1.5.0" -thiserror = "=1.0.26" +rayon = "1.5" +thiserror = "=1.0.29" anyhow = "=1.0" blake2b_simd = "=0.5.11" From d8a6e5c6638fdd868946599d6e6e84fec971699b Mon Sep 17 00:00:00 2001 From: joe bebel <55120843+joebebel@users.noreply.github.com> Date: Wed, 22 Sep 2021 00:31:07 -0700 Subject: [PATCH 15/16] remove failing benchmarks --- Cargo.lock | 13 +++ ferveo/Cargo.toml | 2 +- ferveo/benches/benchmarks/pairing.rs | 8 +- ferveo/benches/benchmarks/pvdkg.rs | 124 ++++++++++++--------------- 4 files changed, 74 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00f1e8fd..19ca049a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,6 +74,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ark-ed-on-bls12-381" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b7ada17db3854f5994e74e60b18e10e818594935ee7e1d329800c117b32970" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-std", +] + [[package]] name = "ark-ff" version = "0.3.0" @@ -633,6 +645,7 @@ dependencies = [ "anyhow", "ark-bls12-381", "ark-ec", + "ark-ed-on-bls12-381", "ark-ff", "ark-poly", "ark-serialize", diff --git a/ferveo/Cargo.toml b/ferveo/Cargo.toml index 4017d4dd..5fc756ec 100644 --- a/ferveo/Cargo.toml +++ b/ferveo/Cargo.toml @@ -47,7 +47,7 @@ subtle = "2.4" itertools = "0.10.1" measure_time = "0.7" #redjubjub = "0.4.0" -#ark-ed-on-bls12-381 = "0.3.0" +ark-ed-on-bls12-381 = "0.3.0" group-threshold-cryptography = { path = "../tpke" } #tendermint = { path = "../../tendermint-rs/tendermint" } tendermint = { git = "https://github.com/heliaxdev/tendermint-rs" } diff --git a/ferveo/benches/benchmarks/pairing.rs b/ferveo/benches/benchmarks/pairing.rs index ad78c1e1..a8c962e6 100644 --- a/ferveo/benches/benchmarks/pairing.rs +++ b/ferveo/benches/benchmarks/pairing.rs @@ -1,7 +1,7 @@ use ark_bls12_381::*; use ark_ec::*; use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use redjubjub::*; +//use redjubjub::*; use std::convert::TryFrom; use ark_bls12_381::*; @@ -260,7 +260,7 @@ pub fn pairing(c: &mut Criterion) { }) }); } - +/* enum Item { SpendAuth { vk_bytes: VerificationKeyBytes, @@ -326,7 +326,7 @@ pub fn redjubjub(c: &mut Criterion) { ); } group.finish(); -} +}*/ fn ed25519_batch(c: &mut Criterion) { let mut group = c.benchmark_group("Ed25519 Batch Verification"); @@ -383,7 +383,7 @@ pub fn bench_batch_inverse(c: &mut Criterion) { criterion_group!( ec, pairing, - redjubjub, + //redjubjub, ed25519_batch, lagrange, bench_batch_inverse diff --git a/ferveo/benches/benchmarks/pvdkg.rs b/ferveo/benches/benchmarks/pvdkg.rs index e5e50d73..42a8c7cf 100644 --- a/ferveo/benches/benchmarks/pvdkg.rs +++ b/ferveo/benches/benchmarks/pvdkg.rs @@ -37,83 +37,71 @@ criterion_group! { criterion_main!(pvdkg_bls); +fn create_info(vp: u64) -> tendermint::validator::Info { + use std::convert::TryFrom; + tendermint::validator::Info::new( + tendermint::public_key::PublicKey::from_raw_ed25519(&vec![ + 48, 163, 55, 132, 231, 147, 230, 163, 56, 158, 127, 218, 179, 139, + 212, 103, 218, 89, 122, 126, 229, 88, 84, 48, 32, 0, 185, 174, 63, + 72, 203, 52, + ]) + .unwrap(), + tendermint::vote::Power::try_from(vp).unwrap(), + ) +} + pub fn pvdkg() { + use ark_ec::{AffineCurve, ProjectiveCurve}; let rng = &mut ark_std::test_rng(); - use rand_old::SeedableRng; - let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); + //use rand_old::SeedableRng; + //let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); let params = Params { tau: 0u64, security_threshold: 300 / 3, total_weight: 300, }; - - for _ in 0..1 { - let mut contexts = vec![]; - for _ in 0..10 { - contexts.push( - PubliclyVerifiableDkg::::new( - ed25519_dalek::Keypair::generate(ed_rng), - params, - rng, - ) - .unwrap(), - ); - } - use std::collections::VecDeque; - let mut messages = VecDeque::new(); - - let stake = (0..150u64).collect::>(); - - for (participant, stake) in contexts.iter_mut().zip(stake.iter()) { - let announce = participant.announce(*stake); - messages.push_back(announce); - } - - let msg_loop = - |contexts: &mut Vec>, - messages: &mut VecDeque| loop { - if messages.is_empty() { - break; - } - let signed_message = messages.pop_front().unwrap(); - for node in contexts.iter_mut() { - let (_, message) = signed_message.verify().unwrap(); - let new_msg = node - .handle_message(&signed_message.signer, message) - .unwrap(); - if let Some(new_msg) = new_msg { - messages.push_back(new_msg); - } - } - }; - - msg_loop(&mut contexts, &mut messages); - - for participant in contexts.iter_mut() { - participant.finish_announce().unwrap(); - } - - msg_loop(&mut contexts, &mut messages); - - let mut dealt_weight = 0u32; - let mut pvss = vec![]; - for participant in contexts.iter_mut() { - if dealt_weight < params.total_weight - params.security_threshold { - let msg = participant.share(rng).unwrap(); - let msg: PubliclyVerifiableMessage = msg; //.verify().unwrap().1; - pvss.push((participant.ed_key.public, msg)); - //messages.push_back(msg); - dealt_weight += participant.participants[participant.me].weight; - } + let validator_set = tendermint::validator::Set::without_proposer( + (1..11u64).map(|vp| create_info(vp)).collect::>(), + ); + + let validator_keys = (0..10) + .map(|_| { + ferveo_common::PublicKey::::default() + }) + .collect::>(); + + // for _ in 0..1 { + let mut contexts = vec![]; + for me in 0..10 { + contexts.push( + PubliclyVerifiableDkg::::new( + &validator_set, + &validator_keys, + params.clone(), + me, + rng, + ) + .unwrap(), + ); + } + use std::collections::VecDeque; + let mut messages = VecDeque::new(); + + let mut dealt_weight = 0u32; + for participant in contexts.iter_mut() { + if dealt_weight < params.total_weight - params.security_threshold { + let msg = participant.share(rng).unwrap(); + let msg: Message = msg; //.verify().unwrap().1; + messages.push_back((participant.me, msg)); + dealt_weight += participant.validators[participant.me].weight; } - for msg in pvss.iter() { - for node in contexts.iter_mut() { - node.handle_message(&msg.0, msg.1.clone()).unwrap(); - } + } + for msg in messages.iter() { + for node in contexts.iter_mut() { + node.handle_message(msg.0 as u32, msg.1.clone()).unwrap(); } - msg_loop(&mut contexts, &mut messages); - - contexts[0].final_key(); } + + let tpke_pubkey = contexts[0].final_key(); } From 691c660a406f4f97dd6a77a07466009bf771008d Mon Sep 17 00:00:00 2001 From: joe bebel <55120843+joebebel@users.noreply.github.com> Date: Wed, 22 Sep 2021 00:37:29 -0700 Subject: [PATCH 16/16] stable toolchain --- rust-toolchain | 1 + 1 file changed, 1 insertion(+) create mode 100644 rust-toolchain diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 00000000..870bbe4e --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +stable \ No newline at end of file