Struct Keccakf

Source
pub struct Keccakf {
    pub input: StateMatrix<Col<B64>>,
    pub output: StateMatrix<Col<B64>>,
    /* private fields */
}
Expand description

Keccak-f[1600] permutation function verification gadget.

This gadget consists of 3x horizontally combined batches of 8x rounds each, 24 rounds in total. You can think about it as 8x wide SIMD performing one permutation per a table row. Below is the graphical representation of the layout.

| Batch 0  | Batch 1  | Batch 3  |
|----------|----------|----------|
| Round 00 | Round 01 | Round 02 |
| Round 03 | Round 04 | Round 05 |
| Round 06 | Round 07 | Round 08 |
| Round 09 | Round 10 | Round 11 |
| Round 12 | Round 13 | Round 14 |
| Round 15 | Round 16 | Round 17 |
| Round 18 | Round 19 | Round 20 |
| Round 21 | Round 22 | Round 23 |

We refer to each individual round within a batch as a track. For example, the 7th ( zero-based here and henceforth) track of the 1st batch is responsible for the 22nd round.

Each batch exposes two notable columns: state_in and state which are inputs and outputs respectively for the rounds in each batch. Both of those has the type of StateMatrix containing PackedLane8. Let’s break those down.

StateMatrix is a concept coming from the keccak which represents a 5x5 matrix. In keccak each cell is a 64-bit integer called lane. In our case however, since the SIMD-like approach, each cell is represented by a pack of columns - one for each track and this is what PackedLane8 represents.

To feed the input to permutation, you need to initialize the state_in column of the 0th batch with the input state matrix. See Self::populate_state_in if you have values handy.

Fields§

§input: StateMatrix<Col<B64>>

The lanes of the input and output state columns. These are exposed to make it convenient to use the gadget along with flushing.

§output: StateMatrix<Col<B64>>

Implementations§

Source§

impl Keccakf

Source

pub fn new(table: &mut TableBuilder<'_>) -> Self

Creates a new instance of the gadget.

See the struct documentation for more details.

Source

pub fn populate<P>(&self, index: &mut TableWitnessSegment<'_, P>) -> Result<()>

Populate the gadget.

Requires state in already to be populated. To populate with known values use Self::populate_state_in.

Source

pub fn packed_state_in(&self) -> &StateMatrix<PackedLane8>

Returns the state_in column for the 0th batch. The input to the permutation is at the 0th track.

Source

pub fn packed_state_out(&self) -> &StateMatrix<PackedLane8>

Returns the state_out column for the 2nd batch. The output of the permutation is at the 7th track.

Source

pub fn populate_state_in<'a, P>( &self, index: &mut TableWitnessSegment<'_, P>, state_ins: impl IntoIterator<Item = &'a StateMatrix<u64>>, ) -> Result<()>

Populate the input state of the permutation.

Source

pub fn read_state_outs<'a, P>( &self, index: &'a TableWitnessSegment<'_, P>, ) -> Result<impl Iterator<Item = StateMatrix<u64>> + 'a>

Read the resulting states of permutation, one item per row.

Only makes sense to call after Self::populate was called.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,