From eff725e8ecc6e16f5bbda7175a77db1fe83bf8e1 Mon Sep 17 00:00:00 2001 From: aniampio Date: Fri, 9 Aug 2024 00:11:27 +0100 Subject: [PATCH] Run cargo fmt --- common/nymcoconut/src/scheme/aggregation.rs | 2 +- common/nymcoconut/src/scheme/issuance.rs | 22 ++++++++++++--------- common/nymcoconut/src/scheme/mod.rs | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/common/nymcoconut/src/scheme/aggregation.rs b/common/nymcoconut/src/scheme/aggregation.rs index 5338be2dfa..68dbb037ef 100644 --- a/common/nymcoconut/src/scheme/aggregation.rs +++ b/common/nymcoconut/src/scheme/aggregation.rs @@ -115,7 +115,7 @@ pub fn aggregate_signatures_and_verify( .map(|(&attr, beta_i)| beta_i * attr) .sum::(); - if bool::from(signature.0.is_identity()){ + if bool::from(signature.0.is_identity()) { return Err(CoconutError::Aggregation( "Verification of the aggregated signature failed - h is an identity point".to_string(), )); diff --git a/common/nymcoconut/src/scheme/issuance.rs b/common/nymcoconut/src/scheme/issuance.rs index f882962e8c..fb3a09a7dd 100644 --- a/common/nymcoconut/src/scheme/issuance.rs +++ b/common/nymcoconut/src/scheme/issuance.rs @@ -258,7 +258,8 @@ pub fn prepare_blind_sign( loop { // Compute the attributes commitment - let (c_opening, c) = compute_attributes_commitment(params, private_attributes, public_attributes, hs); + let (c_opening, c) = + compute_attributes_commitment(params, private_attributes, public_attributes, hs); commitment_opening = c_opening; commitment = c; @@ -317,7 +318,7 @@ pub fn blind_sign( // Verify the commitment hash let h = compute_hash(blind_sign_request.commitment, public_attributes); - if bool::from(blind_sign_request.commitment_hash.is_identity()){ + if bool::from(blind_sign_request.commitment_hash.is_identity()) { return Err(CoconutError::Issuance( "Commitment hash should not be an identity point".to_string(), )); @@ -390,7 +391,7 @@ pub fn verify_partial_blind_signature( if num_private_attributes + public_attributes.len() > partial_verification_key.beta_g2.len() { return false; } - if bool::from(blind_sig.0.is_identity()){ + if bool::from(blind_sig.0.is_identity()) { return false; } @@ -541,7 +542,6 @@ mod tests { ); } - #[test] fn test_blind_sign_with_identity_commitment_hash() { let params = Parameters::new(1).unwrap(); @@ -549,19 +549,25 @@ mod tests { random_scalars_refs!(public_attributes, params, 0); // Call the function to prepare the blind sign - let (_commitments_openings, blind_sign_request) = prepare_blind_sign(¶ms, &private_attributes, &public_attributes).unwrap(); + let (_commitments_openings, blind_sign_request) = + prepare_blind_sign(¶ms, &private_attributes, &public_attributes).unwrap(); let blind_sign_request = BlindSignRequest { commitment_hash: G1Projective::identity(), ..blind_sign_request // This copies the other fields from the existing instance }; - let signing_secret_key = SecretKey{ + let signing_secret_key = SecretKey { x: params.random_scalar(), ys: vec![params.random_scalar()], }; // Call blind_sign and ensure it returns an error due to identity commitment hash - let result = blind_sign(¶ms, &signing_secret_key, &blind_sign_request, &public_attributes); + let result = blind_sign( + ¶ms, + &signing_secret_key, + &blind_sign_request, + &public_attributes, + ); // The result should be an error assert!( @@ -645,6 +651,4 @@ mod tests { validator2_keypair.verification_key() ),); } - - } diff --git a/common/nymcoconut/src/scheme/mod.rs b/common/nymcoconut/src/scheme/mod.rs index ce33dbb694..6ac5feb6a1 100644 --- a/common/nymcoconut/src/scheme/mod.rs +++ b/common/nymcoconut/src/scheme/mod.rs @@ -103,7 +103,7 @@ impl Signature { commitment_hash: &G1Projective, ) -> Result<()> { // Verify the commitment hash - if bool::from(self.0.is_identity()){ + if bool::from(self.0.is_identity()) { return Err(CoconutError::Verification( "Commitment hash should not be an identity point".to_string(), ));