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

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Achim Schneider committed Jan 12, 2023
1 parent 259c6d1 commit 280e690
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

13 changes: 7 additions & 6 deletions primitives/arkworks/src/ed_on_bls12_381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,24 @@

use ark_ec::{
models::CurveConfig,
short_weierstrass::{self, Affine as SWAffine, SWCurveConfig},
short_weierstrass::{Affine as SWAffine, SWCurveConfig, Projective as SWProjective},
twisted_edwards,
twisted_edwards::{Affine as TEAffine, TECurveConfig},
VariableBaseMSM,
};
use ark_ed_on_bls12_381::{EdwardsProjective, JubjubConfig, SWProjective};
use ark_ed_on_bls12_381::{EdwardsProjective, JubjubConfig};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, Compress, Validate};
use ark_std::io::Cursor;
use sp_std::{vec, vec::Vec};

/// Compute a scalar multiplication on G2 through arkworks
pub fn sw_mul_projective(base: Vec<u8>, scalar: Vec<u8>) -> Vec<u8> {
println!("{:?}", base);
let cursor = Cursor::new(base);
let base = ark_ec::short_weierstrass::Projective::<JubjubConfig>::deserialize_with_mode(
let base = SWProjective::<JubjubConfig>::deserialize_with_mode(
cursor,
Compress::Yes,
Validate::No,
Compress::No,
Validate::Yes,
)
.unwrap();
let cursor = Cursor::new(scalar);
Expand Down Expand Up @@ -148,7 +149,7 @@ pub fn sw_msm(bases: Vec<Vec<u8>>, scalars: Vec<Vec<u8>>) -> Vec<u8> {
})
.collect();

let result = <SWProjective as VariableBaseMSM>::msm(&bases, &scalars).unwrap();
let result = <SWProjective::<JubjubConfig> as VariableBaseMSM>::msm(&bases, &scalars).unwrap();
let mut serialized = vec![0; result.serialized_size(Compress::Yes)];
let mut cursor = Cursor::new(&mut serialized[..]);
result.serialize_with_mode(&mut cursor, Compress::Yes).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion primitives/arkworks/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(not(feature = "std"), no_std)]
// #![cfg_attr(not(feature = "std"), no_std)]

pub mod bls12_377;
pub mod bls12_381;
Expand Down
1 change: 1 addition & 0 deletions primitives/arkworks/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ sp-ark-bls12-381 = { git = "https://github.com/achimcc/ark-substrate" }
sp-ark-bw6-761 = { git = "https://github.com/achimcc/ark-substrate" }
sp-ark-ed-on-bls12-377 = { git = "https://github.com/achimcc/ark-substrate" }
sp-ark-ed-on-bls12-381 = { git = "https://github.com/achimcc/ark-substrate" }
frame-support = { version = "4.0.0-dev", path = "../../../frame/support" }



Expand Down

0 comments on commit 280e690

Please sign in to comment.