diff --git a/spartan_parallel/src/dense_mlpoly.rs b/spartan_parallel/src/dense_mlpoly.rs index 83b50e55..524875b5 100644 --- a/spartan_parallel/src/dense_mlpoly.rs +++ b/spartan_parallel/src/dense_mlpoly.rs @@ -1000,7 +1000,7 @@ impl PolyEvalProof { for i in 0..poly_size.len() { let num_vars = poly_size[i].next_power_of_two().log_2(); - let L = if let Some(L) = L_map.get(&num_vars) { + let _L = if let Some(L) = L_map.get(&num_vars) { L } else { let (left_num_vars, right_num_vars) = EqPolynomial::::compute_factored_lens(num_vars); diff --git a/spartan_parallel/src/nizk/mod.rs b/spartan_parallel/src/nizk/mod.rs index 25728835..37122207 100644 --- a/spartan_parallel/src/nizk/mod.rs +++ b/spartan_parallel/src/nizk/mod.rs @@ -4,7 +4,7 @@ use crate::scalar::SpartanExtensionField; use super::errors::ProofVerifyError; use super::math::Math; use super::random::RandomTape; -use super::transcript::{AppendToTranscript, ProofTranscript}; +use super::transcript::ProofTranscript; use merlin::Transcript; use serde::{Deserialize, Serialize}; mod bullet; @@ -45,12 +45,15 @@ impl KnowledgeProof { } pub fn verify(&self, transcript: &mut Transcript) -> Result<(), ProofVerifyError> { - >::append_protocol_name( - transcript, - KnowledgeProof::::protocol_name(), - ); - - let c: S = transcript.challenge_scalar(b"c"); + // Transcript operations to preserve consistency for the verify function + { + >::append_protocol_name( + transcript, + KnowledgeProof::::protocol_name(), + ); + + let _c: S = transcript.challenge_scalar(b"c"); + } // TODO: Alternative PCS Verification Ok(()) @@ -89,12 +92,15 @@ impl EqualityProof { } pub fn verify(&self, transcript: &mut Transcript) -> Result<(), ProofVerifyError> { - >::append_protocol_name( - transcript, - EqualityProof::::protocol_name(), - ); - - let c: S = transcript.challenge_scalar(b"c"); + // Transcript operations to preserve consistency for the verify function + { + >::append_protocol_name( + transcript, + EqualityProof::::protocol_name(), + ); + + let _c: S = transcript.challenge_scalar(b"c"); + } // TODO: Alternative PCS Verification Ok(()) @@ -145,18 +151,21 @@ impl ProductProof { ProductProof { z } } - fn check_equality(_c: &S, _z1: &S, _z2: &S) -> bool { + fn _check_equality(_c: &S, _z1: &S, _z2: &S) -> bool { // TODO: Alternative PCS Verification true } pub fn verify(&self, transcript: &mut Transcript) -> Result<(), ProofVerifyError> { - >::append_protocol_name( - transcript, - ProductProof::::protocol_name(), - ); - - let c: S = transcript.challenge_scalar(b"c"); + // Transcript operations to preserve consistency for the verify function + { + >::append_protocol_name( + transcript, + ProductProof::::protocol_name(), + ); + + let _c: S = transcript.challenge_scalar(b"c"); + } // TODO: Alternative PCS Verification Ok(()) @@ -218,12 +227,15 @@ impl DotProductProof { } pub fn verify(&self, transcript: &mut Transcript, a: &[S]) -> Result<(), ProofVerifyError> { - >::append_protocol_name( - transcript, - DotProductProof::::protocol_name(), - ); - S::append_field_vector_to_transcript(b"a", transcript, a); - let c: S = transcript.challenge_scalar(b"c"); + // Transcript operations to preserve consistency for the verify function + { + >::append_protocol_name( + transcript, + DotProductProof::::protocol_name(), + ); + S::append_field_vector_to_transcript(b"a", transcript, a); + let _c: S = transcript.challenge_scalar(b"c"); + } let _dotproduct_z_a = DotProductProof::compute_dotproduct(&self.z, a); @@ -304,26 +316,29 @@ impl DotProductProofLog { ) -> Result<(), ProofVerifyError> { assert_eq!(a.len(), n); - >::append_protocol_name( - transcript, - DotProductProofLog::::protocol_name(), - ); + // Transcript operations to preserve consistency for the verify function + { + >::append_protocol_name( + transcript, + DotProductProofLog::::protocol_name(), + ); - S::append_field_vector_to_transcript(b"a", transcript, a); + S::append_field_vector_to_transcript(b"a", transcript, a); - // sample a random base and scale the generator used for - // the output of the inner product - let r: S = transcript.challenge_scalar(b"r"); + // sample a random base and scale the generator used for + // the output of the inner product + let _r: S = transcript.challenge_scalar(b"r"); - // BulletReductionProof - verification_scalars - let mut m = a.len(); - while m != 1 { - m /= 2; + // BulletReductionProof - verification_scalars + let mut m = a.len(); + while m != 1 { + m /= 2; - let u: S = transcript.challenge_scalar(b"u"); - } + let _u: S = transcript.challenge_scalar(b"u"); + } - let c: S = transcript.challenge_scalar(b"c"); + let _c: S = transcript.challenge_scalar(b"c"); + } // TODO: Alternative PCS Verification Ok(()) diff --git a/spartan_parallel/src/product_tree.rs b/spartan_parallel/src/product_tree.rs index c12ad115..61dbe78a 100644 --- a/spartan_parallel/src/product_tree.rs +++ b/spartan_parallel/src/product_tree.rs @@ -4,7 +4,6 @@ use crate::scalar::SpartanExtensionField; use super::dense_mlpoly::DensePolynomial; use super::dense_mlpoly::EqPolynomial; use super::math::Math; -use super::scalar::Scalar; use super::sumcheck::SumcheckInstanceProof; use super::transcript::ProofTranscript; use merlin::Transcript; diff --git a/spartan_parallel/src/r1csproof.rs b/spartan_parallel/src/r1csproof.rs index dd70da74..1188c0c9 100644 --- a/spartan_parallel/src/r1csproof.rs +++ b/spartan_parallel/src/r1csproof.rs @@ -485,7 +485,7 @@ impl R1CSProof { // So we need to multiply each entry by (1 - rq0)(1 - rq1) let mut eval_vars_comb_list = Vec::new(); for p in 0..num_instances { - let wit_sec_p = |i: usize| { + let _wit_sec_p = |i: usize| { if witness_secs[i].w_mat.len() == 1 { 0 } else { diff --git a/spartan_parallel/src/scalar/fp.rs b/spartan_parallel/src/scalar/fp.rs index bd9a53c4..294b1e87 100644 --- a/spartan_parallel/src/scalar/fp.rs +++ b/spartan_parallel/src/scalar/fp.rs @@ -1,5 +1,5 @@ use super::SpartanExtensionField; -use crate::{AppendToTranscript, ProofTranscript, Transcript}; +use crate::{ProofTranscript, Transcript}; use ceno_goldilocks::Goldilocks; use core::borrow::Borrow; use core::iter::{Product, Sum}; diff --git a/spartan_parallel/src/scalar/mod.rs b/spartan_parallel/src/scalar/mod.rs index 31795b58..915bd2c2 100644 --- a/spartan_parallel/src/scalar/mod.rs +++ b/spartan_parallel/src/scalar/mod.rs @@ -5,6 +5,7 @@ use ceno_goldilocks::ExtensionField; use ff::Field; pub use fp::Scalar; pub use fp2::ScalarExt2; +use merlin::Transcript; use rand::{CryptoRng, RngCore}; use serde::Serialize; use std::fmt; @@ -17,9 +18,6 @@ use std::{ use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}; use zeroize::Zeroize; -use crate::transcript::AppendToTranscript; -use merlin::Transcript; - /// Trait describing the field element /// Wraps around Goldilocks field towers from ceno-goldilocks /// See: https://github.com/scroll-tech/ceno-Goldilocks diff --git a/spartan_parallel/src/sparse_mlpoly.rs b/spartan_parallel/src/sparse_mlpoly.rs index 19959eba..cff1f6c6 100644 --- a/spartan_parallel/src/sparse_mlpoly.rs +++ b/spartan_parallel/src/sparse_mlpoly.rs @@ -390,7 +390,7 @@ impl SparseMatPolynomial { .collect::>() } - pub fn multiply_vec(&self, num_rows: usize, num_cols: usize, z: &[S]) -> Vec { + pub fn _multiply_vec(&self, num_rows: usize, num_cols: usize, z: &[S]) -> Vec { assert_eq!(z.len(), num_cols); (0..self.M.len()) @@ -1472,53 +1472,6 @@ impl SparseMatPolyEvalProof { } } -pub struct SparsePolyEntry { - pub idx: usize, - pub val: S, -} - -impl SparsePolyEntry { - pub fn new(idx: usize, val: S) -> Self { - SparsePolyEntry { idx, val } - } -} - -pub struct SparsePolynomial { - num_vars: usize, - Z: Vec>, -} - -impl SparsePolynomial { - pub fn new(num_vars: usize, Z: Vec>) -> Self { - SparsePolynomial { num_vars, Z } - } - - fn compute_chi(a: &[bool], r: &[S]) -> S { - assert_eq!(a.len(), r.len()); - let mut chi_i = S::field_one(); - for j in 0..r.len() { - if a[j] { - chi_i = chi_i * r[j]; - } else { - chi_i = chi_i * (S::field_one() - r[j]); - } - } - chi_i - } - - // Takes O(n log n). TODO: do this in O(n) where n is the number of entries in Z - pub fn evaluate(&self, r: &[S]) -> S { - assert_eq!(self.num_vars, r.len()); - - (0..self.Z.len()) - .map(|i| { - let bits = self.Z[i].idx.get_bits(r.len()); - SparsePolynomial::compute_chi(&bits, r) * self.Z[i].val - }) - .sum() - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/spartan_parallel/src/sumcheck.rs b/spartan_parallel/src/sumcheck.rs index 2c50e1fa..e181fdf2 100644 --- a/spartan_parallel/src/sumcheck.rs +++ b/spartan_parallel/src/sumcheck.rs @@ -93,7 +93,7 @@ impl ZKSumcheckInstanceProof { let r_i = transcript.challenge_scalar(b"challenge_nextround"); // verify the proof of sum-check and evals - let res = { + let _res = { // produce two weights let w: Vec = transcript.challenge_vector(b"combine_two_claims_to_one", 2); diff --git a/spartan_parallel/src/unipoly.rs b/spartan_parallel/src/unipoly.rs index f1b764af..281dbf27 100644 --- a/spartan_parallel/src/unipoly.rs +++ b/spartan_parallel/src/unipoly.rs @@ -1,4 +1,4 @@ -use super::scalar::{Scalar, SpartanExtensionField}; +use super::scalar::SpartanExtensionField; use super::transcript::{AppendToTranscript, ProofTranscript}; use merlin::Transcript; use serde::{Deserialize, Serialize}; @@ -115,8 +115,8 @@ impl AppendToTranscript for UniPoly { #[cfg(test)] mod tests { - use super::*; + use crate::scalar::Scalar; #[test] fn test_from_evals_quad() {