From 993d01b712d150c043ee7fec5466cb41719a8f99 Mon Sep 17 00:00:00 2001 From: onyinyang Date: Tue, 18 Oct 2022 00:51:17 -0400 Subject: [PATCH] Added results of cargo clippy --fix --- crates/lox-library/src/bridge_table.rs | 4 ++-- crates/lox-library/src/migration_table.rs | 4 ++-- .../src/proto/blockage_migration.rs | 8 ++++---- crates/lox-library/src/proto/check_blockage.rs | 4 ++-- crates/lox-library/src/proto/issue_invite.rs | 10 +++++----- crates/lox-library/src/proto/level_up.rs | 8 ++++---- crates/lox-library/src/proto/migration.rs | 8 ++++---- crates/lox-library/src/proto/open_invite.rs | 6 +++--- crates/lox-library/src/proto/redeem_invite.rs | 8 ++++---- .../lox-library/src/proto/trust_promotion.rs | 4 ++-- crates/lox-library/src/tests.rs | 18 +++++++++--------- 11 files changed, 41 insertions(+), 41 deletions(-) diff --git a/crates/lox-library/src/bridge_table.rs b/crates/lox-library/src/bridge_table.rs index d7ef7fa..6f385a6 100644 --- a/crates/lox-library/src/bridge_table.rs +++ b/crates/lox-library/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 = cipher.encrypt(&nonce, plainbucket.as_ref()).unwrap(); + let ciphertext: Vec = 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 = cipher.decrypt(&nonce, encbucket[12..].as_ref())?; + let plaintext: Vec = 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(), diff --git a/crates/lox-library/src/migration_table.rs b/crates/lox-library/src/migration_table.rs index 4a596f1..86d5aa8 100644 --- a/crates/lox-library/src/migration_table.rs +++ b/crates/lox-library/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 = cipher.encrypt(&nonce, credbytes.as_ref()).unwrap(); + let ciphertext: Vec = 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 = match cipher.decrypt(&nonce, ciphertext[12..].as_ref()) { + let plaintext: Vec = match cipher.decrypt(nonce, ciphertext[12..].as_ref()) { Ok(v) => v, Err(_) => return None, }; diff --git a/crates/lox-library/src/proto/blockage_migration.rs b/crates/lox-library/src/proto/blockage_migration.rs index dc8c5b6..4705535 100644 --- a/crates/lox-library/src/proto/blockage_migration.rs +++ b/crates/lox-library/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, diff --git a/crates/lox-library/src/proto/check_blockage.rs b/crates/lox-library/src/proto/check_blockage.rs index 9cba4fc..34b3823 100644 --- a/crates/lox-library/src/proto/check_blockage.rs +++ b/crates/lox-library/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, diff --git a/crates/lox-library/src/proto/issue_invite.rs b/crates/lox-library/src/proto/issue_invite.rs index f2ed162..610de25 100644 --- a/crates/lox-library/src/proto/issue_invite.rs +++ b/crates/lox-library/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, diff --git a/crates/lox-library/src/proto/level_up.rs b/crates/lox-library/src/proto/level_up.rs index 7978e68..5f9bc30 100644 --- a/crates/lox-library/src/proto/level_up.rs +++ b/crates/lox-library/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, diff --git a/crates/lox-library/src/proto/migration.rs b/crates/lox-library/src/proto/migration.rs index 383dfa2..585f5b5 100644 --- a/crates/lox-library/src/proto/migration.rs +++ b/crates/lox-library/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, diff --git a/crates/lox-library/src/proto/open_invite.rs b/crates/lox-library/src/proto/open_invite.rs index 306489a..818b32b 100644 --- a/crates/lox-library/src/proto/open_invite.rs +++ b/crates/lox-library/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, diff --git a/crates/lox-library/src/proto/redeem_invite.rs b/crates/lox-library/src/proto/redeem_invite.rs index 59ce73b..6692a38 100644 --- a/crates/lox-library/src/proto/redeem_invite.rs +++ b/crates/lox-library/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, diff --git a/crates/lox-library/src/proto/trust_promotion.rs b/crates/lox-library/src/proto/trust_promotion.rs index fed5a25..9642c8f 100644 --- a/crates/lox-library/src/proto/trust_promotion.rs +++ b/crates/lox-library/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, diff --git a/crates/lox-library/src/tests.rs b/crates/lox-library/src/tests.rs index 1c9f98e..e2b65ea 100644 --- a/crates/lox-library/src/tests.rs +++ b/crates/lox-library/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 = 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 = 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 = 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 = bincode::serialize(&req).unwrap(); let req_t = req_start.elapsed(); @@ -1592,11 +1592,11 @@ fn block_bridges(th: &mut TestHarness, percentage: usize, credentials: Vec = 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