Browse Source

Small optimizations (#142)

main
Srinath Setty 1 year ago
committed by GitHub
parent
commit
b5874df449
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 7 deletions
  1. +2
    -2
      src/provider/pasta.rs
  2. +3
    -4
      src/spartan/sumcheck.rs
  3. +1
    -1
      src/traits/mod.rs

+ 2
- 2
src/provider/pasta.rs

@ -178,8 +178,8 @@ macro_rules! impl_traits {
$name::Scalar::from_bytes_wide(&bytes_arr) $name::Scalar::from_bytes_wide(&bytes_arr)
} }
fn to_bytes(s: &Self) -> Vec<u8> {
s.to_repr().as_ref().to_vec()
fn to_bytes(&self) -> Vec<u8> {
self.to_repr().as_ref().to_vec()
} }
} }

+ 3
- 4
src/spartan/sumcheck.rs

@ -38,10 +38,9 @@ impl SumcheckProof {
return Err(NovaError::InvalidSumcheckProof); return Err(NovaError::InvalidSumcheckProof);
} }
// check if G_k(0) + G_k(1) = e
if poly.eval_at_zero() + poly.eval_at_one() != e {
return Err(NovaError::InvalidSumcheckProof);
}
// we do not need to check if poly(0) + poly(1) = e, as
// decompress() call above already ensures that hods
debug_assert_eq!(poly.eval_at_zero() + poly.eval_at_one(), e);
// append the prover's message to the transcript // append the prover's message to the transcript
poly.append_to_transcript(b"poly", transcript); poly.append_to_transcript(b"poly", transcript);

+ 1
- 1
src/traits/mod.rs

@ -228,7 +228,7 @@ pub trait PrimeFieldExt: PrimeField {
fn from_uniform(bytes: &[u8]) -> Self; fn from_uniform(bytes: &[u8]) -> Self;
/// Returns a vector of bytes representing the scalar /// Returns a vector of bytes representing the scalar
fn to_bytes(s: &Self) -> Vec<u8>;
fn to_bytes(&self) -> Vec<u8>;
} }
impl<G: Group<Scalar = F>, F: PrimeField + PrimeFieldExt> AppendToTranscriptTrait<G> for F { impl<G: Group<Scalar = F>, F: PrimeField + PrimeFieldExt> AppendToTranscriptTrait<G> for F {

Loading…
Cancel
Save