Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow for more general transcripts #352

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/provider/hyperkzg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,17 @@
// This impl block defines helper functions that are not a part of
// EvaluationEngineTrait, but that we will use to implement the trait methods.
fn compute_challenge(com: &[G1Affine<E>], transcript: &mut <E as Engine>::TE) -> E::Scalar {
transcript.absorb(b"c", &com.to_vec().as_slice());
transcript.absorb_affine_group_elements(b"c", &com.to_vec().as_slice());

Check failure on line 286 in src/provider/hyperkzg.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

transcript.squeeze(b"c").unwrap()
}

// Compute challenge q = Hash(vk, C0, ..., C_{k-1}, u0, ...., u_{t-1},
// (f_i(u_j))_{i=0..k-1,j=0..t-1})
fn get_batch_challenge(v: &[Vec<E::Scalar>], transcript: &mut <E as Engine>::TE) -> E::Scalar {
transcript.absorb(
transcript.absorb_scalars(
b"v",
&v.iter()

Check failure on line 296 in src/provider/hyperkzg.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler
.flatten()
.cloned()
.collect::<Vec<E::Scalar>>()
Expand All @@ -313,7 +313,7 @@
}

fn verifier_second_challenge(W: &[G1Affine<E>], transcript: &mut <E as Engine>::TE) -> E::Scalar {
transcript.absorb(b"W", &W.to_vec().as_slice());
transcript.absorb_affine_group_elements(b"W", &W.to_vec().as_slice());

Check failure on line 316 in src/provider/hyperkzg.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

transcript.squeeze(b"d").unwrap()
}
Expand Down
2 changes: 1 addition & 1 deletion src/provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
pub mod bn256_grumpkin;
pub mod hyperkzg;
pub mod ipa_pc;
pub mod keccak;
pub mod pasta;
pub mod poseidon;
pub mod secp_secq;

// crate-private modules
pub(crate) mod keccak;
pub(crate) mod pedersen;
pub(crate) mod traits;

Expand Down
19 changes: 19 additions & 0 deletions src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use crate::{
errors::NovaError,
frontend::{num::AllocatedNum, AllocatedBit, ConstraintSystem, SynthesisError},
provider::traits::DlogGroup,
};
use core::fmt::Debug;
use ff::{PrimeField, PrimeFieldBits};
Expand Down Expand Up @@ -129,6 +130,24 @@ pub trait TranscriptEngineTrait<E: Engine>: Send + Sync {

/// adds a domain separator
fn dom_sep(&mut self, bytes: &'static [u8]);

/// absorbs a slice of scalar elements. This defaults to absorbing the bytes of the scalar using `TranscriptReprTrait`
/// but can be overridden for other reasons
fn absorb_scalars(&mut self, label: &'static [u8], o: &[E::Scalar]) {
TranscriptEngineTrait::absorb(self, label, &o);
}

/// absorbs a slice of group elements. This defaults to absorbing the bytes of the group element using `TranscriptReprTrait`
/// but can be overridden for other reasons
fn absorb_affine_group_elements(
&mut self,
label: &'static [u8],
o: &[<E::GE as DlogGroup>::AffineGroupElement],
) where
E::GE: DlogGroup,
{
TranscriptEngineTrait::absorb(self, label, &o);
}
}

/// Defines additional methods on `PrimeField` objects
Expand Down
Loading