Răsfoiți Sursa

crypto: Clippy lints.

Luther Blissett 3 ani în urmă
părinte
comite
cda5e46f1a
3 a modificat fișierele cu 7 adăugiri și 11 ștergeri
  1. 1 1
      src/crypto/lead_proof.rs
  2. 2 3
      src/crypto/leadcoin.rs
  3. 4 7
      src/crypto/mimc_vdf.rs

+ 1 - 1
src/crypto/lead_proof.rs

@@ -15,7 +15,7 @@ use crate::{
 pub fn create_lead_proof(pk: &ProvingKey, coin: LeadCoin) -> Result<Proof> {
     let contract = coin.create_contract();
     let public_inputs = coin.public_inputs();
-    let proof = Proof::create(&pk, &[contract], &public_inputs, &mut OsRng)?;
+    let proof = Proof::create(pk, &[contract], &public_inputs, &mut OsRng)?;
     Ok(proof)
 }
 

+ 2 - 3
src/crypto/leadcoin.rs

@@ -111,7 +111,7 @@ impl LeadCoin {
     }
 
     pub fn create_contract(&self) -> LeadContract {
-        let contract = LeadContract {
+        LeadContract {
             path: Value::known(self.path.unwrap()),
             root_sk: Value::known(self.root_sk.unwrap()),
             path_sk: Value::known(self.path_sk.unwrap()),
@@ -127,7 +127,6 @@ impl LeadCoin {
             mau_y: Value::known(mod_r_p(self.y_mu.unwrap())),
             root_cm: Value::known(self.root_cm.unwrap()),
             sigma_scalar: Value::known(self.sigma_scalar.unwrap()),
-        };
-        contract
+        }
     }
 }

+ 4 - 7
src/crypto/mimc_vdf.rs

@@ -14,6 +14,7 @@ pub const L_FERMAT_EXPONENT: &str =
 /// Calculates set of round constants to perform MiMC-calculation on.
 fn calculate_round_constants() -> [u64; 64] {
     let mut round_constants = [0u64; 64];
+    #[allow(clippy::needless_range_loop)]
     for i in 0usize..64 {
         round_constants[i] = (i.pow(7) ^ 42) as u64;
     }
@@ -49,7 +50,7 @@ fn backward_mimc(num_steps: u64, input: &BigUint) -> BigUint {
     let mut result = input.clone();
     for i in (1..num_steps).rev() {
         let round_constant = BigUint::from(round_constants[i as usize % round_constants.len()]);
-        result = BigUint::from(&result - &round_constant).modpow(&l_fermat_exp, &modulus);
+        result = (&result - &round_constant).modpow(&l_fermat_exp, &modulus);
     }
 
     result
@@ -57,16 +58,12 @@ fn backward_mimc(num_steps: u64, input: &BigUint) -> BigUint {
 
 /// Performs an Eval() step of the MiMC-based VDF
 pub fn eval(seed: &BigUint, num_steps: u64) -> BigUint {
-    let witness = backward_mimc(num_steps, &seed);
-
-    witness
+    backward_mimc(num_steps, seed)
 }
 
 /// Performs a Verify() step for the MiMC-based VDF result
 pub fn verify(seed: &BigUint, num_steps: u64, witness: &BigUint) -> bool {
-    let result = forward_mimc(num_steps, witness);
-
-    result == *seed
+    forward_mimc(num_steps, witness) == *seed
 }
 
 #[cfg(test)]