From 9c65518dc3fbb34defe9188b0dff6a485105358b Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Tue, 13 Dec 2022 19:40:54 -0500 Subject: [PATCH] Have included return a reference instead of a cloned Vec --- coins/monero/src/ringct/clsag/multisig.rs | 2 +- crypto/dkg/src/lib.rs | 4 ++-- crypto/frost/src/sign.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/coins/monero/src/ringct/clsag/multisig.rs b/coins/monero/src/ringct/clsag/multisig.rs index 10734bf3..9fcbf5e1 100644 --- a/coins/monero/src/ringct/clsag/multisig.rs +++ b/coins/monero/src/ringct/clsag/multisig.rs @@ -229,7 +229,7 @@ impl Algorithm for ClsagMultisig { &mut self.image, self.H, view.offset().0, - &view.included(), + view.included(), l, addendum.key_image.0, ); diff --git a/crypto/dkg/src/lib.rs b/crypto/dkg/src/lib.rs index 079a8462..2a8106d4 100644 --- a/crypto/dkg/src/lib.rs +++ b/crypto/dkg/src/lib.rs @@ -376,8 +376,8 @@ impl ThresholdView { self.group_key } - pub fn included(&self) -> Vec { - self.included.clone() + pub fn included(&self) -> &[u16] { + &self.included } pub fn secret_share(&self) -> &Zeroizing { diff --git a/crypto/frost/src/sign.rs b/crypto/frost/src/sign.rs index eefac41d..5f2dac04 100644 --- a/crypto/frost/src/sign.rs +++ b/crypto/frost/src/sign.rs @@ -461,7 +461,7 @@ impl> SignatureMachine for AlgorithmSign mut shares: HashMap>, ) -> Result { let params = self.params.multisig_params(); - validate_map(&shares, &self.view.included(), params.i())?; + validate_map(&shares, self.view.included(), params.i())?; let mut responses = HashMap::new(); responses.insert(params.i(), self.share); @@ -481,7 +481,7 @@ impl> SignatureMachine for AlgorithmSign // Find out who misbehaved // Randomly sorts the included participants to discover the answer on average within n/2 tries // If we didn't randomly sort them, it would be gameable to n by a malicious participant - let mut rand_included = self.view.included(); + let mut rand_included = self.view.included().to_vec(); // It is unfortunate we have to construct a ChaCha RNG here, yet it's due to the lack of a // provided RNG. Its hashing is cheaper than abused ECC ops rand_included.shuffle(&mut ChaCha8Rng::from_seed(self.blame_entropy));