Skip to content

Commit 596d59a

Browse files
feat: improve brillig performace (#27)
Co-authored-by: Tom French <[email protected]>
1 parent 211d4e9 commit 596d59a

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

.github/workflows/benchmark.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
deployments: write
1616
# contents permission to update benchmark contents in gh-pages branch
1717
contents: write
18+
pull-requests: write
1819

1920
steps:
2021
- name: Checkout sources

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)