Safe

Trait Safe 

Source
pub trait Safe<T, const W: usize>
where T: Default + Copy + Zeroize,
{ // Required methods fn permute(&mut self, state: &mut [T; W]); fn tag(&mut self, input: &[u8]) -> T; fn add(&mut self, right: &T, left: &T) -> T; // Provided method fn initialized_state(tag: T) -> [T; W] { ... } }
Expand description

This trait defines the behavior of a sponge algorithm.

Note: The trait’s specific implementation of addition enables usage within zero-knowledge circuits.

Required Methods§

Source

fn permute(&mut self, state: &mut [T; W])

Apply one permutation to the state.

Source

fn tag(&mut self, input: &[u8]) -> T

Create the tag by hashing the tag input to an element of type T.

§Parameters
  • input: The domain-separator and IO-pattern encoded as a slice of bytes.
§Returns

A tag element as the hash of the input to a field element T.

Source

fn add(&mut self, right: &T, left: &T) -> T

Add two values of type T and return the result.

§Parameters
  • right: The right operand of type T.
  • left: The left operand of type T.
§Returns

The result of the addition, of type T.

Provided Methods§

Source

fn initialized_state(tag: T) -> [T; W]

Create a state and initialize it with the tag and default values of T.

§Parameters
  • tag: The initial tag value as computed by Self::tag.
§Returns

An array of type [T; W] representing the initialized state.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§