mirror of https://github.com/zcash/halo2.git
Minor fixes
This commit is contained in:
parent
a63602df2a
commit
ced73c2bf7
|
@ -182,7 +182,6 @@ fn multiexp_serial<C: CurveAffine>(coeffs: &[C::Scalar], bases: &[C], acc: &mut
|
||||||
|
|
||||||
/// Performs a small multi-exponentiation operation.
|
/// Performs a small multi-exponentiation operation.
|
||||||
/// Uses the double-and-add algorithm with doublings shared across points.
|
/// Uses the double-and-add algorithm with doublings shared across points.
|
||||||
|
|
||||||
pub fn small_multiexp<C: CurveAffine>(coeffs: &[C::Scalar], bases: &[C]) -> C::Projective {
|
pub fn small_multiexp<C: CurveAffine>(coeffs: &[C::Scalar], bases: &[C]) -> C::Projective {
|
||||||
let coeffs: Vec<[u8; 32]> = coeffs.iter().map(|a| a.to_bytes()).collect();
|
let coeffs: Vec<[u8; 32]> = coeffs.iter().map(|a| a.to_bytes()).collect();
|
||||||
let mut acc = C::Projective::zero();
|
let mut acc = C::Projective::zero();
|
||||||
|
@ -195,8 +194,8 @@ pub fn small_multiexp<C: CurveAffine>(coeffs: &[C::Scalar], bases: &[C]) -> C::P
|
||||||
// for each coeff
|
// for each coeff
|
||||||
for coeff_idx in 0..coeffs.len() {
|
for coeff_idx in 0..coeffs.len() {
|
||||||
let byte = coeffs[coeff_idx][byte_idx];
|
let byte = coeffs[coeff_idx][byte_idx];
|
||||||
if (byte >> bit_idx & 1) != 0 {
|
if ((byte >> bit_idx) & 1) != 0 {
|
||||||
acc = acc + &bases[coeff_idx].to_projective();
|
acc += bases[coeff_idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use super::super::{Coeff, Polynomial};
|
use super::super::{Coeff, Polynomial};
|
||||||
use super::{Blind, OpeningProof, Params};
|
use super::{Blind, OpeningProof, Params};
|
||||||
use crate::arithmetic::{
|
use crate::arithmetic::{
|
||||||
best_multiexp, compute_inner_product, get_challenge_scalar, small_multiexp, Challenge, Curve,
|
best_multiexp, compute_inner_product, get_challenge_scalar, parallelize, small_multiexp,
|
||||||
CurveAffine, Field,
|
Challenge, Curve, CurveAffine, Field,
|
||||||
};
|
};
|
||||||
use crate::transcript::Hasher;
|
use crate::transcript::Hasher;
|
||||||
|
|
||||||
|
@ -220,11 +220,14 @@ fn parallel_generator_collapse<C: CurveAffine>(
|
||||||
challenge_inv: C::Scalar,
|
challenge_inv: C::Scalar,
|
||||||
) {
|
) {
|
||||||
let len = g.len() / 2;
|
let len = g.len() / 2;
|
||||||
let (g_lo, g_hi) = g.split_at_mut(len);
|
let (mut g_lo, g_hi) = g.split_at_mut(len);
|
||||||
|
|
||||||
let mut tmp = Vec::with_capacity(g_lo.len());
|
parallelize(&mut g_lo, |g_lo, start| {
|
||||||
for (g_lo, g_hi) in g_lo.iter().zip(g_hi.iter()) {
|
let g_hi = &g_hi[start..];
|
||||||
tmp.push(small_multiexp(&[challenge_inv, challenge], &[*g_lo, *g_hi]));
|
let mut tmp = Vec::with_capacity(g_lo.len());
|
||||||
}
|
for (g_lo, g_hi) in g_lo.iter().zip(g_hi.iter()) {
|
||||||
C::Projective::batch_to_affine(&tmp, g_lo);
|
tmp.push(small_multiexp(&[challenge_inv, challenge], &[*g_lo, *g_hi]));
|
||||||
|
}
|
||||||
|
C::Projective::batch_to_affine(&tmp, g_lo);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue