Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make multi scalar multiplication generic on the size of the Scalar #221

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions halo2_proofs/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn multiexp_serial<C: CurveAffine>(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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if skip_bytes >= (F::NUM_BITS as usize + 7) / 8 {
if skip_bytes >= (F::NUM_BITS as usize + 7) >> 3 {

return 0;
}

Expand All @@ -56,7 +56,7 @@ fn multiexp_serial<C: CurveAffine>(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 {
Expand Down Expand Up @@ -122,7 +122,7 @@ pub fn small_multiexp<C: CurveAffine>(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() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for byte_idx in (0..((C::Scalar::NUM_BITS as usize + 7) / 8)).rev() {
for byte_idx in (0..((C::Scalar::NUM_BITS as usize + 7) >> 3)).rev() {

// for bit idx
for bit_idx in (0..8).rev() {
acc = acc.double();
Expand Down
Loading