From f93c3ad45fe5f2419a533994efaccba371589a91 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 21 Sep 2023 11:44:37 +0200 Subject: [PATCH 01/15] Bump up snarkyjs after artefacts generation --- src/lib/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index 8314d7b3540..21bea447384 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit 8314d7b3540e004ec51dc6ba77e1e6b1d0c76dc6 +Subproject commit 21bea447384bcf58137c999963ce9aa33462a884 From 01226913bbaa99e9883eb3967337c2bc2be0453f Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 21 Sep 2023 11:46:40 +0200 Subject: [PATCH 02/15] Bump up snarkyjs --- src/lib/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index 21bea447384..fb58d4df694 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit 21bea447384bcf58137c999963ce9aa33462a884 +Subproject commit fb58d4df694bd5a214911d0d662bf12e9e5d2e61 From 43c86daf5b6840c6542f96d6af9b071ee145557b Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 21 Sep 2023 12:06:34 +0200 Subject: [PATCH 03/15] Bump up proof-systems to develop --- src/lib/crypto/proof-systems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/crypto/proof-systems b/src/lib/crypto/proof-systems index caddeeb6549..33fd70404c8 160000 --- a/src/lib/crypto/proof-systems +++ b/src/lib/crypto/proof-systems @@ -1 +1 @@ -Subproject commit caddeeb65499fed5a1035664c5001a1e88ca27ae +Subproject commit 33fd70404c8ca997792b9af1202c7f54e33264ff From e556d984a898101058402ad69c693ce320b31282 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 22 Sep 2023 15:24:54 +0200 Subject: [PATCH 04/15] expr_linearization does not use zk_rows --- src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs | 2 +- .../crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs | 2 +- .../kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs | 2 +- .../kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs b/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs index ed18df9de96..6e8bfb83818 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs @@ -34,7 +34,7 @@ pub fn linearization_strings( }) }; let evaluated_cols = linearization_columns::(features.as_ref()); - let (linearization, _powers_of_alpha) = constraints_expr::(features.as_ref(), true, 3); + let (linearization, _powers_of_alpha) = constraints_expr::(features.as_ref(), true); let Linearization { constant_term, diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs index f455e7d859e..5f3d8b4c209 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs @@ -164,7 +164,7 @@ pub fn caml_pasta_fp_plonk_index_read( let mut t = ProverIndex::::deserialize(&mut rmp_serde::Deserializer::new(r))?; t.srs = srs.clone(); - let (linearization, powers_of_alpha) = expr_linearization(Some(&t.cs.feature_flags), true, 3); + let (linearization, powers_of_alpha) = expr_linearization(Some(&t.cs.feature_flags), true); t.linearization = linearization; t.powers_of_alpha = powers_of_alpha; diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs index 4248de2ec13..5e2e03238be 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs @@ -108,7 +108,7 @@ impl From for VerifierIndex { }; // TODO dummy_lookup_value ? - let (linearization, powers_of_alpha) = expr_linearization(Some(&feature_flags), true, 3); + let (linearization, powers_of_alpha) = expr_linearization(Some(&feature_flags), true); VerifierIndex:: { domain, diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs index 08cc264767c..11ed3e36351 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs @@ -108,7 +108,7 @@ impl From for VerifierIndex { }; // TODO dummy_lookup_value ? - let (linearization, powers_of_alpha) = expr_linearization(Some(&feature_flags), true, 3); + let (linearization, powers_of_alpha) = expr_linearization(Some(&feature_flags), true); VerifierIndex:: { domain, From a47946b5d511f5c251d63ceac6fe159031e898ca Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 22 Sep 2023 15:29:34 +0200 Subject: [PATCH 05/15] Add type parameter OpeningProof --- .../kimchi_bindings/stubs/src/oracles.rs | 9 +++--- .../stubs/src/pasta_fp_plonk_index.rs | 9 ++++-- .../stubs/src/pasta_fp_plonk_proof.rs | 32 ++++++++++++------- .../src/pasta_fp_plonk_verifier_index.rs | 29 ++++++++++------- .../stubs/src/pasta_fq_plonk_index.rs | 11 ++++--- .../stubs/src/pasta_fq_plonk_proof.rs | 11 ++++--- .../src/pasta_fq_plonk_verifier_index.rs | 30 +++++++++-------- 7 files changed, 79 insertions(+), 52 deletions(-) diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs b/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs index 238ebabff4c..cb6efeeeb1b 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs @@ -14,6 +14,7 @@ use mina_poseidon::{ }; use paste::paste; use poly_commitment::commitment::{caml::CamlPolyComm, shift_scalar, PolyComm}; +use poly_commitment::evaluation_proof::OpeningProof; #[derive(ocaml::IntoValue, ocaml::FromValue, ocaml_gen::Struct)] pub struct CamlOracles { @@ -34,7 +35,7 @@ macro_rules! impl_oracles { index: $index, proof: CamlProofWithPublic<$CamlG, $CamlF>, ) -> Result, ocaml::Error> { - let index: VerifierIndex<$G> = index.into(); + let index: VerifierIndex<$G, OpeningProof<$G>> = index.into(); let lgr_comm: Vec> = lgr_comm .into_iter() @@ -65,7 +66,7 @@ macro_rules! impl_oracles { .commitment }; - let (proof, public_input): (ProverProof<$G>, Vec<$F>) = proof.into(); + let (proof, public_input): (ProverProof<$G, OpeningProof<$G>>, Vec<$F>) = proof.into(); let oracles_result = proof.oracles::< @@ -110,7 +111,7 @@ macro_rules! impl_oracles { public_evals: None, }; - let index: VerifierIndex<$G> = index.into(); + let index: VerifierIndex<$G, OpeningProof<$G>> = index.into(); let lgr_comm: Vec> = lgr_comm .into_iter() @@ -141,7 +142,7 @@ macro_rules! impl_oracles { .commitment }; - let (proof, public_input): (ProverProof<$G>, Vec<$F>) = proof.into(); + let (proof, public_input): (ProverProof<$G, OpeningProof<$G>>, Vec<$F>) = proof.into(); let oracles_result = proof.oracles::< diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs index 5f3d8b4c209..c186a1132d1 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs @@ -9,6 +9,7 @@ use kimchi::circuits::{constraints::ConstraintSystem, gate::CircuitGate}; use kimchi::{linearization::expr_linearization, prover_index::ProverIndex}; use mina_curves::pasta::{Fp, Pallas, Vesta, VestaParameters}; use mina_poseidon::{constants::PlonkSpongeConstantsKimchi, sponge::DefaultFqSponge}; +use poly_commitment::evaluation_proof::OpeningProof; use serde::{Deserialize, Serialize}; use std::{ fs::{File, OpenOptions}, @@ -17,7 +18,7 @@ use std::{ /// Boxed so that we don't store large proving indexes in the OCaml heap. #[derive(ocaml_gen::CustomType)] -pub struct CamlPastaFpPlonkIndex(pub Box>); +pub struct CamlPastaFpPlonkIndex(pub Box>>); pub type CamlPastaFpPlonkIndexPtr<'a> = ocaml::Pointer<'a, CamlPastaFpPlonkIndex>; extern "C" fn caml_pasta_fp_plonk_index_finalize(v: ocaml::Raw) { @@ -98,7 +99,7 @@ pub fn caml_pasta_fp_plonk_index_create( } // create index - let mut index = ProverIndex::::create(cs, endo_q, srs.clone()); + let mut index = ProverIndex::>::create(cs, endo_q, srs.clone()); // Compute and cache the verifier index digest index.compute_verifier_index_digest::>(); @@ -161,7 +162,9 @@ pub fn caml_pasta_fp_plonk_index_read( } // deserialize the index - let mut t = ProverIndex::::deserialize(&mut rmp_serde::Deserializer::new(r))?; + let mut t = ProverIndex::>::deserialize( + &mut rmp_serde::Deserializer::new(r), + )?; t.srs = srs.clone(); let (linearization, powers_of_alpha) = expr_linearization(Some(&t.cs.feature_flags), true); 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 96d47cf2425..a3595560238 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 @@ -75,7 +75,7 @@ pub fn caml_pasta_fp_plonk_proof_create( let witness: [Vec<_>; COLUMNS] = witness .try_into() .map_err(|_| ocaml::Error::Message("the witness should be a column of 15 vectors"))?; - let index: &ProverIndex = &index.as_ref().0; + let index: &ProverIndex> = &index.as_ref().0; let runtime_tables: Vec> = runtime_tables.into_iter().map(Into::into).collect(); @@ -143,7 +143,7 @@ pub fn caml_pasta_fp_plonk_proof_create_and_verify( let witness: [Vec<_>; COLUMNS] = witness .try_into() .map_err(|_| ocaml::Error::Message("the witness should be a column of 15 vectors"))?; - let index: &ProverIndex = &index.as_ref().0; + let index: &ProverIndex> = &index.as_ref().0; let runtime_tables: Vec> = runtime_tables.into_iter().map(Into::into).collect(); @@ -171,7 +171,12 @@ pub fn caml_pasta_fp_plonk_proof_create_and_verify( let verifier_index = index.verifier_index(); // Verify proof - verify::(&group_map, &verifier_index, &proof, &public_input)?; + verify::>( + &group_map, + &verifier_index, + &proof, + &public_input, + )?; Ok((proof, public_input).into()) }) @@ -261,7 +266,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_lookup( ptr.add_lagrange_basis(cs.domain.d1); let (endo_q, _endo_r) = endos::(); - let index = ProverIndex::::create(cs, endo_q, srs.0); + 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::( @@ -428,7 +433,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_foreign_field_mul( ptr.add_lagrange_basis(cs.domain.d1); let (endo_q, _endo_r) = endos::(); - let index = ProverIndex::::create(cs, endo_q, srs.0); + let index = ProverIndex::>::create(cs, endo_q, srs.0); let group_map = ::Map::setup(); let proof = ProverProof::create_recursive::( &group_map, @@ -497,7 +502,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_range_check( ptr.add_lagrange_basis(cs.domain.d1); let (endo_q, _endo_r) = endos::(); - let index = ProverIndex::::create(cs, endo_q, srs.0); + let index = ProverIndex::>::create(cs, endo_q, srs.0); let group_map = ::Map::setup(); let proof = ProverProof::create_recursive::( &group_map, @@ -572,7 +577,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_range_check0( ptr.add_lagrange_basis(cs.domain.d1); let (endo_q, _endo_r) = endos::(); - let index = ProverIndex::::create(cs, endo_q, srs.0); + let index = ProverIndex::>::create(cs, endo_q, srs.0); let group_map = ::Map::setup(); let proof = ProverProof::create_recursive::( &group_map, @@ -697,7 +702,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_ffadd( ptr.add_lagrange_basis(cs.domain.d1); let (endo_q, _endo_r) = endos::(); - let index = ProverIndex::::create(cs, endo_q, srs.0); + 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::( @@ -786,7 +791,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_xor( ptr.add_lagrange_basis(cs.domain.d1); let (endo_q, _endo_r) = endos::(); - let index = ProverIndex::::create(cs, endo_q, srs.0); + 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::( @@ -880,7 +885,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_rot( ptr.add_lagrange_basis(cs.domain.d1); let (endo_q, _endo_r) = endos::(); - let index = ProverIndex::::create(cs, endo_q, srs.0); + 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::( @@ -919,6 +924,7 @@ pub fn caml_pasta_fp_plonk_proof_verify( Vesta, DefaultFqSponge, DefaultFrSponge, + OpeningProof, >(&group_map, &[context]) .is_ok() } @@ -933,8 +939,9 @@ pub fn caml_pasta_fp_plonk_proof_batch_verify( .into_iter() .zip(proofs.into_iter()) .map(|(caml_index, caml_proof)| { - let verifier_index: VerifierIndex = caml_index.into(); - let (proof, public_input): (ProverProof<_>, Vec<_>) = caml_proof.into(); + let verifier_index: VerifierIndex> = caml_index.into(); + let (proof, public_input): (ProverProof>, Vec<_>) = + caml_proof.into(); (verifier_index, proof, public_input) }) .collect(); @@ -952,6 +959,7 @@ pub fn caml_pasta_fp_plonk_proof_batch_verify( Vesta, DefaultFqSponge, DefaultFrSponge, + OpeningProof, >(&group_map, &ts_ref) .is_ok() } diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs index 5e2e03238be..4b33d23df3c 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs @@ -15,6 +15,7 @@ use kimchi::circuits::wires::{COLUMNS, PERMUTS}; use kimchi::{linearization::expr_linearization, verifier_index::VerifierIndex}; use mina_curves::pasta::{Fp, Pallas, Vesta}; use poly_commitment::commitment::caml::CamlPolyComm; +use poly_commitment::evaluation_proof::OpeningProof; use poly_commitment::{commitment::PolyComm, srs::SRS}; use std::convert::TryInto; use std::path::Path; @@ -22,8 +23,8 @@ use std::path::Path; pub type CamlPastaFpPlonkVerifierIndex = CamlPlonkVerifierIndex>; -impl From> for CamlPastaFpPlonkVerifierIndex { - fn from(vi: VerifierIndex) -> Self { +impl From>> for CamlPastaFpPlonkVerifierIndex { + fn from(vi: VerifierIndex>) -> Self { Self { domain: CamlPlonkDomain { log_size_of_group: vi.domain.log_size_of_group as isize, @@ -62,7 +63,7 @@ impl From> for CamlPastaFpPlonkVerifierIndex { } // TODO: This should really be a TryFrom or TryInto -impl From for VerifierIndex { +impl From for VerifierIndex> { fn from(index: CamlPastaFpPlonkVerifierIndex) -> Self { let evals = index.evals; let shifts = index.shifts; @@ -110,7 +111,7 @@ impl From for VerifierIndex { // TODO dummy_lookup_value ? let (linearization, powers_of_alpha) = expr_linearization(Some(&feature_flags), true); - VerifierIndex:: { + VerifierIndex::> { domain, max_poly_size: index.max_poly_size as usize, public: index.public as usize, @@ -165,16 +166,20 @@ pub fn read_raw( offset: Option, srs: CamlFpSrs, path: String, -) -> Result, ocaml::Error> { +) -> Result>, ocaml::Error> { let path = Path::new(&path); let (endo_q, _endo_r) = poly_commitment::srs::endos::(); - VerifierIndex::::from_file(Some(srs.0), path, offset.map(|x| x as u64), endo_q).map_err( - |_e| { - ocaml::Error::invalid_argument("caml_pasta_fp_plonk_verifier_index_raw_read") - .err() - .unwrap() - }, + VerifierIndex::>::from_file( + srs.0, + path, + offset.map(|x| x as u64), + endo_q, ) + .map_err(|_e| { + ocaml::Error::invalid_argument("caml_pasta_fp_plonk_verifier_index_raw_read") + .err() + .unwrap() + }) } // @@ -199,7 +204,7 @@ pub fn caml_pasta_fp_plonk_verifier_index_write( index: CamlPastaFpPlonkVerifierIndex, path: String, ) -> Result<(), ocaml::Error> { - let index: VerifierIndex = index.into(); + let index: VerifierIndex> = index.into(); let path = Path::new(&path); index.to_file(path, append).map_err(|_e| { ocaml::Error::invalid_argument("caml_pasta_fp_plonk_verifier_index_raw_read") diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_index.rs index c5ad6d2ed4f..4c2ba18d6f0 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_index.rs @@ -9,6 +9,7 @@ use kimchi::circuits::{constraints::ConstraintSystem, gate::CircuitGate}; use kimchi::{linearization::expr_linearization, prover_index::ProverIndex}; use mina_curves::pasta::{Fq, Pallas, PallasParameters, Vesta}; use mina_poseidon::{constants::PlonkSpongeConstantsKimchi, sponge::DefaultFqSponge}; +use poly_commitment::evaluation_proof::OpeningProof; use serde::{Deserialize, Serialize}; use std::{ fs::{File, OpenOptions}, @@ -17,7 +18,7 @@ use std::{ /// Boxed so that we don't store large proving indexes in the OCaml heap. #[derive(ocaml_gen::CustomType)] -pub struct CamlPastaFqPlonkIndex(pub Box>); +pub struct CamlPastaFqPlonkIndex(pub Box>>); pub type CamlPastaFqPlonkIndexPtr<'a> = ocaml::Pointer<'a, CamlPastaFqPlonkIndex>; extern "C" fn caml_pasta_fq_plonk_index_finalize(v: ocaml::Raw) { @@ -98,7 +99,7 @@ pub fn caml_pasta_fq_plonk_index_create( } // create index - let mut index = ProverIndex::::create(cs, endo_q, srs.clone()); + let mut index = ProverIndex::>::create(cs, endo_q, srs.clone()); // Compute and cache the verifier index digest index.compute_verifier_index_digest::>(); @@ -161,10 +162,12 @@ pub fn caml_pasta_fq_plonk_index_read( } // deserialize the index - let mut t = ProverIndex::::deserialize(&mut rmp_serde::Deserializer::new(r))?; + let mut t = ProverIndex::>::deserialize( + &mut rmp_serde::Deserializer::new(r), + )?; t.srs = srs.clone(); - let (linearization, powers_of_alpha) = expr_linearization(Some(&t.cs.feature_flags), true, 3); + let (linearization, powers_of_alpha) = expr_linearization(Some(&t.cs.feature_flags), true); t.linearization = linearization; t.powers_of_alpha = powers_of_alpha; 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 2ddb370f49c..0f3f2ebd9ff 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 @@ -70,7 +70,7 @@ pub fn caml_pasta_fq_plonk_proof_create( let witness: [Vec<_>; COLUMNS] = witness .try_into() .expect("the witness should be a column of 15 vectors"); - let index: &ProverIndex = &index.as_ref().0; + let index: &ProverIndex> = &index.as_ref().0; let runtime_tables: Vec> = runtime_tables.into_iter().map(Into::into).collect(); @@ -115,6 +115,7 @@ pub fn caml_pasta_fq_plonk_proof_verify( Pallas, DefaultFqSponge, DefaultFrSponge, + OpeningProof, >(&group_map, &[context]) .is_ok() } @@ -129,12 +130,13 @@ pub fn caml_pasta_fq_plonk_proof_batch_verify( .into_iter() .zip(proofs.into_iter()) .map(|(caml_index, caml_proof)| { - let verifier_index: VerifierIndex = caml_index.into(); - let (proof, public_input): (ProverProof<_>, Vec<_>) = caml_proof.into(); + let verifier_index: VerifierIndex> = caml_index.into(); + let (proof, public_input): (ProverProof>, Vec<_>) = + caml_proof.into(); (verifier_index, proof, public_input) }) .collect(); - let ts_ref: Vec<_> = ts + let ts_ref: Vec>> = ts .iter() .map(|(verifier_index, proof, public_input)| Context { verifier_index, @@ -148,6 +150,7 @@ pub fn caml_pasta_fq_plonk_proof_batch_verify( Pallas, DefaultFqSponge, DefaultFrSponge, + OpeningProof, >(&group_map, &ts_ref) .is_ok() } diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs index 11ed3e36351..a6ef0e6cd5e 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs @@ -14,7 +14,7 @@ use kimchi::circuits::polynomials::permutation::{permutation_vanishing_polynomia use kimchi::circuits::wires::{COLUMNS, PERMUTS}; use kimchi::{linearization::expr_linearization, verifier_index::VerifierIndex}; use mina_curves::pasta::{Fq, Pallas, Vesta}; -use poly_commitment::commitment::caml::CamlPolyComm; +use poly_commitment::{commitment::caml::CamlPolyComm, evaluation_proof::OpeningProof}; use poly_commitment::{commitment::PolyComm, srs::SRS}; use std::convert::TryInto; use std::path::Path; @@ -22,8 +22,8 @@ use std::path::Path; pub type CamlPastaFqPlonkVerifierIndex = CamlPlonkVerifierIndex>; -impl From> for CamlPastaFqPlonkVerifierIndex { - fn from(vi: VerifierIndex) -> Self { +impl From>> for CamlPastaFqPlonkVerifierIndex { + fn from(vi: VerifierIndex>) -> Self { Self { domain: CamlPlonkDomain { log_size_of_group: vi.domain.log_size_of_group as isize, @@ -62,7 +62,7 @@ impl From> for CamlPastaFqPlonkVerifierIndex { } // TODO: This should really be a TryFrom or TryInto -impl From for VerifierIndex { +impl From for VerifierIndex> { fn from(index: CamlPastaFqPlonkVerifierIndex) -> Self { let evals = index.evals; let shifts = index.shifts; @@ -110,7 +110,7 @@ impl From for VerifierIndex { // TODO dummy_lookup_value ? let (linearization, powers_of_alpha) = expr_linearization(Some(&feature_flags), true); - VerifierIndex:: { + VerifierIndex::> { domain, max_poly_size: index.max_poly_size as usize, public: index.public as usize, @@ -165,16 +165,20 @@ pub fn read_raw( offset: Option, srs: CamlFqSrs, path: String, -) -> Result, ocaml::Error> { +) -> Result>, ocaml::Error> { let path = Path::new(&path); let (endo_q, _endo_r) = poly_commitment::srs::endos::(); - VerifierIndex::::from_file(Some(srs.0), path, offset.map(|x| x as u64), endo_q).map_err( - |_e| { - ocaml::Error::invalid_argument("caml_pasta_fq_plonk_verifier_index_raw_read") - .err() - .unwrap() - }, + VerifierIndex::>::from_file( + srs.0, + path, + offset.map(|x| x as u64), + endo_q, ) + .map_err(|_e| { + ocaml::Error::invalid_argument("caml_pasta_fq_plonk_verifier_index_raw_read") + .err() + .unwrap() + }) } // @@ -199,7 +203,7 @@ pub fn caml_pasta_fq_plonk_verifier_index_write( index: CamlPastaFqPlonkVerifierIndex, path: String, ) -> Result<(), ocaml::Error> { - let index: VerifierIndex = index.into(); + let index: VerifierIndex> = index.into(); let path = Path::new(&path); index.to_file(path, append).map_err(|_e| { ocaml::Error::invalid_argument("caml_pasta_fq_plonk_verifier_index_raw_read") From 51812b2c38077d57b657c235f6a93868fa87a16b Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 22 Sep 2023 15:30:23 +0200 Subject: [PATCH 06/15] Import SRS trait and update SRS related code to match new structure --- src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs | 1 + .../stubs/src/pasta_fp_plonk_verifier_index.rs | 11 +++-------- .../stubs/src/pasta_fq_plonk_verifier_index.rs | 11 +++-------- src/lib/crypto/kimchi_bindings/stubs/src/srs.rs | 1 + 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs b/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs index cb6efeeeb1b..bbf0fa8aba4 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs @@ -15,6 +15,7 @@ use mina_poseidon::{ use paste::paste; use poly_commitment::commitment::{caml::CamlPolyComm, shift_scalar, PolyComm}; use poly_commitment::evaluation_proof::OpeningProof; +use poly_commitment::SRS; #[derive(ocaml::IntoValue, ocaml::FromValue, ocaml_gen::Struct)] pub struct CamlOracles { diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs index 4b33d23df3c..1ad52d423e1 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs @@ -19,6 +19,7 @@ use poly_commitment::evaluation_proof::OpeningProof; use poly_commitment::{commitment::PolyComm, srs::SRS}; use std::convert::TryInto; use std::path::Path; +use std::sync::Arc; pub type CamlPastaFpPlonkVerifierIndex = CamlPlonkVerifierIndex>; @@ -33,7 +34,7 @@ impl From>> for CamlPastaFpPlonkVerifie max_poly_size: vi.max_poly_size as isize, public: vi.public as isize, prev_challenges: vi.prev_challenges as isize, - srs: CamlFpSrs(vi.srs.get().expect("have an srs").clone()), + srs: CamlFpSrs(vi.srs.clone()), evals: CamlPlonkVerificationEvals { sigma_comm: vi.sigma_comm.to_vec().iter().map(Into::into).collect(), coefficients_comm: vi @@ -117,14 +118,8 @@ impl From for VerifierIndex>; @@ -32,7 +33,7 @@ impl From>> for CamlPastaFqPlonkVerif max_poly_size: vi.max_poly_size as isize, public: vi.public as isize, prev_challenges: vi.prev_challenges as isize, - srs: CamlFqSrs(vi.srs.get().expect("have an srs").clone()), + srs: CamlFqSrs(vi.srs.clone()), evals: CamlPlonkVerificationEvals { sigma_comm: vi.sigma_comm.to_vec().iter().map(Into::into).collect(), coefficients_comm: vi @@ -116,14 +117,8 @@ impl From for VerifierIndex Date: Fri, 22 Sep 2023 15:31:51 +0200 Subject: [PATCH 07/15] Reorganize and fix VerifierIndex construction --- .../src/pasta_fp_plonk_verifier_index.rs | 22 +++++++------------ .../src/pasta_fq_plonk_verifier_index.rs | 22 +++++++------------ 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs index 1ad52d423e1..10e1edb0cfe 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs @@ -10,7 +10,7 @@ use ark_poly::{EvaluationDomain, Radix2EvaluationDomain as Domain}; use kimchi::circuits::constraints::FeatureFlags; use kimchi::circuits::lookup::lookups::{LookupFeatures, LookupPatterns}; use kimchi::circuits::polynomials::permutation::Shifts; -use kimchi::circuits::polynomials::permutation::{permutation_vanishing_polynomial, zk_w}; +use kimchi::circuits::polynomials::permutation::{zk_polynomial, zk_w3}; use kimchi::circuits::wires::{COLUMNS, PERMUTS}; use kimchi::{linearization::expr_linearization, verifier_index::VerifierIndex}; use mina_curves::pasta::{Fp, Pallas, Vesta}; @@ -115,44 +115,38 @@ impl From for VerifierIndex> { domain, max_poly_size: index.max_poly_size as usize, + srs: { Arc::clone(&index.srs.0) }, public: index.public as usize, prev_challenges: index.prev_challenges as usize, - powers_of_alpha, - srs: { Arc::clone(&index.srs.0) }, - zk_rows: 3, sigma_comm, coefficients_comm, generic_comm: evals.generic_comm.into(), - psm_comm: evals.psm_comm.into(), - complete_add_comm: evals.complete_add_comm.into(), mul_comm: evals.mul_comm.into(), emul_comm: evals.emul_comm.into(), endomul_scalar_comm: evals.endomul_scalar_comm.into(), - - xor_comm: evals.xor_comm.map(Into::into), range_check0_comm: evals.range_check0_comm.map(Into::into), range_check1_comm: evals.range_check1_comm.map(Into::into), + xor_comm: evals.xor_comm.map(Into::into), + rot_comm: evals.rot_comm.map(Into::into), foreign_field_add_comm: evals.foreign_field_add_comm.map(Into::into), foreign_field_mul_comm: evals.foreign_field_mul_comm.map(Into::into), - rot_comm: evals.rot_comm.map(Into::into), - shift, - permutation_vanishing_polynomial_m: { + zkpm: { let res = once_cell::sync::OnceCell::new(); - res.set(permutation_vanishing_polynomial(domain, 3)).unwrap(); + res.set(zk_polynomial(domain)).unwrap(); res }, w: { let res = once_cell::sync::OnceCell::new(); - res.set(zk_w(domain, 3)).unwrap(); + res.set(zk_w3(domain)).unwrap(); res }, endo: endo_q, - lookup_index: index.lookup_index.map(Into::into), linearization, + powers_of_alpha, } } } diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs index 1016f96048a..cac04cb8861 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs @@ -10,7 +10,7 @@ use ark_poly::{EvaluationDomain, Radix2EvaluationDomain as Domain}; use kimchi::circuits::constraints::FeatureFlags; use kimchi::circuits::lookup::lookups::{LookupFeatures, LookupPatterns}; use kimchi::circuits::polynomials::permutation::Shifts; -use kimchi::circuits::polynomials::permutation::{permutation_vanishing_polynomial, zk_w}; +use kimchi::circuits::polynomials::permutation::{zk_polynomial, zk_w3}; use kimchi::circuits::wires::{COLUMNS, PERMUTS}; use kimchi::{linearization::expr_linearization, verifier_index::VerifierIndex}; use mina_curves::pasta::{Fq, Pallas, Vesta}; @@ -114,44 +114,38 @@ impl From for VerifierIndex> { domain, max_poly_size: index.max_poly_size as usize, + srs: { Arc::clone(&index.srs.0) }, public: index.public as usize, prev_challenges: index.prev_challenges as usize, - powers_of_alpha, - srs: { Arc::clone(&index.srs.0) }, - zk_rows: 3, sigma_comm, coefficients_comm, generic_comm: evals.generic_comm.into(), - psm_comm: evals.psm_comm.into(), - complete_add_comm: evals.complete_add_comm.into(), mul_comm: evals.mul_comm.into(), emul_comm: evals.emul_comm.into(), endomul_scalar_comm: evals.endomul_scalar_comm.into(), - - xor_comm: evals.xor_comm.map(Into::into), range_check0_comm: evals.range_check0_comm.map(Into::into), range_check1_comm: evals.range_check1_comm.map(Into::into), + xor_comm: evals.xor_comm.map(Into::into), + rot_comm: evals.rot_comm.map(Into::into), foreign_field_add_comm: evals.foreign_field_add_comm.map(Into::into), foreign_field_mul_comm: evals.foreign_field_mul_comm.map(Into::into), - rot_comm: evals.rot_comm.map(Into::into), - shift, - permutation_vanishing_polynomial_m: { + zkpm: { let res = once_cell::sync::OnceCell::new(); - res.set(permutation_vanishing_polynomial(domain, 3)).unwrap(); + res.set(zk_polynomial(domain)).unwrap(); res }, w: { let res = once_cell::sync::OnceCell::new(); - res.set(zk_w(domain, 3)).unwrap(); + res.set(zk_w3(domain)).unwrap(); res }, endo: endo_q, - lookup_index: index.lookup_index.map(Into::into), linearization, + powers_of_alpha, } } } From 1276cd1da004ed48e31e988d8cfad85139e517f9 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 22 Sep 2023 15:32:52 +0200 Subject: [PATCH 08/15] Run cargo fmt --- src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs b/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs index bbf0fa8aba4..db3acc979a6 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs @@ -27,7 +27,6 @@ pub struct CamlOracles { macro_rules! impl_oracles { ($CamlF: ty, $F: ty, $CamlG: ty, $G: ty, $index: ty, $curve_params: ty) => { - paste! { #[ocaml_gen::func] #[ocaml::func] From fd01676921086898b7a0539c0e76218881b16764 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 22 Sep 2023 15:41:18 +0200 Subject: [PATCH 09/15] Context: add the correct type parameters --- .../crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_proof.rs | 2 +- .../crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_proof.rs | 2 +- 2 files changed, 2 insertions(+), 2 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 a3595560238..06686bdb72b 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 @@ -945,7 +945,7 @@ pub fn caml_pasta_fp_plonk_proof_batch_verify( (verifier_index, proof, public_input) }) .collect(); - let ts_ref: Vec<_> = ts + let ts_ref: Vec>> = ts .iter() .map(|(verifier_index, proof, public_input)| Context { verifier_index, 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 0f3f2ebd9ff..b54071f636d 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 @@ -136,7 +136,7 @@ pub fn caml_pasta_fq_plonk_proof_batch_verify( (verifier_index, proof, public_input) }) .collect(); - let ts_ref: Vec>> = ts + let ts_ref: Vec>> = ts .iter() .map(|(verifier_index, proof, public_input)| Context { verifier_index, From dcb7d9c309e12dcb9994a14b447ff0896e91440d Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 22 Sep 2023 18:15:13 +0200 Subject: [PATCH 10/15] Bump up snarkyjs --- src/lib/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index fb58d4df694..aacde789337 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit fb58d4df694bd5a214911d0d662bf12e9e5d2e61 +Subproject commit aacde789337b91d04134f386cdab39c8b35b635b From 434dbb137a70cb1caeed4b3e20781b1c6914e5f0 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 3 Oct 2023 12:31:11 -0700 Subject: [PATCH 11/15] Remove ppx_dhall_type [develop] --- src/dune-project | 1 - src/lib/currency/currency.ml | 13 +- src/lib/currency/dune | 1 - src/lib/currency/intf.ml | 12 -- src/lib/mina_numbers/dune | 1 - src/lib/mina_numbers/global_slot.ml | 2 - src/lib/mina_numbers/global_slot_intf.ml | 2 - src/lib/mina_numbers/global_slot_span.ml | 2 - src/lib/mina_numbers/intf.ml | 3 - src/lib/mina_numbers/nat.ml | 3 - src/lib/ppx_dhall_type/deriving.ml | 160 ------------------ src/lib/ppx_dhall_type/dhall_type.ml | 48 ------ src/lib/ppx_dhall_type/dune | 8 - src/lib/runtime_config/dune | 3 +- src/lib/runtime_config/runtime_config.ml | 41 ++--- src/lib/unsigned_extended/dune | 1 - .../unsigned_extended/unsigned_extended.ml | 2 - .../unsigned_extended/unsigned_extended.mli | 2 - src/nonconsensus/currency/dune | 1 - src/nonconsensus/mina_numbers/dune | 1 - src/nonconsensus/unsigned_extended/dune | 1 - 21 files changed, 20 insertions(+), 288 deletions(-) delete mode 100644 src/lib/ppx_dhall_type/deriving.ml delete mode 100644 src/lib/ppx_dhall_type/dhall_type.ml delete mode 100644 src/lib/ppx_dhall_type/dune diff --git a/src/dune-project b/src/dune-project index 5969c24462c..e385e317699 100644 --- a/src/dune-project +++ b/src/dune-project @@ -147,7 +147,6 @@ (package (name pipe_lib)) (package (name pokolog)) (package (name ppx_annot)) -(package (name ppx_dhall_type)) (package (name ppx_mina)) (package (name ppx_register_event)) (package (name ppx_representatives)) diff --git a/src/lib/currency/currency.ml b/src/lib/currency/currency.ml index 39fa21fe55b..9e3155b4915 100644 --- a/src/lib/currency/currency.ml +++ b/src/lib/currency/currency.ml @@ -95,9 +95,6 @@ module Make_str (A : Wire_types.Concrete) = struct type t = Unsigned.t [@@deriving sexp, compare, hash] - (* can't be automatically derived *) - let dhall_type = Ppx_dhall_type.Dhall_type.Text - [%%define_locally Unsigned.(to_uint64, of_uint64, of_int, to_int, of_string, to_string)] @@ -945,7 +942,7 @@ module Make_str (A : Wire_types.Concrete) = struct type t = Unsigned_extended.UInt64.Stable.V1.t [@@deriving sexp, compare, hash, equal] - [%%define_from_scope to_yojson, of_yojson, dhall_type] + [%%define_from_scope to_yojson, of_yojson] let to_latest = Fn.id end @@ -976,9 +973,6 @@ module Make_str (A : Wire_types.Concrete) = struct [@@@with_all_version_tags] type t = A.t [@@deriving sexp, compare, hash, equal, yojson] - - (* not automatically derived *) - val dhall_type : Ppx_dhall_type.Dhall_type.t end end] @@ -1092,7 +1086,7 @@ module Make_str (A : Wire_types.Concrete) = struct type t = Unsigned_extended.UInt64.Stable.V1.t [@@deriving sexp, compare, hash, equal, yojson] - [%%define_from_scope to_yojson, of_yojson, dhall_type] + [%%define_from_scope to_yojson, of_yojson] let to_latest = Fn.id end @@ -1137,9 +1131,6 @@ module Make_str (A : Wire_types.Concrete) = struct [@@deriving sexp, compare, equal, hash, yojson] let to_latest = Fn.id - - (* can't be automatically derived *) - let dhall_type = Ppx_dhall_type.Dhall_type.Text end end] diff --git a/src/lib/currency/dune b/src/lib/currency/dune index aee5571a5b1..f97924689c1 100644 --- a/src/lib/currency/dune +++ b/src/lib/currency/dune @@ -20,7 +20,6 @@ ;; local libraries bignum_bigint bitstring_lib - ppx_dhall_type codable test_util unsigned_extended diff --git a/src/lib/currency/intf.ml b/src/lib/currency/intf.ml index 5709223a18b..372c6524e83 100644 --- a/src/lib/currency/intf.ml +++ b/src/lib/currency/intf.ml @@ -11,9 +11,6 @@ module type Basic = sig type magnitude = t [@@deriving sexp, compare] - (* not automatically derived *) - val dhall_type : Ppx_dhall_type.Dhall_type.t - val max_int : t val length_in_bits : int @@ -307,9 +304,6 @@ module type Full = sig [@@@with_all_version_tags] type t [@@deriving sexp, compare, hash, yojson, equal] - - (* not automatically derived *) - val dhall_type : Ppx_dhall_type.Dhall_type.t end end] @@ -367,9 +361,6 @@ module type Full = sig [@@@with_all_version_tags] type t [@@deriving sexp, compare, hash, equal, yojson] - - (* not automatically derived *) - val dhall_type : Ppx_dhall_type.Dhall_type.t end end] @@ -439,9 +430,6 @@ module type Full = sig module Stable : sig module V1 : sig type t [@@deriving sexp, compare, hash, yojson, equal] - - (* not automatically derived *) - val dhall_type : Ppx_dhall_type.Dhall_type.t end end] diff --git a/src/lib/mina_numbers/dune b/src/lib/mina_numbers/dune index 83f53d82b28..fc7006cb1e3 100644 --- a/src/lib/mina_numbers/dune +++ b/src/lib/mina_numbers/dune @@ -20,7 +20,6 @@ bignum_bigint pickles codable - ppx_dhall_type snarky.backendless fold_lib tuple_lib diff --git a/src/lib/mina_numbers/global_slot.ml b/src/lib/mina_numbers/global_slot.ml index 76d8d481ec3..87e64edaa73 100644 --- a/src/lib/mina_numbers/global_slot.ml +++ b/src/lib/mina_numbers/global_slot.ml @@ -75,8 +75,6 @@ module Make (M : S) = struct let%map.Quickcheck u32 = T.gen_incl u32_1 u32_2 in of_uint32 u32 - let dhall_type = Ppx_dhall_type.Dhall_type.Text - let zero = of_uint32 T.zero let one = of_uint32 T.one diff --git a/src/lib/mina_numbers/global_slot_intf.ml b/src/lib/mina_numbers/global_slot_intf.ml index a57b52e4d13..444ee1073a9 100644 --- a/src/lib/mina_numbers/global_slot_intf.ml +++ b/src/lib/mina_numbers/global_slot_intf.ml @@ -18,8 +18,6 @@ module type S_base = sig val gen_incl : t -> t -> t Core_kernel.Quickcheck.Generator.t - val dhall_type : Ppx_dhall_type.Dhall_type.t - val zero : t val one : t diff --git a/src/lib/mina_numbers/global_slot_span.ml b/src/lib/mina_numbers/global_slot_span.ml index 67f1167d184..2704436d290 100644 --- a/src/lib/mina_numbers/global_slot_span.ml +++ b/src/lib/mina_numbers/global_slot_span.ml @@ -82,8 +82,6 @@ module Make_str (_ : Wire_types.Concrete) = struct let%map.Quickcheck u32 = T.gen_incl u32_1 u32_2 in of_uint32 u32 - let dhall_type = Ppx_dhall_type.Dhall_type.Text - let zero = of_uint32 T.zero let one = of_uint32 T.one diff --git a/src/lib/mina_numbers/intf.ml b/src/lib/mina_numbers/intf.ml index df506258430..d6788d0ea11 100644 --- a/src/lib/mina_numbers/intf.ml +++ b/src/lib/mina_numbers/intf.ml @@ -14,9 +14,6 @@ module type S_unchecked = sig include Hashable.S with type t := t - (* not automatically derived *) - val dhall_type : Ppx_dhall_type.Dhall_type.t - val max_value : t val length_in_bits : int diff --git a/src/lib/mina_numbers/nat.ml b/src/lib/mina_numbers/nat.ml index d0129786252..aa68a9be130 100644 --- a/src/lib/mina_numbers/nat.ml +++ b/src/lib/mina_numbers/nat.ml @@ -196,9 +196,6 @@ end) struct type t = N.t [@@deriving sexp, compare, hash, yojson] - (* can't be automatically derived *) - let dhall_type = Ppx_dhall_type.Dhall_type.Text - let max_value = N.max_int include Comparable.Make (N) diff --git a/src/lib/ppx_dhall_type/deriving.ml b/src/lib/ppx_dhall_type/deriving.ml deleted file mode 100644 index 256017a4ce4..00000000000 --- a/src/lib/ppx_dhall_type/deriving.ml +++ /dev/null @@ -1,160 +0,0 @@ -(* deriving.ml -- deriving ppx for Dhall types *) - -(* TODO: - deriver for signatures - default values in records -*) - -open Core_kernel -open Ppxlib - -let deriver = "dhall_type" - -let field_key_attr = - Attribute.declare (deriver ^ ".key") Attribute.Context.Label_declaration - Ast_pattern.(single_expr_payload (estring __)) - Fn.id - -let make_lident_cmp items lident = - List.mem items (Longident.name lident.txt) ~equal:String.equal - -let is_bool_lident = make_lident_cmp [ "bool"; "Bool.t" ] - -let is_int_lident = make_lident_cmp [ "int"; "Int.t" ] - -let is_float_lident = make_lident_cmp [ "float"; "Float.t" ] - -let is_string_lident = make_lident_cmp [ "string"; "String.t" ] - -let is_option_lident = make_lident_cmp [ "option"; "Option.t" ] - -let is_list_lident = make_lident_cmp [ "list"; "List.t" ] - -let rec dhall_type_of_core_type core_type = - let (module Ast_builder) = Ast_builder.make core_type.ptyp_loc in - let open Ast_builder in - match core_type.ptyp_desc with - | Ptyp_constr (lident, []) when is_bool_lident lident -> - [%expr Ppx_dhall_type.Dhall_type.Bool] - | Ptyp_constr (lident, []) when is_int_lident lident -> - [%expr Ppx_dhall_type.Dhall_type.Integer] - | Ptyp_constr (lident, []) when is_float_lident lident -> - [%expr Ppx_dhall_type.Dhall_type.Double] - | Ptyp_constr (lident, []) when is_string_lident lident -> - [%expr Ppx_dhall_type.Dhall_type.Text] - | Ptyp_constr (lident, [ ty ]) when is_option_lident lident -> - [%expr Ppx_dhall_type.Dhall_type.Optional [%e dhall_type_of_core_type ty]] - | Ptyp_constr (lident, [ ty ]) when is_list_lident lident -> - [%expr Ppx_dhall_type.Dhall_type.List [%e dhall_type_of_core_type ty]] - | Ptyp_constr ({ txt = Lident id; _ }, []) -> - evar (id ^ "_dhall_type") - | Ptyp_constr ({ txt = Lident id; _ }, params) -> - let dhall_type_fun = evar (id ^ "_dhall_type") in - let args = List.map params ~f:dhall_type_of_core_type in - eapply dhall_type_fun args - | Ptyp_constr ({ txt = Ldot (prefix, nm); _ }, []) -> - let mod_path = Longident.name prefix in - if String.equal nm "t" then evar (mod_path ^ ".dhall_type") - else evar (mod_path ^ "." ^ nm ^ "_dhall_type") - | Ptyp_constr ({ txt = Ldot (prefix, nm); _ }, params) -> - let mod_path = Longident.name prefix in - let dhall_type_fun = - if String.equal nm "t" then evar (mod_path ^ ".dhall_type") - else evar (mod_path ^ "." ^ nm ^ "_dhall_type") - in - let args = List.map params ~f:dhall_type_of_core_type in - eapply dhall_type_fun args - | Ptyp_var a -> - evar a - | _ -> - Location.raise_errorf ~loc:core_type.ptyp_loc "Unsupported type" - -let dhall_variant_from_constructor_declaration ctor_decl = - let (module Ast_builder) = Ast_builder.make ctor_decl.pcd_name.loc in - let open Ast_builder in - let name = estring @@ String.lowercase ctor_decl.pcd_name.txt in - match ctor_decl.pcd_args with - | Pcstr_tuple [] -> - [%expr [%e name], None] - | Pcstr_tuple [ ty ] -> - [%expr [%e name], Some [%e dhall_type_of_core_type ty]] - | Pcstr_tuple tys -> - let tys_expr = elist (List.map tys ~f:dhall_type_of_core_type) in - [%expr [%e name], Some (List [%e tys_expr])] - | Pcstr_record _ -> - Location.raise_errorf ~loc:ctor_decl.pcd_name.loc - "Records not yet supported" - -let dhall_field_from_label_declaration label_decl = - let (module Ast_builder) = Ast_builder.make label_decl.pld_name.loc in - let open Ast_builder in - let name = - match Attribute.get field_key_attr label_decl with - | Some name -> - estring name - | None -> - estring label_decl.pld_name.txt - in - let ty = dhall_type_of_core_type label_decl.pld_type in - [%expr [%e name], [%e ty]] - -let generate_dhall_type type_decl = - let (module Ast_builder) = Ast_builder.make type_decl.ptype_loc in - let open Ast_builder in - let dhall_type = - match type_decl.ptype_kind with - | Ptype_abstract -> ( - match type_decl.ptype_manifest with - | None -> - Location.raise_errorf ~loc:type_decl.ptype_loc - "Abstract type declaration has no manifest (right-hand side)" - | Some core_type -> - dhall_type_of_core_type core_type ) - | Ptype_variant ctor_decls -> - [%expr - Ppx_dhall_type.Dhall_type.Union - [%e - elist - (List.map ctor_decls - ~f:dhall_variant_from_constructor_declaration )]] - | Ptype_record label_decls -> - [%expr - Ppx_dhall_type.Dhall_type.Record - [%e - elist (List.map label_decls ~f:dhall_field_from_label_declaration)]] - | Ptype_open -> - Location.raise_errorf ~loc:type_decl.ptype_loc - "Open types not supported" - in - let ty_name = - match type_decl.ptype_name.txt with - | "t" -> - pvar "dhall_type" - | nm -> - pvar (nm ^ "_dhall_type") - in - match type_decl.ptype_params with - | [] -> - [%stri let [%p ty_name] = [%e dhall_type]] - | params -> - let args = - List.map params ~f:(fun (core_type, _variance) -> - match core_type.ptyp_desc with - | Ptyp_var a -> - pvar a - | _ -> - Location.raise_errorf ~loc:type_decl.ptype_loc - "Type parameter not a type variable" ) - in - let abs = eabstract args dhall_type in - [%stri let [%p ty_name] = [%e abs]] - -let generate_dhall_types ~loc:_ ~path:_ (_rec_flag, type_decls) = - List.map type_decls ~f:generate_dhall_type - -let attributes = [ Attribute.T field_key_attr ] - -let str_type_decl = - Deriving.Generator.make_noarg ~attributes generate_dhall_types - -let () = Deriving.add deriver ~str_type_decl |> Ppxlib.Deriving.ignore diff --git a/src/lib/ppx_dhall_type/dhall_type.ml b/src/lib/ppx_dhall_type/dhall_type.ml deleted file mode 100644 index 30f0f90ea60..00000000000 --- a/src/lib/ppx_dhall_type/dhall_type.ml +++ /dev/null @@ -1,48 +0,0 @@ -(* dhall_type.ml -- derive a Dhall type from an OCaml type *) - -open Core_kernel - -(* based on https://github.com/dhall-lang/dhall-lang/blob/master/standard/type-inference.md *) -type t = - | Bool - | Natural - | Text - | Integer - | Double - | Optional of t - | List of t - | Record of (string * t) list - | Union of (string * t option) list - | Function of t * t - -let rec to_string = function - | Bool -> - "Bool" - | Integer -> - "Integer" - | Natural -> - "Natural" - | Text -> - "Text" - | Double -> - "Double" - | Optional t -> - "Optional (" ^ to_string t ^ ")" - | List t -> - "List (" ^ to_string t ^ ")" - | Record fields -> - let field_to_string (nm, ty) = nm ^ " : " ^ to_string ty in - let formatted_fields = - String.concat ~sep:", " (List.map fields ~f:field_to_string) - in - "{ " ^ formatted_fields ^ " }" - | Union alts -> - let alt_to_string (nm, ty_opt) = - match ty_opt with None -> nm | Some ty -> nm ^ " : " ^ to_string ty - in - let formatted_alts = - String.concat ~sep:" | " (List.map alts ~f:alt_to_string) - in - "< " ^ formatted_alts ^ " >" - | Function (t_in, t_out) -> - to_string t_in ^ " -> " ^ to_string t_out diff --git a/src/lib/ppx_dhall_type/dune b/src/lib/ppx_dhall_type/dune deleted file mode 100644 index 7de391a373a..00000000000 --- a/src/lib/ppx_dhall_type/dune +++ /dev/null @@ -1,8 +0,0 @@ -(library - (name ppx_dhall_type) - (public_name ppx_dhall_type) - (kind ppx_deriver) - (libraries ppxlib core_kernel base) - (preprocessor_deps ../../config.mlh) - (instrumentation (backend bisect_ppx)) - (preprocess (pps ppx_version ppxlib.metaquot))) diff --git a/src/lib/runtime_config/dune b/src/lib/runtime_config/dune index dbaa294c3df..04660763290 100644 --- a/src/lib/runtime_config/dune +++ b/src/lib/runtime_config/dune @@ -20,7 +20,6 @@ mina_base.import mina_numbers signature_lib - ppx_dhall_type snark_params unsigned_extended pickles @@ -30,4 +29,4 @@ ) (instrumentation (backend bisect_ppx)) (preprocess (pps ppx_custom_printf ppx_sexp_conv ppx_let ppx_deriving_yojson - ppx_fields_conv ppx_dhall_type ppx_version ppx_compare))) + ppx_fields_conv ppx_version ppx_compare))) diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index b8ef65dde18..ef42c92554e 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -3,7 +3,7 @@ open Core_kernel module Fork_config = struct type t = { previous_state_hash : string; previous_length : int; genesis_slot : int } - [@@deriving yojson, dhall_type, bin_io_unversioned] + [@@deriving yojson, bin_io_unversioned] end let yojson_strip_fields ~keep_fields = function @@ -56,7 +56,7 @@ module Json_layout = struct ; vesting_period : Mina_numbers.Global_slot_span.t ; vesting_increment : Currency.Amount.t } - [@@deriving yojson, fields, dhall_type, sexp] + [@@deriving yojson, fields, sexp] let fields = Fields.names |> Array.of_list @@ -66,7 +66,7 @@ module Json_layout = struct module Permissions = struct module Auth_required = struct type t = None | Either | Proof | Signature | Impossible - [@@deriving dhall_type, sexp, bin_io_unversioned] + [@@deriving sexp, bin_io_unversioned] let to_yojson = function | None -> @@ -127,7 +127,7 @@ module Json_layout = struct ; set_voting_for : Auth_required.t [@default None] ; set_timing : Auth_required.t [@default None] } - [@@deriving yojson, fields, dhall_type, sexp, bin_io_unversioned] + [@@deriving yojson, fields, sexp, bin_io_unversioned] let fields = Fields.names |> Array.of_list @@ -139,9 +139,6 @@ module Json_layout = struct type t = Snark_params.Tick.Field.t [@@deriving sexp, bin_io_unversioned] - (* can't be automatically derived *) - let dhall_type = Ppx_dhall_type.Dhall_type.Text - let to_yojson t = `String (Snark_params.Tick.Field.to_string t) let of_yojson = function @@ -157,9 +154,6 @@ module Json_layout = struct type t = Pickles.Side_loaded.Verification_key.Stable.Latest.t [@@deriving sexp, bin_io_unversioned] - (* can't be automatically derived *) - let dhall_type = Ppx_dhall_type.Dhall_type.Text - let to_yojson t = `String (Pickles.Side_loaded.Verification_key.to_base64 t) @@ -193,7 +187,7 @@ module Json_layout = struct ; proved_state : bool ; zkapp_uri : string } - [@@deriving sexp, fields, dhall_type, yojson, bin_io_unversioned] + [@@deriving sexp, fields, yojson, bin_io_unversioned] let fields = Fields.names |> Array.of_list @@ -215,7 +209,7 @@ module Json_layout = struct ; permissions : Permissions.t option [@default None] ; token_symbol : string option [@default None] } - [@@deriving sexp, fields, yojson, dhall_type] + [@@deriving sexp, fields, yojson] let fields = Fields.names |> Array.of_list @@ -320,13 +314,13 @@ module Json_layout = struct } end - type t = Single.t list [@@deriving yojson, dhall_type] + type t = Single.t list [@@deriving yojson] end module Ledger = struct module Balance_spec = struct type t = { number : int; balance : Currency.Balance.t } - [@@deriving yojson, dhall_type] + [@@deriving yojson] end type t = @@ -337,7 +331,7 @@ module Json_layout = struct ; name : string option [@default None] ; add_genesis_winner : bool option [@default None] } - [@@deriving yojson, fields, dhall_type] + [@@deriving yojson, fields] let fields = Fields.names |> Array.of_list @@ -347,11 +341,10 @@ module Json_layout = struct module Proof_keys = struct module Transaction_capacity = struct type t = - { log_2 : int option - [@default None] [@key "2_to_the"] [@dhall_type.key "two_to_the"] + { log_2 : int option [@default None] [@key "2_to_the"] ; txns_per_second_x10 : int option [@default None] } - [@@deriving yojson, dhall_type] + [@@deriving yojson] (* we don't deriving the field names here, because the first one differs from the field in the record type @@ -379,7 +372,7 @@ module Json_layout = struct ; account_creation_fee : Currency.Fee.t option [@default None] ; fork : Fork_config.t option [@default None] } - [@@deriving yojson, fields, dhall_type] + [@@deriving yojson, fields] let fields = Fields.names |> Array.of_list @@ -394,7 +387,7 @@ module Json_layout = struct ; slots_per_sub_window : int option [@default None] ; genesis_state_timestamp : string option [@default None] } - [@@deriving yojson, fields, dhall_type] + [@@deriving yojson, fields] let fields = Fields.names |> Array.of_list @@ -412,7 +405,7 @@ module Json_layout = struct ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] } - [@@deriving yojson, fields, dhall_type] + [@@deriving yojson, fields] let fields = Fields.names |> Array.of_list @@ -422,7 +415,7 @@ module Json_layout = struct module Epoch_data = struct module Data = struct type t = { accounts : Accounts.t; seed : string } - [@@deriving yojson, fields, dhall_type] + [@@deriving yojson, fields] let fields = Fields.names |> Array.of_list @@ -433,7 +426,7 @@ module Json_layout = struct { staking : Data.t ; next : (Data.t option[@default None]) (*If None then next = staking*) } - [@@deriving yojson, fields, dhall_type] + [@@deriving yojson, fields] let fields = Fields.names |> Array.of_list @@ -447,7 +440,7 @@ module Json_layout = struct ; ledger : Ledger.t option [@default None] ; epoch_data : Epoch_data.t option [@default None] } - [@@deriving yojson, fields, dhall_type] + [@@deriving yojson, fields] let fields = Fields.names |> Array.of_list diff --git a/src/lib/unsigned_extended/dune b/src/lib/unsigned_extended/dune index 523ce94bb22..5c2fdd57601 100644 --- a/src/lib/unsigned_extended/dune +++ b/src/lib/unsigned_extended/dune @@ -18,7 +18,6 @@ ;; local libraries bignum_bigint snark_params - ppx_dhall_type test_util ppx_version.runtime ) diff --git a/src/lib/unsigned_extended/unsigned_extended.ml b/src/lib/unsigned_extended/unsigned_extended.ml index 4c34a6d7d7b..3e7812f240b 100644 --- a/src/lib/unsigned_extended/unsigned_extended.ml +++ b/src/lib/unsigned_extended/unsigned_extended.ml @@ -128,8 +128,6 @@ module UInt64 = struct include M - let dhall_type = Ppx_dhall_type.Dhall_type.Text - let to_uint64 : t -> uint64 = Fn.id let of_uint64 : uint64 -> t = Fn.id diff --git a/src/lib/unsigned_extended/unsigned_extended.mli b/src/lib/unsigned_extended/unsigned_extended.mli index c636e32283a..c1877320b4a 100644 --- a/src/lib/unsigned_extended/unsigned_extended.mli +++ b/src/lib/unsigned_extended/unsigned_extended.mli @@ -23,8 +23,6 @@ module UInt64 : sig include S with type t = Stable.Latest.t - val dhall_type : Ppx_dhall_type.Dhall_type.t - val to_uint64 : t -> uint64 val of_uint64 : uint64 -> t diff --git a/src/nonconsensus/currency/dune b/src/nonconsensus/currency/dune index 5bc3acbdf4e..91851e4d413 100644 --- a/src/nonconsensus/currency/dune +++ b/src/nonconsensus/currency/dune @@ -19,7 +19,6 @@ mina_wire_types codable bignum_bigint - ppx_dhall_type random_oracle_input snark_params_nonconsensus random_oracle_nonconsensus diff --git a/src/nonconsensus/mina_numbers/dune b/src/nonconsensus/mina_numbers/dune index cbbfdacc0f3..c10dda74686 100644 --- a/src/nonconsensus/mina_numbers/dune +++ b/src/nonconsensus/mina_numbers/dune @@ -15,7 +15,6 @@ result ;;local libraries mina_wire_types - ppx_dhall_type bignum_bigint fold_lib tuple_lib diff --git a/src/nonconsensus/unsigned_extended/dune b/src/nonconsensus/unsigned_extended/dune index 7c7eece1bcf..63eea74cf27 100644 --- a/src/nonconsensus/unsigned_extended/dune +++ b/src/nonconsensus/unsigned_extended/dune @@ -17,7 +17,6 @@ ppx_inline_test.config ;;local libraries bignum_bigint - ppx_dhall_type snark_params_nonconsensus ) (enabled_if From f38d1810ace3cef8d9c0ba680ff3397336aebd5c Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 4 Oct 2023 18:23:50 +0100 Subject: [PATCH 12/15] Revert "Bump up snarkyjs" This reverts commit dcb7d9c309e12dcb9994a14b447ff0896e91440d. --- src/lib/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index aacde789337..fb58d4df694 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit aacde789337b91d04134f386cdab39c8b35b635b +Subproject commit fb58d4df694bd5a214911d0d662bf12e9e5d2e61 From 3963a32052b96375827e2584f6cc0b811399ed85 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 4 Oct 2023 23:49:07 +0100 Subject: [PATCH 13/15] Update proof-systems --- .../stubs/src/linearization.rs | 2 +- .../stubs/src/pasta_fp_plonk_index.rs | 2 +- .../src/pasta_fp_plonk_verifier_index.rs | 26 ++++++++++++------- .../stubs/src/pasta_fq_plonk_index.rs | 2 +- .../src/pasta_fq_plonk_verifier_index.rs | 26 ++++++++++++------- src/lib/crypto/proof-systems | 2 +- 6 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs b/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs index 6e8bfb83818..ed18df9de96 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs @@ -34,7 +34,7 @@ pub fn linearization_strings( }) }; let evaluated_cols = linearization_columns::(features.as_ref()); - let (linearization, _powers_of_alpha) = constraints_expr::(features.as_ref(), true); + let (linearization, _powers_of_alpha) = constraints_expr::(features.as_ref(), true, 3); let Linearization { constant_term, diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs index c186a1132d1..abd43294f41 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_index.rs @@ -167,7 +167,7 @@ pub fn caml_pasta_fp_plonk_index_read( )?; t.srs = srs.clone(); - let (linearization, powers_of_alpha) = expr_linearization(Some(&t.cs.feature_flags), true); + let (linearization, powers_of_alpha) = expr_linearization(Some(&t.cs.feature_flags), true, 3); t.linearization = linearization; t.powers_of_alpha = powers_of_alpha; diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs index 10e1edb0cfe..9a885711a04 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fp_plonk_verifier_index.rs @@ -10,7 +10,7 @@ use ark_poly::{EvaluationDomain, Radix2EvaluationDomain as Domain}; use kimchi::circuits::constraints::FeatureFlags; use kimchi::circuits::lookup::lookups::{LookupFeatures, LookupPatterns}; use kimchi::circuits::polynomials::permutation::Shifts; -use kimchi::circuits::polynomials::permutation::{zk_polynomial, zk_w3}; +use kimchi::circuits::polynomials::permutation::{permutation_vanishing_polynomial, zk_w}; use kimchi::circuits::wires::{COLUMNS, PERMUTS}; use kimchi::{linearization::expr_linearization, verifier_index::VerifierIndex}; use mina_curves::pasta::{Fp, Pallas, Vesta}; @@ -110,43 +110,51 @@ impl From for VerifierIndex> { domain, max_poly_size: index.max_poly_size as usize, - srs: { Arc::clone(&index.srs.0) }, public: index.public as usize, prev_challenges: index.prev_challenges as usize, + powers_of_alpha, + srs: { Arc::clone(&index.srs.0) }, + + zk_rows: 3, + sigma_comm, coefficients_comm, generic_comm: evals.generic_comm.into(), + psm_comm: evals.psm_comm.into(), + complete_add_comm: evals.complete_add_comm.into(), mul_comm: evals.mul_comm.into(), emul_comm: evals.emul_comm.into(), endomul_scalar_comm: evals.endomul_scalar_comm.into(), + + xor_comm: evals.xor_comm.map(Into::into), range_check0_comm: evals.range_check0_comm.map(Into::into), range_check1_comm: evals.range_check1_comm.map(Into::into), - xor_comm: evals.xor_comm.map(Into::into), - rot_comm: evals.rot_comm.map(Into::into), foreign_field_add_comm: evals.foreign_field_add_comm.map(Into::into), foreign_field_mul_comm: evals.foreign_field_mul_comm.map(Into::into), + rot_comm: evals.rot_comm.map(Into::into), + shift, - zkpm: { + permutation_vanishing_polynomial_m: { let res = once_cell::sync::OnceCell::new(); - res.set(zk_polynomial(domain)).unwrap(); + res.set(permutation_vanishing_polynomial(domain, 3)).unwrap(); res }, w: { let res = once_cell::sync::OnceCell::new(); - res.set(zk_w3(domain)).unwrap(); + res.set(zk_w(domain, 3)).unwrap(); res }, endo: endo_q, + lookup_index: index.lookup_index.map(Into::into), linearization, - powers_of_alpha, } } } diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_index.rs index 4c2ba18d6f0..24317bfc561 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_index.rs @@ -167,7 +167,7 @@ pub fn caml_pasta_fq_plonk_index_read( )?; t.srs = srs.clone(); - let (linearization, powers_of_alpha) = expr_linearization(Some(&t.cs.feature_flags), true); + let (linearization, powers_of_alpha) = expr_linearization(Some(&t.cs.feature_flags), true, 3); t.linearization = linearization; t.powers_of_alpha = powers_of_alpha; diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs index cac04cb8861..0eb3e57d565 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/pasta_fq_plonk_verifier_index.rs @@ -10,7 +10,7 @@ use ark_poly::{EvaluationDomain, Radix2EvaluationDomain as Domain}; use kimchi::circuits::constraints::FeatureFlags; use kimchi::circuits::lookup::lookups::{LookupFeatures, LookupPatterns}; use kimchi::circuits::polynomials::permutation::Shifts; -use kimchi::circuits::polynomials::permutation::{zk_polynomial, zk_w3}; +use kimchi::circuits::polynomials::permutation::{permutation_vanishing_polynomial, zk_w}; use kimchi::circuits::wires::{COLUMNS, PERMUTS}; use kimchi::{linearization::expr_linearization, verifier_index::VerifierIndex}; use mina_curves::pasta::{Fq, Pallas, Vesta}; @@ -109,43 +109,51 @@ impl From for VerifierIndex> { domain, max_poly_size: index.max_poly_size as usize, - srs: { Arc::clone(&index.srs.0) }, public: index.public as usize, prev_challenges: index.prev_challenges as usize, + powers_of_alpha, + srs: { Arc::clone(&index.srs.0) }, + + zk_rows: 3, + sigma_comm, coefficients_comm, generic_comm: evals.generic_comm.into(), + psm_comm: evals.psm_comm.into(), + complete_add_comm: evals.complete_add_comm.into(), mul_comm: evals.mul_comm.into(), emul_comm: evals.emul_comm.into(), endomul_scalar_comm: evals.endomul_scalar_comm.into(), + + xor_comm: evals.xor_comm.map(Into::into), range_check0_comm: evals.range_check0_comm.map(Into::into), range_check1_comm: evals.range_check1_comm.map(Into::into), - xor_comm: evals.xor_comm.map(Into::into), - rot_comm: evals.rot_comm.map(Into::into), foreign_field_add_comm: evals.foreign_field_add_comm.map(Into::into), foreign_field_mul_comm: evals.foreign_field_mul_comm.map(Into::into), + rot_comm: evals.rot_comm.map(Into::into), + shift, - zkpm: { + permutation_vanishing_polynomial_m: { let res = once_cell::sync::OnceCell::new(); - res.set(zk_polynomial(domain)).unwrap(); + res.set(permutation_vanishing_polynomial(domain, 3)).unwrap(); res }, w: { let res = once_cell::sync::OnceCell::new(); - res.set(zk_w3(domain)).unwrap(); + res.set(zk_w(domain, 3)).unwrap(); res }, endo: endo_q, + lookup_index: index.lookup_index.map(Into::into), linearization, - powers_of_alpha, } } } diff --git a/src/lib/crypto/proof-systems b/src/lib/crypto/proof-systems index 33fd70404c8..970c3ef8ef3 160000 --- a/src/lib/crypto/proof-systems +++ b/src/lib/crypto/proof-systems @@ -1 +1 @@ -Subproject commit 33fd70404c8ca997792b9af1202c7f54e33264ff +Subproject commit 970c3ef8ef3b9a3f5d01aea51ed892ecd53b42b8 From 5b056db76f95024f4f018ffe5ed2bf4f36919fa6 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 4 Oct 2023 23:50:36 +0100 Subject: [PATCH 14/15] Revert SnarkyJS --- src/lib/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index fb58d4df694..8314d7b3540 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit fb58d4df694bd5a214911d0d662bf12e9e5d2e61 +Subproject commit 8314d7b3540e004ec51dc6ba77e1e6b1d0c76dc6 From 7d0e48fd8ec9b76f91b0570ed0e426252cd5dcf9 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Thu, 5 Oct 2023 00:46:50 +0100 Subject: [PATCH 15/15] Update SnarkyJS --- src/lib/crypto/proof-systems | 2 +- src/lib/snarkyjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/crypto/proof-systems b/src/lib/crypto/proof-systems index 970c3ef8ef3..a2a1c8d3b9a 160000 --- a/src/lib/crypto/proof-systems +++ b/src/lib/crypto/proof-systems @@ -1 +1 @@ -Subproject commit 970c3ef8ef3b9a3f5d01aea51ed892ecd53b42b8 +Subproject commit a2a1c8d3b9aee9e90438e15e6f652bcc30b0432c diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index 8314d7b3540..8a5df31be90 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit 8314d7b3540e004ec51dc6ba77e1e6b1d0c76dc6 +Subproject commit 8a5df31be90e07eb8f5b3f5785e8ad9b9f534503