snarkvm_circuit_algorithms::keccak

Struct Keccak

Source
pub struct Keccak<E: Environment, const TYPE: u8, const VARIANT: usize> { /* private fields */ }
Expand description

The sponge construction Sponge[f, pad, r] is a function that takes a variable-length input and produces a fixed-length output (the hash value).

The permutation f is a function that takes a fixed-length input and produces a fixed-length output, defined as f = Keccak-f[b], where b := 25 * 2^l is the width of the permutation, and l is the log width of the permutation. For our case, l = 6, thus b = 1600.

The padding rule pad is a function that takes a variable-length input and produces a fixed-length output. In Keccak, pad is a multi-rate padding, defined as pad(M) = M || 0x01 || 0x00…0x00 || 0x80, where M is the input data, and 0x01 || 0x00…0x00 || 0x80 is the padding. In SHA-3, pad is a SHAKE, defined as pad(M) = M || 0x06 || 0x00…0x00 || 0x80, where M is the input data, and 0x06 || 0x00…0x00 || 0x80 is the padding.

The bitrate r is the number of bits that are absorbed into the sponge state in each iteration of the absorbing phase.

In addition, the capacity is defined as c := b - r.

Implementations§

Source§

impl<E: Environment, const TYPE: u8, const VARIANT: usize> Keccak<E, TYPE, VARIANT>

Source

pub fn new() -> Self

Initializes a new Keccak hash function.

Trait Implementations§

Source§

impl<E: Clone + Environment, const TYPE: u8, const VARIANT: usize> Clone for Keccak<E, TYPE, VARIANT>

Source§

fn clone(&self) -> Keccak<E, TYPE, VARIANT>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E: Debug + Environment, const TYPE: u8, const VARIANT: usize> Debug for Keccak<E, TYPE, VARIANT>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: Default + Environment, const TYPE: u8, const VARIANT: usize> Default for Keccak<E, TYPE, VARIANT>

Source§

fn default() -> Keccak<E, TYPE, VARIANT>

Returns the “default value” for a type. Read more
Source§

impl<E: Environment, const TYPE: u8, const VARIANT: usize> Hash for Keccak<E, TYPE, VARIANT>

Source§

fn hash(&self, input: &[Self::Input]) -> Self::Output

Returns the Keccak hash of the given input as bits.

Source§

type Input = Boolean<E>

Source§

type Output = Vec<Boolean<E>>

Auto Trait Implementations§

§

impl<E, const TYPE: u8, const VARIANT: usize> Freeze for Keccak<E, TYPE, VARIANT>

§

impl<E, const TYPE: u8, const VARIANT: usize> RefUnwindSafe for Keccak<E, TYPE, VARIANT>

§

impl<E, const TYPE: u8, const VARIANT: usize> !Send for Keccak<E, TYPE, VARIANT>

§

impl<E, const TYPE: u8, const VARIANT: usize> !Sync for Keccak<E, TYPE, VARIANT>

§

impl<E, const TYPE: u8, const VARIANT: usize> Unpin for Keccak<E, TYPE, VARIANT>
where <E as Environment>::BaseField: Unpin,

§

impl<E, const TYPE: u8, const VARIANT: usize> UnwindSafe for Keccak<E, TYPE, VARIANT>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

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

Source§

fn vzip(self) -> V