diff --git a/plonky2/src/fri/mod.rs b/plonky2/src/fri/mod.rs index ce104ada..207a2ea8 100644 --- a/plonky2/src/fri/mod.rs +++ b/plonky2/src/fri/mod.rs @@ -1,4 +1,6 @@ -//! Fast Reed-Solomon IOP (FRI) protocol and its circuit version +//! Fast Reed-Solomon IOP (FRI) protocol. +//! +//! It provides both a native implementation and an in-circuit version //! of the FRI verifier for recursive proof composition. use alloc::vec::Vec; diff --git a/plonky2/src/gates/arithmetic_base.rs b/plonky2/src/gates/arithmetic_base.rs index e06c58af..dfdd87e8 100644 --- a/plonky2/src/gates/arithmetic_base.rs +++ b/plonky2/src/gates/arithmetic_base.rs @@ -21,7 +21,7 @@ use crate::plonk::vars::{ use crate::util::serialization::{Buffer, IoResult, Read, Write}; /// A gate which can perform a weighted multiply-add, i.e. `result = c0.x.y + c1.z`. If the config -/// supports enough routed wires, it can support several such operations in one gate. +/// has enough routed wires, it can support several such operations in one gate. #[derive(Debug, Clone)] pub struct ArithmeticGate { /// Number of arithmetic operations performed by an arithmetic gate. diff --git a/plonky2/src/gates/arithmetic_extension.rs b/plonky2/src/gates/arithmetic_extension.rs index 37482a5d..a19c6b4a 100644 --- a/plonky2/src/gates/arithmetic_extension.rs +++ b/plonky2/src/gates/arithmetic_extension.rs @@ -17,7 +17,7 @@ use crate::plonk::vars::{EvaluationTargets, EvaluationVars, EvaluationVarsBase}; use crate::util::serialization::{Buffer, IoResult, Read, Write}; /// A gate which can perform a weighted multiply-add, i.e. `result = c0.x.y + c1.z`. If the config -/// supports enough routed wires, it can support several such operations in one gate. +/// has enough routed wires, it can support several such operations in one gate. #[derive(Debug, Clone)] pub struct ArithmeticExtensionGate { /// Number of arithmetic operations performed by an arithmetic gate. diff --git a/plonky2/src/gates/gate.rs b/plonky2/src/gates/gate.rs index baf26f8c..3087b74c 100644 --- a/plonky2/src/gates/gate.rs +++ b/plonky2/src/gates/gate.rs @@ -41,7 +41,7 @@ use crate::util::serialization::{Buffer, IoResult}; /// instance, to define a multiplication, one can set q_M=1, q_L=q_R=0, q_O = -1 and q_C = 0. /// Hence, the gate equation simplifies to a.b - c = 0, or a.b = c. /// -/// However, such gate is fairly limited for more complex computations. Hence, when a computation may +/// However, such a gate is fairly limited for more complex computations. Hence, when a computation may /// require too many of these "vanilla" gates, or when a computation arises often within the same circuit, /// one may want to construct a tailored custom gate. These custom gates can use more selectors and are /// not necessarily limited to 2 inputs + 1 output = 3 wires. @@ -63,7 +63,7 @@ pub trait Gate, const D: usize>: 'static + Send + S where Self: Sized; - /// Defines the constraints that enforce the statement represented by this gate. + /// Defines and evaluates the constraints that enforce the statement represented by this gate. /// Constraints must be defined in the extension of this custom gate base field. fn eval_unfiltered(&self, vars: EvaluationVars) -> Vec; diff --git a/plonky2/src/gates/mod.rs b/plonky2/src/gates/mod.rs index 446f1aed..b490e12e 100644 --- a/plonky2/src/gates/mod.rs +++ b/plonky2/src/gates/mod.rs @@ -14,7 +14,7 @@ //! instance, to define a multiplication, one can set q_M=1, q_L=q_R=0, q_O = -1 and q_C = 0. //! Hence, the gate equation simplifies to a.b - c = 0, or a.b = c. //! -//! However, such gate is fairly limited for more complex computations. Hence, when a computation may +//! However, such a gate is fairly limited for more complex computations. Hence, when a computation may //! require too many of these "vanilla" gates, or when a computation arises often within the same circuit, //! one may want to construct a tailored custom gate. These custom gates can use more selectors and are //! not necessarily limited to 2 inputs + 1 output = 3 wires. diff --git a/plonky2/src/gates/multiplication_extension.rs b/plonky2/src/gates/multiplication_extension.rs index 1d85817a..3f9fd8fe 100644 --- a/plonky2/src/gates/multiplication_extension.rs +++ b/plonky2/src/gates/multiplication_extension.rs @@ -16,8 +16,8 @@ use crate::plonk::circuit_data::{CircuitConfig, CommonCircuitData}; use crate::plonk::vars::{EvaluationTargets, EvaluationVars, EvaluationVarsBase}; use crate::util::serialization::{Buffer, IoResult, Read, Write}; -/// A gate which can perform a weighted multiplication, i.e. `result = c0.x.y`. If the config -/// supports enough routed wires, it can support several such operations in one gate. +/// A gate which can perform a weighted multiplication, i.e. `result = c0.x.y` on [`ExtensionTarget`]. +/// If the config has enough routed wires, it can support several such operations in one gate. #[derive(Debug, Clone)] pub struct MulExtensionGate { /// Number of multiplications performed by the gate. diff --git a/plonky2/src/iop/target.rs b/plonky2/src/iop/target.rs index b1fe9bf9..705941e0 100644 --- a/plonky2/src/iop/target.rs +++ b/plonky2/src/iop/target.rs @@ -17,8 +17,8 @@ use crate::plonk::circuit_data::CircuitConfig; /// the [PartialWitness](crate::iop::witness::PartialWitness) interface. /// /// There are different "variants" of the `Target` type, namely [`ExtensionTarget`], -/// [ExtensionAlgebraTarget](crate::iop::ext_target::ExtensionAlgebraTarget), but the `Target` -/// type is the default one for most circuits verifying some simple statement. +/// [ExtensionAlgebraTarget](crate::iop::ext_target::ExtensionAlgebraTarget). +/// The `Target` type is the default one for most circuits verifying some simple statement. #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, Serialize, Deserialize)] pub enum Target { /// A target that has a fixed location in the witness (seen as a `degree x num_wires` grid). diff --git a/plonky2/src/plonk/circuit_builder.rs b/plonky2/src/plonk/circuit_builder.rs index 227af85b..2e0904e4 100644 --- a/plonky2/src/plonk/circuit_builder.rs +++ b/plonky2/src/plonk/circuit_builder.rs @@ -486,7 +486,7 @@ impl, const D: usize> CircuitBuilder { } /// Adds a gate type to the set of gates to be used in this circuit. This can be useful - /// in conditional recursion to uniformize the gates set of the different circuits. + /// in conditional recursion to uniformize the set of gates of the different circuits. pub fn add_gate_to_gate_set(&mut self, gate: GateRef) { self.gates.insert(gate); } @@ -575,12 +575,12 @@ impl, const D: usize> CircuitBuilder { self.constant(F::NEG_ONE) } - /// Returns a rootable boolean target set to false. + /// Returns a routable boolean target set to false. pub fn _false(&mut self) -> BoolTarget { BoolTarget::new_unsafe(self.zero()) } - /// Returns a rootable boolean target set to true. + /// Returns a routable boolean target set to true. pub fn _true(&mut self) -> BoolTarget { BoolTarget::new_unsafe(self.one()) } diff --git a/plonky2/src/plonk/circuit_data.rs b/plonky2/src/plonk/circuit_data.rs index 4a2efe06..d9847f4b 100644 --- a/plonky2/src/plonk/circuit_data.rs +++ b/plonky2/src/plonk/circuit_data.rs @@ -66,6 +66,8 @@ pub struct CircuitConfig { /// This allows copy constraints, i.e. enforcing that two distant values in a circuit are equal. /// Non-routed wires are called advice wires. pub num_routed_wires: usize, + /// The number of constants that can be used per gate. If a gate requires more constants than the config + /// allows, the [`CircuitBuilder`] will complain when trying to add this gate to its set of gates. pub num_constants: usize, /// Whether to use a dedicated gate for base field arithmetic, rather than using a single gate /// for both base field and extension field arithmetic. diff --git a/plonky2/src/plonk/config.rs b/plonky2/src/plonk/config.rs index c4e73356..1ed40c40 100644 --- a/plonky2/src/plonk/config.rs +++ b/plonky2/src/plonk/config.rs @@ -3,8 +3,8 @@ //! This module defines a [`Hasher`] trait as well as its recursive //! counterpart [`AlgebraicHasher`] for in-circuit hashing. It also //! provides concrete configurations, one fully recursive leveraging -//! Poseidon hash function both internally and natively, and one mixing -//! Poseidon internally and truncated Keccak externally. +//! the Poseidon hash function both internally and natively, and one +//! mixing Poseidon internally and truncated Keccak externally. use alloc::vec; use alloc::vec::Vec;