-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
103 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//! Random key generation, intended for use in testing | ||
|
||
use super::{AggregateSignature, ByteFmt, PublicKey, SecretKey, Signature}; | ||
use rand::{distributions::Standard, prelude::Distribution, Rng}; | ||
|
||
/// Generates a random SecretKey. This is meant for testing purposes. | ||
impl Distribution<SecretKey> for Standard { | ||
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> SecretKey { | ||
SecretKey::decode(&rng.gen::<[u8; 32]>()).unwrap() | ||
} | ||
} | ||
|
||
/// Generates a random Signature. This is meant for testing purposes. | ||
impl Distribution<Signature> for Standard { | ||
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Signature { | ||
let key = rng.gen::<SecretKey>(); | ||
let msg = rng.gen::<[u8; 4]>(); | ||
key.sign(&msg) | ||
} | ||
} | ||
|
||
/// Generates a random AggregateSignature. This is meant for testing purposes. | ||
impl Distribution<AggregateSignature> for Standard { | ||
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> AggregateSignature { | ||
let sig: Signature = self.sample(rng); | ||
AggregateSignature(sig) | ||
} | ||
} | ||
|
||
/// Generates a random PublicKey. This is meant for testing purposes. | ||
impl Distribution<PublicKey> for Standard { | ||
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> PublicKey { | ||
rng.gen::<SecretKey>().public() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
pub use fmt::*; | ||
|
||
pub mod bls12_381; | ||
pub mod bn254; | ||
pub mod ed25519; | ||
mod fmt; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters