diff --git a/plonky2/src/gates/random_access.rs b/plonky2/src/gates/random_access.rs index b771ba86..40ac955c 100644 --- a/plonky2/src/gates/random_access.rs +++ b/plonky2/src/gates/random_access.rs @@ -24,13 +24,13 @@ use crate::plonk::vars::{ /// A gate for checking that a particular element of a list matches a given value. #[derive(Copy, Clone, Debug)] pub struct RandomAccessGate, const D: usize> { - // Number of bits in the index (log2 of the list size). + /// Number of bits in the index (log2 of the list size). pub bits: usize, - // How many separate copies are packed into one gate. + /// How many separate copies are packed into one gate. pub num_copies: usize, - // Leftover wires are used as global scratch space to store constants. + /// Leftover wires are used as global scratch space to store constants. pub num_extra_constants: usize, _phantom: PhantomData, @@ -218,10 +218,12 @@ impl, const D: usize> Gate for RandomAccessGa .collect() } + // Check that the one remaining element after the folding is the claimed element. debug_assert_eq!(list_items.len(), 1); constraints.push(builder.sub_extension(list_items[0], claimed_element)); } + // Check the constant values. constraints.extend((0..self.num_extra_constants).map(|i| { builder.sub_extension( vars.local_constants[i],