-
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.
feat: Added tool to recover public keys from secret keys (#224)
- Loading branch information
1 parent
8a49824
commit f1522f8
Showing
2 changed files
with
45 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//! This tool calculates a node/validator public key from its corresponding secret key and prints it to stdout. | ||
#![allow(clippy::print_stdout)] | ||
|
||
use crypto::TextFmt as _; | ||
use std::io; | ||
use zksync_consensus_crypto as crypto; | ||
use zksync_consensus_roles::{node, validator}; | ||
|
||
/// This tool calculates a node/validator public key from its corresponding secret key and prints it to stdout. | ||
fn main() { | ||
println!("Please enter the node secret key (don't trim the identifiers at the beginning) or leave empty to skip:"); | ||
|
||
let mut input = String::new(); | ||
|
||
io::stdin() | ||
.read_line(&mut input) | ||
.expect("Failed to read line"); | ||
|
||
let input = input.trim(); | ||
|
||
if !input.is_empty() { | ||
let text = crypto::Text::new(input); | ||
let secret_key = node::SecretKey::decode(text).expect("Failed to decode the secret key"); | ||
println!("{}", secret_key.public().encode()); | ||
} | ||
|
||
println!("Please enter the validator secret key (don't trim the identifiers at the beginning) or leave empty to skip:"); | ||
|
||
let mut input = String::new(); | ||
|
||
io::stdin() | ||
.read_line(&mut input) | ||
.expect("Failed to read line"); | ||
|
||
let input = input.trim(); | ||
|
||
if !input.is_empty() { | ||
let text = crypto::Text::new(input); | ||
let secret_key = | ||
validator::SecretKey::decode(text).expect("Failed to decode the secret key"); | ||
println!("{}", secret_key.public().encode()); | ||
} | ||
} |