Browse Source

clippy fixes (#50)

* clippy fixes

* remove warning

* fix clippy
master
Srinath Setty 2 years ago
committed by maramihali
parent
commit
e1383ff248
10 changed files with 62 additions and 45 deletions
  1. +1
    -0
      benches/nizk.rs
  2. +1
    -0
      benches/snark.rs
  3. +2
    -4
      examples/cubic.rs
  4. +2
    -0
      profiler/nizk.rs
  5. +2
    -0
      profiler/snark.rs
  6. +0
    -1
      rustfmt.toml
  7. +1
    -0
      src/lib.rs
  8. +1
    -1
      src/r1csinstance.rs
  9. +21
    -2
      src/r1csproof.rs
  10. +31
    -37
      src/sparse_mlpoly.rs

+ 1
- 0
benches/nizk.rs

@ -1,3 +1,4 @@
#![allow(clippy::assertions_on_result_states)]
extern crate byteorder; extern crate byteorder;
extern crate core; extern crate core;
extern crate criterion; extern crate criterion;

+ 1
- 0
benches/snark.rs

@ -1,3 +1,4 @@
#![allow(clippy::assertions_on_result_states)]
extern crate libspartan; extern crate libspartan;
extern crate merlin; extern crate merlin;

+ 2
- 4
examples/cubic.rs

@ -8,11 +8,9 @@
//! `(Z3 + 5) * 1 - I0 = 0` //! `(Z3 + 5) * 1 - I0 = 0`
//! //!
//! [here]: https://medium.com/@VitalikButerin/quadratic-arithmetic-programs-from-zero-to-hero-f6d558cea649 //! [here]: https://medium.com/@VitalikButerin/quadratic-arithmetic-programs-from-zero-to-hero-f6d558cea649
use ark_bls12_377::Fr as Scalar;
use ark_ff::{PrimeField, BigInteger};
use ark_std::{One, UniformRand, Zero};
use libspartan::{InputsAssignment, Instance, SNARKGens, VarsAssignment, SNARK}; use libspartan::{InputsAssignment, Instance, SNARKGens, VarsAssignment, SNARK};
use merlin::Transcript; use merlin::Transcript;
use ark_std::{UniformRand, One, Zero};
#[allow(non_snake_case)] #[allow(non_snake_case)]
fn produce_r1cs() -> ( fn produce_r1cs() -> (
@ -72,7 +70,7 @@ fn produce_r1cs() -> (
let inst = Instance::new(num_cons, num_vars, num_inputs, &A, &B, &C).unwrap(); let inst = Instance::new(num_cons, num_vars, num_inputs, &A, &B, &C).unwrap();
// compute a satisfying assignment // compute a satisfying assignment
let mut rng = ark_std::rand::thread_rng();
let mut rng = ark_std::rand::thread_rng();
let z0 = Scalar::rand(&mut rng); let z0 = Scalar::rand(&mut rng);
let z1 = z0 * z0; // constraint 0 let z1 = z0 * z0; // constraint 0
let z2 = z1 * z0; // constraint 1 let z2 = z1 * z0; // constraint 1

+ 2
- 0
profiler/nizk.rs

@ -1,4 +1,6 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![allow(clippy::assertions_on_result_states)]
extern crate flate2; extern crate flate2;
extern crate libspartan; extern crate libspartan;
extern crate merlin; extern crate merlin;

+ 2
- 0
profiler/snark.rs

@ -1,4 +1,6 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![allow(clippy::assertions_on_result_states)]
extern crate flate2; extern crate flate2;
extern crate libspartan; extern crate libspartan;
extern crate merlin; extern crate merlin;

+ 0
- 1
rustfmt.toml

@ -1,5 +1,4 @@
edition = "2018" edition = "2018"
tab_spaces = 2 tab_spaces = 2
newline_style = "Unix" newline_style = "Unix"
report_fixme = "Always"
use_try_shorthand = true use_try_shorthand = true

+ 1
- 0
src/lib.rs

@ -3,6 +3,7 @@
#![feature(int_log)] #![feature(int_log)]
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
#![deny(missing_docs)] #![deny(missing_docs)]
#![allow(clippy::assertions_on_result_states)]
extern crate byteorder; extern crate byteorder;
extern crate core; extern crate core;

+ 1
- 1
src/r1csinstance.rs

@ -229,7 +229,7 @@ impl R1CSInstance {
C: poly_C, C: poly_C,
}; };
assert!(inst.is_sat(&Z[..num_vars].to_vec(), &Z[num_vars + 1..].to_vec()));
assert!(inst.is_sat(&Z[..num_vars], &Z[num_vars + 1..]));
(inst, Z[..num_vars].to_vec(), Z[num_vars + 1..].to_vec()) (inst, Z[..num_vars].to_vec(), Z[num_vars + 1..].to_vec())
} }

+ 21
- 2
src/r1csproof.rs

@ -278,10 +278,30 @@ impl R1CSProof {
let claim_phase2 = r_A * Az_claim + r_B * Bz_claim + r_C * Cz_claim; let claim_phase2 = r_A * Az_claim + r_B * Bz_claim + r_C * Cz_claim;
// verify the joint claim with a sum-check protocol // verify the joint claim with a sum-check protocol
<<<<<<< HEAD
let (claim_post_phase2, ry) = let (claim_post_phase2, ry) =
self self
.sc_proof_phase2 .sc_proof_phase2
.verify(claim_phase2, num_rounds_y, 2, transcript)?; .verify(claim_phase2, num_rounds_y, 2, transcript)?;
=======
let (comm_claim_post_phase2, ry) = self.sc_proof_phase2.verify(
&comm_claim_phase2,
num_rounds_y,
2,
&gens.gens_sc.gens_1,
&gens.gens_sc.gens_3,
transcript,
)?;
// verify Z(ry) proof against the initial commitment
self.proof_eval_vars_at_ry.verify(
&gens.gens_pc,
transcript,
&ry[1..],
&self.comm_vars_at_ry,
&self.comm_vars,
)?;
>>>>>>> clippy fixes (#50)
let poly_input_eval = { let poly_input_eval = {
// constant term // constant term
@ -292,8 +312,7 @@ impl R1CSProof {
.map(|i| SparsePolyEntry::new(i + 1, input[i])) .map(|i| SparsePolyEntry::new(i + 1, input[i]))
.collect::<Vec<SparsePolyEntry>>(), .collect::<Vec<SparsePolyEntry>>(),
); );
SparsePolynomial::new(n.log2() as usize, input_as_sparse_poly_entries)
.evaluate(&ry[1..].to_vec())
SparsePolynomial::new(n.log2() as usize, input_as_sparse_poly_entries).evaluate(&ry[1..])
}; };
let eval_Z_at_ry = (Scalar::one() - ry[0]) * self.eval_vars_at_ry + ry[0] * poly_input_eval; let eval_Z_at_ry = (Scalar::one() - ry[0]) * self.eval_vars_at_ry + ry[0] * poly_input_eval;

+ 31
- 37
src/sparse_mlpoly.rs

@ -967,16 +967,13 @@ impl HashLayerProof {
let mut r_joint_ops = challenges_ops; let mut r_joint_ops = challenges_ops;
r_joint_ops.extend(rand_ops); r_joint_ops.extend(rand_ops);
joint_claim_eval_ops.append_to_transcript(b"joint_claim_eval_ops", transcript); joint_claim_eval_ops.append_to_transcript(b"joint_claim_eval_ops", transcript);
assert!(self
.proof_ops
.verify_plain(
&gens.gens_ops,
transcript,
&r_joint_ops,
&joint_claim_eval_ops,
&comm.comm_comb_ops
)
.is_ok());
self.proof_ops.verify_plain(
&gens.gens_ops,
transcript,
&r_joint_ops,
&joint_claim_eval_ops,
&comm.comm_comb_ops,
)?;
// verify proof-mem using comm_comb_mem at rand_mem // verify proof-mem using comm_comb_mem at rand_mem
// form a single decommitment using comb_comb_mem at rand_mem // form a single decommitment using comb_comb_mem at rand_mem
@ -1408,33 +1405,30 @@ impl PolyEvalNetworkProof {
let (claims_ops_col_read, claims_ops_col_write) = claims_ops_col.split_at_mut(num_instances); let (claims_ops_col_read, claims_ops_col_write) = claims_ops_col.split_at_mut(num_instances);
// verify the proof of hash layer // verify the proof of hash layer
assert!(self
.proof_hash_layer
.verify(
(&rand_mem, &rand_ops),
&(
claims_mem[0],
claims_ops_row_read.to_vec(),
claims_ops_row_write.to_vec(),
claims_mem[1],
),
&(
claims_mem[2],
claims_ops_col_read.to_vec(),
claims_ops_col_write.to_vec(),
claims_mem[3],
),
&claims_dotp,
comm,
gens,
comm_derefs,
rx,
ry,
r_hash,
r_multiset_check,
transcript
)
.is_ok());
self.proof_hash_layer.verify(
(&rand_mem, &rand_ops),
&(
claims_mem[0],
claims_ops_row_read.to_vec(),
claims_ops_row_write.to_vec(),
claims_mem[1],
),
&(
claims_mem[2],
claims_ops_col_read.to_vec(),
claims_ops_col_write.to_vec(),
claims_mem[3],
),
&claims_dotp,
comm,
gens,
comm_derefs,
rx,
ry,
r_hash,
r_multiset_check,
transcript,
)?;
timer.stop(); timer.stop();
Ok(()) Ok(())

Loading…
Cancel
Save