mirror of https://github.com/zcash/halo2.git
Use `ff::BatchInvert` now that we have upstreamed it
This commit is contained in:
parent
3850b9ccd5
commit
9693065a00
|
@ -6,6 +6,8 @@ and this project adheres to Rust's notion of
|
|||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Removed
|
||||
- `halo2::arithmetic::BatchInvert` (use `ff::BatchInvert` instead).
|
||||
|
||||
## [0.1.0-beta.1] - 2021-09-24
|
||||
Initial beta release!
|
||||
|
|
|
@ -3,48 +3,10 @@
|
|||
|
||||
use super::multicore;
|
||||
pub use ff::Field;
|
||||
use group::Group as _;
|
||||
use group::{ff::BatchInvert, Group as _};
|
||||
|
||||
pub use pasta_curves::arithmetic::*;
|
||||
|
||||
/// Extension trait for iterators over mutable field elements which allows those
|
||||
/// field elements to be inverted in a batch.
|
||||
pub trait BatchInvert<F: Field> {
|
||||
/// Consume this iterator and invert each field element (when nonzero),
|
||||
/// returning the inverse of all nonzero field elements. Zero elements
|
||||
/// are left as zero.
|
||||
fn batch_invert(self) -> F;
|
||||
}
|
||||
|
||||
impl<'a, F, I> BatchInvert<F> for I
|
||||
where
|
||||
F: FieldExt,
|
||||
I: IntoIterator<Item = &'a mut F>,
|
||||
{
|
||||
fn batch_invert(self) -> F {
|
||||
let mut acc = F::one();
|
||||
let iter = self.into_iter();
|
||||
let mut tmp = Vec::with_capacity(iter.size_hint().0);
|
||||
for p in iter {
|
||||
let q = *p;
|
||||
tmp.push((acc, p));
|
||||
acc = F::conditional_select(&(acc * q), &acc, q.is_zero());
|
||||
}
|
||||
acc = acc.invert().unwrap();
|
||||
let allinv = acc;
|
||||
|
||||
for (tmp, p) in tmp.into_iter().rev() {
|
||||
let skip = p.is_zero();
|
||||
|
||||
let tmp = tmp * acc;
|
||||
acc = F::conditional_select(&(acc * *p), &acc, skip);
|
||||
*p = F::conditional_select(&tmp, p, skip);
|
||||
}
|
||||
|
||||
allinv
|
||||
}
|
||||
}
|
||||
|
||||
fn multiexp_serial<C: CurveAffine>(coeffs: &[C::Scalar], bases: &[C], acc: &mut C::Curve) {
|
||||
let coeffs: Vec<[u8; 32]> = coeffs.iter().map(|a| a.to_bytes()).collect();
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use super::super::{
|
|||
};
|
||||
use super::Argument;
|
||||
use crate::{
|
||||
arithmetic::{eval_polynomial, parallelize, BatchInvert, CurveAffine, FieldExt},
|
||||
arithmetic::{eval_polynomial, parallelize, CurveAffine, FieldExt},
|
||||
poly::{
|
||||
commitment::{Blind, Params},
|
||||
multiopen::ProverQuery,
|
||||
|
@ -12,8 +12,10 @@ use crate::{
|
|||
},
|
||||
transcript::{EncodedChallenge, TranscriptWrite},
|
||||
};
|
||||
use ff::Field;
|
||||
use group::Curve;
|
||||
use group::{
|
||||
ff::{BatchInvert, Field},
|
||||
Curve,
|
||||
};
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
iter,
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
use ff::Field;
|
||||
use group::Curve;
|
||||
use group::{
|
||||
ff::{BatchInvert, Field},
|
||||
Curve,
|
||||
};
|
||||
use std::iter::{self, ExactSizeIterator};
|
||||
|
||||
use super::super::{circuit::Any, ChallengeBeta, ChallengeGamma, ChallengeX};
|
||||
use super::{Argument, ProvingKey};
|
||||
use crate::{
|
||||
arithmetic::{eval_polynomial, parallelize, BatchInvert, CurveAffine, FieldExt},
|
||||
arithmetic::{eval_polynomial, parallelize, CurveAffine, FieldExt},
|
||||
plonk::{self, Error},
|
||||
poly::{
|
||||
commitment::{Blind, Params},
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
//! the committed polynomials at arbitrary points.
|
||||
|
||||
use crate::arithmetic::parallelize;
|
||||
use crate::arithmetic::BatchInvert;
|
||||
use crate::plonk::Assigned;
|
||||
|
||||
use ff::Field;
|
||||
use group::ff::{BatchInvert, Field};
|
||||
use pasta_curves::arithmetic::FieldExt;
|
||||
use std::fmt::Debug;
|
||||
use std::marker::PhantomData;
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
use ff::Field;
|
||||
use group::Curve;
|
||||
use group::{
|
||||
ff::{BatchInvert, Field},
|
||||
Curve,
|
||||
};
|
||||
|
||||
use super::super::Error;
|
||||
use super::{Params, MSM};
|
||||
use crate::transcript::{EncodedChallenge, TranscriptRead};
|
||||
|
||||
use crate::arithmetic::{best_multiexp, BatchInvert, CurveAffine};
|
||||
use crate::arithmetic::{best_multiexp, CurveAffine};
|
||||
|
||||
/// A guard returned by the verifier
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
//! domain that is of a suitable size for the application.
|
||||
|
||||
use crate::{
|
||||
arithmetic::{best_fft, parallelize, BatchInvert, FieldExt, Group},
|
||||
arithmetic::{best_fft, parallelize, FieldExt, Group},
|
||||
plonk::Assigned,
|
||||
};
|
||||
|
||||
use super::{Coeff, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial, Rotation};
|
||||
|
||||
use ff::{Field, PrimeField};
|
||||
use group::ff::{BatchInvert, Field, PrimeField};
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
/// This structure contains precomputed constants and other details needed for
|
||||
|
|
Loading…
Reference in New Issue