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 06f4214
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 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.

1 change: 1 addition & 0 deletions primitives/arkworks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ark-ed-on-bls12-381 = { version = "0.4.0-alpha" }
ark-ed-on-bls12-377 = { version = "0.4.0-alpha" }
sp-std = { version = "5.0.0", default-features = false, path = "../std" }
better_any = { version = "0.2.0" }
frame-support = { version = "4.0.0-dev", path = "../../frame/support" }

[features]
default = ["std"]
Expand Down
15 changes: 9 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,26 @@

use ark_ec::{
models::CurveConfig,
short_weierstrass::{self, Affine as SWAffine, SWCurveConfig},
short_weierstrass::{self, 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};
use frame_support::debug;

/// Compute a scalar multiplication on G2 through arkworks
pub fn sw_mul_projective(base: Vec<u8>, scalar: Vec<u8>) -> Vec<u8> {
// debug::RuntimeLogger::init();
debug::native::warn!("{:?}", 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 +151,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
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 06f4214

Please sign in to comment.