Skip to content

Commit 9253ada

Browse files
authored
fix: avoid mutating self in TagShare::add (#748)
1 parent 8c889ac commit 9253ada

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

crates/mpc-tls/src/record_layer/aead/ghash.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,12 @@ struct TagShare([u8; 16]);
287287
impl Add for TagShare {
288288
type Output = Vec<u8>;
289289

290-
fn add(mut self, rhs: Self) -> Self::Output {
291-
self.0.iter_mut().zip(rhs.0).for_each(|(a, b)| *a ^= b);
292-
self.0.to_vec()
290+
fn add(self, rhs: Self) -> Self::Output {
291+
self.0
292+
.iter()
293+
.zip(rhs.0)
294+
.map(|(a, b)| *a ^ b)
295+
.collect::<Vec<_>>()
293296
}
294297
}
295298

crates/mpc-tls/src/record_layer/aead/ghash/compute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Task for ComputeTags {
9595
let tags = tag_shares
9696
.into_iter()
9797
.zip(follower_tag_shares)
98-
.map(|(a, b)| (a + b).to_vec())
98+
.map(|(a, b)| a + b)
9999
.collect();
100100

101101
Some(tags)

0 commit comments

Comments
 (0)