Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bench: Poseidon2 with user supplied number of bytes #1649

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
temp: no hash example
  • Loading branch information
codeblooded1729 committed May 6, 2024
commit a95d68f96e85bd5758f84b4b14e44772adc9714e
13 changes: 3 additions & 10 deletions examples/mozak-poseidon2/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,10 @@ fn main() {
let mut bytes = [0u8; 4];
ioread_public(bytes.as_mut_ptr(), bytes.len());
u32::from_le_bytes(bytes).next_multiple_of(8)
};
} as usize;

// using a deterministic vector of bytes since
// using rng to generate random bytes interferes
// with benching poseidon2 ecall, which is the primary
// focus here.
let v: Vec<u8> = black_box((0..n).map(|_i| 0x12).collect());
let mut hash = [0u8; 32];

// flat hash
black_box(poseidon2(v.as_ptr(), v.len(), hash.as_mut_ptr()));
// generate a vector of size n
let v: Vec<u8> = black_box((0..n).map(|i| i.to_le_bytes()[0]).collect());
}

mozak_sdk::entry!(main);