pub struct Tip5 {
pub state: [BFieldElement; 16],
}
Fields§
§state: [BFieldElement; 16]
Implementations§
Source§impl Tip5
impl Tip5
pub const fn new(domain: Domain) -> Self
pub const fn offset_fermat_cube_map(x: u16) -> u16
pub fn permutation(&mut self)
Sourcepub fn trace(&mut self) -> [[BFieldElement; 16]; 6]
pub fn trace(&mut self) -> [[BFieldElement; 16]; 6]
Functionally equivalent to permutation
. Returns the trace of
applying the permutation; that is, the initial state of the sponge as well as its state
after each round.
Sourcepub fn hash_10(input: &[BFieldElement; 10]) -> [BFieldElement; 5]
pub fn hash_10(input: &[BFieldElement; 10]) -> [BFieldElement; 5]
Hash 10 elements, or two digests. There is no padding because the input length is fixed.
pub fn hash_pair(left: Digest, right: Digest) -> Digest
Sourcepub fn hash<T: BFieldCodec>(value: &T) -> Digest
pub fn hash<T: BFieldCodec>(value: &T) -> Digest
Thin wrapper around hash_varlen
.
Sourcepub fn hash_varlen(input: &[BFieldElement]) -> Digest
pub fn hash_varlen(input: &[BFieldElement]) -> Digest
Hash a variable-length sequence of BFieldElement
.
- Apply the correct padding
- Sponge::pad_and_absorb_all()
- Sponge::squeeze() once.
Sourcepub fn sample_indices(
&mut self,
upper_bound: u32,
num_indices: usize,
) -> Vec<u32>
pub fn sample_indices( &mut self, upper_bound: u32, num_indices: usize, ) -> Vec<u32>
Produce num_indices
random integer values in the range [0, upper_bound)
. The
upper_bound
must be a power of 2.
This method uses von Neumann rejection sampling. Specifically, if the top 32 bits of a BFieldElement are all ones, then the bottom 32 bits are not uniformly distributed, and so they are dropped. This method invokes squeeze until enough uniform u32s have been sampled.
Sourcepub fn sample_scalars(&mut self, num_elements: usize) -> Vec<XFieldElement>
pub fn sample_scalars(&mut self, num_elements: usize) -> Vec<XFieldElement>
Produce num_elements
random XFieldElement
values.
If num_elements
is not divisible by RATE
, spill the remaining elements of the
last squeeze
.
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for Tip5
impl<'arbitrary> Arbitrary<'arbitrary> for Tip5
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self
from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured
this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured
this type
needs to construct itself. Read moreSource§impl BFieldCodec for Tip5
impl BFieldCodec for Tip5
type Error = Tip5BFieldDecodingError
fn decode(sequence: &[BFieldElement]) -> Result<Box<Self>, Self::Error>
fn encode(&self) -> Vec<BFieldElement>
Source§fn static_length() -> Option<usize>
fn static_length() -> Option<usize>
Source§impl<'de> Deserialize<'de> for Tip5
impl<'de> Deserialize<'de> for Tip5
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl GetSize for Tip5
impl GetSize for Tip5
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Source§fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>(
&self,
tracker: TRACKER,
) -> (usize, TRACKER)
fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>( &self, tracker: TRACKER, ) -> (usize, TRACKER)
tracker
. Read moreSource§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Source§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker
. Read moreSource§impl Hasher for Tip5
impl Hasher for Tip5
1.26.0 · Source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
u128
into this hasher.1.3.0 · Source§fn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
usize
into this hasher.1.26.0 · Source§fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
i128
into this hasher.1.3.0 · Source§fn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
isize
into this hasher.Source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
hasher_prefixfree_extras
)impl Eq for Tip5
impl StructuralPartialEq for Tip5
Auto Trait Implementations§
impl Freeze for Tip5
impl RefUnwindSafe for Tip5
impl Send for Tip5
impl Sync for Tip5
impl Unpin for Tip5
impl UnwindSafe for Tip5
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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