Skip to content

Commit

Permalink
crypto: replace ed25519-dalek with ed25519-consensus (#624)
Browse files Browse the repository at this point in the history
* crypto: replace ed25519-dalek with ed25519-consensus

* cargo xclippy and hakari generate

* serialize test negative case
  • Loading branch information
joyqvq authored Aug 4, 2022
1 parent d3cb205 commit 75ed6e6
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 132 deletions.
8 changes: 4 additions & 4 deletions narwhal/config/tests/snapshots/config_tests__committee.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expression: committee
---
{
"authorities": {
"IP26ybELdYe7p7W8FjvOaeeW1x5O1EwQ/LRIhon3oUQ=": {
"ildi4hrBzbOHBELHe0w69Yx87bh3nQJw5tTx4vc2fXQ=": {
"stake": 1,
"primary": {
"primary_to_primary": "/ip4/127.0.0.1/tcp/1/http",
Expand Down Expand Up @@ -33,7 +33,7 @@ expression: committee
}
}
},
"YxwVQfOkv0TU2JcGFWSqhJXXZvYZGj/2FWIAPxhLjGU=": {
"rvP0pLjsod/DQzYb+OQ2vULeklnAS4MU644gVN1ugqs=": {
"stake": 1,
"primary": {
"primary_to_primary": "/ip4/127.0.0.1/tcp/1/http",
Expand Down Expand Up @@ -62,7 +62,7 @@ expression: committee
}
}
},
"deQXTdWIIlSAhvF7A3zssO6GUWt9E0AKgMhWtL2vf+E=": {
"ucbuFjDvPnERRKZI2wa7sihPcnTPvuU//O5QPMGkkgA=": {
"stake": 1,
"primary": {
"primary_to_primary": "/ip4/127.0.0.1/tcp/1/http",
Expand Down Expand Up @@ -91,7 +91,7 @@ expression: committee
}
}
},
"vq2gYSbHjZi0oaafbuYYlpTw9HUVONqCTxrcixShtWI=": {
"zGIzLjS7LVzWn2Dvuyo2y5FsfrRYMB6jZjbE27ASvYg=": {
"stake": 1,
"primary": {
"primary_to_primary": "/ip4/127.0.0.1/tcp/1/http",
Expand Down
1 change: 1 addition & 0 deletions narwhal/consensus/src/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub enum ValidatorDagError {
DagInvariantViolation(#[from] dag::node_dag::NodeDagError),
}

#[allow(clippy::large_enum_variant)]
enum DagCommand {
Insert(
Box<Certificate>,
Expand Down
4 changes: 2 additions & 2 deletions narwhal/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ publish = false
[dependencies]
anyhow = { version = "1.0.59", features = ["backtrace"] }
base64ct = { version = "1.5.1", features = ["alloc"] }
ed25519-dalek = { version = "1.0.1", features = ["batch", "serde"] }
ed25519-consensus = { version = "1.2.1", features = ["serde"] }
eyre = "0.6.8"
hex = "0.4.3"
rand = { version = "0.7.3", features = ["std"] }
rand = { version = "0.8.5", features = ["std"] }
serde = { version = "1.0.142", features = ["derive"] }
zeroize = "1.5.7"
signature = "1.5.0"
Expand Down
15 changes: 9 additions & 6 deletions narwhal/crypto/benches/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
#[macro_use]
extern crate criterion;
extern crate ed25519_dalek;
extern crate ed25519_consensus;
extern crate rand;

mod ed25519_benches {
Expand Down Expand Up @@ -44,8 +44,8 @@ mod ed25519_benches {
let mut csprng: ThreadRng = thread_rng();
let ed_keypair = Ed25519KeyPair::generate(&mut csprng);
let bls_keypair = BLS12377KeyPair::generate(&mut csprng);
let blst_keypair = BLS12381KeyPair::generate(&mut csprng);
let secp256k1_keypair = Secp256k1KeyPair::generate(&mut csprng);
let blst_keypair = BLS12381KeyPair::generate(&mut csprng.clone());
let secp256k1_keypair = Secp256k1KeyPair::generate(&mut csprng.clone());

let ed_public = ed_keypair.public();
let bls_public = bls_keypair.public();
Expand Down Expand Up @@ -135,18 +135,21 @@ mod ed25519_benches {

fn key_generation(c: &mut Criterion) {
let mut csprng: ThreadRng = thread_rng();
let mut csprng1 = csprng.clone();
let mut csprng2 = csprng.clone();
let mut csprng3 = csprng.clone();

c.bench_function("Ed25519 keypair generation", move |b| {
b.iter(|| Ed25519KeyPair::generate(&mut csprng))
});
c.bench_function("BLS12377 keypair generation", move |b| {
b.iter(|| BLS12377KeyPair::generate(&mut csprng))
b.iter(|| BLS12377KeyPair::generate(&mut csprng1))
});
c.bench_function("BLS12381 keypair generation", move |b| {
b.iter(|| BLS12381KeyPair::generate(&mut csprng))
b.iter(|| BLS12381KeyPair::generate(&mut csprng2))
});
c.bench_function("Secp256k1 keypair generation", move |b| {
b.iter(|| Secp256k1KeyPair::generate(&mut csprng))
b.iter(|| Secp256k1KeyPair::generate(&mut csprng3))
});
}

Expand Down
Loading

0 comments on commit 75ed6e6

Please sign in to comment.