pub struct Eidos;Expand description
Eidos hash construction.
Byte strings and field-element strings use distinct typed, registered domains. Both
constructions bind the exact input length into the initial chaining value. The fixed
two-to-one Merkle compression exposed by Self::merge is the sole reserved zero-tag
construction and is deliberately distinct from ordinary Felt-sequence hashing.
The CryptographicHasher<u64, _> implementations are bit-level adapters for the generic
Felt-sequence construction. Canonical Goldilocks encodings produce exactly the same digest as
their Felt counterparts. Other u64 values are split into their two limbs without reduction;
this deterministic extension is not a separate registered message domain.
Digests occupy a 252-bit packed subspace and therefore provide at most 126 bits of generic
collision resistance.
Digest coordinates are below 2^63; use crate::rand::EidosRandomCoin when uniform
field samples are required. See the module documentation for the output contract.
Implementations§
Source§impl Eidos
impl Eidos
Sourcepub fn compress(cv: Word, block: [Felt; 8]) -> Word
pub fn compress(cv: Word, block: [Felt; 8]) -> Word
Compress one complete block under a caller-supplied chaining value.
This is the raw compression layer underlying the Eidos hash construction. It does not add domain separation, length binding, padding, or any other message framing. The input CV may contain arbitrary canonical field elements; only the output CV is restricted to Eidos’s 252-bit packed subspace.
Sourcepub fn compress_packed(
cv: [[Felt; 16]; 4],
block: [[Felt; 16]; 8],
) -> [[Felt; 16]; 4]
pub fn compress_packed( cv: [[Felt; 16]; 4], block: [[Felt; 16]; 8], ) -> [[Felt; 16]; 4]
Compress one complete block in each packed lane.
Each lane is independent. Like Self::compress, this adds no message framing.
Sourcepub fn compress_xof(cv: Word, block: [Felt; 8]) -> [Felt; 16]
pub fn compress_xof(cv: Word, block: [Felt; 8]) -> [Felt; 16]
Return all sixteen raw XOF output lanes for one complete block.
Each u32 lane is embedded as one field element. This is raw XOF material for a
caller-supplied CV, not an Eidos digest, and no message framing is added.
Sourcepub fn transcript_init_cv<D>(domain: D) -> Wordwhere
D: EidosDomain<Encoding = Transcript>,
pub fn transcript_init_cv<D>(domain: D) -> Wordwhere
D: EidosDomain<Encoding = Transcript>,
Construct the framed initial CV used by a Fiat-Shamir challenger.
The registered transcript tag occupies the domain lane and all three parameter lanes are zero. The transcript’s subsequent absorb and squeeze schedule is defined by its domain.
Sourcepub fn init_chaining_word<D>(domain: D, param0: u32) -> Wordwhere
D: EidosDomain,
pub fn init_chaining_word<D>(domain: D, param0: u32) -> Wordwhere
D: EidosDomain,
Construct an initial chaining word with param0 in the first parameter lane.
The remaining two parameter lanes are zero. Standard Felt- and byte-sequence domains use
param0 for the complete logical input length; custom domains define it in their registry
schema.
Sourcepub fn init_chaining_word_with_params<D>(_: D, params: [u32; 3]) -> Wordwhere
D: EidosDomain,
pub fn init_chaining_word_with_params<D>(_: D, params: [u32; 3]) -> Wordwhere
D: EidosDomain,
Construct an initial chaining value from a registered domain tag and three parameters.
The domain defines the construction and the meaning of its parameters. Every supplied value occupies one complete low u32 lane; the corresponding high lane is a fixed IV word.
Sourcepub fn init_chaining_word_with_tag(tag: DomainTag, params: [u32; 3]) -> Word
pub fn init_chaining_word_with_tag(tag: DomainTag, params: [u32; 3]) -> Word
Construct an initial chaining value from a structurally valid runtime tag and three parameters.
This is the dynamic counterpart of Self::init_chaining_word_with_params for registries
such as deferred precompiles, where the concrete domain is selected at runtime. Constructing
a super::DomainTag establishes only its structural and namespace rules; the caller
remains responsible for checking membership in the relevant owner registry and enforcing
that domain’s parameter and payload schema.
Sourcepub fn init_packed_chaining_word<D>(_: D, param0: u32) -> [[Felt; 16]; 4]where
D: EidosDomain,
pub fn init_packed_chaining_word<D>(_: D, param0: u32) -> [[Felt; 16]; 4]where
D: EidosDomain,
Construct the same one-parameter initial chaining word in every packed lane.
The interpretation of param0 is defined by the registered domain.
Sourcepub fn hash(bytes: &[u8]) -> Word
pub fn hash(bytes: &[u8]) -> Word
Hash a byte string with the registered generic byte-string domain.
§Panics
Panics if the byte length does not fit in u32.
Sourcepub fn hash_in_domain<D>(bytes: &[u8], _: D) -> Wordwhere
D: EidosDomain<Encoding = ByteString>,
pub fn hash_in_domain<D>(bytes: &[u8], _: D) -> Wordwhere
D: EidosDomain<Encoding = ByteString>,
Hash a byte string under a typed byte-string domain.
A Felt-sequence or custom-schedule domain cannot be passed to this function.
§Panics
Panics if the byte length does not fit in u32.
Sourcepub fn hash_elements<E>(elements: &[E]) -> Wordwhere
E: BasedVectorSpace<Felt>,
pub fn hash_elements<E>(elements: &[E]) -> Wordwhere
E: BasedVectorSpace<Felt>,
Hash a field-element sequence under the registered generic Felt-sequence domain.
§Panics
Panics if the flattened Felt length overflows usize or does not fit in u32.
Sourcepub fn hash_elements_in_domain<E, D>(elements: &[E], _: D) -> Word
pub fn hash_elements_in_domain<E, D>(elements: &[E], _: D) -> Word
Hash a field-element sequence under a typed Felt-sequence domain.
A byte-string or custom-schedule domain cannot be passed to this function.
§Panics
Panics if the flattened Felt length overflows usize or does not fit in u32.
use miden_crypto::{Felt, hash::eidos::{Eidos, domains::GENERIC_BYTE_STRING}};
let values = [Felt::ZERO];
let _ = Eidos::hash_elements_in_domain(&values, GENERIC_BYTE_STRING);Raw field elements are not domain declarations either:
use miden_crypto::{Felt, hash::eidos::Eidos};
let values = [Felt::ZERO];
let byte_tag = Felt::new_unchecked(0x0000_0301);
let _ = Eidos::hash_elements_in_domain(&values, byte_tag);Sourcepub fn merge(values: &[Word; 2]) -> Word
pub fn merge(values: &[Word; 2]) -> Word
Compress two digest words as one reserved Merkle inner node.
This fixed, one-block construction uses the reserved all-zero framing tuple and is
intentionally not equivalent to Self::hash_elements over the same eight Felts.
Sourcepub fn merkle_node_init_chaining_word() -> Word
pub fn merkle_node_init_chaining_word() -> Word
Return the initial chaining word reserved for Merkle inner-node compression.
Its four injected framing lanes are all zero. It is exposed for implementations which
schedule Self::merge through a separate compression engine; ordinary callers should
use Self::merge directly.
Sourcepub fn merge_packed(values: &[[[Felt; 16]; 4]; 2]) -> [[Felt; 16]; 4]
pub fn merge_packed(values: &[[[Felt; 16]; 4]; 2]) -> [[Felt; 16]; 4]
Compress two packed digest words as reserved Merkle inner nodes in every packed lane.
This is the packed equivalent of Self::merge.
Sourcepub fn hash_double_word(values: &[Word; 2]) -> Word
pub fn hash_double_word(values: &[Word; 2]) -> Word
Hash two words as one generic eight-Felt sequence.
Sourcepub fn hash_double_word_packed(values: &[[[Felt; 16]; 4]; 2]) -> [[Felt; 16]; 4]
pub fn hash_double_word_packed(values: &[[[Felt; 16]; 4]; 2]) -> [[Felt; 16]; 4]
Hash packed pairs of words as generic eight-Felt sequences.
Sourcepub fn hash_double_word_in_domain<D>(values: &[Word; 2], _: D) -> Wordwhere
D: EidosDomain<Encoding = FeltSequence>,
pub fn hash_double_word_in_domain<D>(values: &[Word; 2], _: D) -> Wordwhere
D: EidosDomain<Encoding = FeltSequence>,
Hash two words as one eight-Felt sequence under a typed Felt-sequence domain.
Sourcepub fn hash_words(values: &[Word]) -> Word
pub fn hash_words(values: &[Word]) -> Word
Hash a sequence of words under the generic Felt-sequence domain.
§Panics
Panics if the flattened Felt length does not fit in u32.
Trait Implementations§
impl Copy for Eidos
Source§impl CryptographicHasher<Felt, [Felt; 4]> for Eidos
impl CryptographicHasher<Felt, [Felt; 4]> for Eidos
Source§fn hash_iter<I>(&self, input: I) -> [Felt; 4]where
I: IntoIterator<Item = Felt>,
fn hash_iter<I>(&self, input: I) -> [Felt; 4]where
I: IntoIterator<Item = Felt>,
Source§const LANES: usize = 1
const LANES: usize = 1
Source§const PREFER_CONTIGUOUS_INPUT: bool = false
const PREFER_CONTIGUOUS_INPUT: bool = false
Source§fn hash_iter_slices<'a, I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = &'a [Item]>,
Item: 'a,
fn hash_iter_slices<'a, I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = &'a [Item]>,
Item: 'a,
Source§impl CryptographicHasher<[Felt; 16], [[Felt; 16]; 4]> for Eidos
impl CryptographicHasher<[Felt; 16], [[Felt; 16]; 4]> for Eidos
Source§fn hash_iter<I>(&self, input: I) -> [[Felt; 16]; 4]
fn hash_iter<I>(&self, input: I) -> [[Felt; 16]; 4]
Source§fn hash_slice(&self, input: &[[Felt; 16]]) -> [[Felt; 16]; 4]
fn hash_slice(&self, input: &[[Felt; 16]]) -> [[Felt; 16]; 4]
Source§const LANES: usize = 1
const LANES: usize = 1
Source§const PREFER_CONTIGUOUS_INPUT: bool = false
const PREFER_CONTIGUOUS_INPUT: bool = false
Source§fn hash_iter_slices<'a, I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = &'a [Item]>,
Item: 'a,
fn hash_iter_slices<'a, I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = &'a [Item]>,
Item: 'a,
Source§impl CryptographicHasher<[u64; 16], [[u64; 16]; 4]> for Eidos
impl CryptographicHasher<[u64; 16], [[u64; 16]; 4]> for Eidos
Source§fn hash_slice(&self, input: &[[u64; 16]]) -> [[u64; 16]; 4]
fn hash_slice(&self, input: &[[u64; 16]]) -> [[u64; 16]; 4]
Source§const LANES: usize = 1
const LANES: usize = 1
Source§const PREFER_CONTIGUOUS_INPUT: bool = false
const PREFER_CONTIGUOUS_INPUT: bool = false
Source§fn hash_iter_slices<'a, I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = &'a [Item]>,
Item: 'a,
fn hash_iter_slices<'a, I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = &'a [Item]>,
Item: 'a,
Source§impl CryptographicHasher<u64, [u64; 4]> for Eidos
impl CryptographicHasher<u64, [u64; 4]> for Eidos
Source§fn hash_iter<I>(&self, input: I) -> [u64; 4]where
I: IntoIterator<Item = u64>,
fn hash_iter<I>(&self, input: I) -> [u64; 4]where
I: IntoIterator<Item = u64>,
Source§const LANES: usize = 1
const LANES: usize = 1
Source§const PREFER_CONTIGUOUS_INPUT: bool = false
const PREFER_CONTIGUOUS_INPUT: bool = false
Source§fn hash_iter_slices<'a, I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = &'a [Item]>,
Item: 'a,
fn hash_iter_slices<'a, I>(&self, input: I) -> Outwhere
I: IntoIterator<Item = &'a [Item]>,
Item: 'a,
impl Eq for Eidos
impl StructuralPartialEq for Eidos
Auto Trait Implementations§
impl Freeze for Eidos
impl RefUnwindSafe for Eidos
impl Send for Eidos
impl Sync for Eidos
impl Unpin for Eidos
impl UnsafeUnpin for Eidos
impl UnwindSafe for Eidos
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more