pub struct State(pub [Wire; 8]);Expand description
The internal state of SHA-256.
The state size is 256 bits. For efficiency reasons it’s packed in 8 x 32-bit words, and not 4 x 64-bit words.
The elements are referred to as a–h or H0–H7.
Tuple Fields§
§0: [Wire; 8]Implementations§
Source§impl State
impl State
pub const fn new(wires: [Wire; 8]) -> Self
pub fn public(builder: &CircuitBuilder) -> Self
pub fn private(builder: &CircuitBuilder) -> Self
pub fn iv(builder: &CircuitBuilder) -> Self
Sourcepub fn pack_4x64b(&self, builder: &CircuitBuilder) -> [Wire; 4]
pub fn pack_4x64b(&self, builder: &CircuitBuilder) -> [Wire; 4]
Packs the state into 4 x 64-bit big-endian words.
The lower-numbered word of each pair is the more significant, so it takes the high half.
§Preconditions
- Every state word holds its value in the low 32 bits, with the high 32 empty.
- The word lifted into the high half has its own high bits discarded by the shift.
- The word entering the low half is passed through unmasked.
Masking it here would commit one redundant intermediate per word. Every caller already clears before packing.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnsafeUnpin for State
impl UnwindSafe for State
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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 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>
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