From 81c44c605bf290d02976325d587f76669c52a201 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Thu, 12 Jul 2018 11:59:40 -0600 Subject: [PATCH] Add solana-keygen Same as solana-mint, but without a tokens field. --- Cargo.toml | 4 ++++ src/bin/keygen.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/bin/keygen.rs diff --git a/Cargo.toml b/Cargo.toml index 84b7444dccd940..d95aa080786a6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,10 @@ path = "src/bin/wallet.rs" name = "solana-fullnode" path = "src/bin/fullnode.rs" +[[bin]] +name = "solana-keygen" +path = "src/bin/keygen.rs" + [[bin]] name = "solana-fullnode-config" path = "src/bin/fullnode-config.rs" diff --git a/src/bin/keygen.rs b/src/bin/keygen.rs new file mode 100644 index 00000000000000..dba63fb26e76c6 --- /dev/null +++ b/src/bin/keygen.rs @@ -0,0 +1,14 @@ +extern crate ring; +extern crate serde_json; + +use ring::rand::SystemRandom; +use ring::signature::Ed25519KeyPair; +use std::error; + +fn main() -> Result<(), Box> { + let rnd = SystemRandom::new(); + let pkcs8_bytes = Ed25519KeyPair::generate_pkcs8(&rnd)?; + let serialized = serde_json::to_string(&pkcs8_bytes.to_vec())?; + println!("{}", serialized); + Ok(()) +}