Skip to content

Commit f4584e7

Browse files
committed
Format
1 parent 4b53b72 commit f4584e7

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
# Package Manager
99
## cargo
1010
target
11+
# nix
12+
shell.nix
1113
## npm
1214
node_modules
1315

1416
# Test data
1517
test-data
16-
17-
# Nix
18-
shell.nix

precompile/bls12-381/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,17 @@ sp-std = { workspace = true }
2626

2727
[dev-dependencies]
2828
rand = { version = "0.8.5" }
29-
ark-std = { version = "0.4.0", default-features = false }
29+
ark-std = { version = "0.4.0" }
3030

3131
[features]
3232
default = ["std"]
3333
std = [
3434
# crates.io
35-
"sha2/std",
36-
37-
# arkworks
3835
"ark-bls12-381/std",
3936
"ark-serialize/std",
4037
"ark-ec/std",
4138
"ark-ff/std",
39+
"sha2/std",
4240

4341
# frontier
4442
"pallet-evm/std",

precompile/bls12-381/src/bls/mod.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
// core
2222
use core::{borrow::Borrow, ops::Neg};
23-
24-
// substrate
25-
use sp_std::prelude::Vec;
26-
2723
// crates.io
2824
use ark_bls12_381::{
2925
g2::Config as G2Config, Bls12_381, G1Affine, G1Projective, G2Affine, G2Projective,
@@ -40,25 +36,24 @@ use ark_ec::{
4036
use ark_ff::{field_hashers::DefaultFieldHasher, Zero};
4137
use ark_serialize::*;
4238
use sha2::Sha256;
39+
// substrate
40+
use sp_std::prelude::Vec;
4341

4442
/// Domain Separation Tag for signatures on G2
4543
pub const DST_G2: &[u8] = b"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_";
4644

4745
#[derive(Clone, Debug)]
4846
pub struct Signature(G2Projective);
49-
5047
impl From<G2Projective> for Signature {
5148
fn from(sig: G2Projective) -> Signature {
5249
Signature(sig)
5350
}
5451
}
55-
5652
impl AsRef<G2Projective> for Signature {
5753
fn as_ref(&self) -> &G2Projective {
5854
&self.0
5955
}
6056
}
61-
6257
impl Signature {
6358
pub fn from_bytes(bytes: &[u8]) -> Result<Signature, SerializationError> {
6459
let p = G2Affine::deserialize_compressed(bytes)?;
@@ -73,13 +68,11 @@ impl Signature {
7368

7469
#[derive(Clone, Debug, Eq, PartialEq, Hash, CanonicalSerialize, CanonicalDeserialize)]
7570
pub struct PublicKey(pub G1Projective);
76-
7771
impl From<G1Projective> for PublicKey {
7872
fn from(pk: G1Projective) -> PublicKey {
7973
PublicKey(pk)
8074
}
8175
}
82-
8376
impl PublicKey {
8477
pub fn from_bytes(bytes: &[u8]) -> Result<PublicKey, SerializationError> {
8578
let p = G1Affine::deserialize_compressed(bytes)?;
@@ -110,14 +103,14 @@ pub fn hash_to_curve_g2(message: &[u8]) -> Result<G2Projective, HashToCurveError
110103

111104
#[cfg(test)]
112105
mod tests {
113-
use ark_std::test_rng;
106+
// crates.io
114107
use rand::Rng;
115-
116-
use super::*;
117-
108+
use ark_std::test_rng;
118109
use ark_bls12_381::Fr;
119110
use ark_ec::Group;
120111
use ark_ff::UniformRand;
112+
// darwinia
113+
use super::*;
121114

122115
#[derive(Clone, Debug, CanonicalSerialize, CanonicalDeserialize)]
123116
pub struct SecretKey(Fr);

0 commit comments

Comments
 (0)