pub struct Arthur<'a, H = DefaultHash, U = u8>where
H: DuplexHash<U>,
U: Unit,{ /* private fields */ }
Expand description
Implementations§
source§impl<'a, U: Unit, H: DuplexHash<U>> Arthur<'a, H, U>
impl<'a, U: Unit, H: DuplexHash<U>> Arthur<'a, H, U>
sourcepub fn new(io_pattern: &IOPattern<H, U>, transcript: &'a [u8]) -> Self
pub fn new(io_pattern: &IOPattern<H, U>, transcript: &'a [u8]) -> Self
Creates a new Arthur
instance with the given sponge and IO Pattern.
The resulting object will act as the verifier in a zero-knowledge protocol.
let io = IOPattern::<DefaultHash>::new("📝").absorb(1, "inhale 🫁").squeeze(32, "exhale 🎏");
// A silly transcript for the example.
let transcript = &[0x42];
let mut arthur = io.to_arthur(transcript);
assert_eq!(arthur.next_bytes().unwrap(), [0x42]);
let challenge = arthur.challenge_bytes::<32>();
assert!(challenge.is_ok());
assert_ne!(challenge.unwrap(), [0; 32]);
sourcepub fn fill_next_units(&mut self, input: &mut [U]) -> Result<(), IOPatternError>
pub fn fill_next_units(&mut self, input: &mut [U]) -> Result<(), IOPatternError>
Read input.len()
elements from the transcript.
sourcepub fn ratchet(&mut self) -> Result<(), IOPatternError>
pub fn ratchet(&mut self) -> Result<(), IOPatternError>
Signals the end of the statement.
sourcepub fn preprocess(self) -> Result<&'static [U], IOPatternError>
pub fn preprocess(self) -> Result<&'static [U], IOPatternError>
Signals the end of the statement and returns the (compressed) sponge state.
Trait Implementations§
source§impl<'a, H, C, const N: usize> ByteChallenges for Arthur<'a, H, Fp<C, N>>
impl<'a, H, C, const N: usize> ByteChallenges for Arthur<'a, H, Fp<C, N>>
fn fill_challenge_bytes( &mut self, output: &mut [u8] ) -> Result<(), IOPatternError>
fn challenge_bytes<const N: usize>(&mut self) -> Result<[u8; N], IOPatternError>
source§impl<'a, H, C, const N: usize> BytePublic for Arthur<'a, H, Fp<C, N>>
impl<'a, H, C, const N: usize> BytePublic for Arthur<'a, H, Fp<C, N>>
fn public_bytes(&mut self, input: &[u8]) -> Result<(), IOPatternError>
source§impl<'a, H: DuplexHash<u8>> ByteReader for Arthur<'a, H, u8>
impl<'a, H: DuplexHash<u8>> ByteReader for Arthur<'a, H, u8>
source§fn fill_next_bytes(&mut self, input: &mut [u8]) -> Result<(), IOPatternError>
fn fill_next_bytes(&mut self, input: &mut [u8]) -> Result<(), IOPatternError>
Read the next input.len()
bytes from the transcript and return them.
fn next_bytes<const N: usize>(&mut self) -> Result<[u8; N], IOPatternError>
source§impl<H, C, const N: usize> FieldPublic<Fp<C, N>> for Arthur<'_, H, Fp<C, N>>
impl<H, C, const N: usize> FieldPublic<Fp<C, N>> for Arthur<'_, H, Fp<C, N>>
type Repr = ()
fn public_scalars(&mut self, input: &[Fp<C, N>]) -> ProofResult<Self::Repr>
source§impl<'a, F, H, const N: usize> FieldReader<F> for Arthur<'a, H>
impl<'a, F, H, const N: usize> FieldReader<F> for Arthur<'a, H>
fn fill_next_scalars(&mut self, output: &mut [F]) -> ProofResult<()>
fn next_scalars<const N: usize>(&mut self) -> ProofResult<[F; N]>
source§impl<'a, F, H> FieldReader<F> for Arthur<'a, H>where
F: Field,
H: DuplexHash,
impl<'a, F, H> FieldReader<F> for Arthur<'a, H>where
F: Field,
H: DuplexHash,
fn fill_next_scalars(&mut self, output: &mut [F]) -> ProofResult<()>
fn next_scalars<const N: usize>(&mut self) -> ProofResult<[F; N]>
source§impl<'a, H, C, const N: usize> FieldReader<Fp<C, N>> for Arthur<'a, H, Fp<C, N>>
impl<'a, H, C, const N: usize> FieldReader<Fp<C, N>> for Arthur<'a, H, Fp<C, N>>
fn fill_next_scalars(&mut self, output: &mut [Fp<C, N>]) -> ProofResult<()>
fn next_scalars<const N: usize>(&mut self) -> ProofResult<[F; N]>
source§impl<H, C, const N: usize, G> GroupPublic<G> for Arthur<'_, H, Fp<C, N>>
impl<H, C, const N: usize, G> GroupPublic<G> for Arthur<'_, H, Fp<C, N>>
§type Repr = ()
type Repr = ()
In order to be added to the sponge, elements may be serialize into another format.
This associated type represents the format used, so that other implementation can potentially
re-use the serialized element.
source§fn public_points(&mut self, input: &[G]) -> ProofResult<Self::Repr>
fn public_points(&mut self, input: &[G]) -> ProofResult<Self::Repr>
Incorporate group elements into the proof without adding them to the final protocol transcript.
source§impl<'a, G, H> GroupReader<G> for Arthur<'a, H>where
G: CurveGroup,
H: DuplexHash,
impl<'a, G, H> GroupReader<G> for Arthur<'a, H>where
G: CurveGroup,
H: DuplexHash,
source§fn fill_next_points(&mut self, output: &mut [G]) -> ProofResult<()>
fn fill_next_points(&mut self, output: &mut [G]) -> ProofResult<()>
Deserialize group elements from the protocol transcript into
output
.source§fn next_points<const N: usize>(&mut self) -> ProofResult<[G; N]>
fn next_points<const N: usize>(&mut self) -> ProofResult<[G; N]>
Deserialize group elements from the protocol transcript and return them.
source§impl<'a, P, H, C, const N: usize> GroupReader<Projective<P>> for Arthur<'a, H, Fp<C, N>>
impl<'a, P, H, C, const N: usize> GroupReader<Projective<P>> for Arthur<'a, H, Fp<C, N>>
source§fn fill_next_points(
&mut self,
output: &mut [EdwardsCurve<P>]
) -> ProofResult<()>
fn fill_next_points( &mut self, output: &mut [EdwardsCurve<P>] ) -> ProofResult<()>
Deserialize group elements from the protocol transcript into
output
.source§fn next_points<const N: usize>(&mut self) -> ProofResult<[G; N]>
fn next_points<const N: usize>(&mut self) -> ProofResult<[G; N]>
Deserialize group elements from the protocol transcript and return them.
source§impl<'a, P, H, C, const N: usize> GroupReader<Projective<P>> for Arthur<'a, H, Fp<C, N>>
impl<'a, P, H, C, const N: usize> GroupReader<Projective<P>> for Arthur<'a, H, Fp<C, N>>
source§fn fill_next_points(&mut self, output: &mut [SWCurve<P>]) -> ProofResult<()>
fn fill_next_points(&mut self, output: &mut [SWCurve<P>]) -> ProofResult<()>
Deserialize group elements from the protocol transcript into
output
.source§fn next_points<const N: usize>(&mut self) -> ProofResult<[G; N]>
fn next_points<const N: usize>(&mut self) -> ProofResult<[G; N]>
Deserialize group elements from the protocol transcript and return them.
source§impl<'a, H: DuplexHash<U>, U: Unit> UnitTranscript<U> for Arthur<'a, H, U>
impl<'a, H: DuplexHash<U>, U: Unit> UnitTranscript<U> for Arthur<'a, H, U>
source§fn public_units(&mut self, input: &[U]) -> Result<(), IOPatternError>
fn public_units(&mut self, input: &[U]) -> Result<(), IOPatternError>
Add native elements to the sponge without writing them to the protocol transcript.
source§fn fill_challenge_units(
&mut self,
input: &mut [U]
) -> Result<(), IOPatternError>
fn fill_challenge_units( &mut self, input: &mut [U] ) -> Result<(), IOPatternError>
Get a challenge of count
elements.
Auto Trait Implementations§
impl<'a, H, U> Freeze for Arthur<'a, H, U>where
H: Freeze,
impl<'a, H, U> RefUnwindSafe for Arthur<'a, H, U>where
H: RefUnwindSafe,
U: RefUnwindSafe,
impl<'a, H, U> Send for Arthur<'a, H, U>
impl<'a, H, U> Sync for Arthur<'a, H, U>
impl<'a, H, U> Unpin for Arthur<'a, H, U>
impl<'a, H, U> UnwindSafe for Arthur<'a, H, U>where
H: UnwindSafe,
U: 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
Mutably borrows from an owned value. Read more
source§impl<T> ByteChallenges for Twhere
T: UnitTranscript<u8>,
impl<T> ByteChallenges for Twhere
T: UnitTranscript<u8>,
fn fill_challenge_bytes( &mut self, output: &mut [u8] ) -> Result<(), IOPatternError>
fn challenge_bytes<const N: usize>(&mut self) -> Result<[u8; N], IOPatternError>
source§impl<T> BytePublic for Twhere
T: UnitTranscript<u8>,
impl<T> BytePublic for Twhere
T: UnitTranscript<u8>,
fn public_bytes(&mut self, input: &[u8]) -> Result<(), IOPatternError>
source§impl<F, T> FieldChallenges<F> for Twhere
F: PrimeField,
T: ByteChallenges,
impl<F, T> FieldChallenges<F> for Twhere
F: PrimeField,
T: ByteChallenges,
fn fill_challenge_scalars(&mut self, output: &mut [F]) -> Result<(), ProofError>
fn challenge_scalars<const N: usize>(&mut self) -> ProofResult<[F; N]>
source§impl<F, T> FieldChallenges<F> for Twhere
F: PrimeField,
T: ByteChallenges,
impl<F, T> FieldChallenges<F> for Twhere
F: PrimeField,
T: ByteChallenges,
fn fill_challenge_scalars(&mut self, output: &mut [F]) -> Result<(), ProofError>
fn challenge_scalars<const N: usize>(&mut self) -> ProofResult<[F; N]>
source§impl<T, F> FieldPublic<F> for T
impl<T, F> FieldPublic<F> for T
type Repr = Vec<u8>
fn public_scalars( &mut self, input: &[F] ) -> Result<<T as FieldPublic<F>>::Repr, ProofError>
source§impl<F, T> FieldPublic<F> for Twhere
F: PrimeField,
T: BytePublic,
impl<F, T> FieldPublic<F> for Twhere
F: PrimeField,
T: BytePublic,
type Repr = Vec<u8>
fn public_scalars( &mut self, input: &[F] ) -> Result<<T as FieldPublic<F>>::Repr, ProofError>
source§impl<T, G> GroupPublic<G> for T
impl<T, G> GroupPublic<G> for T
§type Repr = Vec<u8>
type Repr = Vec<u8>
In order to be added to the sponge, elements may be serialize into another format.
This associated type represents the format used, so that other implementation can potentially
re-use the serialized element.
source§fn public_points(
&mut self,
input: &[G]
) -> Result<<T as GroupPublic<G>>::Repr, ProofError>
fn public_points( &mut self, input: &[G] ) -> Result<<T as GroupPublic<G>>::Repr, ProofError>
Incorporate group elements into the proof without adding them to the final protocol transcript.