From 06f4214126ef8ee2fc372c54919a9b646055615b Mon Sep 17 00:00:00 2001 From: Achim Schneider Date: Thu, 12 Jan 2023 09:23:55 +0100 Subject: [PATCH] update --- Cargo.lock | 1 + primitives/arkworks/Cargo.toml | 1 + primitives/arkworks/src/ed_on_bls12_381.rs | 15 +++++++++------ primitives/arkworks/test/Cargo.toml | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bdbd00e1811d9..186502d676c18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9995,6 +9995,7 @@ dependencies = [ "ark-relations 0.4.0-alpha.1 (git+https://github.com/arkworks-rs/snark)", "ark-serialize", "ark-std", + "frame-support", "sp-ark-bls12-377", "sp-ark-bls12-381", "sp-ark-bw6-761", diff --git a/primitives/arkworks/Cargo.toml b/primitives/arkworks/Cargo.toml index ad982c85f4a63..500f606c543f6 100644 --- a/primitives/arkworks/Cargo.toml +++ b/primitives/arkworks/Cargo.toml @@ -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"] diff --git a/primitives/arkworks/src/ed_on_bls12_381.rs b/primitives/arkworks/src/ed_on_bls12_381.rs index bf0ef83cfbce6..16db38f58e37c 100644 --- a/primitives/arkworks/src/ed_on_bls12_381.rs +++ b/primitives/arkworks/src/ed_on_bls12_381.rs @@ -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, scalar: Vec) -> Vec { + // debug::RuntimeLogger::init(); + debug::native::warn!("{:?}", base); let cursor = Cursor::new(base); - let base = ark_ec::short_weierstrass::Projective::::deserialize_with_mode( + let base = SWProjective::::deserialize_with_mode( cursor, - Compress::Yes, - Validate::No, + Compress::No, + Validate::Yes, ) .unwrap(); let cursor = Cursor::new(scalar); @@ -148,7 +151,7 @@ pub fn sw_msm(bases: Vec>, scalars: Vec>) -> Vec { }) .collect(); - let result = ::msm(&bases, &scalars).unwrap(); + let result = 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(); diff --git a/primitives/arkworks/test/Cargo.toml b/primitives/arkworks/test/Cargo.toml index 2e8a6ce33bc5a..b29a287b2188d 100644 --- a/primitives/arkworks/test/Cargo.toml +++ b/primitives/arkworks/test/Cargo.toml @@ -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" }