pub struct Transcript { /* private fields */ }Expand description
A Fiat-Shamir transcript.
Operations consume self and return a new transcript,
ensuring the hash state evolves deterministically.
§Examples
use field_cat::BabyBear;
use proof_cat_core::Transcript;
// Create a transcript, absorb some data, squeeze a challenge.
let transcript = Transcript::new(b"my-protocol")
.absorb_field(&BabyBear::new(42));
let (_challenge, _transcript): (BabyBear, _) =
transcript.squeeze_challenge()?;
// The challenge is deterministic: same inputs produce
// the same challenge every time.Implementations§
Source§impl Transcript
impl Transcript
Sourcepub fn absorb_bytes(self, data: &[u8]) -> Self
pub fn absorb_bytes(self, data: &[u8]) -> Self
Absorb raw bytes into the transcript.
Sourcepub fn absorb_field<F: FieldBytes>(self, elem: &F) -> Self
pub fn absorb_field<F: FieldBytes>(self, elem: &F) -> Self
Absorb a field element into the transcript.
Sourcepub fn squeeze_challenge<F: FieldBytes>(self) -> Result<(F, Self), Error>
pub fn squeeze_challenge<F: FieldBytes>(self) -> Result<(F, Self), Error>
Squeeze a challenge field element from the transcript.
Hashes the current state with SHA-256, interprets the output as a field element, and returns the challenge along with an updated transcript.
§Errors
Returns Error::FieldCat if the hash output cannot be
interpreted as a field element.
Trait Implementations§
Source§impl Clone for Transcript
impl Clone for Transcript
Source§fn clone(&self) -> Transcript
fn clone(&self) -> Transcript
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Transcript
impl RefUnwindSafe for Transcript
impl Send for Transcript
impl Sync for Transcript
impl Unpin for Transcript
impl UnsafeUnpin for Transcript
impl UnwindSafe for Transcript
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