diff --git a/benches/plonk.rs b/benches/plonk.rs index 1d3362700f..ec3773d2ab 100644 --- a/benches/plonk.rs +++ b/benches/plonk.rs @@ -19,10 +19,6 @@ use halo2_proofs::utils::rational::Rational; use halo2curves::bn256::Bn256; fn criterion_benchmark(c: &mut Criterion) { - /// This represents an advice column at a certain row in the ConstraintSystem - #[derive(Copy, Clone, Debug)] - pub struct Variable(Column, usize); - #[derive(Clone)] struct PlonkConfig { a: Column, diff --git a/examples/circuit-layout.rs b/examples/circuit-layout.rs index b65adf5599..ab1eccfcdc 100644 --- a/examples/circuit-layout.rs +++ b/examples/circuit-layout.rs @@ -1,17 +1,14 @@ use ff::Field; +use halo2_proofs::utils::rational::Rational; use halo2_proofs::{ circuit::{Cell, Layouter, Region, SimpleFloorPlanner, Value}, - plonk::{Advice, Assigned, Circuit, Column, ConstraintSystem, Error, Fixed, TableColumn}, + plonk::{Advice, Circuit, Column, ConstraintSystem, Error, Fixed, TableColumn}, poly::Rotation, }; use halo2curves::pasta::Fp; use rand_core::OsRng; use std::marker::PhantomData; -/// This represents an advice column at a certain row in the ConstraintSystem -#[derive(Copy, Clone, Debug)] -pub struct Variable(Column, usize); - #[derive(Clone)] struct PlonkConfig { a: Column, @@ -30,10 +27,10 @@ struct PlonkConfig { trait StandardCs { fn raw_multiply(&self, region: &mut Region, f: F) -> Result<(Cell, Cell, Cell), Error> where - F: FnMut() -> Value<(Assigned, Assigned, Assigned)>; + F: FnMut() -> Value<(Rational, Rational, Rational)>; fn raw_add(&self, region: &mut Region, f: F) -> Result<(Cell, Cell, Cell), Error> where - F: FnMut() -> Value<(Assigned, Assigned, Assigned)>; + F: FnMut() -> Value<(Rational, Rational, Rational)>; fn copy(&self, region: &mut Region, a: Cell, b: Cell) -> Result<(), Error>; fn lookup_table(&self, layouter: &mut impl Layouter, values: &[FF]) -> Result<(), Error>; } @@ -64,7 +61,7 @@ impl StandardCs for StandardPlonk { mut f: F, ) -> Result<(Cell, Cell, Cell), Error> where - F: FnMut() -> Value<(Assigned, Assigned, Assigned)>, + F: FnMut() -> Value<(Rational, Rational, Rational)>, { let mut value = None; let lhs = region.assign_advice( @@ -101,7 +98,7 @@ impl StandardCs for StandardPlonk { } fn raw_add(&self, region: &mut Region, mut f: F) -> Result<(Cell, Cell, Cell), Error> where - F: FnMut() -> Value<(Assigned, Assigned, Assigned)>, + F: FnMut() -> Value<(Rational, Rational, Rational)>, { let mut value = None; let lhs = region.assign_advice( @@ -247,7 +244,7 @@ impl Circuit for MyCircuit { layouter.assign_region( || format!("region_{i}"), |mut region| { - let a: Value> = self.a.into(); + let a: Value> = self.a.into(); let mut a_squared = Value::unknown(); let (a0, _, c0) = cs.raw_multiply(&mut region, || { a_squared = a.square(); diff --git a/rust-toolchain b/rust-toolchain index 32a6ce3c71..aaceec04e0 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.76.0 +1.80.0 diff --git a/src/dev/cost_model.rs b/src/dev/cost_model.rs index 3381a501b1..8ac8f7c7fd 100644 --- a/src/dev/cost_model.rs +++ b/src/dev/cost_model.rs @@ -268,7 +268,7 @@ fn run_mock_prover_with_fallback, C: Circu circuit: &C, instances: Vec>, ) -> MockProver { - (5..25) + (1..25) .find_map(|k| { panic::catch_unwind(AssertUnwindSafe(|| { MockProver::run(k, circuit, instances.clone()).unwrap() diff --git a/src/dev/graph.rs b/src/dev/graph.rs index 11654fe415..b5a08950f3 100644 --- a/src/dev/graph.rs +++ b/src/dev/graph.rs @@ -1,11 +1,12 @@ use ff::Field; use tabbycat::{AttrList, Edge, GraphBuilder, GraphType, Identity, StmtList}; +use crate::utils::rational::Rational; use crate::{ circuit::Value, plonk::{ - Advice, Any, Assigned, Assignment, Challenge, Circuit, Column, ConstraintSystem, Error, - Fixed, FloorPlanner, Instance, Selector, + Advice, Any, Assignment, Challenge, Circuit, Column, ConstraintSystem, Error, Fixed, + FloorPlanner, Instance, Selector, }, }; @@ -123,7 +124,7 @@ impl Assignment for Graph { ) -> Result<(), Error> where V: FnOnce() -> Value, - VR: Into>, + VR: Into>, A: FnOnce() -> AR, AR: Into, { @@ -140,7 +141,7 @@ impl Assignment for Graph { ) -> Result<(), Error> where V: FnOnce() -> Value, - VR: Into>, + VR: Into>, A: FnOnce() -> AR, AR: Into, { @@ -163,7 +164,7 @@ impl Assignment for Graph { &mut self, _: Column, _: usize, - _: Value>, + _: Value>, ) -> Result<(), Error> { Ok(()) } diff --git a/src/dev/graph/layout.rs b/src/dev/graph/layout.rs index 94bd7eea14..025c04a997 100644 --- a/src/dev/graph/layout.rs +++ b/src/dev/graph/layout.rs @@ -106,7 +106,7 @@ impl CircuitLayout { cs.constants.clone(), ) .unwrap(); - let (cs, selector_polys) = cs.compress_selectors(layout.selectors); + let (cs, selector_polys) = cs.directly_convert_selectors_to_fixed(layout.selectors.clone()); let non_selector_fixed_columns = cs.num_fixed_columns - selector_polys.len(); // Figure out what order to render the columns in. @@ -115,7 +115,7 @@ impl CircuitLayout { let column_index = |cs: &ConstraintSystem, column: RegionColumn| { let column: Column = match column { RegionColumn::Column(col) => col, - RegionColumn::Selector(selector) => cs.selector_map[selector.0].into(), + RegionColumn::Selector(_) => panic!("We shouldn't have selectors by now"), }; column.index() + match column.column_type() { diff --git a/src/dev/mod.rs b/src/dev/mod.rs index a7093472a2..d76c5f89fe 100644 --- a/src/dev/mod.rs +++ b/src/dev/mod.rs @@ -20,9 +20,11 @@ use crate::{ }, }; -use crate::utils::multicore::{ - IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, - ParallelSliceMut, +use rayon::{ + iter::{ + IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, + }, + slice::ParallelSliceMut, }; pub mod metadata; @@ -912,9 +914,9 @@ impl + Ord> MockProver { cell_values: util::cell_values( gate, poly, - &util::load(n, row, &self.cs.fixed_queries, &self.fixed), - &util::load(n, row, &self.cs.advice_queries, &self.advice), - &util::load_instance( + util::load(n, row, &self.cs.fixed_queries, &self.fixed), + util::load(n, row, &self.cs.advice_queries, &self.advice), + util::load_instance( n, row, &self.cs.instance_queries, diff --git a/src/plonk/circuit.rs b/src/plonk/circuit.rs index 70b295f2a8..9953f34e5b 100644 --- a/src/plonk/circuit.rs +++ b/src/plonk/circuit.rs @@ -1338,10 +1338,10 @@ impl Product for Expression { } } -/// Represents an index into a vector where each entry corresponds to a distinct -/// point that polynomials are queried at. -#[derive(Copy, Clone, Debug)] -pub(crate) struct PointIndex(pub usize); +// /// Represents an index into a vector where each entry corresponds to a distinct +// /// point that polynomials are queried at. +// #[derive(Copy, Clone, Debug)] +// pub(crate) struct PointIndex(pub usize); /// A "virtual cell" is a PLONK cell that has been queried at a particular relative offset /// within a custom gate. diff --git a/src/plonk/evaluation.rs b/src/plonk/evaluation.rs index e8c2b86d96..c71f256945 100644 --- a/src/plonk/evaluation.rs +++ b/src/plonk/evaluation.rs @@ -1,7 +1,6 @@ use crate::plonk::{lookup, permutation, Any, ProvingKey}; use crate::poly::commitment::PolynomialCommitmentScheme; use crate::poly::Basis; -use crate::utils::multicore; use crate::{ poly::{Coeff, ExtendedLagrangeCoeff, Polynomial, Rotation}, utils::arithmetic::parallelize, @@ -171,8 +170,6 @@ pub struct Evaluator { pub custom_gates: GraphEvaluator, /// Lookups evalution pub lookups: Vec>, - /// Shuffle evalution - pub shuffles: Vec>, } /// GraphEvaluator @@ -313,7 +310,7 @@ impl> Evaluator { let mut values = domain.empty_extended(); // Core expression evaluations - let num_threads = multicore::current_num_threads(); + let num_threads = rayon::current_num_threads(); for (((advice, instance), lookups), permutation) in advice .iter() .zip(instance.iter()) @@ -321,7 +318,7 @@ impl> Evaluator { .zip(permutations.iter()) { // Custom gates - multicore::scope(|scope| { + rayon::scope(|scope| { let chunk_size = (size + num_threads - 1) / num_threads; for (thread_idx, values) in values.chunks_mut(chunk_size).enumerate() { let start = thread_idx * chunk_size; diff --git a/src/plonk/keygen.rs b/src/plonk/keygen.rs index bdf15c95df..1cccf55957 100644 --- a/src/plonk/keygen.rs +++ b/src/plonk/keygen.rs @@ -16,7 +16,7 @@ use super::{ }; use crate::circuit::Value; use crate::poly::batch_invert_rational; -use crate::poly::commitment::PolynomialCommitmentScheme; +use crate::poly::commitment::{Params, PolynomialCommitmentScheme}; use crate::utils::rational::Rational; use crate::{poly::EvaluationDomain, utils::arithmetic::parallelize}; @@ -253,8 +253,15 @@ where CS: PolynomialCommitmentScheme, ConcreteCircuit: Circuit, { + let k = k_from_circuit(circuit); + if params.max_k() < k { + return Err(Error::NotEnoughRowsAvailable { + current_k: params.max_k(), + }); + } + let (domain, cs, config) = create_domain::( - k_from_circuit(circuit), + k, #[cfg(feature = "circuit-params")] circuit.params(), ); diff --git a/src/plonk/lookup/prover.rs b/src/plonk/lookup/prover.rs index 9ce8108f9e..c2a73d535e 100644 --- a/src/plonk/lookup/prover.rs +++ b/src/plonk/lookup/prover.rs @@ -43,6 +43,7 @@ impl + Ord> Argument { /// obtaining A' and S', and /// - constructs Permuted struct using permuted_input_value = A', and /// permuted_table_expression = S'. + /// /// The Permuted struct is used to update the Lookup, and is then returned. #[allow(clippy::too_many_arguments)] pub(in crate::plonk) fn commit_permuted< @@ -230,7 +231,7 @@ impl> Permuted { // It can be used for debugging purposes. { // While in Lagrange basis, check that product is correctly constructed - let u = (params.n() as usize) - (blinding_factors + 1); + let u = (pk.vk.n() as usize) - (blinding_factors + 1); // l_0(X) * (1 - z(X)) = 0 assert_eq!(z[0], F::ONE); @@ -243,15 +244,15 @@ impl> Permuted { let permuted_table_value = &self.permuted_table_expression[i]; - left *= &(*beta + permuted_input_value); - left *= &(*gamma + permuted_table_value); + left *= &(beta + permuted_input_value); + left *= &(gamma + permuted_table_value); let mut right = z[i]; let mut input_term = self.compressed_input_expression[i]; let mut table_term = self.compressed_table_expression[i]; - input_term += &(*beta); - table_term += &(*gamma); + input_term += &(beta); + table_term += &(gamma); right *= &(input_term * &table_term); assert_eq!(left, right); @@ -357,12 +358,9 @@ type ExpressionPair = (Polynomial, Polynomial + Ord, - CS: PolynomialCommitmentScheme, - R: RngCore, ->( +fn permute_expression_pair, R: RngCore>( pk: &ProvingKey, domain: &EvaluationDomain, mut rng: R, @@ -370,7 +368,7 @@ fn permute_expression_pair< table_expression: &Polynomial, ) -> Result, Error> where - F: FromUniformBytes<64> + SerdeObject, + F: WithSmallOrderMulGroup<3> + Ord + FromUniformBytes<64> + SerdeObject, { let blinding_factors = pk.vk.cs.blinding_factors(); let usable_rows = pk.vk.n() as usize - (blinding_factors + 1); diff --git a/src/plonk/mod.rs b/src/plonk/mod.rs index 35d9266413..7366e3aa4b 100644 --- a/src/plonk/mod.rs +++ b/src/plonk/mod.rs @@ -74,11 +74,11 @@ where /// /// Writes a curve element according to `format`: /// - `Processed`: Writes a compressed curve element with coordinates in standard form. - /// Writes a field element in standard form, with endianness specified by the - /// `PrimeField` implementation. + /// Writes a field element in standard form, with endianness specified by the + /// `PrimeField` implementation. /// - Otherwise: Writes an uncompressed curve element with coordinates in Montgomery form - /// Writes a field element into raw bytes in its internal Montgomery representation, - /// WITHOUT performing the expensive Montgomery reduction. + /// Writes a field element into raw bytes in its internal Montgomery representation, + /// WITHOUT performing the expensive Montgomery reduction. pub fn write(&self, writer: &mut W, format: SerdeFormat) -> io::Result<()> { // Version byte that will be checked on read. writer.write_all(&[VERSION])?; @@ -337,7 +337,7 @@ where /// Writes a curve element according to `format`: /// - `Processed`: Writes a compressed curve element with coordinates in standard form. /// Writes a field element in standard form, with endianness specified by the - /// `PrimeField` implementation. + /// `PrimeField` implementation. /// - Otherwise: Writes an uncompressed curve element with coordinates in Montgomery form /// Writes a field element into raw bytes in its internal Montgomery representation, /// WITHOUT performing the expensive Montgomery reduction. diff --git a/src/plonk/permutation/keygen.rs b/src/plonk/permutation/keygen.rs index 07f42e7714..c378eb074b 100644 --- a/src/plonk/permutation/keygen.rs +++ b/src/plonk/permutation/keygen.rs @@ -8,10 +8,13 @@ use crate::{ }; #[cfg(feature = "thread-safe-region")] -use crate::utils::multicore::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator}; +use { + ff::PrimeField, + rayon::iter::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator}, +}; #[cfg(not(feature = "thread-safe-region"))] -use crate::utils::multicore::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; +use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; use crate::poly::commitment::PolynomialCommitmentScheme; use rayon::iter::IntoParallelRefMutIterator; @@ -239,8 +242,6 @@ impl Assembly { /// Builds the ordered mapping of the cycles. /// This will only get executed once. pub fn build_ordered_mapping(&mut self) { - use crate::multicore::IntoParallelRefMutIterator; - // will only get called once if self.ordered_cycles.is_empty() && !self.cycles.is_empty() { self.ordered_cycles = self @@ -281,9 +282,12 @@ impl Assembly { } } - pub(crate) fn build_vk>( + pub(crate) fn build_vk< + F: PrimeField + WithSmallOrderMulGroup<3>, + CS: PolynomialCommitmentScheme, + >( &mut self, - params: &CS::VerifierParameters, + params: &CS::Parameters, domain: &EvaluationDomain, p: &Argument, ) -> VerifyingKey { @@ -291,14 +295,13 @@ impl Assembly { build_vk(params, domain, p, |i, j| self.mapping_at_idx(i, j)) } - pub(crate) fn build_pk>( + pub(crate) fn build_pk>( &mut self, - params: &CS::Parameters, domain: &EvaluationDomain, p: &Argument, ) -> ProvingKey { self.build_ordered_mapping(); - build_pk(params, domain, p, |i, j| self.mapping_at_idx(i, j)) + build_pk(domain, p, |i, j| self.mapping_at_idx(i, j)) } /// Returns columns that participate in the permutation argument. diff --git a/src/plonk/prover.rs b/src/plonk/prover.rs index bf961e47c9..64122509c7 100644 --- a/src/plonk/prover.rs +++ b/src/plonk/prover.rs @@ -32,7 +32,7 @@ use halo2curves::serde::SerdeObject; /// generated previously for the same circuit. The provided `instances` /// are zero-padded internally. pub fn create_proof< - F: WithSmallOrderMulGroup<3>, + F, CS: PolynomialCommitmentScheme, T: Transcript, ConcreteCircuit: Circuit, @@ -46,7 +46,12 @@ pub fn create_proof< ) -> Result<(), Error> where CS::Commitment: Hashable + SerdeObject, - F: Sampleable + Hashable + SerdeObject + Ord + FromUniformBytes<64>, + F: WithSmallOrderMulGroup<3> + + Sampleable + + Hashable + + SerdeObject + + Ord + + FromUniformBytes<64>, { if circuits.len() != instances.len() { return Err(Error::InvalidInstances); diff --git a/src/plonk/vanishing/prover.rs b/src/plonk/vanishing/prover.rs index 392339addd..116149e0d9 100644 --- a/src/plonk/vanishing/prover.rs +++ b/src/plonk/vanishing/prover.rs @@ -12,9 +12,10 @@ use crate::{ plonk::Error, poly::{Coeff, EvaluationDomain, ExtendedLagrangeCoeff, Polynomial, ProverQuery}, utils::arithmetic::{eval_polynomial, parallelize}, - utils::multicore::current_num_threads, }; +use rayon::current_num_threads; + pub(in crate::plonk) struct Committed { random_poly: Polynomial, } diff --git a/src/plonk/verifier.rs b/src/plonk/verifier.rs index aff7d0bbb1..fed4e7912a 100644 --- a/src/plonk/verifier.rs +++ b/src/plonk/verifier.rs @@ -9,17 +9,17 @@ use crate::transcript::{read_n, Hashable, Sampleable, Transcript}; use crate::utils::arithmetic::compute_inner_product; /// Prepares a plonk proof into a PCS instance that can be finalized or batched. -pub fn prepare< - F: WithSmallOrderMulGroup<3> + Hashable + Sampleable + SerdeObject, - CS: PolynomialCommitmentScheme, - T: Transcript, ->( +pub fn prepare, T: Transcript>( vk: &VerifyingKey, instances: &[&[&[F]]], transcript: &mut T, ) -> Result where - F: FromUniformBytes<64> + WithSmallOrderMulGroup<3>, + F: WithSmallOrderMulGroup<3> + + Hashable + + Sampleable + + SerdeObject + + FromUniformBytes<64>, CS::Commitment: Hashable + SerdeObject, { // Check that instances matches the expected number of instance columns diff --git a/src/poly/commitment.rs b/src/poly/commitment.rs index 254874a3d8..50c0f61123 100644 --- a/src/poly/commitment.rs +++ b/src/poly/commitment.rs @@ -8,7 +8,7 @@ use std::fmt::Debug; /// Public interface for a Polynomial Commitment Scheme (PCS) pub trait PolynomialCommitmentScheme: Clone + Debug { /// Parameters needed to generate a proof in the PCS - type Parameters; + type Parameters: Params; /// Parameters needed to verify a proof in the PCS type VerifierParameters; @@ -72,15 +72,13 @@ pub trait Guard>: Sized { { guards .into_iter() - .zip(params.into_iter()) + .zip(params) .try_for_each(|(guard, params)| guard.verify(params)) } } -/// Interface for prover/verifier params -pub trait Params> { - /// This commits to a polynomial using its evaluations over the $2^k$ size - /// evaluation domain. The commitment will be blinded by the blinding factor - /// `r`. - fn commit_lagrange(&self, poly: &Polynomial) -> CS::Commitment; +/// Interface for PCS params +pub trait Params { + /// Returns the max size of polynomials that these parameters can commit to + fn max_k(&self) -> u32; } diff --git a/src/poly/kzg/params.rs b/src/poly/kzg/params.rs index 35ab632595..454c10acac 100644 --- a/src/poly/kzg/params.rs +++ b/src/poly/kzg/params.rs @@ -7,6 +7,7 @@ use halo2curves::pairing::Engine; use rand_core::RngCore; use std::fmt::Debug; +use crate::poly::commitment::Params; use crate::utils::helpers::ProcessedSerdeObject; use halo2curves::CurveAffine; use std::io; @@ -20,6 +21,14 @@ pub struct ParamsKZG { pub(crate) s_g2: E::G2Affine, } +impl Params for ParamsKZG { + fn max_k(&self) -> u32 { + assert_eq!(self.g.len(), self.g_lagrange.len()); + + self.g.len().ilog2() + } +} + impl ParamsKZG { /// Initializes parameters for the curve, draws toxic secret from given rng. /// MUST NOT be used in production. diff --git a/src/poly/mod.rs b/src/poly/mod.rs index 850c968ffc..7b60626a25 100644 --- a/src/poly/mod.rs +++ b/src/poly/mod.rs @@ -197,7 +197,7 @@ pub(crate) fn batch_invert_rational( impl Polynomial, LagrangeCoeff> { pub(crate) fn invert( &self, - inv_denoms: impl Iterator + ExactSizeIterator, + inv_denoms: impl ExactSizeIterator, ) -> Polynomial { assert_eq!(inv_denoms.len(), self.values.len()); Polynomial { diff --git a/src/utils/arithmetic.rs b/src/utils/arithmetic.rs index e831b19f59..697e3a02c8 100644 --- a/src/utils/arithmetic.rs +++ b/src/utils/arithmetic.rs @@ -1,7 +1,6 @@ //! This module provides common utilities, traits and structures for group, //! field and polynomial arithmetic. -use super::multicore; pub use ff::Field; use group::prime::PrimeCurveAffine; use group::{ @@ -63,13 +62,13 @@ pub fn eval_polynomial(poly: &[F], point: F) -> F { .fold(F::ZERO, |acc, coeff| acc * point + coeff) } let n = poly.len(); - let num_threads = multicore::current_num_threads(); + let num_threads = rayon::current_num_threads(); if n * 2 < num_threads { evaluate(poly, point) } else { let chunk_size = (n + num_threads - 1) / num_threads; let mut parts = vec![F::ZERO; num_threads]; - multicore::scope(|scope| { + rayon::scope(|scope| { for (chunk_idx, (out, poly)) in parts.chunks_mut(1).zip(poly.chunks(chunk_size)).enumerate() { @@ -149,13 +148,13 @@ pub fn parallelize(v: &mu let f = &f; let total_iters = v.len(); - let num_threads = multicore::current_num_threads(); + let num_threads = rayon::current_num_threads(); let base_chunk_size = total_iters / num_threads; let cutoff_chunk_id = total_iters % num_threads; let split_pos = cutoff_chunk_id * (base_chunk_size + 1); let (v_hi, v_lo) = v.split_at_mut(split_pos); - multicore::scope(|scope| { + rayon::scope(|scope| { // Skip special-case: number of iterations is cleanly divided by number of threads. if cutoff_chunk_id != 0 { for (chunk_id, chunk) in v_hi.chunks_exact_mut(base_chunk_size + 1).enumerate() { diff --git a/src/utils/mod.rs b/src/utils/mod.rs index ab861289b0..a600627c59 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -2,7 +2,6 @@ pub mod arithmetic; pub mod helpers; -pub(crate) mod multicore; pub mod rational; pub use helpers::SerdeFormat; diff --git a/tests/plonk_api.rs b/tests/plonk_api.rs index aacf148e59..b0947b9e70 100644 --- a/tests/plonk_api.rs +++ b/tests/plonk_api.rs @@ -3,7 +3,7 @@ use assert_matches::assert_matches; use blake2b_simd::State; -use ff::{FromUniformBytes, PrimeField, WithSmallOrderMulGroup}; +use ff::{FromUniformBytes, WithSmallOrderMulGroup}; use halo2_proofs::circuit::{Cell, Layouter, SimpleFloorPlanner, Value}; use halo2_proofs::dev::MockProver; use halo2_proofs::plonk::{ @@ -25,10 +25,6 @@ use std::marker::PhantomData; fn plonk_api() { const K: u32 = 5; - /// This represents an advice column at a certain row in the ConstraintSystem - #[derive(Copy, Clone, Debug)] - pub struct Variable(Column, usize); - #[derive(Clone)] struct PlonkConfig { a: Column, @@ -420,8 +416,8 @@ fn plonk_api() { assert_matches!( keygen_vk::<_, $scheme, _>(&much_too_small_params, &empty_circuit), Err(Error::NotEnoughRowsAvailable { - current_k, - }) if current_k == 1 + current_k: 1, + }) ); // Check that we get an error if we try to initialize the proving key with a value of @@ -436,7 +432,7 @@ fn plonk_api() { }}; } - fn keygen>( + fn keygen>( params: &Scheme::Parameters, ) -> ProvingKey where @@ -455,7 +451,7 @@ fn plonk_api() { } fn create_proof< - F: PrimeField, + F, Scheme: PolynomialCommitmentScheme, T: Transcript, R: RngCore + CryptoRng, @@ -502,7 +498,7 @@ fn plonk_api() { transcript.finalize() } - fn verify_proof, T: Transcript>( + fn verify_proof, T: Transcript>( params_verifier: &Scheme::VerifierParameters, vk: &VerifyingKey, proof: &[u8],