diff --git a/.gitmodules b/.gitmodules index 04f0cfdf2c4..0bfe4da2492 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,4 @@ url = https://github.com/o1-labs/snarky [submodule "src/lib/crypto/proof-systems"] path = src/lib/crypto/proof-systems - url = https://github.com/o1-labs/proof-systems.git -[submodule "src/lib/crypto/kimchi_bindings/stubs/kimchi-stubs-vendors"] - path = src/lib/crypto/kimchi_bindings/stubs/kimchi-stubs-vendors - url = https://github.com/MinaProtocol/kimchi-stubs-vendors.git + url = https://github.com/o1-labs/proof-systems.git \ No newline at end of file diff --git a/buildkite/src/Constants/ContainerImages.dhall b/buildkite/src/Constants/ContainerImages.dhall index b42dfd5ecae..5b5cebecc99 100644 --- a/buildkite/src/Constants/ContainerImages.dhall +++ b/buildkite/src/Constants/ContainerImages.dhall @@ -4,11 +4,11 @@ -- NOTE: minaToolchainBookworm is also used for building Ubuntu Jammy packages in CI { toolchainBase = "codaprotocol/ci-toolchain-base:v3" , minaToolchainBullseye = - "gcr.io/o1labs-192920/mina-toolchain@sha256:fee11e64a54fd8f026c4632fed7b7b9835b8262a037cdb156deb61d3d0aac8b2" + "gcr.io/o1labs-192920/mina-toolchain@sha256:8dc3a721b2be119db98a45970c21249f7ed9a95a75f2b330d7c0f37cdafcc99a" , minaToolchainBookworm = - "gcr.io/o1labs-192920/mina-toolchain@sha256:fee11e64a54fd8f026c4632fed7b7b9835b8262a037cdb156deb61d3d0aac8b2" + "gcr.io/o1labs-192920/mina-toolchain@sha256:8dc3a721b2be119db98a45970c21249f7ed9a95a75f2b330d7c0f37cdafcc99a" , minaToolchain = - "gcr.io/o1labs-192920/mina-toolchain@sha256:fee11e64a54fd8f026c4632fed7b7b9835b8262a037cdb156deb61d3d0aac8b2" + "gcr.io/o1labs-192920/mina-toolchain@sha256:8dc3a721b2be119db98a45970c21249f7ed9a95a75f2b330d7c0f37cdafcc99a" , elixirToolchain = "elixir:1.10-alpine" , nodeToolchain = "node:14.13.1-stretch-slim" , ubuntu2004 = "ubuntu:20.04" diff --git a/dockerfiles/stages/1-build-deps b/dockerfiles/stages/1-build-deps index 3e5348cc6e5..2dc9f42f32f 100644 --- a/dockerfiles/stages/1-build-deps +++ b/dockerfiles/stages/1-build-deps @@ -23,10 +23,7 @@ ARG GO_CAPNP_VERSION=v3.0.0-alpha.5 # This should stay in line with: # - src/lib/crypto/kimchi_bindings/stubs/rust-toolchain.toml # - src/lib/crypto/proof-systems/rust-toolchain.toml -ARG RUST_VERSION=1.72 -# Nightly Rust Version used for WebAssembly builds -# - src/lib/crypto/kimchi_bindings/wasm/rust-toolchain.toml -ARG RUST_NIGHTLY=2023-09-01 +ARG RUST_VERSION=1.74 # wasm-pack version ARG WASM_PACK_VERSION=v0.12.1 @@ -97,7 +94,6 @@ RUN curl -sL \ RUN curl -s "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" | tar -xz -C /usr/lib/ # --- Rust install via rustup-init to a given RUST_VERSION -# --- Additionally, install RUST_NIGHTLY via rustup # For more about rustup-init see: https://github.com/rust-lang/rustup/blob/master/README.md # As opposed to introducing another shell script here (that mostly just determines the platform) # we just download the binary for the only platform we care about in this docker environment @@ -106,7 +102,6 @@ RUN curl --proto '=https' --tlsv1.2 -sSf -o /tmp/rustup-init \ https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init \ && chmod +x /tmp/rustup-init \ && /tmp/rustup-init -y --default-toolchain "${RUST_VERSION}" --profile minimal --component rust-src --target wasm32-unknown-unknown \ - && $HOME/.cargo/bin/rustup toolchain install "nightly-${RUST_NIGHTLY}" --profile minimal --component rust-src --target wasm32-unknown-unknown --no-self-update \ && rm /tmp/rustup-init USER root diff --git a/nix/rust.nix b/nix/rust.nix index dad90f34a49..b1d5824c3d1 100644 --- a/nix/rust.nix +++ b/nix/rust.nix @@ -8,9 +8,7 @@ let # override stdenv.targetPlatform here, if neccesary }; toolchainHashes = { - "1.72" = "sha256-dxE7lmCFWlq0nl/wKcmYvpP9zqQbBitAQgZ1zx9Ooik="; - "nightly-2023-09-01" = - "sha256-zek9JAnRaoX8V0U2Y5ssXVe9tvoQ0ERGXfUCUGYdrMA="; + "1.74" = "sha256-PjvuouwTsYfNKW5Vi5Ye7y+lL7SsWGBxCtBOOm2z14c="; # copy the placeholder line with the correct toolchain name when adding a new toolchain # That is, # 1. Put the correct version name; @@ -19,7 +17,7 @@ let # error: hash mismatch in fixed-output derivation '/nix/store/XXXXX' # specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= # got: sha256-Q9UgzzvxLi4x9aWUJTn+/5EXekC98ODRU1TwhUs9RnY= - "placeholder" = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + # "placeholder" = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; }; # rust-toolchain.toml -> { rustc, cargo, rust-analyzer, ... } rustChannelFromToolchainFileOf = file: diff --git a/src/lib/crypto/kimchi_bindings/js/node_js/build.sh b/src/lib/crypto/kimchi_bindings/js/node_js/build.sh index 41a7c57bc5c..37fef114428 100755 --- a/src/lib/crypto/kimchi_bindings/js/node_js/build.sh +++ b/src/lib/crypto/kimchi_bindings/js/node_js/build.sh @@ -4,7 +4,7 @@ set -euo pipefail if [[ -z "${PLONK_WASM_NODEJS-}" ]]; then export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296" # The version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml - rustup run nightly-2023-09-01 wasm-pack build --target nodejs --out-dir ../js/node_js ../../wasm -- -Z build-std=panic_abort,std --features nodejs + rustup run 1.74 wasm-pack build --target nodejs --out-dir ../js/node_js ../../wasm -- --features nodejs else cp "$PLONK_WASM_NODEJS"/* -R . fi diff --git a/src/lib/crypto/kimchi_bindings/js/web/build.sh b/src/lib/crypto/kimchi_bindings/js/web/build.sh index f99564ef81d..de4fa8bd4f7 100755 --- a/src/lib/crypto/kimchi_bindings/js/web/build.sh +++ b/src/lib/crypto/kimchi_bindings/js/web/build.sh @@ -4,7 +4,7 @@ set -euo pipefail if [[ -z "${PLONK_WASM_WEB-}" ]]; then export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296" # The version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml - rustup run nightly-2023-09-01 wasm-pack build --target web --out-dir ../js/web ../../wasm -- -Z build-std=panic_abort,std + rustup run 1.74 wasm-pack build --target web --out-dir ../js/web ../../wasm else cp "$PLONK_WASM_WEB"/* -R . fi diff --git a/src/lib/crypto/kimchi_bindings/stubs/.cargo/config b/src/lib/crypto/kimchi_bindings/stubs/.cargo/config index 394e1c1f0f0..e261afe0e21 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/.cargo/config +++ b/src/lib/crypto/kimchi_bindings/stubs/.cargo/config @@ -1,8 +1,2 @@ [build] -rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"] - -[source.crates-io] -replace-with = "vendored-sources" - -[source.vendored-sources] -directory = "kimchi-stubs-vendors" \ No newline at end of file +rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"] \ No newline at end of file diff --git a/src/lib/crypto/kimchi_bindings/stubs/Cargo.lock b/src/lib/crypto/kimchi_bindings/stubs/Cargo.lock index 97a33e14b7a..f0b2954dcc8 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/Cargo.lock +++ b/src/lib/crypto/kimchi_bindings/stubs/Cargo.lock @@ -61,7 +61,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -79,7 +79,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -420,12 +420,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "disjoint-set" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d102f1a462fdcdddce88d6d46c06c074a2d2749b262230333726b06c52bb7585" - [[package]] name = "either" version = "1.8.1" @@ -584,6 +578,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" @@ -608,11 +611,11 @@ dependencies = [ "ark-poly", "ark-serialize", "blake2", - "disjoint-set", "groupmap", "hex", "internal-tracing", - "itertools", + "itertools 0.12.1", + "log", "mina-curves", "mina-poseidon", "num-bigint", @@ -679,6 +682,7 @@ version = "0.1.0" dependencies = [ "ark-ec", "ark-ff", + "num-bigint", ] [[package]] @@ -802,7 +806,6 @@ dependencies = [ "ark-serialize", "bcs", "hex", - "mina-curves", "num-bigint", "num-integer", "num-traits", @@ -915,7 +918,7 @@ dependencies = [ "ark-serialize", "blake2", "groupmap", - "itertools", + "itertools 0.12.1", "mina-curves", "mina-poseidon", "o1-utils", diff --git a/src/lib/crypto/kimchi_bindings/stubs/Cargo.toml b/src/lib/crypto/kimchi_bindings/stubs/Cargo.toml index b2db36f6951..0c24b9ac52e 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/Cargo.toml +++ b/src/lib/crypto/kimchi_bindings/stubs/Cargo.toml @@ -13,31 +13,31 @@ crate-type = ["lib", "staticlib"] [dependencies] array-init = "2.0.0" -rmp-serde = "1.1.2" libc = "0.2.62" num-bigint = { version = "0.4.4", features = [ "rand", "serde" ] } +# ocaml-specific +ocaml = { version = "0.22.2", features = ["no-caml-startup"] } +ocaml-gen = "0.1.5" +once_cell = "1.10.0" paste = "1.0.5" rand = "0.8.5" rayon = "1.5.0" +rmp-serde = "1.1.2" serde = "1.0.130" serde_json = "1.0.103" sprs = { version = "0.11.0", features = ["multi_thread"] } -once_cell = "1.10.0" # arkworks -ark-ff = { version = "0.4.2", features = ["parallel", "asm"] } -ark-serialize = "0.4.2" ark-ec = { version = "0.4.2", features = ["parallel"] } +ark-ff = { version = "0.4.2", features = ["parallel", "asm"] } ark-poly = { version = "0.4.2", features = ["parallel"] } +ark-serialize = "0.4.2" # proof-systems -poly-commitment = { path = "../../proof-systems/poly-commitment", features = ["ocaml_types"] } groupmap = { path = "../../proof-systems/groupmap" } +kimchi = { path = "../../proof-systems/kimchi", features = ["ocaml_types"] } mina-curves = { path = "../../proof-systems/curves" } -o1-utils = { path = "../../proof-systems/utils" } mina-poseidon = { path = "../../proof-systems/poseidon" } -kimchi = { path = "../../proof-systems/kimchi", features = ["ocaml_types"] } +o1-utils = { path = "../../proof-systems/utils" } +poly-commitment = { path = "../../proof-systems/poly-commitment", features = ["ocaml_types"] } -# ocaml-specific -ocaml = { version = "0.22.2", features = ["no-caml-startup"] } -ocaml-gen = "0.1.5" diff --git a/src/lib/crypto/kimchi_bindings/stubs/dune b/src/lib/crypto/kimchi_bindings/stubs/dune index 6c1400892a4..bb9f6dcb945 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/dune +++ b/src/lib/crypto/kimchi_bindings/stubs/dune @@ -59,7 +59,7 @@ (setenv RUSTFLAGS %{read:rustflags.sexp} - (run cargo build --release --offline))) + (run cargo build --release))) (run cp %{read:../dune-build-root}/cargo_kimchi_stubs/release/libwires_15_stubs.a @@ -161,7 +161,7 @@ (setenv CARGO_TARGET_DIR "%{read:../dune-build-root}/cargo_kimchi_bindgen" - (run cargo run %{targets} --offline)) + (run cargo run %{targets})) (run ocamlformat -i %{targets})))) ;; this is used by nix diff --git a/src/lib/crypto/kimchi_bindings/stubs/kimchi-stubs-vendors b/src/lib/crypto/kimchi_bindings/stubs/kimchi-stubs-vendors deleted file mode 160000 index 2201f3527b3..00000000000 --- a/src/lib/crypto/kimchi_bindings/stubs/kimchi-stubs-vendors +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2201f3527b330a2888d6e7f9921465f3e326cdc0 diff --git a/src/lib/crypto/kimchi_bindings/stubs/rust-toolchain.toml b/src/lib/crypto/kimchi_bindings/stubs/rust-toolchain.toml index 5a82cfe5ab4..c2547d7095b 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/rust-toolchain.toml +++ b/src/lib/crypto/kimchi_bindings/stubs/rust-toolchain.toml @@ -11,4 +11,4 @@ # 4. figure out the hashes of the (now obsolete) docker images used in CI rules that are failing, grep for these hashes and replace them with the new hashes [toolchain] -channel = "1.72" +channel = "1.74" diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fp.rs b/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fp.rs index dee87bb87ac..58d453db201 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fp.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fp.rs @@ -2,8 +2,11 @@ use crate::arkworks::CamlBigInteger256; use crate::caml::caml_bytes_string::CamlBytesString; use ark_ff::{FftField, Field, One, PrimeField, UniformRand, Zero}; use ark_poly::{EvaluationDomain, Radix2EvaluationDomain as Domain}; -use ark_serialize::{CanonicalSerialize, CanonicalDeserialize}; -use mina_curves::pasta::fields::{fp::{Fp, FpParameters as Fp_params}, fft::FpParameters}; +use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; +use mina_curves::pasta::fields::{ + fft::FpParameters, + fp::{Fp, FpParameters as Fp_params}, +}; use num_bigint::BigUint; use rand::rngs::StdRng; use std::{ diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fq.rs b/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fq.rs index cb289002976..1dfe8284b9b 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fq.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fq.rs @@ -2,8 +2,11 @@ use crate::arkworks::CamlBigInteger256; use crate::caml::caml_bytes_string::CamlBytesString; use ark_ff::{FftField, Field, One, PrimeField, UniformRand, Zero}; use ark_poly::{EvaluationDomain, Radix2EvaluationDomain as Domain}; -use ark_serialize::{CanonicalSerialize, CanonicalDeserialize}; -use mina_curves::pasta::{fields::{fq::FqParameters as Fq_params, fft::FpParameters}, Fq}; +use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; +use mina_curves::pasta::{ + fields::{fft::FpParameters, fq::FqParameters as Fq_params}, + Fq, +}; use num_bigint::BigUint; use rand::rngs::StdRng; use std::{ diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/caml/caml_pointer.rs b/src/lib/crypto/kimchi_bindings/stubs/src/caml/caml_pointer.rs index 55629e74c40..33c3e67aa62 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/caml/caml_pointer.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/caml/caml_pointer.rs @@ -1,7 +1,7 @@ macro_rules! impl_caml_pointer { ($name: ident => $typ: ty) => { #[derive(std::fmt::Debug, Clone, ::ocaml_gen::CustomType)] - pub struct $name(pub ::std::rc::Rc<$typ>); + pub struct $name(pub ::std::rc::Rc>); impl $name { extern "C" fn caml_pointer_finalize(v: ocaml::Raw) { @@ -12,8 +12,8 @@ macro_rules! impl_caml_pointer { } extern "C" fn caml_pointer_compare(_: ocaml::Raw, _: ocaml::Raw) -> i32 { - // Always return equal. We can use this for sanity checks, and anything else using this - // would be broken anyway. + // Always return equal. We can use this for sanity checks, and + // anything else using this would be broken anyway. 0 } } @@ -32,7 +32,7 @@ macro_rules! impl_caml_pointer { impl $name { pub fn create(x: $typ) -> $name { - $name(::std::rc::Rc::new(x)) + $name(::std::rc::Rc::new(std::cell::UnsafeCell::new(x))) } } @@ -40,7 +40,7 @@ macro_rules! impl_caml_pointer { type Target = $typ; fn deref(&self) -> &Self::Target { - &*self.0 + unsafe { &*self.0.get() } } } @@ -49,14 +49,15 @@ macro_rules! impl_caml_pointer { unsafe { // Wholely unsafe, Batman! // We would use [`get_mut_unchecked`] here, but it is nightly-only. - // Instead, we get coerce our constant pointer to a mutable pointer, in the knowledge - // that - // * all of our mutations called from OCaml are blocking, so we won't have multiple - // live mutable references live simultaneously, and - // * the underlying pointer is in the correct state to be mutable, since we can call - // [`get_mut_unchecked`] in nightly, or can call [`get_mut`] and unwrap if this is + // Instead, we use UnsafeCell in the knowledge that + // * all of our mutations called from OCaml are blocking, so + // we won't have multiple live mutable references + // simultaneously, and + // * the underlying pointer is in the correct state to be + // mutable, since we can call [`get_mut_unchecked`] in + // nightly, or can call [`get_mut`] and unwrap if this is // the only live reference. - &mut *(((&*self.0) as *const Self::Target) as *mut Self::Target) + &mut *self.0.get() } } } diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/field_vector.rs b/src/lib/crypto/kimchi_bindings/stubs/src/field_vector.rs index 60ac328f37e..4cd6d9ac315 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/field_vector.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/field_vector.rs @@ -1,4 +1,5 @@ -//! We implement a custom type for field vectors in order to quickly build field vectors from the OCaml side and avoid large vector clones. +//! We implement a custom type for field vectors in order to quickly build field +//! vectors from the OCaml side and avoid large vector clones. use paste::paste; diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/lagrange_basis.rs b/src/lib/crypto/kimchi_bindings/stubs/src/lagrange_basis.rs index a132e142621..fcc53e1b1f3 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/lagrange_basis.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/lagrange_basis.rs @@ -2,7 +2,9 @@ use ark_ec::AffineRepr; use ark_poly::{EvaluationDomain, Radix2EvaluationDomain as D}; use cache::LagrangeCache; use mina_curves::pasta::{Pallas, Vesta}; -use poly_commitment::{commitment::CommitmentCurve, srs::SRS}; +use poly_commitment::commitment::CommitmentCurve; +use poly_commitment::ipa::SRS; +use poly_commitment::SRS as _; use std::env; pub trait WithLagrangeBasis { @@ -42,7 +44,6 @@ fn add_lagrange_basis_with_cache>( } if let Some(basis) = cache.load_lagrange_basis_from_cache(srs.g.len(), &domain) { srs.lagrange_bases.get_or_generate(n, || basis); - return; } else { let basis = srs.get_lagrange_basis(domain); cache.cache_lagrange_basis(srs.g.len(), &domain, basis); @@ -81,7 +82,7 @@ mod cache { &self, srs_length: usize, domain: &D, - basis: &Vec>, + basis: &[PolyComm], ); } @@ -100,10 +101,9 @@ mod cache { } } - /* - The FileCache implementation uses a directory as a cache for the Lagrange basis hash map -- - i.e every file corresponds to a Lagrange basis for a given G-basis and domain size. - */ + // The FileCache implementation uses a directory as a cache for the Lagrange + // basis hash map -- i.e every file corresponds to a Lagrange basis for a + // given G-basis and domain size. impl LagrangeCache for FileCache { type CacheKey = PathBuf; @@ -115,7 +115,7 @@ mod cache { self.cache_dir.clone().join(format!( "lagrange_basis_{:}-{:}", srs_length, - domain.size().to_string() + domain.size() )) } @@ -126,14 +126,13 @@ mod cache { ) -> Option>> { let cache_key = self.lagrange_basis_cache_key(srs_length, domain); if Path::exists(&cache_key) { - let f = File::open(cache_key.clone()).expect(&format!( - "Missing lagrange basis cache file {:?}", - cache_key - )); - let basis: Vec> = rmp_serde::decode::from_read(f).expect(&format!( - "Error decoding lagrange cache file {:?}", - cache_key - )); + let f = File::open(cache_key.clone()).unwrap_or_else(|_| { + panic!("Missing lagrange basis cache file {:?}", cache_key) + }); + let basis: Vec> = + rmp_serde::decode::from_read(f).unwrap_or_else(|_| { + panic!("Error decoding lagrange cache file {:?}", cache_key) + }); Some(basis) } else { None @@ -144,26 +143,22 @@ mod cache { &self, srs_length: usize, domain: &D, - basis: &Vec>, + basis: &[PolyComm], ) { let cache_key = self.lagrange_basis_cache_key(srs_length, domain); - if Path::exists(&cache_key) { - return; - } else { - let mut f = File::create(cache_key.clone()).expect(&format!( - "Error creating lagrabnge basis cache file {:?}", - cache_key - )); - rmp_serde::encode::write(&mut f, basis).expect(&format!( - "Error encoding lagrange basis to file {:?}", - cache_key - )); + if !Path::exists(&cache_key) { + let mut f = File::create(cache_key.clone()).unwrap_or_else(|_| { + panic!("Error creating lagrabnge basis cache file {:?}", cache_key) + }); + rmp_serde::encode::write(&mut f, basis).unwrap_or_else(|_| { + panic!("Error encoding lagrange basis to file {:?}", cache_key) + }); } } } - // The following two caches are all that we need for mina tests. These will not be initialized unless they are - // explicitly called. + // The following two caches are all that we need for mina tests. These will + // not be initialized unless they are explicitly called. static VESTA_FILE_CACHE: Lazy> = Lazy::new(|| { let cache_base_dir: String = env::var("LAGRANGE_CACHE_DIR").expect("LAGRANGE_CACHE_DIR missing in env"); @@ -175,7 +170,7 @@ mod cache { }); pub fn get_vesta_file_cache() -> &'static FileCache { - &*VESTA_FILE_CACHE + &VESTA_FILE_CACHE } static PALLAS_FILE_CACHE: Lazy> = Lazy::new(|| { @@ -189,6 +184,6 @@ mod cache { }); pub fn get_pallas_file_cache() -> &'static FileCache { - &*PALLAS_FILE_CACHE + &PALLAS_FILE_CACHE } } diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/lib.rs b/src/lib/crypto/kimchi_bindings/stubs/src/lib.rs index 78728f438ea..2510ae8378c 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/lib.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/lib.rs @@ -68,5 +68,6 @@ pub use { CamlLookupCommitments, CamlProofWithPublic, CamlProverCommitments, CamlProverProof, }, mina_poseidon::sponge::caml::CamlScalarChallenge, - poly_commitment::commitment::caml::{CamlOpeningProof, CamlPolyComm}, + poly_commitment::commitment::caml::CamlPolyComm, + poly_commitment::ipa::caml::CamlOpeningProof, }; diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs b/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs index 4ca294fd6cf..03e87883de1 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/linearization.rs @@ -7,12 +7,13 @@ use kimchi::{ linearization::{constraints_expr, linearization_columns}, }; -/// Converts the linearization of the kimchi circuit polynomial into a printable string. +/// Converts the linearization of the kimchi circuit polynomial into a printable +/// string. pub fn linearization_strings( uses_custom_gates: bool, ) -> (String, Vec<(String, String)>) - where - num_bigint::BigUint: From, +where + num_bigint::BigUint: From, { let features = if uses_custom_gates { None @@ -44,8 +45,8 @@ pub fn linearization_strings( mut index_terms, } = linearization.linearize(evaluated_cols).unwrap(); - // HashMap deliberately uses an unstable order; here we sort to ensure that the output is - // consistent when printing. + // HashMap deliberately uses an unstable order; here we sort to ensure that + // the output is consistent when printing. index_terms.sort_by(|(x, _), (y, _)| x.cmp(y)); let constant = constant_term.ocaml_str(); diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs b/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs index db3acc979a6..3b9a725c1dd 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/oracles.rs @@ -14,7 +14,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::ipa::OpeningProof; use poly_commitment::SRS; #[derive(ocaml::IntoValue, ocaml::FromValue, ocaml_gen::Struct)] 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 acd6f90a390..f2f767062f4 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 @@ -10,7 +10,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, SRS as _}; +use poly_commitment::{ipa::OpeningProof, SRS as _}; use serde::{Deserialize, Serialize}; use std::{ fs::{File, OpenOptions}, @@ -85,7 +85,7 @@ pub fn caml_pasta_fp_plonk_index_create( }; // endo - let (endo_q, _endo_r) = poly_commitment::srs::endos::(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); srs.0.with_lagrange_basis(cs.domain.d1); @@ -100,7 +100,7 @@ pub fn caml_pasta_fp_plonk_index_create( #[ocaml_gen::func] #[ocaml::func] pub fn caml_pasta_fp_plonk_index_max_degree(index: CamlPastaFpPlonkIndexPtr) -> ocaml::Int { - index.as_ref().0.srs.max_degree() as isize + index.as_ref().0.srs.max_poly_size() as isize } #[ocaml_gen::func] 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 23816ccf39c..c0ee7346c34 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 @@ -29,7 +29,7 @@ use mina_poseidon::{ sponge::{DefaultFqSponge, DefaultFrSponge}, }; use poly_commitment::commitment::{CommitmentCurve, PolyComm}; -use poly_commitment::evaluation_proof::OpeningProof; +use poly_commitment::ipa::OpeningProof; use std::array; use std::convert::TryInto; @@ -66,13 +66,13 @@ pub fn caml_pasta_fp_plonk_proof_create( .iter() .map(Into::::into) .collect(); - let comm = PolyComm:: { elems: vec![sg] }; + let comm = PolyComm:: { chunks: vec![sg] }; RecursionChallenge { chals, comm } }) .collect() }; - let witness: Vec> = witness.iter().map(|x| (*x.0).clone()).collect(); + let witness: Vec> = witness.iter().map(|x| (**x).clone()).collect(); let witness: [Vec<_>; COLUMNS] = witness .try_into() .map_err(|_| ocaml::Error::Message("the witness should be a column of 15 vectors"))?; @@ -134,13 +134,13 @@ pub fn caml_pasta_fp_plonk_proof_create_and_verify( .iter() .map(Into::::into) .collect(); - let comm = PolyComm:: { elems: vec![sg] }; + let comm = PolyComm:: { chunks: vec![sg] }; RecursionChallenge { chals, comm } }) .collect() }; - let witness: Vec> = witness.iter().map(|x| (*x.0).clone()).collect(); + let witness: Vec> = witness.iter().map(|x| (**x).clone()).collect(); let witness: [Vec<_>; COLUMNS] = witness .try_into() .map_err(|_| ocaml::Error::Message("the witness should be a column of 15 vectors"))?; @@ -204,7 +204,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_lookup( polynomial::COLUMNS, wires::Wire, }; - use poly_commitment::srs::endos; + use poly_commitment::ipa::endos; let num_gates = 1000; let num_tables: usize = 5; @@ -316,6 +316,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_foreign_field_mul( CamlProofWithPublic, ) { use ark_ff::Zero; + use kimchi::circuits::polynomials::foreign_field_common::BigUintForeignFieldHelpers; use kimchi::circuits::{ constraints::ConstraintSystem, gate::{CircuitGate, Connect}, @@ -324,8 +325,8 @@ pub fn caml_pasta_fp_plonk_proof_example_with_foreign_field_mul( }; use num_bigint::BigUint; use num_bigint::RandBigInt; - use o1_utils::{foreign_field::BigUintForeignFieldHelpers, FieldHelpers}; - use poly_commitment::srs::endos; + use o1_utils::FieldHelpers; + use poly_commitment::ipa::endos; use rand::{rngs::StdRng, SeedableRng}; let foreign_field_modulus = Fq::modulus_biguint(); @@ -475,13 +476,14 @@ pub fn caml_pasta_fp_plonk_proof_example_with_range_check( CamlProofWithPublic, ) { use ark_ff::Zero; + use kimchi::circuits::polynomials::foreign_field_common::BigUintForeignFieldHelpers; use kimchi::circuits::{ constraints::ConstraintSystem, gate::CircuitGate, polynomials::range_check, wires::Wire, }; use num_bigint::BigUint; use num_bigint::RandBigInt; - use o1_utils::{foreign_field::BigUintForeignFieldHelpers, BigUintFieldHelpers}; - use poly_commitment::srs::endos; + use o1_utils::BigUintFieldHelpers; + use poly_commitment::ipa::endos; use rand::{rngs::StdRng, SeedableRng}; let rng = &mut StdRng::from_seed([255u8; 32]); @@ -548,7 +550,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_range_check0( polynomials::{generic::GenericGateSpec, range_check}, wires::Wire, }; - use poly_commitment::srs::endos; + use poly_commitment::ipa::endos; let gates = { // Public input row with value 0 @@ -626,7 +628,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_ffadd( wires::Wire, }; use num_bigint::BigUint; - use poly_commitment::srs::endos; + use poly_commitment::ipa::endos; // Includes a row to store value 1 let num_public_inputs = 1; @@ -662,7 +664,8 @@ pub fn caml_pasta_fp_plonk_proof_example_with_ffadd( for _ in 0..4 { CircuitGate::extend_multi_range_check(&mut gates, &mut curr_row); } - // Connect the witnesses of the addition to the corresponding range checks + // Connect the witnesses of the addition to the corresponding range + // checks gates.connect_ffadd_range_checks(1, Some(4), Some(8), 12); // Connect the bound check range checks gates.connect_ffadd_range_checks(2, None, None, 16); @@ -701,7 +704,8 @@ pub fn caml_pasta_fp_plonk_proof_example_with_ffadd( witness }; - // not sure if theres a smarter way instead of the double unwrap, but should be fine in the test + // not sure if theres a smarter way instead of the double unwrap, but should + // be fine in the test let cs = ConstraintSystem::::create(gates) .public(num_public_inputs) .build() @@ -747,7 +751,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_xor( polynomials::{generic::GenericGateSpec, xor}, wires::Wire, }; - use poly_commitment::srs::endos; + use poly_commitment::ipa::endos; let num_public_inputs = 2; @@ -762,7 +766,8 @@ pub fn caml_pasta_fp_plonk_proof_example_with_xor( None, )); } - // 1 XOR of 128 bits. This will create 8 Xor16 gates and a Generic final gate with all zeros. + // 1 XOR of 128 bits. This will create 8 Xor16 gates and a Generic final + // gate with all zeros. CircuitGate::::extend_xor_gadget(&mut gates, 128); // connect public inputs to the inputs of the XOR gates.connect_cell_pair((0, 0), (2, 0)); @@ -789,7 +794,8 @@ pub fn caml_pasta_fp_plonk_proof_example_with_xor( cols }; - // not sure if theres a smarter way instead of the double unwrap, but should be fine in the test + // not sure if theres a smarter way instead of the double unwrap, but should + // be fine in the test let cs = ConstraintSystem::::create(gates) .public(num_public_inputs) .build() @@ -838,7 +844,7 @@ pub fn caml_pasta_fp_plonk_proof_example_with_rot( }, wires::Wire, }; - use poly_commitment::srs::endos; + use poly_commitment::ipa::endos; // Includes the actual input of the rotation and a row with the zero value let num_public_inputs = 2; @@ -882,7 +888,8 @@ pub fn caml_pasta_fp_plonk_proof_example_with_rot( cols }; - // not sure if theres a smarter way instead of the double unwrap, but should be fine in the test + // not sure if theres a smarter way instead of the double unwrap, but should + // be fine in the test let cs = ConstraintSystem::::create(gates) .public(num_public_inputs) .build() @@ -977,7 +984,7 @@ pub fn caml_pasta_fp_plonk_proof_dummy() -> CamlProofWithPublic PolyComm { let g = Vesta::generator(); PolyComm { - elems: vec![g, g, g], + chunks: vec![g, g, g], } } 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 ed950841f3f..b313a855706 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 @@ -16,8 +16,9 @@ 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 poly_commitment::ipa::OpeningProof; +use poly_commitment::SRS as _; +use poly_commitment::{commitment::PolyComm, ipa::SRS}; use std::convert::TryInto; use std::path::Path; use std::sync::Arc; @@ -71,7 +72,7 @@ impl From for VerifierIndex(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); let domain = Domain::::new(1 << index.domain.log_size_of_group).expect("wrong size"); let coefficients_comm: Vec> = @@ -171,7 +172,7 @@ pub fn read_raw( path: String, ) -> Result>, ocaml::Error> { let path = Path::new(&path); - let (endo_q, _endo_r) = poly_commitment::srs::endos::(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); VerifierIndex::>::from_file( srs.0, path, 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 fc360eb168b..e7f67f6cef9 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 @@ -10,7 +10,8 @@ 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 poly_commitment::ipa::OpeningProof; +use poly_commitment::SRS as _; use serde::{Deserialize, Serialize}; use std::{ fs::{File, OpenOptions}, @@ -84,7 +85,7 @@ pub fn caml_pasta_fq_plonk_index_create( }; // endo - let (endo_q, _endo_r) = poly_commitment::srs::endos::(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); srs.0.with_lagrange_basis(cs.domain.d1); @@ -99,7 +100,7 @@ pub fn caml_pasta_fq_plonk_index_create( #[ocaml_gen::func] #[ocaml::func] pub fn caml_pasta_fq_plonk_index_max_degree(index: CamlPastaFqPlonkIndexPtr) -> ocaml::Int { - index.as_ref().0.srs.max_degree() as isize + index.as_ref().0.srs.max_poly_size() as isize } #[ocaml_gen::func] 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 14be39c2269..34beeacc045 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 @@ -27,7 +27,7 @@ use mina_poseidon::{ sponge::{DefaultFqSponge, DefaultFrSponge}, }; use poly_commitment::commitment::{CommitmentCurve, PolyComm}; -use poly_commitment::evaluation_proof::OpeningProof; +use poly_commitment::ipa::OpeningProof; use std::array; use std::convert::TryInto; @@ -60,13 +60,13 @@ pub fn caml_pasta_fq_plonk_proof_create( .iter() .map(Into::::into) .collect(); - let comm = PolyComm:: { elems: vec![sg] }; + let comm = PolyComm:: { chunks: vec![sg] }; RecursionChallenge { chals, comm } }) .collect() }; - let witness: Vec> = witness.iter().map(|x| (*x.0).clone()).collect(); + let witness: Vec> = witness.iter().map(|x| (**x).clone()).collect(); let witness: [Vec<_>; COLUMNS] = witness .try_into() .expect("the witness should be a column of 15 vectors"); @@ -78,12 +78,17 @@ pub fn caml_pasta_fq_plonk_proof_create( // public input let public_input = witness[0][0..index.cs.public].to_vec(); - // NB: This method is designed only to be used by tests. However, since creating a new reference will cause `drop` to be called on it once we are done with it. Since `drop` calls `caml_shutdown` internally, we *really, really* do not want to do this, but we have no other way to get at the active runtime. - // TODO: There's actually a way to get a handle to the runtime as a function argument. Switch - // to doing this instead. + // NB: This method is designed only to be used by tests. However, since + // creating a new reference will cause `drop` to be called on it once we are + // done with it. Since `drop` calls `caml_shutdown` internally, we *really, + // really* do not want to do this, but we have no other way to get at the + // active runtime. + // TODO: There's actually a way to get a handle to the runtime as a function + // argument. Switch to doing this instead. let runtime = unsafe { ocaml::Runtime::recover_handle() }; - // Release the runtime lock so that other threads can run using it while we generate the proof. + // 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::< @@ -170,7 +175,7 @@ pub fn caml_pasta_fq_plonk_proof_dummy() -> CamlProofWithPublic PolyComm { let g = Pallas::generator(); PolyComm { - elems: vec![g, g, g], + chunks: vec![g, g, g], } } 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 5251923a42d..3e086dd5bc0 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 @@ -15,8 +15,9 @@ 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, evaluation_proof::OpeningProof}; -use poly_commitment::{commitment::PolyComm, srs::SRS}; +use poly_commitment::SRS as _; +use poly_commitment::{commitment::caml::CamlPolyComm, ipa::OpeningProof}; +use poly_commitment::{commitment::PolyComm, ipa::SRS}; use std::convert::TryInto; use std::path::Path; use std::sync::Arc; @@ -70,7 +71,7 @@ impl From for VerifierIndex(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); let domain = Domain::::new(1 << index.domain.log_size_of_group).expect("wrong size"); let coefficients_comm: Vec> = @@ -170,7 +171,7 @@ pub fn read_raw( path: String, ) -> Result>, ocaml::Error> { let path = Path::new(&path); - let (endo_q, _endo_r) = poly_commitment::srs::endos::(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); VerifierIndex::>::from_file( srs.0, path, diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/projective.rs b/src/lib/crypto/kimchi_bindings/stubs/src/projective.rs index 2eac668905a..178ac0a8665 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/projective.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/projective.rs @@ -68,7 +68,8 @@ macro_rules! impl_projective { #[ocaml_gen::func] #[ocaml::func] pub fn [](i: ocaml::Int) -> $GroupProjective { - // We only care about entropy here, so we force a conversion i32 -> u32. + // We only care about entropy here, so we force a conversion i32 + // -> u32. let i: u64 = (i as u32).into(); let mut rng: StdRng = rand::SeedableRng::seed_from_u64(i); let proj: $Projective = UniformRand::rand(&mut rng); @@ -78,14 +79,14 @@ macro_rules! impl_projective { #[ocaml_gen::func] #[ocaml::func] pub extern "C" fn []() -> $CamlBaseField { - let (endo_q, _endo_r) = poly_commitment::srs::endos::(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); endo_q.into() } #[ocaml_gen::func] #[ocaml::func] pub extern "C" fn []() -> $CamlScalarField { - let (_endo_q, endo_r) = poly_commitment::srs::endos::(); + let (_endo_q, endo_r) = poly_commitment::ipa::endos::(); endo_r.into() } diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/srs.rs b/src/lib/crypto/kimchi_bindings/stubs/src/srs.rs index 6269de0aa9d..13238ba2e67 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/srs.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/srs.rs @@ -5,7 +5,7 @@ use paste::paste; use poly_commitment::SRS as _; use poly_commitment::{ commitment::{b_poly_coefficients, caml::CamlPolyComm}, - srs::SRS, + ipa::SRS, }; use serde::{Deserialize, Serialize}; use std::{ diff --git a/src/lib/crypto/kimchi_bindings/stubs/src/urs_utils.rs b/src/lib/crypto/kimchi_bindings/stubs/src/urs_utils.rs index 14b2b49f589..0ff8387daca 100644 --- a/src/lib/crypto/kimchi_bindings/stubs/src/urs_utils.rs +++ b/src/lib/crypto/kimchi_bindings/stubs/src/urs_utils.rs @@ -1,8 +1,8 @@ -use ark_ec::{VariableBaseMSM, CurveGroup}; +use ark_ec::{CurveGroup, VariableBaseMSM}; use ark_ff::{batch_inversion, One, PrimeField, UniformRand, Zero}; use poly_commitment::{ commitment::{b_poly_coefficients, CommitmentCurve}, - srs::SRS, + ipa::SRS, }; use rayon::prelude::*; diff --git a/src/lib/crypto/kimchi_bindings/wasm/Cargo.lock b/src/lib/crypto/kimchi_bindings/wasm/Cargo.lock index 9b7dbe5f608..91f508b5b8c 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/Cargo.lock +++ b/src/lib/crypto/kimchi_bindings/wasm/Cargo.lock @@ -61,7 +61,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -79,7 +79,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -386,12 +386,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "disjoint-set" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d102f1a462fdcdddce88d6d46c06c074a2d2749b262230333726b06c52bb7585" - [[package]] name = "either" version = "1.9.0" @@ -548,6 +542,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" @@ -572,11 +575,11 @@ dependencies = [ "ark-poly", "ark-serialize", "blake2", - "disjoint-set", "groupmap", "hex", "internal-tracing", - "itertools", + "itertools 0.12.1", + "log", "mina-curves", "mina-poseidon", "num-bigint", @@ -642,6 +645,7 @@ version = "0.1.0" dependencies = [ "ark-ec", "ark-ff", + "num-bigint", ] [[package]] @@ -763,7 +767,6 @@ dependencies = [ "ark-serialize", "bcs", "hex", - "mina-curves", "num-bigint", "num-integer", "num-traits", @@ -838,7 +841,7 @@ dependencies = [ "ark-serialize", "blake2", "groupmap", - "itertools", + "itertools 0.12.1", "mina-curves", "mina-poseidon", "o1-utils", diff --git a/src/lib/crypto/kimchi_bindings/wasm/Cargo.toml b/src/lib/crypto/kimchi_bindings/wasm/Cargo.toml index 438b73d0e29..1be61923e36 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/Cargo.toml +++ b/src/lib/crypto/kimchi_bindings/wasm/Cargo.toml @@ -14,9 +14,30 @@ crate-type = ["cdylib"] ################################# Dependencies ################################ [dependencies] -# Strictly enforcing 0.2.87 -wasm-bindgen = { version = "=0.2.87" } +array-init = "2.0.0" +base64 = "0.13.0" console_error_panic_hook = { version = "0.1.6" } +getrandom = { version = "0.2", features = ["js"] } +js-sys = "0.3" +libc = "0.2.62" +num-bigint = { version = "0.4.0" } +once_cell = "1.10.0" +paste = "1.0.5" +# Version for proc-macro2 needs to be 1.0.60+ to be compatible with newer rust +# versions https://github.com/rust-lang/rust/issues/113152 +proc-macro2 = { version = "=1.0.66", features = ["default", "proc-macro"] } +quote = "1.0.31" +rand = { version = "0.8.0" } +rayon = { version = "1" } +rmp-serde = "1.0.0" +sprs = { version = "0.11.0" } +spmc = { version = "0.3.0" } +serde = "1.0.171" +serde_json = "1.0.103" +serde_with = ">=2.1.0" +serde-wasm-bindgen = ">=0.4" +# Check it is up-to-date with the version in proof-systems/Cargo.toml +wasm-bindgen = { version = "=0.2.87" } web-sys = { version = "0.3.35", features = [ "Window", "Document", @@ -26,42 +47,19 @@ web-sys = { version = "0.3.35", features = [ "Element", ] } -once_cell = "1.10.0" -libc = "0.2.62" - # arkworks -ark-ff = { version = "0.4.2", features = ["parallel", "asm"] } -ark-serialize = "0.4.2" ark-ec = { version = "0.4.2", features = ["parallel"] } +ark-ff = { version = "0.4.2", features = ["parallel", "asm"] } ark-poly = { version = "0.4.2", features = ["parallel"] } +ark-serialize = "0.4.2" # proof-systems -poly-commitment = { path = "../../proof-systems/poly-commitment" } groupmap = { path = "../../proof-systems/groupmap" } +kimchi = { path = "../../proof-systems/kimchi", features = ["wasm_types"] } mina-curves = { path = "../../proof-systems/curves" } -o1-utils = { path = "../../proof-systems/utils" } mina-poseidon = { path = "../../proof-systems/poseidon" } -kimchi = { path = "../../proof-systems/kimchi", features = ["wasm_types"] } - -array-init = "2.0.0" -base64 = "0.13.0" -getrandom = { version = "0.2", features = ["js"] } -num-bigint = { version = "0.4.0" } -paste = "1.0.5" -rand = { version = "0.8.0" } -rayon = { version = "1" } -rmp-serde = "1.0.0" -sprs = { version = "0.11.0" } -spmc = { version = "0.3.0" } -serde = "1.0.171" -serde_json = "1.0.103" -serde_with = ">=2.1.0" -serde-wasm-bindgen = ">=0.4" -js-sys = "0.3" -# Version for proc-macro2 needs to be 1.0.60+ to be compatible with newer rust versions -# https://github.com/rust-lang/rust/issues/113152 -proc-macro2 = { version = "=1.0.66", features = ["default", "proc-macro"] } -quote = "1.0.31" +o1-utils = { path = "../../proof-systems/utils" } +poly-commitment = { path = "../../proof-systems/poly-commitment" } [dev-dependencies] wasm-bindgen-test = ">=0.3.0" diff --git a/src/lib/crypto/kimchi_bindings/wasm/rust-toolchain.toml b/src/lib/crypto/kimchi_bindings/wasm/rust-toolchain.toml index b04d9639e65..e26dbd4c0ba 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/rust-toolchain.toml +++ b/src/lib/crypto/kimchi_bindings/wasm/rust-toolchain.toml @@ -3,4 +3,4 @@ # This should stay in line with the versions in # - kimchi_bindings/js/node_js/build.sh # - kimchi_bindings/js/web/build.sh -channel = "nightly-2023-09-01" # roughly matches 1.72 +channel = "1.74" diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/arkworks/bigint_256.rs b/src/lib/crypto/kimchi_bindings/wasm/src/arkworks/bigint_256.rs index 3c97b9e7170..9fd2e7aa2d0 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/arkworks/bigint_256.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/arkworks/bigint_256.rs @@ -38,9 +38,7 @@ impl IntoWasmAbi for WasmBigInteger256 { type Abi = as FromWasmAbi>::Abi; fn into_abi(self) -> Self::Abi { let mut bytes: Vec = vec![]; - (&mut bytes) - .write_all(self.0.to_bytes_le().as_slice()) - .unwrap(); + bytes.write_all(self.0.to_bytes_le().as_slice()).unwrap(); bytes.into_abi() } } diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/lib.rs b/src/lib/crypto/kimchi_bindings/wasm/src/lib.rs index 3f994cc2caa..89d527afa57 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/lib.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(get_mut_unchecked)] //! The Marlin_plonk_stubs crate exports some functionalities //! and structures from the following the Rust crates to OCaml: //! diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/oracles.rs b/src/lib/crypto/kimchi_bindings/wasm/src/oracles.rs index 96a17baa432..47262466b80 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/oracles.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/oracles.rs @@ -9,7 +9,7 @@ use mina_poseidon::{ }; use paste::paste; use poly_commitment::commitment::{shift_scalar, PolyComm}; -use poly_commitment::evaluation_proof::OpeningProof; +use poly_commitment::ipa::OpeningProof; use poly_commitment::SRS; use wasm_bindgen::prelude::*; // use wasm_bindgen::convert::{IntoWasmAbi, FromWasmAbi}; diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/pasta_fp_plonk_index.rs b/src/lib/crypto/kimchi_bindings/wasm/src/pasta_fp_plonk_index.rs index 9cbe1e15513..16f3eb47c76 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/pasta_fp_plonk_index.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/pasta_fp_plonk_index.rs @@ -9,10 +9,11 @@ use crate::wasm_vector::{fp::*, WasmVector}; use kimchi::circuits::lookup::tables::LookupTable; use kimchi::circuits::{constraints::ConstraintSystem, gate::CircuitGate}; use kimchi::linearization::expr_linearization; -use kimchi::poly_commitment::evaluation_proof::OpeningProof; +use kimchi::poly_commitment::ipa::OpeningProof; use kimchi::prover_index::ProverIndex; use mina_curves::pasta::{Fp, Pallas as GAffineOther, Vesta as GAffine, VestaParameters}; use mina_poseidon::{constants::PlonkSpongeConstantsKimchi, sponge::DefaultFqSponge}; +use poly_commitment::SRS; use serde::{Deserialize, Serialize}; use std::{ fs::{File, OpenOptions}, @@ -44,7 +45,7 @@ pub struct WasmPastaFpLookupTable { impl From for LookupTable { fn from(wasm_lt: WasmPastaFpLookupTable) -> LookupTable { LookupTable { - id: wasm_lt.id.into(), + id: wasm_lt.id, data: wasm_lt.data.0, } } @@ -142,7 +143,7 @@ pub fn caml_pasta_fp_plonk_index_create( }; // endo - let (endo_q, _endo_r) = poly_commitment::srs::endos::(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); srs.0.get_lagrange_basis(cs.domain.d1); @@ -162,7 +163,7 @@ pub fn caml_pasta_fp_plonk_index_create( #[wasm_bindgen] pub fn caml_pasta_fp_plonk_index_max_degree(index: &WasmPastaFpPlonkIndex) -> i32 { - index.0.srs.max_degree() as i32 + index.0.srs.max_poly_size() as i32 } #[wasm_bindgen] diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/pasta_fq_plonk_index.rs b/src/lib/crypto/kimchi_bindings/wasm/src/pasta_fq_plonk_index.rs index ec8640781c6..86c61d01e12 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/pasta_fq_plonk_index.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/pasta_fq_plonk_index.rs @@ -9,10 +9,11 @@ use crate::wasm_vector::{fq::*, WasmVector}; use kimchi::circuits::lookup::tables::LookupTable; use kimchi::circuits::{constraints::ConstraintSystem, gate::CircuitGate}; use kimchi::linearization::expr_linearization; -use kimchi::poly_commitment::evaluation_proof::OpeningProof; +use kimchi::poly_commitment::ipa::OpeningProof; use kimchi::prover_index::ProverIndex; use mina_curves::pasta::{Fq, Pallas as GAffine, PallasParameters, Vesta as GAffineOther}; use mina_poseidon::{constants::PlonkSpongeConstantsKimchi, sponge::DefaultFqSponge}; +use poly_commitment::SRS; use serde::{Deserialize, Serialize}; use std::{ fs::{File, OpenOptions}, @@ -41,7 +42,7 @@ pub struct WasmPastaFqLookupTable { impl From for LookupTable { fn from(wasm_lt: WasmPastaFqLookupTable) -> LookupTable { LookupTable { - id: wasm_lt.id.into(), + id: wasm_lt.id, data: wasm_lt.data.0, } } @@ -140,7 +141,7 @@ pub fn caml_pasta_fq_plonk_index_create( }; // endo - let (endo_q, _endo_r) = poly_commitment::srs::endos::(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); srs.0.get_lagrange_basis(cs.domain.d1); @@ -161,7 +162,7 @@ pub fn caml_pasta_fq_plonk_index_create( #[wasm_bindgen] pub fn caml_pasta_fq_plonk_index_max_degree(index: &WasmPastaFqPlonkIndex) -> i32 { - index.0.srs.max_degree() as i32 + index.0.srs.max_poly_size() as i32 } #[wasm_bindgen] 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 2a1ab686201..3017af8ce23 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/plonk_proof.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/plonk_proof.rs @@ -30,9 +30,10 @@ use mina_poseidon::{ constants::PlonkSpongeConstantsKimchi, sponge::{DefaultFqSponge, DefaultFrSponge}, }; +use poly_commitment::SRS as _; use poly_commitment::{ commitment::{CommitmentCurve, PolyComm}, - evaluation_proof::OpeningProof, + ipa::OpeningProof, }; use serde::{Deserialize, Serialize}; @@ -681,7 +682,7 @@ macro_rules! impl_proof { .map(|a| a.clone().into()) .collect(); let comm = PolyComm::<$G> { - elems: vec![sg], + chunks: vec![sg], }; RecursionChallenge { chals, comm } }) @@ -782,7 +783,7 @@ macro_rules! impl_proof { fn comm() -> PolyComm<$G> { let g = $G::generator(); PolyComm { - elems: vec![g, g, g], + chunks: vec![g, g, g], } } diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/plonk_verifier_index.rs b/src/lib/crypto/kimchi_bindings/wasm/src/plonk_verifier_index.rs index def0114de61..a0a68815fd6 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/plonk_verifier_index.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/plonk_verifier_index.rs @@ -11,11 +11,12 @@ use kimchi::circuits::{ wires::{COLUMNS, PERMUTS}, }; use kimchi::linearization::expr_linearization; -use kimchi::poly_commitment::evaluation_proof::OpeningProof; +use kimchi::poly_commitment::ipa::OpeningProof; use kimchi::verifier_index::{LookupVerifierIndex, VerifierIndex as DlogVerifierIndex}; use paste::paste; use poly_commitment::commitment::PolyComm; -use poly_commitment::srs::SRS; +use poly_commitment::ipa::SRS; +use poly_commitment::SRS as _; use std::path::Path; use std::sync::Arc; use wasm_bindgen::prelude::*; @@ -603,7 +604,7 @@ macro_rules! impl_verification_key { evals: evals.clone(), shifts: shifts.clone(), lookup_index: lookup_index.clone(), - zk_rows: zk_rows, + zk_rows, } } @@ -732,12 +733,12 @@ macro_rules! impl_verification_key { let runtime_tables = index .lookup_index.as_ref() .map_or(false, |li| li.runtime_tables_selector.is_some()); - + let patterns = LookupPatterns { xor, lookup, range_check: range_check0 || range_check1 || rot, - foreign_field_mul: foreign_field_mul, + foreign_field_mul, }; FeatureFlags { @@ -774,7 +775,7 @@ macro_rules! impl_verification_key { // Rc<_>s into weak pointers. SRSValue::Ref(unsafe { &*Rc::into_raw(urs_copy) }) }; */ - let (endo_q, _endo_r) = poly_commitment::srs::endos::<$GOther>(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::<$GOther>(); let domain = Domain::<$F>::new(1 << log_size_of_group).unwrap(); let feature_flags = compute_feature_flags(&index); @@ -853,7 +854,7 @@ macro_rules! impl_verification_key { path: String, ) -> Result>, JsValue> { let path = Path::new(&path); - let (endo_q, _endo_r) = poly_commitment::srs::endos::(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); DlogVerifierIndex::<$G, OpeningProof<$G>>::from_file( srs.0.clone(), path, diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/poly_comm.rs b/src/lib/crypto/kimchi_bindings/wasm/src/poly_comm.rs index aeefce15bd7..6c9ef6edf7f 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/poly_comm.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/poly_comm.rs @@ -49,9 +49,9 @@ macro_rules! impl_poly_comm { impl From> for WasmPolyComm { fn from(x: PolyComm<$G>) -> Self { - let PolyComm { elems } = x; + let PolyComm { chunks } = x; let unshifted: Vec<$WasmG> = - elems.into_iter().map(|x| x.into()).collect(); + chunks.into_iter().map(|x| x.into()).collect(); WasmPolyComm { unshifted: unshifted.into(), shifted: None @@ -62,7 +62,7 @@ macro_rules! impl_poly_comm { impl From<&PolyComm<$G>> for WasmPolyComm { fn from(x: &PolyComm<$G>) -> Self { let unshifted: Vec<$WasmG> = - x.elems.iter().map(|x| x.into()).collect(); + x.chunks.iter().map(|x| x.into()).collect(); WasmPolyComm { unshifted: unshifted.into(), shifted: None, @@ -78,7 +78,7 @@ macro_rules! impl_poly_comm { "mina#14628: Shifted commitments are deprecated and must not be used" ); PolyComm { - elems: (*unshifted).iter().map(|x| { (*x).into() }).collect(), + chunks: (*unshifted).iter().map(|x| { (*x).into() }).collect(), } } } @@ -90,7 +90,7 @@ macro_rules! impl_poly_comm { "mina#14628: Shifted commitments are deprecated and must not be used" ); PolyComm { - elems: x.unshifted.iter().map(|x| { (*x).into() }).collect(), + chunks: x.unshifted.iter().map(|x| { (*x).into() }).collect(), } } } diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/poseidon.rs b/src/lib/crypto/kimchi_bindings/wasm/src/poseidon.rs index cf1564460f5..378505665a6 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/poseidon.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/poseidon.rs @@ -15,7 +15,7 @@ pub fn caml_pasta_fp_poseidon_block_cipher( ) -> WasmFlatVector { let mut state_vec: Vec = state.into_iter().map(Into::into).collect(); poseidon_block_cipher::( - &mina_poseidon::pasta::fp_kimchi::static_params(), + mina_poseidon::pasta::fp_kimchi::static_params(), &mut state_vec, ); state_vec @@ -33,7 +33,7 @@ pub fn caml_pasta_fq_poseidon_block_cipher( ) -> WasmFlatVector { let mut state_vec: Vec = state.into_iter().map(Into::into).collect(); poseidon_block_cipher::( - &mina_poseidon::pasta::fq_kimchi::static_params(), + mina_poseidon::pasta::fq_kimchi::static_params(), &mut state_vec, ); state_vec diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/projective.rs b/src/lib/crypto/kimchi_bindings/wasm/src/projective.rs index 63f524859e2..3da74f3318b 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/projective.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/projective.rs @@ -77,13 +77,13 @@ macro_rules! impl_projective { #[wasm_bindgen] pub extern "C" fn []() -> $CamlBaseField { - let (endo_q, _endo_r) = poly_commitment::srs::endos::(); + let (endo_q, _endo_r) = poly_commitment::ipa::endos::(); endo_q.into() } #[wasm_bindgen] pub extern "C" fn []() -> $CamlScalarField { - let (_endo_q, endo_r) = poly_commitment::srs::endos::(); + let (_endo_q, endo_r) = poly_commitment::ipa::endos::(); endo_r.into() } diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/srs.rs b/src/lib/crypto/kimchi_bindings/wasm/src/srs.rs index 2b33c56d59f..84bb117b563 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/srs.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/srs.rs @@ -4,7 +4,7 @@ use ark_poly::DenseUVPolynomial; use ark_poly::{univariate::DensePolynomial, EvaluationDomain, Evaluations}; use paste::paste; use poly_commitment::SRS as ISRS; -use poly_commitment::{commitment::b_poly_coefficients, srs::SRS, hash_map_cache::HashMapCache}; +use poly_commitment::{commitment::b_poly_coefficients, hash_map_cache::HashMapCache, ipa::SRS}; use serde::{Deserialize, Serialize}; use std::ops::Deref; use std::{ @@ -226,8 +226,8 @@ pub mod fp { #[wasm_bindgen] pub fn caml_fp_srs_get(srs: &WasmFpSrs) -> WasmVector { // return a vector which consists of h, then all the gs - let mut h_and_gs: Vec = vec![srs.0.h.clone().into()]; - h_and_gs.extend(srs.0.g.iter().map(|x: &G| WasmG::from(x.clone()))); + let mut h_and_gs: Vec = vec![srs.0.h.into()]; + h_and_gs.extend(srs.0.g.iter().map(|x: &G| WasmG::from(*x))); h_and_gs.into() } @@ -267,9 +267,10 @@ pub mod fp { domain_size: i32, input_bases: WasmVector, ) { - srs.lagrange_bases.get_or_generate(domain_size as usize, || { - input_bases.into_iter().map(Into::into).collect() - }); + srs.lagrange_bases + .get_or_generate(domain_size as usize, || { + input_bases.into_iter().map(Into::into).collect() + }); } // compute & add lagrange basis internally, return the entire basis @@ -279,13 +280,12 @@ pub mod fp { domain_size: i32, ) -> WasmVector { // compute lagrange basis - let basis = - crate::rayon::run_in_pool(|| { + let basis = crate::rayon::run_in_pool(|| { let domain = EvaluationDomain::::new(domain_size as usize).expect("invalid domain size"); srs.get_lagrange_basis(domain) }); - basis.into_iter().map(Into::into).collect() + basis.iter().map(Into::into).collect() } } @@ -306,8 +306,8 @@ pub mod fq { #[wasm_bindgen] pub fn caml_fq_srs_get(srs: &WasmFqSrs) -> WasmVector { // return a vector which consists of h, then all the gs - let mut h_and_gs: Vec = vec![srs.0.h.clone().into()]; - h_and_gs.extend(srs.0.g.iter().map(|x: &G| WasmG::from(x.clone()))); + let mut h_and_gs: Vec = vec![srs.0.h.into()]; + h_and_gs.extend(srs.0.g.iter().map(|x: &G| WasmG::from(*x))); h_and_gs.into() } @@ -347,9 +347,10 @@ pub mod fq { domain_size: i32, input_bases: WasmVector, ) { - srs.lagrange_bases.get_or_generate(domain_size as usize, || { - input_bases.into_iter().map(Into::into).collect() - }); + srs.lagrange_bases + .get_or_generate(domain_size as usize, || { + input_bases.into_iter().map(Into::into).collect() + }); } // compute & add lagrange basis internally, return the entire basis @@ -359,12 +360,11 @@ pub mod fq { domain_size: i32, ) -> WasmVector { // compute lagrange basis - let basis = - crate::rayon::run_in_pool(|| { + let basis = crate::rayon::run_in_pool(|| { let domain = EvaluationDomain::::new(domain_size as usize).expect("invalid domain size"); srs.get_lagrange_basis(domain) }); - basis.into_iter().map(Into::into).collect() + basis.iter().map(Into::into).collect() } } diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/urs_utils.rs b/src/lib/crypto/kimchi_bindings/wasm/src/urs_utils.rs index dacb7271ba4..0ff8387daca 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/urs_utils.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/urs_utils.rs @@ -2,7 +2,7 @@ use ark_ec::{CurveGroup, VariableBaseMSM}; use ark_ff::{batch_inversion, One, PrimeField, UniformRand, Zero}; use poly_commitment::{ commitment::{b_poly_coefficients, CommitmentCurve}, - srs::SRS, + ipa::SRS, }; use rayon::prelude::*; diff --git a/src/lib/crypto/proof-systems b/src/lib/crypto/proof-systems index 872c8f2d1ca..2fc23249a3d 160000 --- a/src/lib/crypto/proof-systems +++ b/src/lib/crypto/proof-systems @@ -1 +1 @@ -Subproject commit 872c8f2d1cae6bc0e46d1cf79655eb4592792b52 +Subproject commit 2fc23249a3d498da793780015ee44c0692ed45f0 diff --git a/src/lib/pickles/plonk_checks/scalars.ml b/src/lib/pickles/plonk_checks/scalars.ml index 74cc2136a21..6a62b3b3096 100644 --- a/src/lib/pickles/plonk_checks/scalars.ml +++ b/src/lib/pickles/plonk_checks/scalars.ml @@ -2393,70 +2393,46 @@ module Tick : S = struct cell (var (Index Xor16, Curr)) * ( cell (var (Witness 3, Curr)) + cell (var (Witness 4, Curr)) - * pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 4 ) + * field + "0x0000000000000000000000000000000000000000000000000000000000000010" + cell (var (Witness 5, Curr)) - * pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 8 ) + * field + "0x0000000000000000000000000000000000000000000000000000000000000100" + cell (var (Witness 6, Curr)) - * pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 12 ) - + pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 16 ) + * field + "0x0000000000000000000000000000000000000000000000000000000000001000" + + field + "0x0000000000000000000000000000000000000000000000000000000000010000" * cell (var (Witness 0, Next)) - cell (var (Witness 0, Curr)) + alpha_pow 1 * ( cell (var (Witness 7, Curr)) + cell (var (Witness 8, Curr)) - * pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 4 ) + * field + "0x0000000000000000000000000000000000000000000000000000000000000010" + cell (var (Witness 9, Curr)) - * pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 8 ) + * field + "0x0000000000000000000000000000000000000000000000000000000000000100" + cell (var (Witness 10, Curr)) - * pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 12 ) - + pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 16 ) + * field + "0x0000000000000000000000000000000000000000000000000000000000001000" + + field + "0x0000000000000000000000000000000000000000000000000000000000010000" * cell (var (Witness 1, Next)) - cell (var (Witness 1, Curr)) ) + alpha_pow 2 * ( cell (var (Witness 11, Curr)) + cell (var (Witness 12, Curr)) - * pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 4 ) + * field + "0x0000000000000000000000000000000000000000000000000000000000000010" + cell (var (Witness 13, Curr)) - * pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 8 ) + * field + "0x0000000000000000000000000000000000000000000000000000000000000100" + cell (var (Witness 14, Curr)) - * pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 12 ) - + pow - ( field - "0x0000000000000000000000000000000000000000000000000000000000000002" - , 16 ) + * field + "0x0000000000000000000000000000000000000000000000000000000000001000" + + field + "0x0000000000000000000000000000000000000000000000000000000000010000" * cell (var (Witness 2, Next)) - cell (var (Witness 2, Curr)) ) ) ) , fun () ->