From f974a9484da58c476eeb607cdefe6f0391ee963c Mon Sep 17 00:00:00 2001 From: Joey Kraut Date: Tue, 16 Apr 2024 16:06:22 -0700 Subject: [PATCH] plonk: multiprover: proof-system: Ingest `ark-mpc` interface changes --- plonk/src/multiprover/proof_system/prover.rs | 61 ++++++++++++++++++-- primitives/benches/merkle_path.rs | 2 +- primitives/benches/reed_solomon.rs | 2 +- primitives/src/lib.rs | 2 +- primitives/src/rescue/mod.rs | 2 +- rust-toolchain | 2 +- 6 files changed, 62 insertions(+), 9 deletions(-) diff --git a/plonk/src/multiprover/proof_system/prover.rs b/plonk/src/multiprover/proof_system/prover.rs index 0d11d8001..1e0abe1dc 100644 --- a/plonk/src/multiprover/proof_system/prover.rs +++ b/plonk/src/multiprover/proof_system/prover.rs @@ -27,7 +27,7 @@ use crate::{ proof_system::structs::{CommitKey, ProvingKey}, }; -use super::{MpcArithmetization, MpcOracles}; +use super::MpcArithmetization; // ------------------------- // | Prover Implementation | @@ -710,7 +710,7 @@ impl MpcProver { // with t_lowest_i(X) = t_lowest_i(X) - 0 + b_now_i * X^(n+2) // and t_highest_i(X) = t_highest_i(X) - b_last_i let mut last_randomizer = self.fabric.zero_authenticated(); - let mut randomizers = self.fabric.random_shared_scalars_authenticated(num_wire_types - 1); + let mut randomizers = self.fabric.random_shared_scalars(num_wire_types - 1); split_quot_polys.iter_mut().take(num_wire_types - 1).for_each(|poly| { poly.coeffs[0] = &poly.coeffs[0] - &last_randomizer; @@ -934,10 +934,12 @@ pub fn mul_poly_result( #[cfg(test)] pub(crate) mod test { + use ark_ec::CurveGroup; use ark_ff::{One, Zero}; use ark_mpc::{ - algebra::{AuthenticatedDensePoly, Scalar}, - beaver::ZeroBeaverSource, + algebra::{AuthenticatedDensePoly, Scalar, ScalarShare}, + network::PartyId, + offline_prep::PreprocessingPhase, test_helpers::{execute_mock_mpc, execute_mock_mpc_with_beaver_source}, MpcFabric, PARTY0, PARTY1, }; @@ -961,6 +963,57 @@ pub(crate) mod test { use super::MpcProver; + /// A beaver source that always returns zero + #[cfg(any(feature = "test_helpers", test))] + struct ZeroBeaverSource { + /// The ID of the local party + party_id: PartyId, + } + + impl ZeroBeaverSource { + /// Create a new beaver source given the local party_id + pub fn new(party_id: PartyId) -> Self { + Self { party_id } + } + } + + impl PreprocessingPhase for ZeroBeaverSource { + fn get_mac_key_share(&self) -> Scalar { + Scalar::zero() + } + + fn next_local_input_mask(&mut self) -> (Scalar, ScalarShare) { + (Scalar::zero(), ScalarShare::new(Scalar::zero(), Scalar::zero())) + } + + fn next_counterparty_input_mask(&mut self) -> ScalarShare { + ScalarShare::new(Scalar::zero(), Scalar::zero()) + } + + fn next_shared_bit(&mut self) -> ScalarShare { + ScalarShare::new(Scalar::zero(), Scalar::zero()) + } + + fn next_triplet(&mut self) -> (ScalarShare, ScalarShare, ScalarShare) { + let zero = ScalarShare::new(Scalar::zero(), Scalar::zero()); + (zero, zero, zero) + } + + /// For the shared inverse pair, we return 1 to give a valid member of + /// the multiplicative subgroup + /// + /// This means that each party holds their party ID as a shared value + fn next_shared_inverse_pair(&mut self) -> (ScalarShare, ScalarShare) { + let val = Scalar::from(self.party_id); + let share = ScalarShare::new(val, val); + (share, share) + } + + fn next_shared_value(&mut self) -> ScalarShare { + ScalarShare::new(Scalar::zero(), Scalar::zero()) + } + } + /// Get a randomized set of challenges fn randomized_challenges() -> Challenges { let mut rng = thread_rng(); diff --git a/primitives/benches/merkle_path.rs b/primitives/benches/merkle_path.rs index 1e6a8555c..814bc614d 100644 --- a/primitives/benches/merkle_path.rs +++ b/primitives/benches/merkle_path.rs @@ -4,7 +4,7 @@ // You should have received a copy of the MIT License // along with the Jellyfish library. If not, see . -#![deny(warnings)] +// #![deny(warnings)] #[macro_use] extern crate criterion; use ark_ed_on_bls12_381::Fq as Fq381; diff --git a/primitives/benches/reed_solomon.rs b/primitives/benches/reed_solomon.rs index fad3eafa9..27a27f8d6 100644 --- a/primitives/benches/reed_solomon.rs +++ b/primitives/benches/reed_solomon.rs @@ -4,7 +4,7 @@ // You should have received a copy of the MIT License // along with the Jellyfish library. If not, see . -#![deny(warnings)] +// #![deny(warnings)] #[macro_use] extern crate criterion; use ark_bn254::Fr as Fr254; diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 81eed6d8d..f517ede87 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -8,7 +8,7 @@ //! well as the plonk circuit implementation of those primitives. #![cfg_attr(not(feature = "std"), no_std)] -#![deny(warnings)] +// #![deny(warnings)] #![deny(missing_docs)] #![allow(unknown_lints)] #[cfg(test)] diff --git a/primitives/src/rescue/mod.rs b/primitives/src/rescue/mod.rs index fc4f246b7..439de60d2 100644 --- a/primitives/src/rescue/mod.rs +++ b/primitives/src/rescue/mod.rs @@ -18,7 +18,7 @@ //! //! Those three place holders should never be used. -#![deny(warnings)] +// #![deny(warnings)] pub mod errors; mod rescue_constants; pub mod sponge; diff --git a/rust-toolchain b/rust-toolchain index 2679c1b5d..a11a6b2b2 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2023-08-19 +nightly-2024-02-26