mirror of https://github.com/zcash/halo2.git
Minor changes and documentation
This commit is contained in:
parent
24b85dec67
commit
742c15bb51
|
@ -440,8 +440,8 @@ pub fn lagrange_interpolate<F: Field>(points: &[F], evals: &[F]) -> Vec<F> {
|
|||
} else {
|
||||
let mut interpolation_polys = vec![];
|
||||
for (j, x_j) in points.iter().enumerate() {
|
||||
let mut tmp: Vec<F> = Vec::with_capacity(points.len() + 1);
|
||||
let mut product = Vec::with_capacity(points.len() + 1);
|
||||
let mut tmp: Vec<F> = Vec::with_capacity(points.len());
|
||||
let mut product = Vec::with_capacity(points.len() - 1);
|
||||
tmp.push(F::one());
|
||||
for (k, x_k) in points.iter().enumerate() {
|
||||
if k != j {
|
||||
|
@ -459,6 +459,8 @@ pub fn lagrange_interpolate<F: Field>(points: &[F], evals: &[F]) -> Vec<F> {
|
|||
std::mem::swap(&mut tmp, &mut product);
|
||||
}
|
||||
}
|
||||
assert_eq!(tmp.len(), points.len());
|
||||
assert_eq!(product.len(), points.len() - 1);
|
||||
interpolation_polys.push(tmp);
|
||||
}
|
||||
let mut final_poly = vec![F::zero(); points.len()];
|
||||
|
|
|
@ -40,6 +40,9 @@ impl<C: CurveAffine> Proof<C> {
|
|||
// x_4 challenge.
|
||||
let mut q_polys: Vec<Option<Polynomial<C::Scalar, Coeff>>> = vec![None; point_sets.len()];
|
||||
let mut q_blinds = vec![Blind(C::Scalar::zero()); point_sets.len()];
|
||||
|
||||
// A vec of vecs of evals. The outer vec corresponds to the point set,
|
||||
// while the inner vec corresponds to the points in a particular set.
|
||||
let mut q_eval_sets: Vec<Vec<_>> = vec![Vec::new(); point_sets.len()];
|
||||
for (set_idx, point_set) in point_sets.iter().enumerate() {
|
||||
q_eval_sets[set_idx] = vec![C::Scalar::zero(); point_set.len()];
|
||||
|
@ -66,6 +69,8 @@ impl<C: CurveAffine> Proof<C> {
|
|||
});
|
||||
q_blinds[set_idx] *= x_4;
|
||||
q_blinds[set_idx] += blind;
|
||||
// Each polynomial is evaluated at a set of points. For each set,
|
||||
// we collapse each polynomial's evals pointwise.
|
||||
for (eval_idx, &eval) in evals.iter().enumerate() {
|
||||
q_eval_sets[set_idx][eval_idx] *= &x_4;
|
||||
q_eval_sets[set_idx][eval_idx] += &eval;
|
||||
|
@ -142,7 +147,7 @@ impl<C: CurveAffine> Proof<C> {
|
|||
(f_poly.clone(), f_blind),
|
||||
|(f_poly, f_blind), (poly, blind)| {
|
||||
(
|
||||
f_poly * x_7 + &poly.clone().unwrap(),
|
||||
f_poly * x_7 + poly.as_ref().unwrap(),
|
||||
Blind((f_blind.0 * &x_7) + &blind.0),
|
||||
)
|
||||
},
|
||||
|
|
|
@ -17,9 +17,9 @@ struct CommitmentData<C: CurveAffine> {
|
|||
evals: Vec<C::Scalar>,
|
||||
}
|
||||
|
||||
impl<'a, C: CurveAffine> Proof<C> {
|
||||
impl<C: CurveAffine> Proof<C> {
|
||||
/// Verify a multi-opening proof
|
||||
pub fn verify<I, HBase: Hasher<C::Base>, HScalar: Hasher<C::Scalar>>(
|
||||
pub fn verify<'a, I, HBase: Hasher<C::Base>, HScalar: Hasher<C::Scalar>>(
|
||||
&self,
|
||||
params: &'a Params<C>,
|
||||
transcript: &mut HBase,
|
||||
|
@ -43,6 +43,9 @@ impl<'a, C: CurveAffine> Proof<C> {
|
|||
// Compress the commitments and expected evaluations at x_3 together.
|
||||
// using the challenge x_4
|
||||
let mut q_commitments: Vec<_> = vec![params.empty_msm(); point_sets.len()];
|
||||
|
||||
// A vec of vecs of evals. The outer vec corresponds to the point set,
|
||||
// while the inner vec corresponds to the points in a particular set.
|
||||
let mut q_eval_sets: Vec<Vec<C::Scalar>> = vec![Vec::new(); point_sets.len()];
|
||||
for (set_idx, point_set) in point_sets.iter().enumerate() {
|
||||
q_eval_sets[set_idx] = vec![C::Scalar::zero(); point_set.len()];
|
||||
|
@ -57,6 +60,8 @@ impl<'a, C: CurveAffine> Proof<C> {
|
|||
}
|
||||
};
|
||||
|
||||
// Each commitment corresponds to evaluations at a set of points.
|
||||
// For each set, we collapse each commitment's evals pointwise.
|
||||
for (commitment, commitment_data) in commitment_map {
|
||||
accumulate(
|
||||
commitment_data.set_index, // set_idx,
|
||||
|
|
Loading…
Reference in New Issue