Skip to content

Commit

Permalink
DefaultCommitter now uses Windowed version for first five elements
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed Sep 23, 2024
1 parent 3e540a4 commit bbfc00e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions banderwagon/src/msm_windowed_sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ark_ff::Zero;
use ark_ff::{BigInteger, BigInteger256};
use std::ops::Neg;

#[derive(Debug, Clone)]
pub struct MSMPrecompWindowSigned {
tables: Vec<Vec<EdwardsAffine>>,
num_windows: usize,
Expand Down
19 changes: 16 additions & 3 deletions ipa-multipoint/src/committer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use banderwagon::{msm::MSMPrecompWnaf, Element, Fr};
use banderwagon::{msm::MSMPrecompWnaf, msm_windowed_sign::MSMPrecompWindowSigned, Element, Fr};

// This is the functionality that commits to the branch nodes and computes the delta optimization
// For consistency with the Pcs, ensure that this component uses the same CRS as the Pcs
Expand All @@ -24,19 +24,32 @@ pub trait Committer {

#[derive(Clone, Debug)]
pub struct DefaultCommitter {
precomp_first_five: MSMPrecompWindowSigned,
precomp: MSMPrecompWnaf,
}

impl DefaultCommitter {
pub fn new(points: &[Element]) -> Self {
let precomp = MSMPrecompWnaf::new(points, 12);
// Take the first five elements and use a more aggressive optimization strategy
// since they are used for computing storage keys.

Self { precomp }
let (points_five, rest) = points.split_at(5);

let precomp_first_five = MSMPrecompWindowSigned::new(points_five, 16);
let precomp = MSMPrecompWnaf::new(rest, 12);

Self {
precomp,
precomp_first_five,
}
}
}

impl Committer for DefaultCommitter {
fn commit_lagrange(&self, evaluations: &[Fr]) -> Element {
if evaluations.len() <= 5 {
return self.precomp_first_five.mul(&evaluations);
}
// Preliminary benchmarks indicate that the parallel version is faster
// for vectors of length 64 or more
if evaluations.len() >= 64 {
Expand Down

0 comments on commit bbfc00e

Please sign in to comment.