From f834f3005694ef29dd125a72736e644dd2ea9b36 Mon Sep 17 00:00:00 2001 From: iquerejeta Date: Mon, 30 Oct 2023 10:14:45 +0100 Subject: [PATCH] Make multiexp generic on the size of the Scalar --- halo2_proofs/src/arithmetic.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/halo2_proofs/src/arithmetic.rs b/halo2_proofs/src/arithmetic.rs index f8694e069a..0163e355eb 100644 --- a/halo2_proofs/src/arithmetic.rs +++ b/halo2_proofs/src/arithmetic.rs @@ -40,7 +40,7 @@ fn multiexp_serial(coeffs: &[C::Scalar], bases: &[C], acc: &mut let skip_bits = segment * c; let skip_bytes = skip_bits / 8; - if skip_bytes >= 32 { + if skip_bytes >= (F::NUM_BITS as usize + 7) / 8 { return 0; } @@ -56,7 +56,7 @@ fn multiexp_serial(coeffs: &[C::Scalar], bases: &[C], acc: &mut tmp as usize } - let segments = (256 / c) + 1; + let segments = (C::Scalar::NUM_BITS as usize / c) + 1; for current_segment in (0..segments).rev() { for _ in 0..c { @@ -122,7 +122,7 @@ pub fn small_multiexp(coeffs: &[C::Scalar], bases: &[C]) -> C::C let mut acc = C::Curve::identity(); // for byte idx - for byte_idx in (0..32).rev() { + for byte_idx in (0..((C::Scalar::NUM_BITS as usize + 7) / 8)).rev() { // for bit idx for bit_idx in (0..8).rev() { acc = acc.double();