From 5b4107e5140f066bbb5307badbdbc83ad859af86 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Mon, 5 Aug 2024 12:14:26 +0400 Subject: [PATCH] Crates.io 0.8.0 release (#59) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # What ❔ ## Why ❔ ## Checklist - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`. --------- Co-authored-by: Oles Holembovskyy Co-authored-by: Yury Akudovich --- Cargo.toml | 6 +-- src/plonk/better_better_cs/cs.rs | 2 +- src/plonk/better_better_cs/proof/mod.rs | 47 +++++++++++++++++++++++ src/plonk/better_better_cs/setup/mod.rs | 5 ++- src/plonk/blake2_const/blake2s/Cargo.toml | 2 +- 5 files changed, 56 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2e5603fa..0fd36fcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://github.com/matter-labs/bellman" license = "MIT/Apache-2.0" name = "bellman_ce" repository = "https://github.com/matter-labs/bellman" -version = "0.7.0" +version = "0.8.0" edition = "2018" [lib] @@ -33,8 +33,8 @@ tiny-keccak = {version = "1.5", optional = true} blake2-rfc = {version = "0.2.18", optional = true} blake2s_simd = {version = "0.5"} lazy_static = {version = "1", optional = true} -blake2s_const = {version = "=0.7", optional = true, path = "./src/plonk/blake2_const/blake2s/"} -hex = "0.4.3" +blake2s_const = {version = "=0.8.0", optional = true, path = "./src/plonk/blake2_const/blake2s/"} +hex = "0.4" [features] default = ["multicore", "plonk"] diff --git a/src/plonk/better_better_cs/cs.rs b/src/plonk/better_better_cs/cs.rs index 4b1aace3..d4c62659 100644 --- a/src/plonk/better_better_cs/cs.rs +++ b/src/plonk/better_better_cs/cs.rs @@ -54,7 +54,7 @@ impl SynthesisMode for SynthesisModeTesting { pub trait Circuit { type MainGate: MainGate; - fn synthesize>(&self, cs: &mut CS) -> Result<(), SynthesisError>; + fn synthesize + 'static>(&self, cs: &mut CS) -> Result<(), SynthesisError>; fn declare_used_gates() -> Result>>, SynthesisError> { Ok( vec![Self::MainGate::default().into_internal()] diff --git a/src/plonk/better_better_cs/proof/mod.rs b/src/plonk/better_better_cs/proof/mod.rs index dbfe0d3e..44cc02db 100644 --- a/src/plonk/better_better_cs/proof/mod.rs +++ b/src/plonk/better_better_cs/proof/mod.rs @@ -279,6 +279,53 @@ impl> Proof { Ok(new) } + + pub unsafe fn redefine_circuit>(mut self) -> Proof { + let mut new = Proof::::empty(); + + // it's still possible that lookups are different + assert_eq!(C::declare_used_gates().unwrap(), C2::declare_used_gates().unwrap()); + + new.n = self.n; + new.inputs = std::mem::replace(&mut self.inputs, vec![]); + new.state_polys_commitments = std::mem::replace(&mut self.state_polys_commitments, vec![]); + new.witness_polys_commitments = std::mem::replace(&mut self.witness_polys_commitments, vec![]); + new.copy_permutation_grand_product_commitment = std::mem::replace(&mut self.copy_permutation_grand_product_commitment, E::G1Affine::zero()); + + new.lookup_s_poly_commitment = std::mem::replace(&mut self.lookup_s_poly_commitment, None); + new.lookup_grand_product_commitment = std::mem::replace(&mut self.lookup_grand_product_commitment, None); + + new.quotient_poly_parts_commitments = std::mem::replace(&mut self.quotient_poly_parts_commitments, vec![]); + + new.state_polys_openings_at_z = std::mem::replace(&mut self.state_polys_openings_at_z, vec![]); + new.state_polys_openings_at_dilations = std::mem::replace(&mut self.state_polys_openings_at_dilations, vec![]); + new.witness_polys_openings_at_z = std::mem::replace(&mut self.witness_polys_openings_at_z, vec![]); + new.witness_polys_openings_at_dilations = std::mem::replace(&mut self.witness_polys_openings_at_dilations, vec![]); + + new.gate_setup_openings_at_z = std::mem::replace(&mut self.gate_setup_openings_at_z, vec![]); + new.gate_selectors_openings_at_z = std::mem::replace(&mut self.gate_selectors_openings_at_z, vec![]); + + new.copy_permutation_polys_openings_at_z = std::mem::replace(&mut self.copy_permutation_polys_openings_at_z, vec![]); + new.copy_permutation_grand_product_opening_at_z_omega = std::mem::replace(&mut self.copy_permutation_grand_product_opening_at_z_omega, E::Fr::zero()); + + new.lookup_s_poly_opening_at_z_omega = std::mem::replace(&mut self.lookup_s_poly_opening_at_z_omega, None); + new.lookup_grand_product_opening_at_z_omega = std::mem::replace(&mut self.lookup_grand_product_opening_at_z_omega, None); + + new.lookup_t_poly_opening_at_z = std::mem::replace(&mut self.lookup_t_poly_opening_at_z, None); + new.lookup_t_poly_opening_at_z_omega = std::mem::replace(&mut self.lookup_t_poly_opening_at_z_omega, None); + + new.lookup_selector_poly_opening_at_z = std::mem::replace(&mut self.lookup_selector_poly_opening_at_z, None); + new.lookup_table_type_poly_opening_at_z = std::mem::replace(&mut self.lookup_table_type_poly_opening_at_z, None); + + new.quotient_poly_opening_at_z = std::mem::replace(&mut self.quotient_poly_opening_at_z, E::Fr::zero()); + + new.linearization_poly_opening_at_z = std::mem::replace(&mut self.linearization_poly_opening_at_z, E::Fr::zero()); + + new.opening_proof_at_z = std::mem::replace(&mut self.opening_proof_at_z, E::G1Affine::zero()); + new.opening_proof_at_z_omega = std::mem::replace(&mut self.opening_proof_at_z_omega, E::G1Affine::zero()); + + new + } } use super::cs::*; diff --git a/src/plonk/better_better_cs/setup/mod.rs b/src/plonk/better_better_cs/setup/mod.rs index f21d4cf0..e1fdf0f5 100644 --- a/src/plonk/better_better_cs/setup/mod.rs +++ b/src/plonk/better_better_cs/setup/mod.rs @@ -20,7 +20,7 @@ use std::io::{Read, Write}; use crate::plonk::better_cs::keys::*; -#[derive(Clone, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Setup> { pub n: usize, pub num_inputs: usize, @@ -38,6 +38,9 @@ pub struct Setup> { pub non_residues: Vec, + #[serde(skip_serializing,skip_deserializing, default)] + #[serde(bound(serialize = ""))] + #[serde(bound(deserialize = ""))] _marker: std::marker::PhantomData } diff --git a/src/plonk/blake2_const/blake2s/Cargo.toml b/src/plonk/blake2_const/blake2s/Cargo.toml index 34a9f42a..72ae0c7d 100644 --- a/src/plonk/blake2_const/blake2s/Cargo.toml +++ b/src/plonk/blake2_const/blake2s/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blake2s_const" -version = "0.7.0" +version = "0.8.0" authors = ["Jack O'Connor"] description = "a pure Rust BLAKE2s implementation with dynamic SIMD" license = "MIT"