We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e422a4c + 596d59a commit 7f4ef85Copy full SHA for 7f4ef85
src/poseidon2.nr
@@ -25,13 +25,10 @@ impl Poseidon2 {
25
26
fn perform_duplex(&mut self) {
27
// 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
+ self.state[0] += self.cache[0] * (0 < self.cache_size) as Field;
+ self.state[1] += self.cache[1] * (1 < self.cache_size) as Field;
+ self.state[2] += self.cache[2] * (2 < self.cache_size) as Field;
+ self.state[3] += self.cache[3] * (3 < self.cache_size) as Field;
35
self.state = crate::poseidon2_permutation(self.state, 4);
36
}
37
0 commit comments