Small optimizations (#142)

This commit is contained in:
Srinath Setty
2023-02-13 11:04:35 -08:00
committed by GitHub
parent c4b07f0925
commit b5874df449
3 changed files with 6 additions and 7 deletions

View File

@@ -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> { fn to_bytes(&self) -> Vec<u8> {
s.to_repr().as_ref().to_vec() self.to_repr().as_ref().to_vec()
} }
} }

View File

@@ -38,10 +38,9 @@ impl<G: Group> SumcheckProof<G> {
return Err(NovaError::InvalidSumcheckProof); return Err(NovaError::InvalidSumcheckProof);
} }
// check if G_k(0) + G_k(1) = e // we do not need to check if poly(0) + poly(1) = e, as
if poly.eval_at_zero() + poly.eval_at_one() != e { // decompress() call above already ensures that hods
return Err(NovaError::InvalidSumcheckProof); 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);

View File

@@ -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 {