From bbfc00edf75be23ba985662a6303e9713b14faf6 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Mon, 23 Sep 2024 21:22:53 +0100 Subject: [PATCH] DefaultCommitter now uses Windowed version for first five elements --- banderwagon/src/msm_windowed_sign.rs | 1 + ipa-multipoint/src/committer.rs | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/banderwagon/src/msm_windowed_sign.rs b/banderwagon/src/msm_windowed_sign.rs index be7c84e..b55de0a 100644 --- a/banderwagon/src/msm_windowed_sign.rs +++ b/banderwagon/src/msm_windowed_sign.rs @@ -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>, num_windows: usize, diff --git a/ipa-multipoint/src/committer.rs b/ipa-multipoint/src/committer.rs index 968877e..e97a470 100644 --- a/ipa-multipoint/src/committer.rs +++ b/ipa-multipoint/src/committer.rs @@ -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 @@ -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 {