pub struct ZKWrappedProverChannel<'a, P, NTT, Channel, ReplayFn, A>where
P: PackedField<Scalar: BinaryField>,
NTT: AdditiveNTT<Field = P::Scalar> + Sync,
Channel: MerkleIPProverChannel<P::Scalar>,
A: Allocator,{ /* private fields */ }Expand description
A prover channel that wraps a BaseFoldProverChannel and an outer Spartan IOP prover.
This channel records all channel values. On
send_*/sample/observe_*, it delegates to the inner BaseFold channel and records each
value. After the inner proof is run through this channel, call
finish to replay the interaction, fill the outer witness, and generate the
outer proof.
The ReplayFn closure is called during finish with a ReplayChannel to
replay the inner verification and fill the outer witness. This allows the channel to be generic
over different inner verification protocols.
Implementations§
Source§impl<'a, F, P, NTT, Channel, ReplayFn, A> ZKWrappedProverChannel<'a, P, NTT, Channel, ReplayFn, A>where
F: BinaryField,
P: PackedField<Scalar = F>,
NTT: AdditiveNTT<Field = F> + Sync,
Channel: MerkleIPProverChannel<F>,
A: Allocator,
impl<'a, F, P, NTT, Channel, ReplayFn, A> ZKWrappedProverChannel<'a, P, NTT, Channel, ReplayFn, A>where
F: BinaryField,
P: PackedField<Scalar = F>,
NTT: AdditiveNTT<Field = F> + Sync,
Channel: MerkleIPProverChannel<F>,
A: Allocator,
Sourcepub fn new(
inner_channel: BaseFoldProverChannel<'a, F, P, NTT, Channel, A>,
outer_prover: &'a IOPProver<F>,
outer_layout: Arc<WitnessLayout<F>>,
alloc: &'a A,
rng: impl CryptoRng,
replay_fn: ReplayFn,
) -> Self
pub fn new( inner_channel: BaseFoldProverChannel<'a, F, P, NTT, Channel, A>, outer_prover: &'a IOPProver<F>, outer_layout: Arc<WitnessLayout<F>>, alloc: &'a A, rng: impl CryptoRng, replay_fn: ReplayFn, ) -> Self
Creates a new ZK-wrapped prover channel.
Commits the outer prover’s precommit oracle on the inner channel as part of construction:
a random FieldBuffer<P> the size of the outer precommit oracle
segment is sent to the channel and kept for use in Self::finish. This random buffer is
the one-time-pad encryption key for the (future) outer encrypted transcript.
The inner channel’s oracle specs are expected to be laid out as
[outer_precommit, inner..., outer_private, outer_mask].
§Arguments
inner_channel- The BaseFold ZK channel with oracle specs for both inner and outer proofsouter_prover- The IOP prover for the outer (wrapper) constraint systemouter_layout- The witness layout for the outer constraint systemalloc- Allocator for the outer proof’s working buffers, borrowed from the owning proverrng- RNG used to generate the random precommit buffer (the future OTP key)replay_fn- Closure called duringfinishwith aReplayChannelto replay the inner verification and fill the outer witness
Sourcepub fn finish(self, rng: impl CryptoRng) -> Result<(), Error>where
ReplayFn: FnOnce(&mut ReplayChannel<F>),
pub fn finish(self, rng: impl CryptoRng) -> Result<(), Error>where
ReplayFn: FnOnce(&mut ReplayChannel<F>),
Consumes the channel and runs the outer proof.
This should be called after the inner proof has been run through this channel. It:
- Creates a
ReplayChannelfrom the recorded interaction - Calls the
replay_fnclosure to replay the inner verification and fill the outer witness - Validates and generates the outer IOP proof
Trait Implementations§
Source§impl<F, P, NTT, Channel, ReplayFn, A> IOPProverChannel<P, A> for ZKWrappedProverChannel<'_, P, NTT, Channel, ReplayFn, A>where
F: BinaryField,
P: PackedField<Scalar = F>,
NTT: AdditiveNTT<Field = F> + Sync,
Channel: MerkleIPProverChannel<F>,
A: Allocator,
impl<F, P, NTT, Channel, ReplayFn, A> IOPProverChannel<P, A> for ZKWrappedProverChannel<'_, P, NTT, Channel, ReplayFn, A>where
F: BinaryField,
P: PackedField<Scalar = F>,
NTT: AdditiveNTT<Field = F> + Sync,
Channel: MerkleIPProverChannel<F>,
A: Allocator,
type Oracle = BaseFoldOracle
Source§fn remaining_oracle_specs(&self) -> &[OracleSpec]
fn remaining_oracle_specs(&self) -> &[OracleSpec]
Source§fn send_oracle(&mut self, buffer: FieldSlice<'_, P>) -> Self::Oracle
fn send_oracle(&mut self, buffer: FieldSlice<'_, P>) -> Self::Oracle
Source§fn prove_oracle_relation(
&mut self,
oracle: Self::Oracle,
transparent: StructuredBuffer<P, A::Vec<P>>,
claim: P::Scalar,
)
fn prove_oracle_relation( &mut self, oracle: Self::Oracle, transparent: StructuredBuffer<P, A::Vec<P>>, claim: P::Scalar, )
Source§impl<F, P, NTT, Channel, ReplayFn, A> IPProverChannel<F> for ZKWrappedProverChannel<'_, P, NTT, Channel, ReplayFn, A>where
F: BinaryField,
P: PackedField<Scalar = F>,
NTT: AdditiveNTT<Field = F> + Sync,
Channel: MerkleIPProverChannel<F>,
A: Allocator,
impl<F, P, NTT, Channel, ReplayFn, A> IPProverChannel<F> for ZKWrappedProverChannel<'_, P, NTT, Channel, ReplayFn, A>where
F: BinaryField,
P: PackedField<Scalar = F>,
NTT: AdditiveNTT<Field = F> + Sync,
Channel: MerkleIPProverChannel<F>,
A: Allocator,
Source§fn send_public_claim(&mut self, elem: F)
fn send_public_claim(&mut self, elem: F)
Source§fn observe_one(&mut self, val: F)
fn observe_one(&mut self, val: F)
Source§fn observe_many(&mut self, vals: &[F])
fn observe_many(&mut self, vals: &[F])
Source§fn sample_many(&mut self, n: usize) -> Vec<F>
fn sample_many(&mut self, n: usize) -> Vec<F>
n random challenges.Source§fn sample_array<const N: usize>(&mut self) -> [F; N]
fn sample_array<const N: usize>(&mut self) -> [F; N]
Source§impl<F, P, NTT, Channel, ReplayFn, A> WordIPProverChannel<F> for ZKWrappedProverChannel<'_, P, NTT, Channel, ReplayFn, A>where
F: BinaryField,
P: PackedField<Scalar = F>,
NTT: AdditiveNTT<Field = F> + Sync,
Channel: MerkleIPProverChannel<F>,
A: Allocator,
impl<F, P, NTT, Channel, ReplayFn, A> WordIPProverChannel<F> for ZKWrappedProverChannel<'_, P, NTT, Channel, ReplayFn, A>where
F: BinaryField,
P: PackedField<Scalar = F>,
NTT: AdditiveNTT<Field = F> + Sync,
Channel: MerkleIPProverChannel<F>,
A: Allocator,
Source§type Word = <Channel as WordIPProverChannel<F>>::Word
type Word = <Channel as WordIPProverChannel<F>>::Word
Source§fn observe_words(&mut self, words: &[Self::Word])
fn observe_words(&mut self, words: &[Self::Word])
Auto Trait Implementations§
impl<'a, P, NTT, Channel, ReplayFn, A> Freeze for ZKWrappedProverChannel<'a, P, NTT, Channel, ReplayFn, A>
impl<'a, P, NTT, Channel, ReplayFn, A> RefUnwindSafe for ZKWrappedProverChannel<'a, P, NTT, Channel, ReplayFn, A>where
<<P as FieldOps>::Scalar as UnderlierView>::Underlier: Sized,
<P as FieldOps>::Scalar: Sized + RefUnwindSafe,
ReplayFn: RefUnwindSafe,
Channel: RefUnwindSafe,
A: RefUnwindSafe,
<A as Allocator>::Vec<P>: RefUnwindSafe,
NTT: RefUnwindSafe,
<Channel as MerkleIPProverChannel<<P as FieldOps>::Scalar>>::Commitment: RefUnwindSafe,
impl<'a, P, NTT, Channel, ReplayFn, A> Send for ZKWrappedProverChannel<'a, P, NTT, Channel, ReplayFn, A>
impl<'a, P, NTT, Channel, ReplayFn, A> Sync for ZKWrappedProverChannel<'a, P, NTT, Channel, ReplayFn, A>
impl<'a, P, NTT, Channel, ReplayFn, A> Unpin for ZKWrappedProverChannel<'a, P, NTT, Channel, ReplayFn, A>
impl<'a, P, NTT, Channel, ReplayFn, A> UnsafeUnpin for ZKWrappedProverChannel<'a, P, NTT, Channel, ReplayFn, A>where
<<P as FieldOps>::Scalar as UnderlierView>::Underlier: Sized,
<P as FieldOps>::Scalar: Sized,
ReplayFn: UnsafeUnpin,
Channel: UnsafeUnpin,
A: UnsafeUnpin,
<A as Allocator>::Vec<P>: UnsafeUnpin,
impl<'a, P, NTT, Channel, ReplayFn, A> UnwindSafe for ZKWrappedProverChannel<'a, P, NTT, Channel, ReplayFn, A>where
<<P as FieldOps>::Scalar as UnderlierView>::Underlier: Sized,
<P as FieldOps>::Scalar: Sized + UnwindSafe + RefUnwindSafe,
ReplayFn: UnwindSafe,
Channel: UnwindSafe,
A: UnwindSafe + RefUnwindSafe,
<A as Allocator>::Vec<P>: UnwindSafe,
NTT: RefUnwindSafe,
<Channel as MerkleIPProverChannel<<P as FieldOps>::Scalar>>::Commitment: 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> 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