Have included return a reference instead of a cloned Vec

This commit is contained in:
Luke Parker 2022-12-13 19:40:54 -05:00
parent 2b042015b5
commit 9c65518dc3
No known key found for this signature in database
3 changed files with 5 additions and 5 deletions

View file

@ -229,7 +229,7 @@ impl Algorithm<Ed25519> for ClsagMultisig {
&mut self.image, &mut self.image,
self.H, self.H,
view.offset().0, view.offset().0,
&view.included(), view.included(),
l, l,
addendum.key_image.0, addendum.key_image.0,
); );

View file

@ -376,8 +376,8 @@ impl<C: Ciphersuite> ThresholdView<C> {
self.group_key self.group_key
} }
pub fn included(&self) -> Vec<u16> { pub fn included(&self) -> &[u16] {
self.included.clone() &self.included
} }
pub fn secret_share(&self) -> &Zeroizing<C::F> { pub fn secret_share(&self) -> &Zeroizing<C::F> {

View file

@ -461,7 +461,7 @@ impl<C: Curve, A: Algorithm<C>> SignatureMachine<A::Signature> for AlgorithmSign
mut shares: HashMap<u16, SignatureShare<C>>, mut shares: HashMap<u16, SignatureShare<C>>,
) -> Result<A::Signature, FrostError> { ) -> Result<A::Signature, FrostError> {
let params = self.params.multisig_params(); 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(); let mut responses = HashMap::new();
responses.insert(params.i(), self.share); responses.insert(params.i(), self.share);
@ -481,7 +481,7 @@ impl<C: Curve, A: Algorithm<C>> SignatureMachine<A::Signature> for AlgorithmSign
// Find out who misbehaved // Find out who misbehaved
// Randomly sorts the included participants to discover the answer on average within n/2 tries // 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 // 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 // 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 // provided RNG. Its hashing is cheaper than abused ECC ops
rand_included.shuffle(&mut ChaCha8Rng::from_seed(self.blame_entropy)); rand_included.shuffle(&mut ChaCha8Rng::from_seed(self.blame_entropy));