-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add test and benchmarks for poseidon2 (#5386)
# Description ## Problem\* Resolves <!-- Link to GitHub Issue --> ## Summary\* This PR adds benchmarks for poseidon2 ## Additional Context ## Documentation\* Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
1 parent
df73fe2
commit 44abe7f
Showing
21 changed files
with
380 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "bench_poseidon2_hash" | ||
version = "0.1.0" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
input = [1,2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use std::hash::poseidon2; | ||
|
||
fn main(input: [Field; 2]) -> pub Field { | ||
poseidon2::Poseidon2::hash(input, input.len()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "bench_poseidon2_hash_100" | ||
version = "0.1.0" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
102 changes: 102 additions & 0 deletions
102
test_programs/benchmarks/bench_poseidon2_hash_100/Prover.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
input = [ | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
] |
12 changes: 12 additions & 0 deletions
12
test_programs/benchmarks/bench_poseidon2_hash_100/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use std::hash::poseidon2; | ||
|
||
global SIZE = 100; | ||
|
||
fn main(input: [[Field; 2]; SIZE]) -> pub [Field; SIZE] { | ||
let mut results: [Field; SIZE] = [0; SIZE]; | ||
for i in 0..SIZE { | ||
results[i] = poseidon2::Poseidon2::hash(input[i], 2); | ||
} | ||
|
||
results | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "bench_poseidon2_hash_30" | ||
version = "0.1.0" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
32 changes: 32 additions & 0 deletions
32
test_programs/benchmarks/bench_poseidon2_hash_30/Prover.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
input = [ | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
] |
12 changes: 12 additions & 0 deletions
12
test_programs/benchmarks/bench_poseidon2_hash_30/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use std::hash::poseidon2; | ||
|
||
global SIZE = 30; | ||
|
||
fn main(input: [[Field; 2]; SIZE]) -> pub [Field; SIZE] { | ||
let mut results: [Field; SIZE] = [0; SIZE]; | ||
for i in 0..SIZE { | ||
results[i] = poseidon2::Poseidon2::hash(input[i], 2); | ||
} | ||
|
||
results | ||
} |
7 changes: 7 additions & 0 deletions
7
test_programs/benchmarks/bench_poseidon_hash/bench_poseidon_hash_100/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "bench_poseidon_hash_100" | ||
version = "0.1.0" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
102 changes: 102 additions & 0 deletions
102
test_programs/benchmarks/bench_poseidon_hash/bench_poseidon_hash_100/Prover.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
input = [ | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
] |
12 changes: 12 additions & 0 deletions
12
test_programs/benchmarks/bench_poseidon_hash/bench_poseidon_hash_100/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use std::hash; | ||
|
||
global SIZE = 100; | ||
|
||
fn main(input: [[Field; 2]; SIZE]) -> pub [Field; SIZE] { | ||
let mut results: [Field; SIZE] = [0; SIZE]; | ||
for i in 0..SIZE { | ||
results[i] = hash::poseidon::bn254::hash_2(input[i]); | ||
} | ||
|
||
results | ||
} |
7 changes: 7 additions & 0 deletions
7
test_programs/benchmarks/bench_poseidon_hash/bench_poseidon_hash_30/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "bench_poseidon_hash_30" | ||
version = "0.1.0" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
32 changes: 32 additions & 0 deletions
32
test_programs/benchmarks/bench_poseidon_hash/bench_poseidon_hash_30/Prover.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
input = [ | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
[1,2], | ||
] |
12 changes: 12 additions & 0 deletions
12
test_programs/benchmarks/bench_poseidon_hash/bench_poseidon_hash_30/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use std::hash; | ||
|
||
global SIZE = 30; | ||
|
||
fn main(input: [[Field; 2]; SIZE]) -> pub [Field; SIZE] { | ||
let mut results: [Field; SIZE] = [0; SIZE]; | ||
for i in 0..SIZE { | ||
results[i] = hash::poseidon::bn254::hash_2(input[i]); | ||
} | ||
|
||
results | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "poseidon2" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
inputs = ["4218458030232820015255714794613421442512497197372123294583664908262453897094", | ||
"4218458030232820015255714794613421442512497197372123294583664908262453897094", | ||
"4218458030232820015255714794613421442512497197372123294583664908262453897094", | ||
"4218458030232820015255714794613421442512497197372123294583664908262453897094"] | ||
expected_hash = "0x2f43a0f83b51a6f5fc839dea0ecec74947637802a579fa9841930a25a0bcec11" |
Oops, something went wrong.