pub struct TranscriptReader<F, T> {
sponge: T,
transcript: Transcript<F>,
next_element: (usize, usize),
}Expand description
A TranscriptReader is typically created using a Transcript produced by a
TranscriptWriter.
Its operation is similar to that of the writer, except that instead of an
“append” operation, it provides a “consume” operation which returns the next
field element that was appended to the circuit by the prover. The user of a
TranscriptReader (typically that is the verifier) is responsible for
running any checks (if necessary) to verify the validity of the consumed
elements. The “squeeze” operation behaves similarly to that of a
TranscriptWriter.
Consume/Squeeze operations on a TranscriptReader may return errors when an
unexpected operation is requested. An operation can be unexpected if it
doesn’t match the sequence of operations performed by the TranscriptWriter
that produced the Transcript used in the initialization of the reader.
Fields§
§sponge: TThe sponge that this reader is wrapping around.
transcript: Transcript<F>The transcript that this reader is using to consume elements from and verify the order of operations is valid.
next_element: (usize, usize)An internal state representing the position of the next operation on the transcript.
Implementations§
Source§impl<F: Field, T: TranscriptSponge<F>> TranscriptReader<F, T>
impl<F: Field, T: TranscriptSponge<F>> TranscriptReader<F, T>
Sourcefn consume_input_element(&mut self, label: &'static str) -> Result<F>
fn consume_input_element(&mut self, label: &'static str) -> Result<F>
Reads off a single input element from the transcript and returns it if it exists. Note that this is identical to TranscriptReader::consume_element(), but using Operation::AppendInput rather than Operation::Append. Note that this function should not be called externally!
The operation can fail with:
TranscriptReaderError::ConsumeInputError: if there are no more elements to consume or if a squeeze or non-input consume was expected.
label is as described in the other TranscriptReader functions.
Sourcefn consume_input_hash_chain_digest_element(
&mut self,
label: &'static str,
) -> Result<F>
fn consume_input_hash_chain_digest_element( &mut self, label: &'static str, ) -> Result<F>
Reads off a single element from the hash chain digest elements in an input commitment and returns it if it exists. Note that this function should not be called externally!
Source§impl<F: Debug, Tr: TranscriptSponge<F>> TranscriptReader<F, Tr>
impl<F: Debug, Tr: TranscriptSponge<F>> TranscriptReader<F, Tr>
Sourcepub fn new(transcript: Transcript<F>) -> Self
pub fn new(transcript: Transcript<F>) -> Self
Generate a new TranscriptReader to operate on a given transcript.
Sourcefn advance_indices(&mut self) -> Result<()>
fn advance_indices(&mut self) -> Result<()>
Internal method used to advance the internal state to the next operation.
Trait Implementations§
Source§impl<F: Field, T: TranscriptSponge<F>> VerifierTranscript<F> for TranscriptReader<F, T>
impl<F: Field, T: TranscriptSponge<F>> VerifierTranscript<F> for TranscriptReader<F, T>
Source§fn consume_element(&mut self, label: &'static str) -> Result<F>
fn consume_element(&mut self, label: &'static str) -> Result<F>
Reads off a single element from the transcript and returns it if successful. The operation can fail with:
TranscriptReaderError::ConsumeError: if there are no more elements to consume or if a squeeze was expected.
The label is used for sanity checking against the label that was used
by the TranscriptWriter for the corresponding operation. If the labels
don’t match, a trace warning message is produced, but the caller is not
otherwise notified of this discrepancy.
Source§fn consume_elements(
&mut self,
label: &'static str,
num_elements: usize,
) -> Result<Vec<F>>
fn consume_elements( &mut self, label: &'static str, num_elements: usize, ) -> Result<Vec<F>>
A multi-element version of the consume_element method. Reads off a
sequence of num_elements elements from the transcript and returns a
vector of them if successful.
The operation can fail with:
TranscriptReaderError::ConsumeError: if less thannum_elementselements remain in the transcript or if a squeeze operation was expected to occur at any point before the consumption ofnum_elementselements.
The label is used for sanity checking against the label that was used
by the TranscriptWriter for the corresponding operations. In
particular, the TranscriptWriter may have appended either a sequence
of elements using TranscriptWritter::append_elements or may have
called TranscriptWritter::append multiple times. Both scenarios are
valid and in both cases, label should match with the corresponding
labels used on the writer side. If there is a label mismatch for any of
the num_elements elements, a trace warning message is produced, but
the caller is not otherwise notified of this discrepancy.
Source§fn consume_input_elements(
&mut self,
label: &'static str,
num_elements: usize,
) -> Result<(Vec<F>, Vec<F>)>
fn consume_input_elements( &mut self, label: &'static str, num_elements: usize, ) -> Result<(Vec<F>, Vec<F>)>
Reads off input elements from the transcript and returns them, alongside their hash chain digest, if successful. The operation can fail with:
TranscriptReaderError::ConsumeInputError: if there are no more elements to consume or if a squeeze or non-input consume was expected.
label is as described in the other TranscriptReader functions.
Source§fn get_challenge(&mut self, label: &'static str) -> Result<F>
fn get_challenge(&mut self, label: &'static str) -> Result<F>
Squeezes the sponge once and returns a single element if successful. The operation can fail with:
TranscriptReaderError::SqueezeError: if a squeeze is requested at a time when either a consume operation was expected or no more operations were expected.
The label is used for sanity checking against the label that was used
by the TranscriptWriter for the corresponding operation. If the labels
don’t match, a trace warning message is produced, but the caller is not
otherwise notified of this discrepancy.
Source§fn get_challenges(
&mut self,
label: &'static str,
num_elements: usize,
) -> Result<Vec<F>>
fn get_challenges( &mut self, label: &'static str, num_elements: usize, ) -> Result<Vec<F>>
Squeezes the sponge num_elements times and returns a vector of the
resulting elements if successful.
The operation can fail with:
TranscriptReaderError::SqueezeError: if any of the squeeze operations requested does not correspond to a squeeze operation performed by theTranscriptWriterthat produced the transcript.
The label is used for sanity checking against the label that was used
by the TranscriptWriter for the corresponding operations. In
particular, the TranscriptWriter may have squeezed either a sequence
of elements using TranscriptWriter::get_challenges or may have called
TranscriptWriter::get_challenge multiple times. Both scenarios are
valid and in both cases, label should match with the corresponding
labels used on the writer side. If there is a label mismatch for any of
the num_elements elements, a trace warning message is produced, but
the caller is not otherwise notified of this discrepancy.
Auto Trait Implementations§
impl<F, T> Freeze for TranscriptReader<F, T>where
T: Freeze,
impl<F, T> RefUnwindSafe for TranscriptReader<F, T>where
T: RefUnwindSafe,
F: RefUnwindSafe,
impl<F, T> Send for TranscriptReader<F, T>
impl<F, T> Sync for TranscriptReader<F, T>
impl<F, T> Unpin for TranscriptReader<F, T>
impl<F, T> UnwindSafe for TranscriptReader<F, T>where
T: UnwindSafe,
F: UnwindSafe,
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<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§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>
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§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.