From 8c5fa2aecda0f52f5fb9ff3f7a9ebce56a9dfd2c Mon Sep 17 00:00:00 2001 From: Eduard S Date: Mon, 17 Apr 2023 17:38:59 +0200 Subject: [PATCH] Extend Circuit trait to take parameters in config The Circuit trait is extended with the following: ``` pub trait Circuit { /// [...] type Params: Default; fn params(&self) -> Self::Params { Self::Params::default() } fn configure_with_params(meta: &mut ConstraintSystem, params: &Self::Params) -> Self::Config { Self::configure(meta) } fn configure(meta: &mut ConstraintSystem) -> Self::Config; } ``` This allows runtime parametrization of the circuit configuration. The extension to the Circuit trait has been designed to minimize the breaking change: existing circuits only need to define the associated `type Params`. Unfortunately "Associated type defaults" are unstable in Rust, otherwise this would be a non-breaking change. See https://github.com/rust-lang/rust/issues/29661 --- halo2_gadgets/benches/poseidon.rs | 1 + halo2_gadgets/benches/sha256.rs | 1 + halo2_gadgets/src/ecc.rs | 1 + halo2_gadgets/src/ecc/chip/mul_fixed/short.rs | 1 + halo2_gadgets/src/poseidon/pow5.rs | 2 ++ halo2_gadgets/src/sha256/table16.rs | 1 + halo2_gadgets/src/sha256/table16/compression.rs | 1 + .../src/sha256/table16/message_schedule.rs | 1 + halo2_gadgets/src/sha256/table16/spread_table.rs | 1 + halo2_gadgets/src/sinsemilla.rs | 1 + halo2_gadgets/src/sinsemilla/merkle.rs | 1 + halo2_gadgets/src/utilities.rs | 1 + halo2_gadgets/src/utilities/cond_swap.rs | 1 + .../src/utilities/decompose_running_sum.rs | 1 + .../src/utilities/lookup_range_check.rs | 2 ++ halo2_proofs/benches/dev_lookup.rs | 1 + halo2_proofs/benches/plonk.rs | 1 + halo2_proofs/examples/circuit-layout.rs | 1 + halo2_proofs/examples/serialization.rs | 9 +++++++-- halo2_proofs/examples/shuffle.rs | 1 + halo2_proofs/examples/simple-example.rs | 1 + halo2_proofs/examples/two-chip.rs | 1 + .../src/circuit/floor_planner/single_pass.rs | 1 + halo2_proofs/src/circuit/floor_planner/v1.rs | 1 + halo2_proofs/src/dev.rs | 7 ++++++- halo2_proofs/src/dev/cost.rs | 2 +- halo2_proofs/src/dev/gates.rs | 7 ++++--- halo2_proofs/src/plonk.rs | 12 ++++++++---- halo2_proofs/src/plonk/circuit.rs | 16 ++++++++++++++++ halo2_proofs/src/plonk/keygen.rs | 7 ++++--- halo2_proofs/src/plonk/prover.rs | 2 +- halo2_proofs/tests/plonk_api.rs | 1 + 32 files changed, 73 insertions(+), 15 deletions(-) diff --git a/halo2_gadgets/benches/poseidon.rs b/halo2_gadgets/benches/poseidon.rs index 4494e77a0f..d7770e4c91 100644 --- a/halo2_gadgets/benches/poseidon.rs +++ b/halo2_gadgets/benches/poseidon.rs @@ -53,6 +53,7 @@ where { type Config = MyConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self { diff --git a/halo2_gadgets/benches/sha256.rs b/halo2_gadgets/benches/sha256.rs index 670956cb0d..99ac161f0c 100644 --- a/halo2_gadgets/benches/sha256.rs +++ b/halo2_gadgets/benches/sha256.rs @@ -37,6 +37,7 @@ fn bench(name: &str, k: u32, c: &mut Criterion) { impl Circuit for MyCircuit { type Config = Table16Config; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self::default() diff --git a/halo2_gadgets/src/ecc.rs b/halo2_gadgets/src/ecc.rs index 08f34b15f2..8bbee5629b 100644 --- a/halo2_gadgets/src/ecc.rs +++ b/halo2_gadgets/src/ecc.rs @@ -731,6 +731,7 @@ pub(crate) mod tests { impl Circuit for MyCircuit { type Config = EccConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { MyCircuit { test_errors: false } diff --git a/halo2_gadgets/src/ecc/chip/mul_fixed/short.rs b/halo2_gadgets/src/ecc/chip/mul_fixed/short.rs index 4c92becb86..dcf528a61d 100644 --- a/halo2_gadgets/src/ecc/chip/mul_fixed/short.rs +++ b/halo2_gadgets/src/ecc/chip/mul_fixed/short.rs @@ -434,6 +434,7 @@ pub mod tests { impl Circuit for MyCircuit { type Config = EccConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self::default() diff --git a/halo2_gadgets/src/poseidon/pow5.rs b/halo2_gadgets/src/poseidon/pow5.rs index 52b0d27312..3e3e2ccfe1 100644 --- a/halo2_gadgets/src/poseidon/pow5.rs +++ b/halo2_gadgets/src/poseidon/pow5.rs @@ -620,6 +620,7 @@ mod tests { { type Config = Pow5Config; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { PermuteCircuit::(PhantomData) @@ -735,6 +736,7 @@ mod tests { { type Config = Pow5Config; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self { diff --git a/halo2_gadgets/src/sha256/table16.rs b/halo2_gadgets/src/sha256/table16.rs index c4919158bc..f646e3604e 100644 --- a/halo2_gadgets/src/sha256/table16.rs +++ b/halo2_gadgets/src/sha256/table16.rs @@ -468,6 +468,7 @@ mod tests { impl Circuit for MyCircuit { type Config = Table16Config; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { MyCircuit {} diff --git a/halo2_gadgets/src/sha256/table16/compression.rs b/halo2_gadgets/src/sha256/table16/compression.rs index 62deb42937..0c8124c2cd 100644 --- a/halo2_gadgets/src/sha256/table16/compression.rs +++ b/halo2_gadgets/src/sha256/table16/compression.rs @@ -954,6 +954,7 @@ mod tests { impl Circuit for MyCircuit { type Config = Table16Config; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { MyCircuit {} diff --git a/halo2_gadgets/src/sha256/table16/message_schedule.rs b/halo2_gadgets/src/sha256/table16/message_schedule.rs index 690e086c49..b12e3771bd 100644 --- a/halo2_gadgets/src/sha256/table16/message_schedule.rs +++ b/halo2_gadgets/src/sha256/table16/message_schedule.rs @@ -411,6 +411,7 @@ mod tests { impl Circuit for MyCircuit { type Config = Table16Config; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { MyCircuit {} diff --git a/halo2_gadgets/src/sha256/table16/spread_table.rs b/halo2_gadgets/src/sha256/table16/spread_table.rs index 031f088084..6efcfb86da 100644 --- a/halo2_gadgets/src/sha256/table16/spread_table.rs +++ b/halo2_gadgets/src/sha256/table16/spread_table.rs @@ -304,6 +304,7 @@ mod tests { impl Circuit for MyCircuit { type Config = SpreadTableConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { MyCircuit {} diff --git a/halo2_gadgets/src/sinsemilla.rs b/halo2_gadgets/src/sinsemilla.rs index 2670529229..ab58d081a1 100644 --- a/halo2_gadgets/src/sinsemilla.rs +++ b/halo2_gadgets/src/sinsemilla.rs @@ -525,6 +525,7 @@ pub(crate) mod tests { SinsemillaConfig, ); type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { MyCircuit {} diff --git a/halo2_gadgets/src/sinsemilla/merkle.rs b/halo2_gadgets/src/sinsemilla/merkle.rs index a9ae781d5c..c8b211de5e 100644 --- a/halo2_gadgets/src/sinsemilla/merkle.rs +++ b/halo2_gadgets/src/sinsemilla/merkle.rs @@ -213,6 +213,7 @@ pub mod tests { MerkleConfig, ); type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self::default() diff --git a/halo2_gadgets/src/utilities.rs b/halo2_gadgets/src/utilities.rs index 683a553b7e..feec1e9c69 100644 --- a/halo2_gadgets/src/utilities.rs +++ b/halo2_gadgets/src/utilities.rs @@ -271,6 +271,7 @@ mod tests { impl Circuit for MyCircuit { type Config = Config; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { MyCircuit(self.0) diff --git a/halo2_gadgets/src/utilities/cond_swap.rs b/halo2_gadgets/src/utilities/cond_swap.rs index 2dc96d5904..8247db3a2c 100644 --- a/halo2_gadgets/src/utilities/cond_swap.rs +++ b/halo2_gadgets/src/utilities/cond_swap.rs @@ -217,6 +217,7 @@ mod tests { impl Circuit for MyCircuit { type Config = CondSwapConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self::default() diff --git a/halo2_gadgets/src/utilities/decompose_running_sum.rs b/halo2_gadgets/src/utilities/decompose_running_sum.rs index 96fd279942..933a13ba80 100644 --- a/halo2_gadgets/src/utilities/decompose_running_sum.rs +++ b/halo2_gadgets/src/utilities/decompose_running_sum.rs @@ -243,6 +243,7 @@ mod tests { { type Config = RunningSumConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self { diff --git a/halo2_gadgets/src/utilities/lookup_range_check.rs b/halo2_gadgets/src/utilities/lookup_range_check.rs index 36be7c7745..814c6f1900 100644 --- a/halo2_gadgets/src/utilities/lookup_range_check.rs +++ b/halo2_gadgets/src/utilities/lookup_range_check.rs @@ -410,6 +410,7 @@ mod tests { impl Circuit for MyCircuit { type Config = LookupRangeCheckConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { *self @@ -506,6 +507,7 @@ mod tests { impl Circuit for MyCircuit { type Config = LookupRangeCheckConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { MyCircuit { diff --git a/halo2_proofs/benches/dev_lookup.rs b/halo2_proofs/benches/dev_lookup.rs index 745a36b928..2762324849 100644 --- a/halo2_proofs/benches/dev_lookup.rs +++ b/halo2_proofs/benches/dev_lookup.rs @@ -28,6 +28,7 @@ fn criterion_benchmark(c: &mut Criterion) { impl Circuit for MyCircuit { type Config = MyConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self::default() diff --git a/halo2_proofs/benches/plonk.rs b/halo2_proofs/benches/plonk.rs index cf02cf87e8..3d1d6bcd6f 100644 --- a/halo2_proofs/benches/plonk.rs +++ b/halo2_proofs/benches/plonk.rs @@ -183,6 +183,7 @@ fn criterion_benchmark(c: &mut Criterion) { impl Circuit for MyCircuit { type Config = PlonkConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self { diff --git a/halo2_proofs/examples/circuit-layout.rs b/halo2_proofs/examples/circuit-layout.rs index 6a73f51ff8..1cd264a634 100644 --- a/halo2_proofs/examples/circuit-layout.rs +++ b/halo2_proofs/examples/circuit-layout.rs @@ -161,6 +161,7 @@ impl StandardCs for StandardPlonk { impl Circuit for MyCircuit { type Config = PlonkConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self { diff --git a/halo2_proofs/examples/serialization.rs b/halo2_proofs/examples/serialization.rs index 91ed5464e4..52643cf9bf 100644 --- a/halo2_proofs/examples/serialization.rs +++ b/halo2_proofs/examples/serialization.rs @@ -86,6 +86,7 @@ struct StandardPlonk(Fr); impl Circuit for StandardPlonk { type Config = StandardPlonkConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self::default() @@ -140,8 +141,12 @@ fn main() { let f = File::open("serialization-test.pk").unwrap(); let mut reader = BufReader::new(f); - let pk = ProvingKey::::read::<_, StandardPlonk>(&mut reader, SerdeFormat::RawBytes) - .unwrap(); + let pk = ProvingKey::::read::<_, StandardPlonk>( + &mut reader, + SerdeFormat::RawBytes, + &circuit.params(), + ) + .unwrap(); std::fs::remove_file("serialization-test.pk").unwrap(); diff --git a/halo2_proofs/examples/shuffle.rs b/halo2_proofs/examples/shuffle.rs index 08d16b9f27..95a86d3fad 100644 --- a/halo2_proofs/examples/shuffle.rs +++ b/halo2_proofs/examples/shuffle.rs @@ -136,6 +136,7 @@ impl MyCircuit { impl Circuit for MyCircuit { type Config = MyConfig; type FloorPlanner = V1; + type Params = (); fn without_witnesses(&self) -> Self { Self::default() diff --git a/halo2_proofs/examples/simple-example.rs b/halo2_proofs/examples/simple-example.rs index 2273ce9759..4d68d6c4db 100644 --- a/halo2_proofs/examples/simple-example.rs +++ b/halo2_proofs/examples/simple-example.rs @@ -248,6 +248,7 @@ impl Circuit for MyCircuit { // Since we are using a single chip for everything, we can just reuse its config. type Config = FieldConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self::default() diff --git a/halo2_proofs/examples/two-chip.rs b/halo2_proofs/examples/two-chip.rs index 4113d94143..14c097d5f3 100644 --- a/halo2_proofs/examples/two-chip.rs +++ b/halo2_proofs/examples/two-chip.rs @@ -458,6 +458,7 @@ impl Circuit for MyCircuit { // Since we are using a single chip for everything, we can just reuse its config. type Config = FieldConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self::default() diff --git a/halo2_proofs/src/circuit/floor_planner/single_pass.rs b/halo2_proofs/src/circuit/floor_planner/single_pass.rs index f5b80bf833..3bba58a2a2 100644 --- a/halo2_proofs/src/circuit/floor_planner/single_pass.rs +++ b/halo2_proofs/src/circuit/floor_planner/single_pass.rs @@ -479,6 +479,7 @@ mod tests { impl Circuit for MyCircuit { type Config = Column; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { MyCircuit {} diff --git a/halo2_proofs/src/circuit/floor_planner/v1.rs b/halo2_proofs/src/circuit/floor_planner/v1.rs index eb139cb946..a967637f77 100644 --- a/halo2_proofs/src/circuit/floor_planner/v1.rs +++ b/halo2_proofs/src/circuit/floor_planner/v1.rs @@ -517,6 +517,7 @@ mod tests { impl Circuit for MyCircuit { type Config = Column; type FloorPlanner = super::V1; + type Params = (); fn without_witnesses(&self) -> Self { MyCircuit {} diff --git a/halo2_proofs/src/dev.rs b/halo2_proofs/src/dev.rs index 8aba9cb84b..b6b800b6d1 100644 --- a/halo2_proofs/src/dev.rs +++ b/halo2_proofs/src/dev.rs @@ -208,6 +208,7 @@ impl Mul for Value { /// impl Circuit for MyCircuit { /// type Config = MyConfig; /// type FloorPlanner = SimpleFloorPlanner; +/// type Params = (); /// /// fn without_witnesses(&self) -> Self { /// Self::default() @@ -601,7 +602,7 @@ impl + Ord> MockProver { let n = 1 << k; let mut cs = ConstraintSystem::default(); - let config = ConcreteCircuit::configure(&mut cs); + let config = ConcreteCircuit::configure_with_params(&mut cs, &circuit.params()); let cs = cs; assert!( @@ -1536,6 +1537,7 @@ mod tests { impl Circuit for FaultyCircuit { type Config = FaultyCircuitConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn configure(meta: &mut ConstraintSystem) -> Self::Config { let a = meta.advice_column(); @@ -1622,6 +1624,7 @@ mod tests { impl Circuit for FaultyCircuit { type Config = FaultyCircuitConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn configure(meta: &mut ConstraintSystem) -> Self::Config { let a = meta.advice_column(); @@ -1791,6 +1794,7 @@ mod tests { impl Circuit for FaultyCircuit { type Config = FaultyCircuitConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn configure(meta: &mut ConstraintSystem) -> Self::Config { let a = meta.advice_column(); @@ -1925,6 +1929,7 @@ mod tests { impl Circuit for FaultyCircuit { type Config = FaultyCircuitConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn configure(meta: &mut ConstraintSystem) -> Self::Config { let a = meta.advice_column(); diff --git a/halo2_proofs/src/dev/cost.rs b/halo2_proofs/src/dev/cost.rs index d3043508f5..6f3c6a11b6 100644 --- a/halo2_proofs/src/dev/cost.rs +++ b/halo2_proofs/src/dev/cost.rs @@ -150,7 +150,7 @@ impl> CircuitCost Self { // Collect the layout details. let mut cs = ConstraintSystem::default(); - let config = ConcreteCircuit::configure(&mut cs); + let config = ConcreteCircuit::configure_with_params(&mut cs, &circuit.params()); let mut assembly = Assembly { selectors: vec![vec![false; 1 << k]; cs.num_selectors], }; diff --git a/halo2_proofs/src/dev/gates.rs b/halo2_proofs/src/dev/gates.rs index cfc71c021e..ca882f2634 100644 --- a/halo2_proofs/src/dev/gates.rs +++ b/halo2_proofs/src/dev/gates.rs @@ -49,6 +49,7 @@ struct Gate { /// impl Circuit for MyCircuit { /// type Config = MyConfig; /// type FloorPlanner = SimpleFloorPlanner; +/// type Params = (); /// /// fn without_witnesses(&self) -> Self { /// Self::default() @@ -79,7 +80,7 @@ struct Gate { /// } /// } /// -/// let gates = CircuitGates::collect::(); +/// let gates = CircuitGates::collect::(&()); /// assert_eq!( /// format!("{}", gates), /// r#####"R1CS constraint: @@ -103,10 +104,10 @@ pub struct CircuitGates { impl CircuitGates { /// Collects the gates from within the circuit. - pub fn collect>() -> Self { + pub fn collect>(params: &C::Params) -> Self { // Collect the graph details. let mut cs = ConstraintSystem::default(); - let _ = C::configure(&mut cs); + let _ = C::configure_with_params(&mut cs, params); let gates = cs .gates diff --git a/halo2_proofs/src/plonk.rs b/halo2_proofs/src/plonk.rs index 4465d59fe6..758eb46adb 100644 --- a/halo2_proofs/src/plonk.rs +++ b/halo2_proofs/src/plonk.rs @@ -101,11 +101,12 @@ where pub fn read>( reader: &mut R, format: SerdeFormat, + params: &ConcreteCircuit::Params, ) -> io::Result { let mut k = [0u8; 4]; reader.read_exact(&mut k)?; let k = u32::from_be_bytes(k); - let (domain, cs, _) = keygen::create_domain::(k); + let (domain, cs, _) = keygen::create_domain::(k, params); let mut num_fixed_columns = [0u8; 4]; reader.read_exact(&mut num_fixed_columns)?; let num_fixed_columns = u32::from_be_bytes(num_fixed_columns); @@ -150,8 +151,9 @@ where pub fn from_bytes>( mut bytes: &[u8], format: SerdeFormat, + params: &ConcreteCircuit::Params, ) -> io::Result { - Self::read::<_, ConcreteCircuit>(&mut bytes, format) + Self::read::<_, ConcreteCircuit>(&mut bytes, format, params) } } @@ -335,8 +337,9 @@ where pub fn read>( reader: &mut R, format: SerdeFormat, + params: &ConcreteCircuit::Params, ) -> io::Result { - let vk = VerifyingKey::::read::(reader, format)?; + let vk = VerifyingKey::::read::(reader, format, params)?; let l0 = Polynomial::read(reader, format)?; let l_last = Polynomial::read(reader, format)?; let l_active_row = Polynomial::read(reader, format)?; @@ -369,8 +372,9 @@ where pub fn from_bytes>( mut bytes: &[u8], format: SerdeFormat, + params: &ConcreteCircuit::Params, ) -> io::Result { - Self::read::<_, ConcreteCircuit>(&mut bytes, format) + Self::read::<_, ConcreteCircuit>(&mut bytes, format, params) } } diff --git a/halo2_proofs/src/plonk/circuit.rs b/halo2_proofs/src/plonk/circuit.rs index bef769b8c0..8fc7bf90b5 100644 --- a/halo2_proofs/src/plonk/circuit.rs +++ b/halo2_proofs/src/plonk/circuit.rs @@ -664,13 +664,29 @@ pub trait Circuit { /// The floor planner used for this circuit. This is an associated type of the /// `Circuit` trait because its behaviour is circuit-critical. type FloorPlanner: FloorPlanner; + /// Optional circuit configuration parameters. + type Params: Default; /// Returns a copy of this circuit with no witness values (i.e. all witnesses set to /// `None`). For most circuits, this will be equal to `Self::default()`. fn without_witnesses(&self) -> Self; + /// Returns a reference to the parameters that should be used to configure the circuit. + fn params(&self) -> Self::Params { + Self::Params::default() + } + /// The circuit is given an opportunity to describe the exact gate /// arrangement, column arrangement, etc. + fn configure_with_params( + meta: &mut ConstraintSystem, + _params: &Self::Params, + ) -> Self::Config { + Self::configure(meta) + } + + /// Configuration function without parameters. This method is usually only called via the default + /// `configure_with_params` implementation for backwards-compatibility purposes. fn configure(meta: &mut ConstraintSystem) -> Self::Config; /// Given the provided `cs`, synthesize the circuit. The concrete type of diff --git a/halo2_proofs/src/plonk/keygen.rs b/halo2_proofs/src/plonk/keygen.rs index 331850e540..3363b03f00 100644 --- a/halo2_proofs/src/plonk/keygen.rs +++ b/halo2_proofs/src/plonk/keygen.rs @@ -26,6 +26,7 @@ use crate::{ pub(crate) fn create_domain( k: u32, + params: &ConcreteCircuit::Params, ) -> ( EvaluationDomain, ConstraintSystem, @@ -36,7 +37,7 @@ where ConcreteCircuit: Circuit, { let mut cs = ConstraintSystem::default(); - let config = ConcreteCircuit::configure(&mut cs); + let config = ConcreteCircuit::configure_with_params(&mut cs, params); let degree = cs.degree(); @@ -210,7 +211,7 @@ where ConcreteCircuit: Circuit, C::Scalar: FromUniformBytes<64>, { - let (domain, cs, config) = create_domain::(params.k()); + let (domain, cs, config) = create_domain::(params.k(), &circuit.params()); if (params.n() as usize) < cs.minimum_rows() { return Err(Error::not_enough_rows_available(params.k())); @@ -271,7 +272,7 @@ where ConcreteCircuit: Circuit, { let mut cs = ConstraintSystem::default(); - let config = ConcreteCircuit::configure(&mut cs); + let config = ConcreteCircuit::configure_with_params(&mut cs, &circuit.params()); let cs = cs; diff --git a/halo2_proofs/src/plonk/prover.rs b/halo2_proofs/src/plonk/prover.rs index db85f7e880..5840f25b95 100644 --- a/halo2_proofs/src/plonk/prover.rs +++ b/halo2_proofs/src/plonk/prover.rs @@ -68,7 +68,7 @@ where let domain = &pk.vk.domain; let mut meta = ConstraintSystem::default(); - let config = ConcreteCircuit::configure(&mut meta); + let config = ConcreteCircuit::configure_with_params(&mut meta, &circuits[0].params()); // Selector optimizations cannot be applied here; use the ConstraintSystem // from the verification key. diff --git a/halo2_proofs/tests/plonk_api.rs b/halo2_proofs/tests/plonk_api.rs index da61cd5409..4bc69e022c 100644 --- a/halo2_proofs/tests/plonk_api.rs +++ b/halo2_proofs/tests/plonk_api.rs @@ -265,6 +265,7 @@ fn plonk_api() { impl Circuit for MyCircuit { type Config = PlonkConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self {