Переглянути джерело

Added results of cargo clippy --fix

onyinyang 2 роки тому
батько
коміт
1a126f10d9

+ 2 - 2
src/bridge_table.rs

@@ -287,7 +287,7 @@ impl BridgeTable {
             let nonce = GenericArray::from_slice(&noncebytes);
             // Encrypt
             let cipher = Aes128Gcm::new(aeskey);
-            let ciphertext: Vec<u8> = cipher.encrypt(&nonce, plainbucket.as_ref()).unwrap();
+            let ciphertext: Vec<u8> = cipher.encrypt(nonce, plainbucket.as_ref()).unwrap();
             encbucket[0..12].copy_from_slice(&noncebytes);
             encbucket[12..].copy_from_slice(ciphertext.as_slice());
             self.encbuckets.push(encbucket);
@@ -307,7 +307,7 @@ impl BridgeTable {
         let aeskey = GenericArray::from_slice(key);
         // Decrypt
         let cipher = Aes128Gcm::new(aeskey);
-        let plaintext: Vec<u8> = cipher.decrypt(&nonce, encbucket[12..].as_ref())?;
+        let plaintext: Vec<u8> = cipher.decrypt(nonce, encbucket[12..].as_ref())?;
         // Convert the plaintext bytes to an array of BridgeLines
         Ok(BridgeLine::bucket_decode(
             plaintext.as_slice().try_into().unwrap(),

+ 2 - 2
src/migration_table.rs

@@ -127,7 +127,7 @@ pub fn encrypt_cred(
     let aeskey = GenericArray::from_slice(&fullhash[16..]);
     // Encrypt
     let cipher = Aes128Gcm::new(aeskey);
-    let ciphertext: Vec<u8> = cipher.encrypt(&nonce, credbytes.as_ref()).unwrap();
+    let ciphertext: Vec<u8> = cipher.encrypt(nonce, credbytes.as_ref()).unwrap();
     let mut enccredbytes: [u8; ENC_MIGRATION_BYTES] = [0; ENC_MIGRATION_BYTES];
     enccredbytes[..12].copy_from_slice(&noncebytes);
     enccredbytes[12..].copy_from_slice(ciphertext.as_slice());
@@ -239,7 +239,7 @@ pub fn decrypt_cred(
     // Decrypt
     let nonce = GenericArray::from_slice(&ciphertext[..12]);
     let cipher = Aes128Gcm::new(aeskey);
-    let plaintext: Vec<u8> = match cipher.decrypt(&nonce, ciphertext[12..].as_ref()) {
+    let plaintext: Vec<u8> = match cipher.decrypt(nonce, ciphertext[12..].as_ref()) {
         Ok(v) => v,
         Err(_) => return None,
     };

+ 4 - 4
src/proto/blockage_migration.rs

@@ -299,8 +299,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P_lox: &P_lox,
             CBucket: &CBucket,
             CSince: &CSince,
@@ -531,8 +531,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 2 - 2
src/proto/check_blockage.rs

@@ -186,8 +186,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P: &P,
             CBucket: &CBucket,
             CSince: &CSince,

+ 5 - 5
src/proto/issue_invite.rs

@@ -408,8 +408,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P: &P,
             CBucket: &CBucket,
             CLevel: &CLevel,
@@ -464,7 +464,7 @@ pub fn request(
             id_client: &id_client,
             inv_id_client: &inv_id_client,
             einv_id_client: &einv_id_client,
-            invremain_inverse: &invremain_inverse,
+            invremain_inverse,
             zinvremain_inverse: &zinvremain_inverse,
         },
     )
@@ -698,8 +698,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 4 - 4
src/proto/level_up.rs

@@ -524,8 +524,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P: &P,
             CBucket: &CBucket,
             CSince: &CSince,
@@ -874,8 +874,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 4 - 4
src/proto/migration.rs

@@ -246,8 +246,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P_lox: &P_lox,
             CBucket: &CBucket,
             CSince: &CSince,
@@ -428,8 +428,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 3 - 3
src/proto/open_invite.rs

@@ -121,7 +121,7 @@ pub fn request(invite: &[u8; OPENINV_LENGTH]) -> (Request, State) {
     let piUserBlinding = userblinding::prove_compact(
         &mut transcript,
         userblinding::ProveAssignments {
-            B: &B,
+            B,
             D: &D,
             EncIdClient0: &EncIdClient.0,
             EncIdClient1: &EncIdClient.1,
@@ -228,8 +228,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 4 - 4
src/proto/redeem_invite.rs

@@ -290,8 +290,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P: &P,
             CDate: &CDate,
             CBucket: &CBucket,
@@ -498,8 +498,8 @@ impl BridgeAuth {
         let piBlindIssue = blindissue::prove_compact(
             &mut transcript,
             blindissue::ProveAssignments {
-                A: &A,
-                B: &B,
+                A,
+                B,
                 P: &P,
                 EncQ0: &EncQ.0,
                 EncQ1: &EncQ.1,

+ 2 - 2
src/proto/trust_promotion.rs

@@ -301,8 +301,8 @@ pub fn request(
     let piUser = requestproof::prove_compact(
         &mut transcript,
         requestproof::ProveAssignments {
-            A: &A,
-            B: &B,
+            A,
+            B,
             P: &P,
             CBucket: &CBucket,
             CSince: &CSince,

+ 9 - 9
src/tests.rs

@@ -108,7 +108,7 @@ impl TestHarness {
     fn trust_promotion(&mut self, cred: &cred::Lox) -> (PerfStat, cred::Migration) {
         let req_start = Instant::now();
         let (promreq, promstate) =
-            trust_promotion::request(&cred, &self.ba.lox_pub, self.ba.today()).unwrap();
+            trust_promotion::request(cred, &self.ba.lox_pub, self.ba.today()).unwrap();
         let encoded: Vec<u8> = bincode::serialize(&promreq).unwrap();
         let req_t = req_start.elapsed();
         let req_len = encoded.len();
@@ -187,7 +187,7 @@ impl TestHarness {
         // level
         let req_start = Instant::now();
         let (req, state) = level_up::request(
-            &cred,
+            cred,
             &reachcred,
             &self.ba.lox_pub,
             &self.ba.reachability_pub,
@@ -233,7 +233,7 @@ impl TestHarness {
 
         let req_start = Instant::now();
         let (req, state) = issue_invite::request(
-            &cred,
+            cred,
             &reachcred,
             &self.ba.lox_pub,
             &self.ba.reachability_pub,
@@ -277,7 +277,7 @@ impl TestHarness {
     fn redeem_invite(&mut self, inv: &cred::Invitation) -> (PerfStat, cred::Lox) {
         let req_start = Instant::now();
         let (req, state) =
-            redeem_invite::request(&inv, &self.ba.invitation_pub, self.ba.today()).unwrap();
+            redeem_invite::request(inv, &self.ba.invitation_pub, self.ba.today()).unwrap();
         let encoded: Vec<u8> = bincode::serialize(&req).unwrap();
         let req_t = req_start.elapsed();
         let req_len = encoded.len();
@@ -308,7 +308,7 @@ impl TestHarness {
 
     fn check_blockage(&mut self, cred: &cred::Lox) -> (PerfStat, cred::Migration) {
         let req_start = Instant::now();
-        let (req, state) = check_blockage::request(&cred, &self.ba.lox_pub).unwrap();
+        let (req, state) = check_blockage::request(cred, &self.ba.lox_pub).unwrap();
         let encoded: Vec<u8> = bincode::serialize(&req).unwrap();
         let req_t = req_start.elapsed();
         let req_len = encoded.len();
@@ -344,7 +344,7 @@ impl TestHarness {
     ) -> (PerfStat, cred::Lox) {
         let req_start = Instant::now();
         let (req, state) =
-            blockage_migration::request(&cred, &mig, &self.ba.lox_pub, &self.ba.migration_pub)
+            blockage_migration::request(cred, mig, &self.ba.lox_pub, &self.ba.migration_pub)
                 .unwrap();
         let encoded: Vec<u8> = bincode::serialize(&req).unwrap();
         let req_t = req_start.elapsed();
@@ -1592,11 +1592,11 @@ fn block_bridges(th: &mut TestHarness, percentage: usize, credentials: Vec<cred:
         - th.ba.bridge_table.spares.len()
         - th.bdb.openinv_buckets.len();
     let blockable_range = th.ba.bridge_table.buckets.len() - th.ba.bridge_table.spares.len();
-    let to_block: usize = (blockable_num * percentage / 100).into();
+    let to_block: usize = blockable_num * percentage / 100;
     let mut block_index: HashSet<usize> = HashSet::new();
     let mut rng = rand::thread_rng();
 
-    while block_index.len() <= to_block - 1 {
+    while block_index.len() < to_block {
         let rand_num = rng.gen_range(0, blockable_range);
         if !th.bdb.openinv_buckets.contains(&(rand_num as u32)) {
             block_index.insert(rand_num);
@@ -1631,7 +1631,7 @@ fn block_bridges(th: &mut TestHarness, percentage: usize, credentials: Vec<cred:
         let mut count = 0;
         for bridge_line in &bucket.0 {
             if th.ba.bridge_table.reachable.contains_key(bridge_line) {
-                count = count + 1;
+                count += 1;
             }
         }