-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Faheelsattar/add gen bls flag (#328)
## π Summary Adds `gen-bls` flag to rbuilder for generating BLS address Closes #307 ## β I have completed the following steps: * [x] Run `make lint` * [x] Run `make test` * [x] Added tests (if applicable)
- Loading branch information
1 parent
821a88c
commit 278de7a
Showing
3 changed files
with
31 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use ethereum_consensus::crypto::SecretKey; | ||
use rand; | ||
use revm_primitives::hex; | ||
|
||
pub fn generate_random_bls_address() -> String { | ||
let mut rng = rand::thread_rng(); | ||
let sk = SecretKey::random(&mut rng).unwrap(); | ||
let pk = sk.public_key(); | ||
let raw_bytes = pk.as_ref(); | ||
hex::encode(raw_bytes) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::utils::bls::generate_random_bls_address; | ||
|
||
#[test] | ||
fn test_generate_random_bls_address() { | ||
let bls_address = generate_random_bls_address(); | ||
assert_eq!(bls_address.len(), 96, "BLS address should be of 96 length"); | ||
} | ||
} |
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