Skip to content

Commit

Permalink
use into_iter
Browse files Browse the repository at this point in the history
  • Loading branch information
Achim Schneider committed Mar 18, 2023
1 parent db18dca commit 2e31d91
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions primitives/arkworks/src/ed_on_bls12_377.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ use sp_std::vec::Vec;
pub fn msm(bases: Vec<u8>, scalars: Vec<u8>) -> Vec<u8> {
let bases: Vec<_> = bases
.chunks(twisted_edwards::Affine::<EdwardsConfig>::generator().serialized_size(Compress::No))
.into()
.map(|a| deserialize_argument::<twisted_edwards::Affine<EdwardsConfig>>(a))
.into_iter()
.map(|a| deserialize_argument::<twisted_edwards::Affine<EdwardsConfig>>(&a.to_vec()))
.collect();
let scalars: Vec<_> = scalars
.chunks(<EdwardsConfig as CurveConfig>::ScalarField::zero().serialized_size(Compress::No))
.into()
.map(|a| deserialize_argument::<<EdwardsConfig as CurveConfig>::ScalarField>(a))
.into_iter()
.map(|a| deserialize_argument::<<EdwardsConfig as CurveConfig>::ScalarField>(&a.to_vec()))
.collect();

let result = <EdwardsProjective as VariableBaseMSM>::msm(&bases, &scalars).unwrap();
Expand Down
16 changes: 8 additions & 8 deletions primitives/arkworks/src/ed_on_bls12_381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ use sp_std::vec::Vec;
pub fn te_msm(bases: Vec<u8>, scalars: Vec<u8>) -> Vec<u8> {
let bases: Vec<_> = bases
.chunks(TEAffine::<JubjubConfig>::generator().serialized_size(Compress::No))
.iter()
.map(|a| deserialize_argument::<TEAffine<JubjubConfig>>(a))
.into_iter()
.map(|a| deserialize_argument::<TEAffine<JubjubConfig>>(&a.to_vec()))
.collect();
let scalars: Vec<_> = scalars
.chunks(<JubjubConfig as CurveConfig>::ScalarField::zero().serialized_size(Compress::No))
.iter()
.map(|a| deserialize_argument::<<JubjubConfig as CurveConfig>::ScalarField>(a))
.into_iter()
.map(|a| deserialize_argument::<<JubjubConfig as CurveConfig>::ScalarField>(&a.to_vec()))
.collect();

let result = <EdwardsProjective as VariableBaseMSM>::msm(&bases, &scalars).unwrap();
Expand All @@ -51,13 +51,13 @@ pub fn te_msm(bases: Vec<u8>, scalars: Vec<u8>) -> Vec<u8> {
pub fn sw_msm(bases: Vec<u8>, scalars: Vec<u8>) -> Vec<u8> {
let bases: Vec<_> = bases
.chunks(SWAffine::<JubjubConfig>::genrator().serialized_size(Compress::No))
.iter()
.map(|a| deserialize_argument::<SWAffine<JubjubConfig>>(a))
.into_iter()
.map(|a| deserialize_argument::<SWAffine<JubjubConfig>>(&a.to_vec()))
.collect();
let scalars: Vec<_> = scalars
.chunks(<JubjubConfig as CurveConfig>::ScalarField::zero().serialized_size(Compress::No))
.iter()
.map(|a| deserialize_argument::<<JubjubConfig as CurveConfig>::ScalarField>(a))
.into_iter()
.map(|a| deserialize_argument::<<JubjubConfig as CurveConfig>::ScalarField>(&a.to_vec()))
.collect();

let result = <SWProjective as VariableBaseMSM>::msm(&bases, &scalars).unwrap();
Expand Down
24 changes: 12 additions & 12 deletions primitives/arkworks/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ pub fn multi_miller_loop_generic<Curve: Pairing>(
) -> Result<Vec<u8>, PairingError> {
let g1: Vec<_> = a_vec
.chunks(<Curve as Pairing>::G1Affine::generator().serialized_size(Compress::No))
.iter()
.map(|elem| deserialize_argument::<<Curve as Pairing>::G1Affine>(elem))
.into_iter()
.map(|elem| deserialize_argument::<<Curve as Pairing>::G1Affine>(&elem.to_vec()))
.collect();
let g2: Vec<_> = b_vec
.chunks(<Curve as Pairing>::G2Affine::generator().serialized_size(Compress::No))
.iter()
.map(|elem| deserialize_argument::<<Curve as Pairing>::G2Affine>(elem))
.into_iter()
.map(|elem| deserialize_argument::<<Curve as Pairing>::G2Affine>(&elem.to_vec()))
.collect();

let result = Curve::multi_miller_loop(g1, g2);
Expand All @@ -55,13 +55,13 @@ pub fn final_exponentiation_generic<Curve: Pairing>(
pub fn msm_g1_generic<Curve: Pairing>(bases: Vec<u8>, scalars: Vec<u8>) -> Vec<u8> {
let bases: Vec<_> = bases
.chunks(<Curve as Pairing>::G1Affine::generator().serialized_size(Compress::No))
.iter()
.map(|a| deserialize_argument::<<Curve as Pairing>::G1Affine>(a))
.into_iter()
.map(|a| deserialize_argument::<<Curve as Pairing>::G1Affine>(&a.to_vec()))
.collect();
let scalars: Vec<_> = scalars
.chunks(Curve::ScalarField::zero().serialized_size(Compress::No))
.iter()
.map(|a| deserialize_argument::<Curve::ScalarField>(a))
.into_iter()
.map(|a| deserialize_argument::<Curve::ScalarField>(&a.to_vec()))
.collect();

let result =
Expand All @@ -73,13 +73,13 @@ pub fn msm_g1_generic<Curve: Pairing>(bases: Vec<u8>, scalars: Vec<u8>) -> Vec<u
pub fn msm_g2_generic<Curve: Pairing>(bases: Vec<u8>, scalars: Vec<u8>) -> Vec<u8> {
let bases: Vec<_> = bases
.chunks(<Curve as Pairing>::G2Affine::generator().serialized_size(Compress::No))
.iter()
.map(|a| deserialize_argument::<<Curve as Pairing>::G2Affine>(a))
.into_iter()
.map(|a| deserialize_argument::<<Curve as Pairing>::G2Affine>(&a.to_vec()))
.collect();
let scalars: Vec<_> = scalars
.chunks(Curve::ScalarField::zero().serialized_size(Compress::No))
.iter()
.map(|a| deserialize_argument::<Curve::ScalarField>(a))
.into_iter()
.map(|a| deserialize_argument::<Curve::ScalarField>(&a.to_vec()))
.collect();

let result =
Expand Down

0 comments on commit 2e31d91

Please sign in to comment.