Skip to content

Commit

Permalink
Merge pull request #16139 from MinaProtocol/volhovm/arkworks024-regre…
Browse files Browse the repository at this point in the history
…ssion-tests

Update proof-systems: external prover randomness & regression tests
  • Loading branch information
volhovm authored Oct 1, 2024
2 parents 3a00659 + d68deac commit b267729
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
27 changes: 18 additions & 9 deletions src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ pub fn caml_pasta_fp_plonk_proof_create(
// Release the runtime lock so that other threads can run using it while we generate the proof.
runtime.releasing_runtime(|| {
let group_map = GroupMap::<Fq>::setup();
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge>(
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge, _>(
&group_map,
witness,
&runtime_tables,
index,
prev,
None,
&mut rand::rngs::OsRng,
)
.map_err(|e| ocaml::Error::Error(e.into()))?;
Ok((proof, public_input).into())
Expand Down Expand Up @@ -153,13 +154,14 @@ pub fn caml_pasta_fp_plonk_proof_create_and_verify(
// Release the runtime lock so that other threads can run using it while we generate the proof.
runtime.releasing_runtime(|| {
let group_map = GroupMap::<Fq>::setup();
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge>(
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge, _>(
&group_map,
witness,
&runtime_tables,
index,
prev,
None,
&mut rand::rngs::OsRng,
)
.map_err(|e| ocaml::Error::Error(e.into()))?;

Expand Down Expand Up @@ -281,13 +283,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_lookup(
let index = ProverIndex::<Vesta, OpeningProof<Vesta>>::create(cs, endo_q, srs.0);
let group_map = <Vesta as CommitmentCurve>::Map::setup();
let public_input = witness[0][0];
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge>(
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge, _>(
&group_map,
witness,
&runtime_tables,
&index,
vec![],
None,
&mut rand::rngs::OsRng,
)
.unwrap();

Expand Down Expand Up @@ -444,13 +447,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_foreign_field_mul(
let (endo_q, _endo_r) = endos::<Pallas>();
let index = ProverIndex::<Vesta, OpeningProof<Vesta>>::create(cs, endo_q, srs.0);
let group_map = <Vesta as CommitmentCurve>::Map::setup();
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge>(
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge, _>(
&group_map,
witness,
&[],
&index,
vec![],
None,
&mut rand::rngs::OsRng,
)
.unwrap();
(
Expand Down Expand Up @@ -510,13 +514,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_range_check(
let (endo_q, _endo_r) = endos::<Pallas>();
let index = ProverIndex::<Vesta, OpeningProof<Vesta>>::create(cs, endo_q, srs.0);
let group_map = <Vesta as CommitmentCurve>::Map::setup();
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge>(
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge, _>(
&group_map,
witness,
&[],
&index,
vec![],
None,
&mut rand::rngs::OsRng,
)
.unwrap();
(
Expand Down Expand Up @@ -582,13 +587,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_range_check0(
let (endo_q, _endo_r) = endos::<Pallas>();
let index = ProverIndex::<Vesta, OpeningProof<Vesta>>::create(cs, endo_q, srs.0);
let group_map = <Vesta as CommitmentCurve>::Map::setup();
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge>(
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge, _>(
&group_map,
witness,
&[],
&index,
vec![],
None,
&mut rand::rngs::OsRng,
)
.unwrap();
(
Expand Down Expand Up @@ -707,13 +713,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_ffadd(
let index = ProverIndex::<Vesta, OpeningProof<Vesta>>::create(cs, endo_q, srs.0);
let group_map = <Vesta as CommitmentCurve>::Map::setup();
let public_input = witness[0][0];
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge>(
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge, _>(
&group_map,
witness,
&[],
&index,
vec![],
None,
&mut rand::rngs::OsRng,
)
.unwrap();
(
Expand Down Expand Up @@ -795,13 +802,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_xor(
let index = ProverIndex::<Vesta, OpeningProof<Vesta>>::create(cs, endo_q, srs.0);
let group_map = <Vesta as CommitmentCurve>::Map::setup();
let public_input = (witness[0][0], witness[0][1]);
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge>(
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge, _>(
&group_map,
witness,
&[],
&index,
vec![],
None,
&mut rand::rngs::OsRng,
)
.unwrap();
(
Expand Down Expand Up @@ -888,13 +896,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_rot(
let index = ProverIndex::<Vesta, OpeningProof<Vesta>>::create(cs, endo_q, srs.0);
let group_map = <Vesta as CommitmentCurve>::Map::setup();
let public_input = (witness[0][0], witness[0][1]);
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge>(
let proof = ProverProof::create_recursive::<EFqSponge, EFrSponge, _>(
&group_map,
witness,
&[],
&index,
vec![],
None,
&mut rand::rngs::OsRng,
)
.unwrap();
(
Expand Down
11 changes: 10 additions & 1 deletion src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@ pub fn caml_pasta_fq_plonk_proof_create(
let proof = ProverProof::create_recursive::<
DefaultFqSponge<PallasParameters, PlonkSpongeConstantsKimchi>,
DefaultFrSponge<Fq, PlonkSpongeConstantsKimchi>,
>(&group_map, witness, &runtime_tables, index, prev, None)
_,
>(
&group_map,
witness,
&runtime_tables,
index,
prev,
None,
&mut rand::rngs::OsRng,
)
.map_err(|e| ocaml::Error::Error(e.into()))?;
Ok((proof, public_input).into())
})
Expand Down
4 changes: 3 additions & 1 deletion src/lib/crypto/kimchi_bindings/wasm/src/plonk_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,9 @@ macro_rules! impl_proof {
let maybe_proof = ProverProof::create_recursive::<
DefaultFqSponge<_, PlonkSpongeConstantsKimchi>,
DefaultFrSponge<_, PlonkSpongeConstantsKimchi>,
>(&group_map, witness, &rust_runtime_tables, index, prev, None);
_>(&group_map, witness, &rust_runtime_tables, index, prev, None,
&mut rand::rngs::OsRng
);
(maybe_proof, public_input)
});

Expand Down
2 changes: 1 addition & 1 deletion src/lib/crypto/proof-systems
Submodule proof-systems updated 65 files
+8 −0 .github/workflows/ci.yml
+3 −0 .rustfmt.toml
+1 −1 book/specifications/kimchi/template.md
+90 −90 book/src/specs/kimchi.md
+1 −2 curves/src/pasta/curves/tests.rs
+5 −2 curves/src/pasta/fields/fp.rs
+1 −2 hasher/src/tests/hasher.rs
+2 −1 kimchi/src/bench.rs
+1 −3 kimchi/src/circuits/constraints.rs
+4 −3 kimchi/src/circuits/domain_constant_evaluation.rs
+5 −5 kimchi/src/circuits/expr.rs
+5 −2 kimchi/src/circuits/lookup/index.rs
+10 −6 kimchi/src/circuits/lookup/lookups.rs
+1 −2 kimchi/src/circuits/polynomials/endomul_scalar.rs
+1 −1 kimchi/src/circuits/polynomials/foreign_field_add/circuitgates.rs
+2 −3 kimchi/src/circuits/polynomials/foreign_field_add/witness.rs
+2 −1 kimchi/src/circuits/polynomials/foreign_field_mul/circuitgates.rs
+11 −9 kimchi/src/circuits/polynomials/generic.rs
+1 −2 kimchi/src/circuits/polynomials/permutation.rs
+2 −2 kimchi/src/circuits/polynomials/range_check/circuitgates.rs
+3 −6 kimchi/src/circuits/polynomials/range_check/witness.rs
+1 −2 kimchi/src/circuits/polynomials/turshi.rs
+1 −2 kimchi/src/circuits/serialization_helper.rs
+23 −20 kimchi/src/linearization.rs
+1 −1 kimchi/src/plonk_sponge.rs
+1 −2 kimchi/src/precomputed_srs.rs
+6 −6 kimchi/src/proof.rs
+8 −6 kimchi/src/prover.rs
+11 −7 kimchi/src/snarky/asm.rs
+5 −3 kimchi/src/snarky/constraint_system.rs
+336 −0 kimchi/src/tests/and.rs
+1 −1 kimchi/src/tests/chunked.rs
+1 −2 kimchi/src/tests/ec.rs
+8 −7 kimchi/src/tests/endomul.rs
+14 −14 kimchi/src/tests/foreign_field_add.rs
+64 −2 kimchi/src/tests/framework.rs
+4 −2 kimchi/src/tests/generic.rs
+1 −2 kimchi/src/tests/lookup.rs
+9 −5 kimchi/src/tests/range_check.rs
+8 −5 kimchi/src/tests/recursion.rs
+9 −5 kimchi/src/tests/serde.rs
+8 −8 kimchi/src/tests/varbasemul.rs
+1 −1 kimchi/src/verifier.rs
+1 −1 kimchi/src/verifier_index.rs
+1 −2 poly-commitment/src/chunked.rs
+7 −7 poly-commitment/src/commitment.rs
+7 −5 poly-commitment/src/evaluation_proof.rs
+5 −3 poly-commitment/src/lib.rs
+8 −10 poly-commitment/src/pairing_proof.rs
+2 −5 poly-commitment/src/srs.rs
+3 −3 poly-commitment/src/tests/batch_15_wires.rs
+25 −13 poly-commitment/src/tests/commitment.rs
+1 −0 poly-commitment/src/tests/mod.rs
+160 −0 poly-commitment/src/tests/serialization.rs
+6 −4 poseidon/export_test_vectors/src/main.rs
+107 −105 poseidon/src/permutation.rs
+4 −2 poseidon/src/poseidon.rs
+4 −2 poseidon/src/sponge.rs
+3 −6 poseidon/src/tests/poseidon_tests.rs
+5 −4 turshi/src/memory.rs
+5 −3 turshi/src/runner.rs
+5 −4 turshi/src/word.rs
+5 −4 utils/Cargo.toml
+5 −3 utils/src/foreign_field.rs
+137 −31 utils/src/serialization.rs

0 comments on commit b267729

Please sign in to comment.