mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 06:13:07 +00:00
Apply review
This commit is contained in:
parent
85524cfacc
commit
cda30847a9
@ -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;
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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<const D: usize> {
|
||||
/// Number of arithmetic operations performed by an arithmetic gate.
|
||||
|
||||
@ -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<F: RichField + Extendable<D>, 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<F, D>) -> Vec<F::Extension>;
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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<const D: usize> {
|
||||
/// Number of multiplications performed by the gate.
|
||||
|
||||
@ -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).
|
||||
|
||||
@ -486,7 +486,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
}
|
||||
|
||||
/// 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<F, D>) {
|
||||
self.gates.insert(gate);
|
||||
}
|
||||
@ -575,12 +575,12 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
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())
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user