From 65ef3f02e74fe11e2b61ff2d98c58aaa60b63146 Mon Sep 17 00:00:00 2001 From: aniampio Date: Wed, 3 Nov 2021 16:14:13 +0000 Subject: [PATCH] Run cargo fmt --- common/credentials/src/utils.rs | 8 +-- common/nymcoconut/src/proofs/mod.rs | 56 ++++++++++---------- common/nymcoconut/src/scheme/verification.rs | 24 ++++----- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/common/credentials/src/utils.rs b/common/credentials/src/utils.rs index 8ecfc63086..36bce5f562 100644 --- a/common/credentials/src/utils.rs +++ b/common/credentials/src/utils.rs @@ -4,8 +4,8 @@ use url::Url; use coconut_interface::{ - aggregate_signature_shares, aggregate_verification_keys, Attribute, - BlindSignRequestBody, Credential, Parameters, prepare_blind_sign, prove_bandwidth_credential, Signature, + aggregate_signature_shares, aggregate_verification_keys, prepare_blind_sign, + prove_bandwidth_credential, Attribute, BlindSignRequestBody, Credential, Parameters, Signature, SignatureShare, VerificationKey, }; @@ -122,7 +122,7 @@ pub async fn obtain_aggregate_signature( &client, &validator_partial_vk.key, ) - .await?; + .await?; shares.push(SignatureShare::new(first, 0)); for (id, validator_url) in validators.iter().enumerate().skip(1) { @@ -135,7 +135,7 @@ pub async fn obtain_aggregate_signature( &client, &validator_partial_vk.key, ) - .await?; + .await?; let share = SignatureShare::new(signature, id as u64); shares.push(share) } diff --git a/common/nymcoconut/src/proofs/mod.rs b/common/nymcoconut/src/proofs/mod.rs index 79fb2059ec..07dd3a4b8d 100644 --- a/common/nymcoconut/src/proofs/mod.rs +++ b/common/nymcoconut/src/proofs/mod.rs @@ -18,18 +18,18 @@ use std::borrow::Borrow; use std::convert::TryInto; use bls12_381::{G1Projective, G2Projective, Scalar}; -use digest::Digest; use digest::generic_array::typenum::Unsigned; +use digest::Digest; use group::GroupEncoding; use itertools::izip; use sha2::Sha256; -use crate::{Attribute, elgamal, ElGamalKeyPair}; use crate::elgamal::Ciphertext; use crate::error::{CoconutError, Result}; use crate::scheme::setup::Parameters; use crate::scheme::VerificationKey; use crate::utils::{hash_g1, try_deserialize_scalar, try_deserialize_scalar_vec}; +use crate::{elgamal, Attribute, ElGamalKeyPair}; // as per the reference python implementation type ChallengeDigest = Sha256; @@ -51,10 +51,10 @@ pub struct ProofCmCs { // and as per the bls12-381 library all elements are using big-endian form /// Generates a Scalar [or Fp] challenge by hashing a number of elliptic curve points. fn compute_challenge(iter: I) -> Scalar - where - D: Digest, - I: Iterator, - B: AsRef<[u8]>, +where + D: Digest, + I: Iterator, + B: AsRef<[u8]>, { let mut h = D::new(); for point_representation in iter { @@ -82,8 +82,8 @@ fn produce_response(witness: &Scalar, challenge: &Scalar, secret: &Scalar) -> Sc // note: it's caller's responsibility to ensure witnesses.len() = secrets.len() fn produce_responses(witnesses: &[Scalar], challenge: &Scalar, secrets: &[S]) -> Vec - where - S: Borrow, +where + S: Borrow, { debug_assert_eq!(witnesses.len(), secrets.len()); @@ -150,10 +150,10 @@ impl ProofCmCs { // Ccm = (wr * g1) + (wm[0] * hs[0]) + ... + (wm[i] * hs[i]) let commitment_attributes = g1 * witness_commitment_opening + witness_attributes - .iter() - .zip(params.gen_hs().iter()) - .map(|(wm_i, hs_i)| hs_i * wm_i) - .sum::(); + .iter() + .zip(params.gen_hs().iter()) + .map(|(wm_i, hs_i)| hs_i * wm_i) + .sum::(); let ciphertexts_bytes = priv_attributes_ciphertexts .iter() @@ -244,19 +244,19 @@ impl ProofCmCs { self.response_keys.iter(), self.response_attributes.iter() ) - .map(|(c2, res_key, res_attr)| c2 * self.challenge + pub_key * res_key + h * res_attr) - .map(|witness| witness.to_bytes()) - .collect::>(); + .map(|(c2, res_key, res_attr)| c2 * self.challenge + pub_key * res_key + h * res_attr) + .map(|witness| witness.to_bytes()) + .collect::>(); // Cw = (cm * c) + (rr * g1) + (rm[0] * hs[0]) + ... + (rm[n] * hs[n]) let commitment_attributes = commitment * self.challenge + g1 * self.response_opening + self - .response_attributes - .iter() - .zip(params.gen_hs().iter()) - .map(|(res_attr, hs)| hs * res_attr) - .sum::(); + .response_attributes + .iter() + .zip(params.gen_hs().iter()) + .map(|(res_attr, hs)| hs * res_attr) + .sum::(); let ciphertexts_bytes = attributes_ciphertexts .iter() @@ -413,10 +413,10 @@ impl ProofKappaNu { let commitment_kappa = params.gen2() * witness_blinder + verification_key.alpha + witness_attributes - .iter() - .zip(verification_key.beta.iter()) - .map(|(wm_i, beta_i)| beta_i * wm_i) - .sum::(); + .iter() + .zip(verification_key.beta.iter()) + .map(|(wm_i, beta_i)| beta_i * wm_i) + .sum::(); // zeta is the public value associated with the serial number let commitment_zeta = params.gen2() * witness_serial_number; @@ -470,10 +470,10 @@ impl ProofKappaNu { + params.gen2() * self.response_blinder + verification_key.alpha * (Scalar::one() - self.challenge) + response_attributes - .iter() - .zip(verification_key.beta.iter()) - .map(|(priv_attr, beta_i)| beta_i * priv_attr) - .sum::(); + .iter() + .zip(verification_key.beta.iter()) + .map(|(priv_attr, beta_i)| beta_i * priv_attr) + .sum::(); // zeta is the public value associated with the serial number let commitment_zeta = zeta * self.challenge + params.gen2() * self.response_serial_number; diff --git a/common/nymcoconut/src/scheme/verification.rs b/common/nymcoconut/src/scheme/verification.rs index 3557717039..5ac78d0387 100644 --- a/common/nymcoconut/src/scheme/verification.rs +++ b/common/nymcoconut/src/scheme/verification.rs @@ -16,10 +16,9 @@ use core::ops::Neg; use std::convert::TryFrom; use std::convert::TryInto; -use bls12_381::{G1Affine, G2Prepared, G2Projective, multi_miller_loop, Scalar}; +use bls12_381::{multi_miller_loop, G1Affine, G2Prepared, G2Projective, Scalar}; use group::{Curve, Group}; -use crate::Attribute; use crate::error::{CoconutError, Result}; use crate::proofs::ProofKappaNu; use crate::scheme::setup::Parameters; @@ -27,6 +26,7 @@ use crate::scheme::Signature; use crate::scheme::VerificationKey; use crate::traits::{Base58, Bytable}; use crate::utils::try_deserialize_g2_projective; +use crate::Attribute; // TODO NAMING: this whole thing // Theta @@ -133,10 +133,10 @@ pub fn compute_kappa( params.gen2() * blinding_factor + verification_key.alpha + private_attributes - .iter() - .zip(verification_key.beta.iter()) - .map(|(priv_attr, beta_i)| beta_i * priv_attr) - .sum::() + .iter() + .zip(verification_key.beta.iter()) + .map(|(priv_attr, beta_i)| beta_i * priv_attr) + .sum::() } pub fn compute_zeta(params: &Parameters, serial_number: Attribute) -> G2Projective { @@ -258,11 +258,11 @@ pub fn verify( ) -> bool { let kappa = (verification_key.alpha + public_attributes - .iter() - .zip(verification_key.beta.iter()) - .map(|(m_i, b_i)| b_i * m_i) - .sum::()) - .to_affine(); + .iter() + .zip(verification_key.beta.iter()) + .map(|(m_i, b_i)| b_i * m_i) + .sum::()) + .to_affine(); check_bilinear_pairing( &sig.0.to_affine(), @@ -298,7 +298,7 @@ mod tests { serial_number, binding_number, ) - .unwrap(); + .unwrap(); let bytes = theta.to_bytes(); assert_eq!(Theta::try_from(bytes.as_slice()).unwrap(), theta);