mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 00:03:10 +00:00
Do some additional cleanup pre-release (#1532)
* Add Debug impl for types * Remove outdated clippy lint exceptions * Hide internal custom gate methods and make some const
This commit is contained in:
parent
4a620f4d79
commit
598ac876ae
@ -1,8 +1,8 @@
|
||||
#![allow(incomplete_features)]
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
#![allow(clippy::type_complexity)]
|
||||
#![allow(clippy::len_without_is_empty)]
|
||||
#![allow(clippy::needless_range_loop)]
|
||||
#![deny(rustdoc::broken_intra_doc_links)]
|
||||
#![deny(missing_debug_implementations)]
|
||||
#![feature(specialization)]
|
||||
#![cfg_attr(not(test), no_std)]
|
||||
#![cfg(not(test))]
|
||||
|
||||
@ -563,7 +563,7 @@ pub trait PrimeField64: PrimeField + Field64 {
|
||||
}
|
||||
|
||||
/// An iterator over the powers of a certain base element `b`: `b^0, b^1, b^2, ...`.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Powers<F: Field> {
|
||||
base: F,
|
||||
current: F,
|
||||
|
||||
@ -4,6 +4,7 @@ use crate::packed::PackedField;
|
||||
use crate::types::Field;
|
||||
|
||||
/// Precomputations of the evaluation of `Z_H(X) = X^n - 1` on a coset `gK` with `H <= K`.
|
||||
#[derive(Debug)]
|
||||
pub struct ZeroPolyOnCoset<F: Field> {
|
||||
/// `n = |H|`.
|
||||
n: F,
|
||||
|
||||
@ -10,6 +10,7 @@ use crate::hash::hash_types::RichField;
|
||||
use crate::iop::ext_target::ExtensionTarget;
|
||||
|
||||
/// Describes an instance of a FRI-based batch opening.
|
||||
#[derive(Debug)]
|
||||
pub struct FriInstanceInfo<F: RichField + Extendable<D>, const D: usize> {
|
||||
/// The oracles involved, not counting oracles created during the commit phase.
|
||||
pub oracles: Vec<FriOracleInfo>,
|
||||
@ -18,6 +19,7 @@ pub struct FriInstanceInfo<F: RichField + Extendable<D>, const D: usize> {
|
||||
}
|
||||
|
||||
/// Describes an instance of a FRI-based batch opening.
|
||||
#[derive(Debug)]
|
||||
pub struct FriInstanceInfoTarget<const D: usize> {
|
||||
/// The oracles involved, not counting oracles created during the commit phase.
|
||||
pub oracles: Vec<FriOracleInfo>,
|
||||
@ -25,19 +27,21 @@ pub struct FriInstanceInfoTarget<const D: usize> {
|
||||
pub batches: Vec<FriBatchInfoTarget<D>>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct FriOracleInfo {
|
||||
pub num_polys: usize,
|
||||
pub blinding: bool,
|
||||
}
|
||||
|
||||
/// A batch of openings at a particular point.
|
||||
#[derive(Debug)]
|
||||
pub struct FriBatchInfo<F: RichField + Extendable<D>, const D: usize> {
|
||||
pub point: F::Extension,
|
||||
pub polynomials: Vec<FriPolynomialInfo>,
|
||||
}
|
||||
|
||||
/// A batch of openings at a particular point.
|
||||
#[derive(Debug)]
|
||||
pub struct FriBatchInfoTarget<const D: usize> {
|
||||
pub point: ExtensionTarget<D>,
|
||||
pub polynomials: Vec<FriPolynomialInfo>,
|
||||
@ -66,21 +70,25 @@ impl FriPolynomialInfo {
|
||||
}
|
||||
|
||||
/// Opened values of each polynomial.
|
||||
#[derive(Debug)]
|
||||
pub struct FriOpenings<F: RichField + Extendable<D>, const D: usize> {
|
||||
pub batches: Vec<FriOpeningBatch<F, D>>,
|
||||
}
|
||||
|
||||
/// Opened values of each polynomial that's opened at a particular point.
|
||||
#[derive(Debug)]
|
||||
pub struct FriOpeningBatch<F: RichField + Extendable<D>, const D: usize> {
|
||||
pub values: Vec<F::Extension>,
|
||||
}
|
||||
|
||||
/// Opened values of each polynomial.
|
||||
#[derive(Debug)]
|
||||
pub struct FriOpeningsTarget<const D: usize> {
|
||||
pub batches: Vec<FriOpeningBatchTarget<D>>,
|
||||
}
|
||||
|
||||
/// Opened values of each polynomial that's opened at a particular point.
|
||||
#[derive(Debug)]
|
||||
pub struct FriOpeningBatchTarget<const D: usize> {
|
||||
pub values: Vec<ExtensionTarget<D>>,
|
||||
}
|
||||
|
||||
@ -424,7 +424,7 @@ impl<F: RichField + Extendable<D>, const D: usize> SimpleGenerator<F, D> for Equ
|
||||
}
|
||||
|
||||
/// Represents a base arithmetic operation in the circuit. Used to memoize results.
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub(crate) struct BaseArithmeticOperation<F: Field64> {
|
||||
const_0: F,
|
||||
const_1: F,
|
||||
|
||||
@ -545,7 +545,7 @@ impl<F: RichField + Extendable<D>, const D: usize> SimpleGenerator<F, D>
|
||||
}
|
||||
|
||||
/// An iterator over the powers of a certain base element `b`: `b^0, b^1, b^2, ...`.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PowersTarget<const D: usize> {
|
||||
base: ExtensionTarget<D>,
|
||||
current: ExtensionTarget<D>,
|
||||
@ -584,7 +584,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
}
|
||||
|
||||
/// Represents an extension arithmetic operation in the circuit. Used to memoize results.
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub(crate) struct ExtensionArithmeticOperation<F: Field64 + Extendable<D>, const D: usize> {
|
||||
const_0: F,
|
||||
const_1: F,
|
||||
|
||||
@ -40,6 +40,7 @@ impl<const D: usize> PolynomialCoeffsExtTarget<D> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PolynomialCoeffsExtAlgebraTarget<const D: usize>(pub Vec<ExtensionAlgebraTarget<D>>);
|
||||
|
||||
impl<const D: usize> PolynomialCoeffsExtAlgebraTarget<D> {
|
||||
|
||||
@ -44,16 +44,16 @@ impl ArithmeticGate {
|
||||
config.num_routed_wires / wires_per_op
|
||||
}
|
||||
|
||||
pub const fn wire_ith_multiplicand_0(i: usize) -> usize {
|
||||
pub(crate) const fn wire_ith_multiplicand_0(i: usize) -> usize {
|
||||
4 * i
|
||||
}
|
||||
pub const fn wire_ith_multiplicand_1(i: usize) -> usize {
|
||||
pub(crate) const fn wire_ith_multiplicand_1(i: usize) -> usize {
|
||||
4 * i + 1
|
||||
}
|
||||
pub const fn wire_ith_addend(i: usize) -> usize {
|
||||
pub(crate) const fn wire_ith_addend(i: usize) -> usize {
|
||||
4 * i + 2
|
||||
}
|
||||
pub const fn wire_ith_output(i: usize) -> usize {
|
||||
pub(crate) const fn wire_ith_output(i: usize) -> usize {
|
||||
4 * i + 3
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,16 +40,16 @@ impl<const D: usize> ArithmeticExtensionGate<D> {
|
||||
config.num_routed_wires / wires_per_op
|
||||
}
|
||||
|
||||
pub const fn wires_ith_multiplicand_0(i: usize) -> Range<usize> {
|
||||
pub(crate) const fn wires_ith_multiplicand_0(i: usize) -> Range<usize> {
|
||||
4 * D * i..4 * D * i + D
|
||||
}
|
||||
pub const fn wires_ith_multiplicand_1(i: usize) -> Range<usize> {
|
||||
pub(crate) const fn wires_ith_multiplicand_1(i: usize) -> Range<usize> {
|
||||
4 * D * i + D..4 * D * i + 2 * D
|
||||
}
|
||||
pub const fn wires_ith_addend(i: usize) -> Range<usize> {
|
||||
pub(crate) const fn wires_ith_addend(i: usize) -> Range<usize> {
|
||||
4 * D * i + 2 * D..4 * D * i + 3 * D
|
||||
}
|
||||
pub const fn wires_ith_output(i: usize) -> Range<usize> {
|
||||
pub(crate) const fn wires_ith_output(i: usize) -> Range<usize> {
|
||||
4 * D * i + 3 * D..4 * D * i + 4 * D
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,11 +40,11 @@ impl<const B: usize> BaseSumGate<B> {
|
||||
Self::new(num_limbs)
|
||||
}
|
||||
|
||||
pub const WIRE_SUM: usize = 0;
|
||||
pub const START_LIMBS: usize = 1;
|
||||
pub(crate) const WIRE_SUM: usize = 0;
|
||||
pub(crate) const START_LIMBS: usize = 1;
|
||||
|
||||
/// Returns the index of the `i`th limb wire.
|
||||
pub const fn limbs(&self) -> Range<usize> {
|
||||
pub(crate) const fn limbs(&self) -> Range<usize> {
|
||||
Self::START_LIMBS..Self::START_LIMBS + self.num_limbs
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,12 +30,12 @@ impl ConstantGate {
|
||||
Self { num_consts }
|
||||
}
|
||||
|
||||
pub fn const_input(&self, i: usize) -> usize {
|
||||
const fn const_input(&self, i: usize) -> usize {
|
||||
debug_assert!(i < self.num_consts);
|
||||
i
|
||||
}
|
||||
|
||||
pub fn wire_output(&self, i: usize) -> usize {
|
||||
const fn wire_output(&self, i: usize) -> usize {
|
||||
debug_assert!(i < self.num_consts);
|
||||
i
|
||||
}
|
||||
|
||||
@ -141,31 +141,31 @@ impl<F: RichField + Extendable<D>, const D: usize> CosetInterpolationGate<F, D>
|
||||
self.start_intermediates()
|
||||
}
|
||||
|
||||
fn num_intermediates(&self) -> usize {
|
||||
(self.num_points() - 2) / (self.degree() - 1)
|
||||
const fn num_intermediates(&self) -> usize {
|
||||
(self.num_points() - 2) / (self.degree - 1)
|
||||
}
|
||||
|
||||
/// The wires corresponding to the i'th intermediate evaluation.
|
||||
fn wires_intermediate_eval(&self, i: usize) -> Range<usize> {
|
||||
const fn wires_intermediate_eval(&self, i: usize) -> Range<usize> {
|
||||
debug_assert!(i < self.num_intermediates());
|
||||
let start = self.start_intermediates() + D * i;
|
||||
start..start + D
|
||||
}
|
||||
|
||||
/// The wires corresponding to the i'th intermediate product.
|
||||
fn wires_intermediate_prod(&self, i: usize) -> Range<usize> {
|
||||
const fn wires_intermediate_prod(&self, i: usize) -> Range<usize> {
|
||||
debug_assert!(i < self.num_intermediates());
|
||||
let start = self.start_intermediates() + D * (self.num_intermediates() + i);
|
||||
start..start + D
|
||||
}
|
||||
|
||||
/// End of wire indices, exclusive.
|
||||
fn end(&self) -> usize {
|
||||
const fn end(&self) -> usize {
|
||||
self.start_intermediates() + D * (2 * self.num_intermediates() + 1)
|
||||
}
|
||||
|
||||
/// Wire indices of the shifted point to evaluate the interpolant at.
|
||||
fn wires_shifted_evaluation_point(&self) -> Range<usize> {
|
||||
const fn wires_shifted_evaluation_point(&self) -> Range<usize> {
|
||||
let start = self.start_intermediates() + D * 2 * self.num_intermediates();
|
||||
start..start + D
|
||||
}
|
||||
|
||||
@ -55,12 +55,12 @@ impl<F: RichField + Extendable<D>, const D: usize> ExponentiationGate<F, D> {
|
||||
max_for_routed_wires.min(max_for_wires)
|
||||
}
|
||||
|
||||
pub const fn wire_base(&self) -> usize {
|
||||
pub(crate) const fn wire_base(&self) -> usize {
|
||||
0
|
||||
}
|
||||
|
||||
/// The `i`th bit of the exponent, in little-endian order.
|
||||
pub fn wire_power_bit(&self, i: usize) -> usize {
|
||||
pub(crate) const fn wire_power_bit(&self, i: usize) -> usize {
|
||||
debug_assert!(i < self.num_power_bits);
|
||||
1 + i
|
||||
}
|
||||
@ -69,7 +69,7 @@ impl<F: RichField + Extendable<D>, const D: usize> ExponentiationGate<F, D> {
|
||||
1 + self.num_power_bits
|
||||
}
|
||||
|
||||
pub fn wire_intermediate_value(&self, i: usize) -> usize {
|
||||
pub(crate) const fn wire_intermediate_value(&self, i: usize) -> usize {
|
||||
debug_assert!(i < self.num_power_bits);
|
||||
2 + self.num_power_bits + i
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ pub struct CurrentSlot<F: RichField + Extendable<D>, const D: usize> {
|
||||
}
|
||||
|
||||
/// A gate along with any constants used to configure it.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct GateInstance<F: RichField + Extendable<D>, const D: usize> {
|
||||
pub gate_ref: GateRef<F, D>,
|
||||
pub constants: Vec<F>,
|
||||
|
||||
@ -40,13 +40,13 @@ impl<const D: usize> MulExtensionGate<D> {
|
||||
config.num_routed_wires / wires_per_op
|
||||
}
|
||||
|
||||
pub const fn wires_ith_multiplicand_0(i: usize) -> Range<usize> {
|
||||
pub(crate) const fn wires_ith_multiplicand_0(i: usize) -> Range<usize> {
|
||||
3 * D * i..3 * D * i + D
|
||||
}
|
||||
pub const fn wires_ith_multiplicand_1(i: usize) -> Range<usize> {
|
||||
pub(crate) const fn wires_ith_multiplicand_1(i: usize) -> Range<usize> {
|
||||
3 * D * i + D..3 * D * i + 2 * D
|
||||
}
|
||||
pub const fn wires_ith_output(i: usize) -> Range<usize> {
|
||||
pub(crate) const fn wires_ith_output(i: usize) -> Range<usize> {
|
||||
3 * D * i + 2 * D..3 * D * i + 3 * D
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ use crate::plonk::vars::{EvaluationTargets, EvaluationVars, EvaluationVarsBaseBa
|
||||
use crate::util::serialization::{Buffer, IoResult};
|
||||
|
||||
/// A gate which does nothing.
|
||||
#[derive(Debug)]
|
||||
pub struct NoopGate;
|
||||
|
||||
impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for NoopGate {
|
||||
|
||||
@ -39,23 +39,23 @@ impl<F: RichField + Extendable<D>, const D: usize> PoseidonGate<F, D> {
|
||||
}
|
||||
|
||||
/// The wire index for the `i`th input to the permutation.
|
||||
pub const fn wire_input(i: usize) -> usize {
|
||||
pub(crate) const fn wire_input(i: usize) -> usize {
|
||||
i
|
||||
}
|
||||
|
||||
/// The wire index for the `i`th output to the permutation.
|
||||
pub const fn wire_output(i: usize) -> usize {
|
||||
pub(crate) const fn wire_output(i: usize) -> usize {
|
||||
SPONGE_WIDTH + i
|
||||
}
|
||||
|
||||
/// If this is set to 1, the first four inputs will be swapped with the next four inputs. This
|
||||
/// is useful for ordering hashes in Merkle proofs. Otherwise, this should be set to 0.
|
||||
pub const WIRE_SWAP: usize = 2 * SPONGE_WIDTH;
|
||||
pub(crate) const WIRE_SWAP: usize = 2 * SPONGE_WIDTH;
|
||||
|
||||
const START_DELTA: usize = 2 * SPONGE_WIDTH + 1;
|
||||
|
||||
/// A wire which stores `swap * (input[i + 4] - input[i])`; used to compute the swapped inputs.
|
||||
fn wire_delta(i: usize) -> usize {
|
||||
const fn wire_delta(i: usize) -> usize {
|
||||
assert!(i < 4);
|
||||
Self::START_DELTA + i
|
||||
}
|
||||
@ -64,7 +64,7 @@ impl<F: RichField + Extendable<D>, const D: usize> PoseidonGate<F, D> {
|
||||
|
||||
/// A wire which stores the input of the `i`-th S-box of the `round`-th round of the first set
|
||||
/// of full rounds.
|
||||
fn wire_full_sbox_0(round: usize, i: usize) -> usize {
|
||||
const fn wire_full_sbox_0(round: usize, i: usize) -> usize {
|
||||
debug_assert!(
|
||||
round != 0,
|
||||
"First round S-box inputs are not stored as wires"
|
||||
@ -78,7 +78,7 @@ impl<F: RichField + Extendable<D>, const D: usize> PoseidonGate<F, D> {
|
||||
Self::START_FULL_0 + SPONGE_WIDTH * (poseidon::HALF_N_FULL_ROUNDS - 1);
|
||||
|
||||
/// A wire which stores the input of the S-box of the `round`-th round of the partial rounds.
|
||||
fn wire_partial_sbox(round: usize) -> usize {
|
||||
const fn wire_partial_sbox(round: usize) -> usize {
|
||||
debug_assert!(round < poseidon::N_PARTIAL_ROUNDS);
|
||||
Self::START_PARTIAL + round
|
||||
}
|
||||
@ -87,7 +87,7 @@ impl<F: RichField + Extendable<D>, const D: usize> PoseidonGate<F, D> {
|
||||
|
||||
/// A wire which stores the input of the `i`-th S-box of the `round`-th round of the second set
|
||||
/// of full rounds.
|
||||
fn wire_full_sbox_1(round: usize, i: usize) -> usize {
|
||||
const fn wire_full_sbox_1(round: usize, i: usize) -> usize {
|
||||
debug_assert!(round < poseidon::HALF_N_FULL_ROUNDS);
|
||||
debug_assert!(i < SPONGE_WIDTH);
|
||||
Self::START_FULL_1 + SPONGE_WIDTH * round + i
|
||||
|
||||
@ -33,12 +33,12 @@ impl<F: RichField + Extendable<D> + Poseidon, const D: usize> PoseidonMdsGate<F,
|
||||
Self(PhantomData)
|
||||
}
|
||||
|
||||
pub fn wires_input(i: usize) -> Range<usize> {
|
||||
pub(crate) const fn wires_input(i: usize) -> Range<usize> {
|
||||
assert!(i < SPONGE_WIDTH);
|
||||
i * D..(i + 1) * D
|
||||
}
|
||||
|
||||
pub fn wires_output(i: usize) -> Range<usize> {
|
||||
pub(crate) const fn wires_output(i: usize) -> Range<usize> {
|
||||
assert!(i < SPONGE_WIDTH);
|
||||
(SPONGE_WIDTH + i) * D..(SPONGE_WIDTH + i + 1) * D
|
||||
}
|
||||
|
||||
@ -19,10 +19,11 @@ use crate::plonk::vars::{
|
||||
use crate::util::serialization::{Buffer, IoResult};
|
||||
|
||||
/// A gate whose first four wires will be equal to a hash of public inputs.
|
||||
#[derive(Debug)]
|
||||
pub struct PublicInputGate;
|
||||
|
||||
impl PublicInputGate {
|
||||
pub const fn wires_public_inputs_hash() -> Range<usize> {
|
||||
pub(crate) const fn wires_public_inputs_hash() -> Range<usize> {
|
||||
0..4
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,19 +80,19 @@ impl<F: RichField + Extendable<D>, const D: usize> RandomAccessGate<F, D> {
|
||||
}
|
||||
|
||||
/// For each copy, a wire containing the claimed index of the element.
|
||||
pub fn wire_access_index(&self, copy: usize) -> usize {
|
||||
pub(crate) const fn wire_access_index(&self, copy: usize) -> usize {
|
||||
debug_assert!(copy < self.num_copies);
|
||||
(2 + self.vec_size()) * copy
|
||||
}
|
||||
|
||||
/// For each copy, a wire containing the element claimed to be at the index.
|
||||
pub fn wire_claimed_element(&self, copy: usize) -> usize {
|
||||
pub(crate) const fn wire_claimed_element(&self, copy: usize) -> usize {
|
||||
debug_assert!(copy < self.num_copies);
|
||||
(2 + self.vec_size()) * copy + 1
|
||||
}
|
||||
|
||||
/// For each copy, wires containing the entire list.
|
||||
pub fn wire_list_item(&self, i: usize, copy: usize) -> usize {
|
||||
pub(crate) const fn wire_list_item(&self, i: usize, copy: usize) -> usize {
|
||||
debug_assert!(i < self.vec_size());
|
||||
debug_assert!(copy < self.num_copies);
|
||||
(2 + self.vec_size()) * copy + 2 + i
|
||||
@ -102,7 +102,7 @@ impl<F: RichField + Extendable<D>, const D: usize> RandomAccessGate<F, D> {
|
||||
(2 + self.vec_size()) * self.num_copies
|
||||
}
|
||||
|
||||
fn wire_extra_constant(&self, i: usize) -> usize {
|
||||
const fn wire_extra_constant(&self, i: usize) -> usize {
|
||||
debug_assert!(i < self.num_extra_constants);
|
||||
self.start_extra_constants() + i
|
||||
}
|
||||
@ -114,7 +114,7 @@ impl<F: RichField + Extendable<D>, const D: usize> RandomAccessGate<F, D> {
|
||||
|
||||
/// An intermediate wire where the prover gives the (purported) binary decomposition of the
|
||||
/// index.
|
||||
pub fn wire_bit(&self, i: usize, copy: usize) -> usize {
|
||||
pub(crate) const fn wire_bit(&self, i: usize, copy: usize) -> usize {
|
||||
debug_assert!(i < self.bits);
|
||||
debug_assert!(copy < self.num_copies);
|
||||
self.num_routed_wires() + copy * self.bits + i
|
||||
|
||||
@ -35,17 +35,17 @@ impl<const D: usize> ReducingGate<D> {
|
||||
(num_routed_wires - 3 * D).min((num_wires - 2 * D) / (D + 1))
|
||||
}
|
||||
|
||||
pub const fn wires_output() -> Range<usize> {
|
||||
pub(crate) const fn wires_output() -> Range<usize> {
|
||||
0..D
|
||||
}
|
||||
pub const fn wires_alpha() -> Range<usize> {
|
||||
pub(crate) const fn wires_alpha() -> Range<usize> {
|
||||
D..2 * D
|
||||
}
|
||||
pub const fn wires_old_acc() -> Range<usize> {
|
||||
pub(crate) const fn wires_old_acc() -> Range<usize> {
|
||||
2 * D..3 * D
|
||||
}
|
||||
const START_COEFFS: usize = 3 * D;
|
||||
pub const fn wires_coeffs(&self) -> Range<usize> {
|
||||
pub(crate) const fn wires_coeffs(&self) -> Range<usize> {
|
||||
Self::START_COEFFS..Self::START_COEFFS + self.num_coeffs
|
||||
}
|
||||
const fn start_accs(&self) -> usize {
|
||||
|
||||
@ -37,23 +37,23 @@ impl<const D: usize> ReducingExtensionGate<D> {
|
||||
((num_routed_wires - 3 * D) / D).min((num_wires - 2 * D) / (D * 2))
|
||||
}
|
||||
|
||||
pub const fn wires_output() -> Range<usize> {
|
||||
pub(crate) const fn wires_output() -> Range<usize> {
|
||||
0..D
|
||||
}
|
||||
pub const fn wires_alpha() -> Range<usize> {
|
||||
pub(crate) const fn wires_alpha() -> Range<usize> {
|
||||
D..2 * D
|
||||
}
|
||||
pub const fn wires_old_acc() -> Range<usize> {
|
||||
pub(crate) const fn wires_old_acc() -> Range<usize> {
|
||||
2 * D..3 * D
|
||||
}
|
||||
const START_COEFFS: usize = 3 * D;
|
||||
pub const fn wires_coeff(i: usize) -> Range<usize> {
|
||||
pub(crate) const fn wires_coeff(i: usize) -> Range<usize> {
|
||||
Self::START_COEFFS + i * D..Self::START_COEFFS + (i + 1) * D
|
||||
}
|
||||
const fn start_accs(&self) -> usize {
|
||||
Self::START_COEFFS + self.num_coeffs * D
|
||||
}
|
||||
fn wires_accs(&self, i: usize) -> Range<usize> {
|
||||
const fn wires_accs(&self, i: usize) -> Range<usize> {
|
||||
debug_assert!(i < self.num_coeffs);
|
||||
if i == self.num_coeffs - 1 {
|
||||
// The last accumulator is the output.
|
||||
|
||||
@ -6,6 +6,7 @@ use crate::field::packed::PackedField;
|
||||
/// Permits us to abstract the underlying memory layout. In particular, we can make a matrix of
|
||||
/// constraints where every column is an evaluation point and every row is a constraint index, with
|
||||
/// the matrix stored in row-contiguous form.
|
||||
#[derive(Debug)]
|
||||
pub struct StridedConstraintConsumer<'a, P: PackedField> {
|
||||
// This is a particularly neat way of doing this, more so than a slice. We increase start by
|
||||
// stride at every step and terminate when it equals end.
|
||||
|
||||
@ -12,7 +12,7 @@ use crate::plonk::circuit_builder::CircuitBuilder;
|
||||
use crate::plonk::config::{AlgebraicHasher, GenericHashOut, Hasher};
|
||||
|
||||
/// Observes prover messages, and generates challenges by hashing the transcript, a la Fiat-Shamir.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Challenger<F: RichField, H: Hasher<F>> {
|
||||
pub(crate) sponge_state: H::Permutation,
|
||||
pub(crate) input_buffer: Vec<F>,
|
||||
@ -161,6 +161,7 @@ impl<F: RichField, H: AlgebraicHasher<F>> Default for Challenger<F, H> {
|
||||
/// A recursive version of `Challenger`. The main difference is that `RecursiveChallenger`'s input
|
||||
/// buffer can grow beyond `H::Permutation::RATE`. This is so that `observe_element` etc do not need access
|
||||
/// to the `CircuitBuilder`.
|
||||
#[derive(Debug)]
|
||||
pub struct RecursiveChallenger<F: RichField + Extendable<D>, H: AlgebraicHasher<F>, const D: usize>
|
||||
{
|
||||
sponge_state: H::AlgebraicPermutation,
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
#![allow(clippy::needless_range_loop)]
|
||||
#![deny(rustdoc::broken_intra_doc_links)]
|
||||
#![deny(missing_debug_implementations)]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
|
||||
@ -63,6 +63,7 @@ pub const NUM_COINS_LOOKUP: usize = 4;
|
||||
/// `ChallengeB` is used for the linear combination of input and output pairs in the polynomial RE.
|
||||
/// `ChallengeAlpha` is used for the running sums: 1/(alpha - combo_i).
|
||||
/// `ChallengeDelta` is a challenge on which to evaluate the interpolated LUT function.
|
||||
#[derive(Debug)]
|
||||
pub enum LookupChallenges {
|
||||
ChallengeA = 0,
|
||||
ChallengeB = 1,
|
||||
@ -135,6 +136,7 @@ pub struct LookupWire {
|
||||
/// // Verify the proof
|
||||
/// assert!(circuit_data.verify(proof).is_ok());
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct CircuitBuilder<F: RichField + Extendable<D>, const D: usize> {
|
||||
/// Circuit configuration to be used by this [`CircuitBuilder`].
|
||||
pub config: CircuitConfig,
|
||||
|
||||
@ -252,6 +252,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
/// structure as succinct as we can. Thus we include various precomputed data which isn't strictly
|
||||
/// required, like LDEs of preprocessed polynomials. If more succinctness was desired, we could
|
||||
/// construct a more minimal prover structure and convert back and forth.
|
||||
#[derive(Debug)]
|
||||
pub struct ProverCircuitData<
|
||||
F: RichField + Extendable<D>,
|
||||
C: GenericConfig<D, F = F>,
|
||||
|
||||
@ -4,6 +4,7 @@ use alloc::string::String;
|
||||
use crate::iop::target::Target;
|
||||
|
||||
/// A named copy constraint.
|
||||
#[derive(Debug)]
|
||||
pub struct CopyConstraint {
|
||||
pub pair: (Target, Target),
|
||||
pub name: String,
|
||||
|
||||
@ -256,6 +256,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ProofChallenges<F: RichField + Extendable<D>, const D: usize> {
|
||||
/// Random values used in Plonk's permutation argument.
|
||||
pub plonk_betas: Vec<F>,
|
||||
|
||||
@ -132,6 +132,7 @@ impl<'a, F: Field> EvaluationVarsBase<'a, F> {
|
||||
}
|
||||
|
||||
/// Iterator of views (`EvaluationVarsBase`) into a `EvaluationVarsBaseBatch`.
|
||||
#[derive(Debug)]
|
||||
pub struct EvaluationVarsBaseBatchIter<'a, F: Field> {
|
||||
i: usize,
|
||||
vars_batch: EvaluationVarsBaseBatch<'a, F>,
|
||||
@ -159,6 +160,7 @@ impl<'a, F: Field> Iterator for EvaluationVarsBaseBatchIter<'a, F> {
|
||||
/// Iterator of packed views (`EvaluationVarsBasePacked`) into a `EvaluationVarsBaseBatch`.
|
||||
/// Note: if the length of `EvaluationVarsBaseBatch` is not a multiple of `P::WIDTH`, then the
|
||||
/// leftovers at the end are ignored.
|
||||
#[derive(Debug)]
|
||||
pub struct EvaluationVarsBaseBatchIterPacked<'a, P: PackedField> {
|
||||
/// Index to yield next, in units of `P::Scalar`. E.g. if `P::WIDTH == 4`, then we will yield
|
||||
/// the vars for points `i`, `i + 1`, `i + 2`, and `i + 3`, packed.
|
||||
@ -219,7 +221,7 @@ impl<'a, const D: usize> EvaluationTargets<'a, D> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct EvaluationTargets<'a, const D: usize> {
|
||||
pub local_constants: &'a [ExtensionTarget<D>],
|
||||
pub local_wires: &'a [ExtensionTarget<D>],
|
||||
|
||||
@ -8,6 +8,7 @@ use alloc::{
|
||||
use log::{log, Level};
|
||||
|
||||
/// The hierarchy of contexts, and the gate count contributed by each one. Useful for debugging.
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct ContextTree {
|
||||
/// The name of this scope.
|
||||
name: String,
|
||||
|
||||
@ -113,7 +113,6 @@ pub mod default {
|
||||
use crate::gates::reducing_extension::ReducingExtensionGate;
|
||||
use crate::hash::hash_types::RichField;
|
||||
use crate::util::serialization::GateSerializer;
|
||||
|
||||
/// A gate serializer that can be used to serialize all default gates supported
|
||||
/// by the `plonky2` library.
|
||||
/// Being a unit struct, it can be simply called as
|
||||
@ -123,6 +122,7 @@ pub mod default {
|
||||
/// ```
|
||||
/// Applications using custom gates should define their own serializer implementing
|
||||
/// the `GateSerializer` trait. This can be easily done through the `impl_gate_serializer` macro.
|
||||
#[derive(Debug)]
|
||||
pub struct DefaultGateSerializer;
|
||||
impl<F: RichField + Extendable<D>, const D: usize> GateSerializer<F, D> for DefaultGateSerializer {
|
||||
impl_gate_serializer! {
|
||||
|
||||
@ -140,7 +140,7 @@ pub mod default {
|
||||
/// Applications using custom generators should define their own serializer implementing
|
||||
/// the `WitnessGeneratorSerializer` trait. This can be easily done through the
|
||||
/// `impl_generator_serializer` macro.
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct DefaultGeneratorSerializer<C: GenericConfig<D>, const D: usize> {
|
||||
pub _phantom: PhantomData<C>,
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ use web_time::{Duration, Instant};
|
||||
|
||||
/// The hierarchy of scopes, and the time consumed by each one. Useful for profiling.
|
||||
#[cfg(feature = "timing")]
|
||||
#[derive(Debug)]
|
||||
pub struct TimingTree {
|
||||
/// The name of this scope.
|
||||
name: String,
|
||||
@ -18,6 +19,7 @@ pub struct TimingTree {
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "timing"))]
|
||||
#[derive(Debug)]
|
||||
pub struct TimingTree(Level);
|
||||
|
||||
#[cfg(feature = "timing")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user