Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
use chunks for scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
Achim Schneider committed Mar 18, 2023
1 parent 1ddd6b8 commit 67987ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions primitives/arkworks/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ pub fn msm_g1_generic<Curve: Pairing>(bases: Vec<u8>, scalars: Vec<u8>) -> Vec<u
.into_iter()
.map(|a| deserialize_argument::<<Curve as Pairing>::G1Affine>(a))
.collect();
let scalars: Vec<_> =
scalars.iter().map(|a| deserialize_argument::<Curve::ScalarField>(a)).collect();
let scalars: Vec<_> = scalars
.chunks(Curve::ScalarField.serialized_size(Compress::No))
.into_iter()
.map(|a| deserialize_argument::<Curve::ScalarField>(a))
.collect();

let result =
<<Curve as Pairing>::G1 as ark_ec::VariableBaseMSM>::msm(&bases, &scalars).unwrap();
Expand All @@ -69,8 +72,11 @@ pub fn msm_g2_generic<Curve: Pairing>(bases: Vec<u8>, scalars: Vec<u8>) -> Vec<u
.into_iter()
.map(|a| deserialize_argument::<<Curve as Pairing>::G2Affine>(a))
.collect();
let scalars: Vec<_> =
scalars.iter().map(|a| deserialize_argument::<Curve::ScalarField>(a)).collect();
let scalars: Vec<_> = scalars
.chunks(Curve::ScalarField.serialized_size(Compress::No))
.into_iter()
.map(|a| deserialize_argument::<Curve::ScalarField>(a))
.collect();

let result =
<<Curve as Pairing>::G2 as ark_ec::VariableBaseMSM>::msm(&bases, &scalars).unwrap();
Expand Down

0 comments on commit 67987ae

Please sign in to comment.