Skip to content

Commit 7f4ef85

Browse files
authored
Merge branch 'master' into jl/unroll
2 parents e422a4c + 596d59a commit 7f4ef85

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/poseidon2.nr

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ impl Poseidon2 {
2525

2626
fn perform_duplex(&mut self) {
2727
// add the cache into sponge state
28-
for i in 0..RATE {
29-
// We effectively zero-pad the cache by only adding to the state
30-
// cache that is less than the specified `cache_size`
31-
if i < self.cache_size {
32-
self.state[i] += self.cache[i];
33-
}
34-
}
28+
self.state[0] += self.cache[0] * (0 < self.cache_size) as Field;
29+
self.state[1] += self.cache[1] * (1 < self.cache_size) as Field;
30+
self.state[2] += self.cache[2] * (2 < self.cache_size) as Field;
31+
self.state[3] += self.cache[3] * (3 < self.cache_size) as Field;
3532
self.state = crate::poseidon2_permutation(self.state, 4);
3633
}
3734

0 commit comments

Comments
 (0)