pub struct ProofStream {
pub items: Vec<ProofItem>,
pub items_index: usize,
pub sponge: Tip5,
}
Fields§
§items: Vec<ProofItem>
§items_index: usize
§sponge: Tip5
Implementations§
Source§impl ProofStream
impl ProofStream
pub fn new() -> Self
Sourcepub fn transcript_length(&self) -> usize
pub fn transcript_length(&self) -> usize
The number of field elements required to encode the proof.
Sourcepub fn alter_fiat_shamir_state_with(&mut self, item: &impl BFieldCodec)
pub fn alter_fiat_shamir_state_with(&mut self, item: &impl BFieldCodec)
Alters the Fiat-Shamir’s sponge state with the encoding of the given item.
Does not record the given item in the proof stream.
This is useful for items that are not sent to the verifier, e.g., the
Claim
.
See also Self::enqueue()
and Self::dequeue()
.
Sourcepub fn enqueue(&mut self, item: ProofItem)
pub fn enqueue(&mut self, item: ProofItem)
Send a proof item as prover to verifier.
Some items do not need to be included in the Fiat-Shamir heuristic, i.e., they do not
need to modify the sponge state. For those items, namely those that evaluate to false
according to ProofItem::include_in_fiat_shamir_heuristic
, the sponge state is not
modified.
For example:
- Merkle authentication structure do not need to be hashed if the root of the tree in question was hashed previously.
- If the proof stream is not used to sample any more randomness, i.e., after the last round of interaction, no further items need to be hashed.
Sourcepub fn dequeue(&mut self) -> Result<ProofItem, ProofStreamError>
pub fn dequeue(&mut self) -> Result<ProofItem, ProofStreamError>
Receive a proof item from prover as verifier.
See ProofStream::enqueue
for more details.
Sourcepub fn sample_indices(
&mut self,
upper_bound: usize,
num_indices: usize,
) -> Vec<usize>
pub fn sample_indices( &mut self, upper_bound: usize, num_indices: usize, ) -> Vec<usize>
Given an upper_bound
that is a power of 2, produce num_indices
uniform random numbers
in the interval [0; upper_bound)
.
upper_bound
: The (non-inclusive) upper bound. Must be a power of two.num_indices
: The number of indices to sample
Sourcepub fn sample_scalars(&mut self, num_scalars: usize) -> Vec<XFieldElement>
pub fn sample_scalars(&mut self, num_scalars: usize) -> Vec<XFieldElement>
A thin wrapper around H::sample_scalars
.
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for ProofStream
impl<'arbitrary> Arbitrary<'arbitrary> for ProofStream
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§impl BFieldCodec for ProofStream
impl BFieldCodec for ProofStream
type Error = ProofStreamBFieldDecodingError
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 Clone for ProofStream
impl Clone for ProofStream
Source§fn clone(&self) -> ProofStream
fn clone(&self) -> ProofStream
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ProofStream
impl Debug for ProofStream
Source§impl Default for ProofStream
impl Default for ProofStream
Source§fn default() -> ProofStream
fn default() -> ProofStream
Source§impl From<&ProofStream> for Proof
impl From<&ProofStream> for Proof
Source§fn from(proof_stream: &ProofStream) -> Self
fn from(proof_stream: &ProofStream) -> Self
Source§impl From<<ProofStream as BFieldCodec>::Error> for ProofStreamError
impl From<<ProofStream as BFieldCodec>::Error> for ProofStreamError
Source§fn from(source: <ProofStream as BFieldCodec>::Error) -> Self
fn from(source: <ProofStream as BFieldCodec>::Error) -> Self
Source§impl From<ProofStream> for Proof
impl From<ProofStream> for Proof
Source§fn from(proof_stream: ProofStream) -> Self
fn from(proof_stream: ProofStream) -> Self
Source§impl PartialEq for ProofStream
impl PartialEq for ProofStream
Source§impl TryFrom<&Proof> for ProofStream
impl TryFrom<&Proof> for ProofStream
Source§type Error = ProofStreamError
type Error = ProofStreamError
impl Eq for ProofStream
impl StructuralPartialEq for ProofStream
Auto Trait Implementations§
impl Freeze for ProofStream
impl RefUnwindSafe for ProofStream
impl Send for ProofStream
impl Sync for ProofStream
impl Unpin for ProofStream
impl UnwindSafe for ProofStream
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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