diff --git a/plonky2/src/plonk/circuit_builder.rs b/plonky2/src/plonk/circuit_builder.rs index 5f8c3200..0954483f 100644 --- a/plonky2/src/plonk/circuit_builder.rs +++ b/plonky2/src/plonk/circuit_builder.rs @@ -1095,7 +1095,12 @@ impl, const D: usize> CircuitBuilder { { self.connect(hash_part, Target::wire(pi_gate, wire)) } - self.randomize_unused_pi_wires(pi_gate); + + // See + // however randomization makes debugging harder as runs are not deterministic + if self.config.randomize_unused_wires { + self.randomize_unused_pi_wires(pi_gate); + } // Place LUT-related gates. self.add_all_lookups(); diff --git a/plonky2/src/plonk/circuit_data.rs b/plonky2/src/plonk/circuit_data.rs index 441e8103..c327e38b 100644 --- a/plonky2/src/plonk/circuit_data.rs +++ b/plonky2/src/plonk/circuit_data.rs @@ -80,6 +80,9 @@ pub struct CircuitConfig { /// A boolean to activate the zero-knowledge property. When this is set to `false`, proofs *may* /// leak additional information. pub zero_knowledge: bool, + /// See + /// Can be turned off for deterministic results + pub randomize_unused_wires: bool, /// A cap on the quotient polynomial's degree factor. The actual degree factor is derived /// systematically, but will never exceed this value. pub max_quotient_degree_factor: usize, @@ -107,6 +110,7 @@ impl CircuitConfig { security_bits: 100, num_challenges: 2, zero_knowledge: false, + randomize_unused_wires: false, max_quotient_degree_factor: 8, fri_config: FriConfig { rate_bits: 3, diff --git a/plonky2/src/util/serialization/mod.rs b/plonky2/src/util/serialization/mod.rs index 90e150ea..64e9ee23 100644 --- a/plonky2/src/util/serialization/mod.rs +++ b/plonky2/src/util/serialization/mod.rs @@ -661,6 +661,7 @@ pub trait Read { let max_quotient_degree_factor = self.read_usize()?; let use_base_arithmetic_gate = self.read_bool()?; let zero_knowledge = self.read_bool()?; + let randomize_unused_wires = self.read_bool()?; let fri_config = self.read_fri_config()?; Ok(CircuitConfig { @@ -672,6 +673,7 @@ pub trait Read { max_quotient_degree_factor, use_base_arithmetic_gate, zero_knowledge, + randomize_unused_wires, fri_config, }) } @@ -1696,6 +1698,7 @@ pub trait Write { max_quotient_degree_factor, use_base_arithmetic_gate, zero_knowledge, + randomize_unused_wires, fri_config, } = config; @@ -1707,6 +1710,7 @@ pub trait Write { self.write_usize(*max_quotient_degree_factor)?; self.write_bool(*use_base_arithmetic_gate)?; self.write_bool(*zero_knowledge)?; + self.write_bool(*randomize_unused_wires)?; self.write_fri_config(fri_config)?; Ok(())