Skip to content

Commit

Permalink
Update proof-systems: external prover randomness & regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
volhovm committed Sep 25, 2024
1 parent 565c147 commit 391f009
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 106 files

0 comments on commit 391f009

Please sign in to comment.