Skip to main content

Transcript

Trait Transcript 

Source
pub trait Transcript:
    Clone
    + Read
    + Write {
    // Required methods
    fn new(label: &[u8]) -> Self;
    fn absorb_raw(&mut self, data: &[u8]);
    fn squeeze_raw(&mut self, buf: &mut [u8]);

    // Provided methods
    fn absorb_serialize(&mut self, obj: &impl CanonicalSerialize) { ... }
    fn squeeze_deserialize<T: CanonicalDeserialize>(&mut self) -> T { ... }
    fn to_rng(self) -> TranscriptRng<Self>
       where Self: Sized { ... }
}
Expand description

Fiat-Shamir transcript with absorb/squeeze interface.

Provides a streaming hash abstraction where data is absorbed into an internal state and arbitrary-length output is squeezed out.

Implements io::Write so that serializable types (points, scalars) can be written directly into the transcript without intermediate buffers.

Implementations do not need to handle domain separation or length-prefixing of variable-length inputs. The protocol layer takes care of this by absorbing domain-separation tags and explicit lengths before variable-length data. Since absorb_raw is a plain concatenation into a single hash stream (absorb then squeeze, no resets), the domain-separation bytes injected by the caller are sufficient to prevent ambiguous parses.

Required Methods§

Source

fn new(label: &[u8]) -> Self

Create a new transcript.

Source

fn absorb_raw(&mut self, data: &[u8])

Absorb raw bytes into the transcript.

This is a plain concatenation into the internal hash state. Domain separation and length-prefixing of variable-length fields are the caller’s responsibility (handled by the protocol layer).

§Panics

Panics if called after squeeze_raw.

Source

fn squeeze_raw(&mut self, buf: &mut [u8])

Squeeze output bytes from the transcript.

The first call finalizes the internal hash and transitions to squeezing.

After the first squeeze_raw call, absorb_raw must not be called.

Provided Methods§

Source

fn absorb_serialize(&mut self, obj: &impl CanonicalSerialize)

Absorb a serializable object into the transcript.

Serializes the object directly into the transcript via the io::Write implementation, avoiding intermediate allocations.

Source

fn squeeze_deserialize<T: CanonicalDeserialize>(&mut self) -> T

Squeeze and deserialize an object from the transcript.

Reads bytes from the squeeze_raw stream via the io::Read implementation and deserializes them directly.

Source

fn to_rng(self) -> TranscriptRng<Self>
where Self: Sized,

Consume the transcript and return an RNG that draws from the squeeze stream.

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§