From b5874df4494a6fb6e4e6a20cdef56bedbf6e7584 Mon Sep 17 00:00:00 2001 From: Srinath Setty Date: Mon, 13 Feb 2023 11:04:35 -0800 Subject: [PATCH] Small optimizations (#142) --- src/provider/pasta.rs | 4 ++-- src/spartan/sumcheck.rs | 7 +++---- src/traits/mod.rs | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/provider/pasta.rs b/src/provider/pasta.rs index 9009b99..1197154 100644 --- a/src/provider/pasta.rs +++ b/src/provider/pasta.rs @@ -178,8 +178,8 @@ macro_rules! impl_traits { $name::Scalar::from_bytes_wide(&bytes_arr) } - fn to_bytes(s: &Self) -> Vec { - s.to_repr().as_ref().to_vec() + fn to_bytes(&self) -> Vec { + self.to_repr().as_ref().to_vec() } } diff --git a/src/spartan/sumcheck.rs b/src/spartan/sumcheck.rs index d32d07b..d84eb9b 100644 --- a/src/spartan/sumcheck.rs +++ b/src/spartan/sumcheck.rs @@ -38,10 +38,9 @@ impl SumcheckProof { 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 poly.append_to_transcript(b"poly", transcript); diff --git a/src/traits/mod.rs b/src/traits/mod.rs index d8f5caf..6e7a166 100644 --- a/src/traits/mod.rs +++ b/src/traits/mod.rs @@ -228,7 +228,7 @@ pub trait PrimeFieldExt: PrimeField { fn from_uniform(bytes: &[u8]) -> Self; /// Returns a vector of bytes representing the scalar - fn to_bytes(s: &Self) -> Vec; + fn to_bytes(&self) -> Vec; } impl, F: PrimeField + PrimeFieldExt> AppendToTranscriptTrait for F {