From d68deacf78c2845e55e7fd8888e42571ac0fac97 Mon Sep 17 00:00:00 2001 From: Mikhail Volkhov Date: Wed, 25 Sep 2024 11:14:08 +0100 Subject: [PATCH] Update proof-systems: external prover randomness & regression tests --- .../stubs/src/pasta_fp_plonk_proof.rs | 27 ++++++++++++------- .../stubs/src/pasta_fq_plonk_proof.rs | 11 +++++++- .../kimchi_bindings/wasm/src/plonk_proof.rs | 4 ++- src/lib/crypto/proof-systems | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_proof.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_proof.rs index 700250eeff2..dd15d0e1303 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_proof.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_proof.rs @@ -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::::setup(); - let proof = ProverProof::create_recursive::( + let proof = ProverProof::create_recursive::( &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()) @@ -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::::setup(); - let proof = ProverProof::create_recursive::( + let proof = ProverProof::create_recursive::( &group_map, witness, &runtime_tables, index, prev, None, + &mut rand::rngs::OsRng, ) .map_err(|e| ocaml::Error::Error(e.into()))?; @@ -281,13 +283,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_lookup( let index = ProverIndex::>::create(cs, endo_q, srs.0); let group_map = ::Map::setup(); let public_input = witness[0][0]; - let proof = ProverProof::create_recursive::( + let proof = ProverProof::create_recursive::( &group_map, witness, &runtime_tables, &index, vec![], None, + &mut rand::rngs::OsRng, ) .unwrap(); @@ -444,13 +447,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_foreign_field_mul( let (endo_q, _endo_r) = endos::(); let index = ProverIndex::>::create(cs, endo_q, srs.0); let group_map = ::Map::setup(); - let proof = ProverProof::create_recursive::( + let proof = ProverProof::create_recursive::( &group_map, witness, &[], &index, vec![], None, + &mut rand::rngs::OsRng, ) .unwrap(); ( @@ -510,13 +514,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_range_check( let (endo_q, _endo_r) = endos::(); let index = ProverIndex::>::create(cs, endo_q, srs.0); let group_map = ::Map::setup(); - let proof = ProverProof::create_recursive::( + let proof = ProverProof::create_recursive::( &group_map, witness, &[], &index, vec![], None, + &mut rand::rngs::OsRng, ) .unwrap(); ( @@ -582,13 +587,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_range_check0( let (endo_q, _endo_r) = endos::(); let index = ProverIndex::>::create(cs, endo_q, srs.0); let group_map = ::Map::setup(); - let proof = ProverProof::create_recursive::( + let proof = ProverProof::create_recursive::( &group_map, witness, &[], &index, vec![], None, + &mut rand::rngs::OsRng, ) .unwrap(); ( @@ -707,13 +713,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_ffadd( let index = ProverIndex::>::create(cs, endo_q, srs.0); let group_map = ::Map::setup(); let public_input = witness[0][0]; - let proof = ProverProof::create_recursive::( + let proof = ProverProof::create_recursive::( &group_map, witness, &[], &index, vec![], None, + &mut rand::rngs::OsRng, ) .unwrap(); ( @@ -795,13 +802,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_xor( let index = ProverIndex::>::create(cs, endo_q, srs.0); let group_map = ::Map::setup(); let public_input = (witness[0][0], witness[0][1]); - let proof = ProverProof::create_recursive::( + let proof = ProverProof::create_recursive::( &group_map, witness, &[], &index, vec![], None, + &mut rand::rngs::OsRng, ) .unwrap(); ( @@ -888,13 +896,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_rot( let index = ProverIndex::>::create(cs, endo_q, srs.0); let group_map = ::Map::setup(); let public_input = (witness[0][0], witness[0][1]); - let proof = ProverProof::create_recursive::( + let proof = ProverProof::create_recursive::( &group_map, witness, &[], &index, vec![], None, + &mut rand::rngs::OsRng, ) .unwrap(); ( diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_proof.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_proof.rs index 9cf95b978e1..607d28691ae 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_proof.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_proof.rs @@ -87,7 +87,16 @@ pub fn caml_pasta_fq_plonk_proof_create( let proof = ProverProof::create_recursive::< DefaultFqSponge, DefaultFrSponge, - >(&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()) }) diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/plonk_proof.rs b/src/lib/crypto/kimchi_bindings/wasm/src/plonk_proof.rs index d3a3498bd66..55e4250ba68 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/plonk_proof.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/plonk_proof.rs @@ -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) }); diff --git a/src/lib/crypto/proof-systems b/src/lib/crypto/proof-systems index 4b11acf9e29..eb5357a69a9 160000 --- a/src/lib/crypto/proof-systems +++ b/src/lib/crypto/proof-systems @@ -1 +1 @@ -Subproject commit 4b11acf9e293edee3758f1e5e3a90000cfb763c0 +Subproject commit eb5357a69a93b90e79a75666bf61472ab2e1f625