mirror of https://github.com/zcash/halo2.git
Address clippy lints
This commit is contained in:
parent
6e7895d8d5
commit
a37c926a89
|
@ -47,9 +47,9 @@ where
|
||||||
{
|
{
|
||||||
fn batch_invert(self) -> F {
|
fn batch_invert(self) -> F {
|
||||||
let mut acc = F::one();
|
let mut acc = F::one();
|
||||||
let mut iter = self.into_iter();
|
let iter = self.into_iter();
|
||||||
let mut tmp = Vec::with_capacity(iter.size_hint().0);
|
let mut tmp = Vec::with_capacity(iter.size_hint().0);
|
||||||
while let Some(p) = iter.next() {
|
for p in iter {
|
||||||
let q = *p;
|
let q = *p;
|
||||||
tmp.push((acc, p));
|
tmp.push((acc, p));
|
||||||
acc = F::conditional_select(&(acc * q), &acc, q.is_zero());
|
acc = F::conditional_select(&(acc * q), &acc, q.is_zero());
|
||||||
|
|
10
src/plonk.rs
10
src/plonk.rs
|
@ -395,26 +395,26 @@ fn test_proving() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
{
|
{
|
||||||
let msm = guard.clone().use_challenges();
|
let msm = guard.clone().use_challenges();
|
||||||
assert!(msm.is_zero());
|
assert!(msm.eval());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let g = guard.compute_g();
|
let g = guard.compute_g();
|
||||||
let (msm, _) = guard.clone().use_g(g);
|
let (msm, _) = guard.clone().use_g(g);
|
||||||
assert!(msm.is_zero());
|
assert!(msm.eval());
|
||||||
}
|
}
|
||||||
let msm = guard.clone().use_challenges();
|
let msm = guard.clone().use_challenges();
|
||||||
assert!(msm.clone().is_zero());
|
assert!(msm.clone().eval());
|
||||||
let guard = proof
|
let guard = proof
|
||||||
.verify::<DummyHash<Fq>, DummyHash<Fp>>(¶ms, &srs, msm, &[pubinput])
|
.verify::<DummyHash<Fq>, DummyHash<Fp>>(¶ms, &srs, msm, &[pubinput])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
{
|
{
|
||||||
let msm = guard.clone().use_challenges();
|
let msm = guard.clone().use_challenges();
|
||||||
assert!(msm.is_zero());
|
assert!(msm.eval());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let g = guard.compute_g();
|
let g = guard.compute_g();
|
||||||
let (msm, _) = guard.clone().use_g(g);
|
let (msm, _) = guard.clone().use_g(g);
|
||||||
assert!(msm.is_zero());
|
assert!(msm.eval());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,8 +108,7 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let aux_polys: Vec<_> = aux
|
let aux_polys: Vec<_> = aux
|
||||||
.clone()
|
.iter()
|
||||||
.into_iter()
|
|
||||||
.map(|poly| {
|
.map(|poly| {
|
||||||
let lagrange_vec = domain.lagrange_from_vec(poly.to_vec());
|
let lagrange_vec = domain.lagrange_from_vec(poly.to_vec());
|
||||||
domain.lagrange_to_coeff(lagrange_vec)
|
domain.lagrange_to_coeff(lagrange_vec)
|
||||||
|
@ -616,7 +615,7 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
let x_7: C::Scalar =
|
let x_7: C::Scalar =
|
||||||
get_challenge_scalar(Challenge(transcript.squeeze().get_lower_128()));
|
get_challenge_scalar(Challenge(transcript.squeeze().get_lower_128()));
|
||||||
|
|
||||||
let mut f_blind_dup = f_blind.clone();
|
let mut f_blind_dup = f_blind;
|
||||||
let mut f_poly = f_poly.clone();
|
let mut f_poly = f_poly.clone();
|
||||||
for (_, &point_index) in meta.rotations.iter() {
|
for (_, &point_index) in meta.rotations.iter() {
|
||||||
f_blind_dup *= x_7;
|
f_blind_dup *= x_7;
|
||||||
|
@ -632,10 +631,11 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let opening = OpeningProof::create(¶ms, &mut transcript, &f_poly, f_blind_dup, x_6);
|
|
||||||
|
|
||||||
if opening.is_ok() {
|
if let Ok(opening) =
|
||||||
break (opening.unwrap(), q_evals);
|
OpeningProof::create(¶ms, &mut transcript, &f_poly, f_blind_dup, x_6)
|
||||||
|
{
|
||||||
|
break (opening, q_evals);
|
||||||
} else {
|
} else {
|
||||||
f_blind += C::Scalar::one();
|
f_blind += C::Scalar::one();
|
||||||
f_commitment = (f_commitment + params.h).to_affine();
|
f_commitment = (f_commitment + params.h).to_affine();
|
||||||
|
|
|
@ -119,9 +119,9 @@ impl<F, B> Polynomial<F, B> {
|
||||||
self.values.iter_mut()
|
self.values.iter_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the length of this polynomial in terms of the number of
|
/// Gets the size of this polynomial in terms of the number of
|
||||||
/// coefficients used to describe it.
|
/// coefficients used to describe it.
|
||||||
pub fn len(&self) -> usize {
|
pub fn num_coeffs(&self) -> usize {
|
||||||
self.values.len()
|
self.values.len()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,8 @@ impl<'a, C: CurveAffine> MSM<'a, C> {
|
||||||
|
|
||||||
/// Add arbitrary term (the scalar and the point)
|
/// Add arbitrary term (the scalar and the point)
|
||||||
pub fn add_term(&mut self, scalar: C::Scalar, point: C) {
|
pub fn add_term(&mut self, scalar: C::Scalar, point: C) {
|
||||||
&self.other_scalars.push(scalar);
|
self.other_scalars.push(scalar);
|
||||||
&self.other_bases.push(point);
|
self.other_bases.push(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a vector of scalars to `g_scalars`. This function will panic if the
|
/// Add a vector of scalars to `g_scalars`. This function will panic if the
|
||||||
|
@ -100,7 +100,7 @@ impl<'a, C: CurveAffine> MSM<'a, C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform multiexp and check that it results in zero
|
/// Perform multiexp and check that it results in zero
|
||||||
pub fn is_zero(self) -> bool {
|
pub fn eval(self) -> bool {
|
||||||
let len = self.g_scalars.as_ref().map(|v| v.len()).unwrap_or(0)
|
let len = self.g_scalars.as_ref().map(|v| v.len()).unwrap_or(0)
|
||||||
+ self.h_scalar.map(|_| 1).unwrap_or(0)
|
+ self.h_scalar.map(|_| 1).unwrap_or(0)
|
||||||
+ self.other_scalars.len();
|
+ self.other_scalars.len();
|
||||||
|
@ -304,7 +304,7 @@ impl<'a, C: CurveAffine> Guard<'a, C> {
|
||||||
/// Lets caller supply the purported G point and simply appends it to
|
/// Lets caller supply the purported G point and simply appends it to
|
||||||
/// return an updated MSM.
|
/// return an updated MSM.
|
||||||
pub fn use_g(mut self, g: C) -> (MSM<'a, C>, Accumulator<C>) {
|
pub fn use_g(mut self, g: C) -> (MSM<'a, C>, Accumulator<C>) {
|
||||||
&self.msm.add_term(self.neg_z1, g);
|
self.msm.add_term(self.neg_z1, g);
|
||||||
|
|
||||||
let accumulator = Accumulator {
|
let accumulator = Accumulator {
|
||||||
g,
|
g,
|
||||||
|
@ -458,12 +458,12 @@ fn test_opening_proof() {
|
||||||
{
|
{
|
||||||
// Test use_challenges()
|
// Test use_challenges()
|
||||||
let msm_challenges = guard.clone().use_challenges();
|
let msm_challenges = guard.clone().use_challenges();
|
||||||
assert!(msm_challenges.is_zero());
|
assert!(msm_challenges.eval());
|
||||||
|
|
||||||
// Test use_g()
|
// Test use_g()
|
||||||
let g = guard.compute_g();
|
let g = guard.compute_g();
|
||||||
let (msm_g, _accumulator) = guard.clone().use_g(g);
|
let (msm_g, _accumulator) = guard.clone().use_g(g);
|
||||||
assert!(msm_g.is_zero());
|
assert!(msm_g.eval());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check another proof to populate `msm.g_scalars`
|
// Check another proof to populate `msm.g_scalars`
|
||||||
|
@ -483,12 +483,12 @@ fn test_opening_proof() {
|
||||||
|
|
||||||
// Test use_challenges()
|
// Test use_challenges()
|
||||||
let msm_challenges = guard.clone().use_challenges();
|
let msm_challenges = guard.clone().use_challenges();
|
||||||
assert!(msm_challenges.is_zero());
|
assert!(msm_challenges.eval());
|
||||||
|
|
||||||
// Test use_g()
|
// Test use_g()
|
||||||
let g = guard.compute_g();
|
let g = guard.compute_g();
|
||||||
let (msm_g, _accumulator) = guard.clone().use_g(g);
|
let (msm_g, _accumulator) = guard.clone().use_g(g);
|
||||||
assert!(msm_g.is_zero());
|
assert!(msm_g.eval());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue