Skip to content

Commit

Permalink
Merge pull request privacy-scaling-explorations#138 from input-output…
Browse files Browse the repository at this point in the history
…-hk/dev-fix/add-test-vectors-to-poseidon-duplex

Resolve "Add test vectors to poseidon duplex"
  • Loading branch information
b13decker authored Mar 7, 2024
2 parents b2752df + adbc67b commit 10623d5
Show file tree
Hide file tree
Showing 5 changed files with 1,214 additions and 0 deletions.
3 changes: 3 additions & 0 deletions halo2_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ required-features = ["dev-graph"]

[[example]]
name = "emit-duplex-pattern"

[[example]]
name = "random-duplex-test-vectors"
5 changes: 5 additions & 0 deletions halo2_proofs/examples/random-duplex-test-vectors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use halo2_proofs::poseidon::duplex::test_vector_tools::print_random_duplex_test_vectors;

fn main() {
print_random_duplex_test_vectors(5);
}
51 changes: 51 additions & 0 deletions halo2_proofs/src/poseidon/duplex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,3 +709,54 @@ mod test_complex_pattern {
duplex.finish();
}
}

pub mod test_vector_tools;

#[cfg(test)]
mod test_vectors;

#[cfg(test)]
mod check_test_vectors {
use super::test_vector_tools::check_duplex_test_vector;
use super::test_vectors;

#[test]
fn check_fp_test_vectors() {
test_vectors::fp_a1_s1()
.into_iter()
.enumerate()
.for_each(|(i, tv)| check_duplex_test_vector(tv, &format!("fp_a1_s1[{i}]")));
test_vectors::fp_a1_s2()
.into_iter()
.enumerate()
.for_each(|(i, tv)| check_duplex_test_vector(tv, &format!("fp_a1_s2[{i}]")));
test_vectors::fp_a2_s1()
.into_iter()
.enumerate()
.for_each(|(i, tv)| check_duplex_test_vector(tv, &format!("fp_a2_s1[{i}]")));
test_vectors::fp_a2_s2()
.into_iter()
.enumerate()
.for_each(|(i, tv)| check_duplex_test_vector(tv, &format!("fp_a2_s2[{i}]")));
}

#[test]
fn check_fq_test_vectors() {
test_vectors::fq_a1_s1()
.into_iter()
.enumerate()
.for_each(|(i, tv)| check_duplex_test_vector(tv, &format!("fq_a1_s1[{i}]")));
test_vectors::fq_a1_s2()
.into_iter()
.enumerate()
.for_each(|(i, tv)| check_duplex_test_vector(tv, &format!("fq_a1_s2[{i}]")));
test_vectors::fq_a2_s1()
.into_iter()
.enumerate()
.for_each(|(i, tv)| check_duplex_test_vector(tv, &format!("fq_a2_s1[{i}]")));
test_vectors::fq_a2_s2()
.into_iter()
.enumerate()
.for_each(|(i, tv)| check_duplex_test_vector(tv, &format!("fq_a2_s2[{i}]")));
}
}
Loading

0 comments on commit 10623d5

Please sign in to comment.