From 33305dc7c8ea4df817fa576db05c565823e5a949 Mon Sep 17 00:00:00 2001 From: KaoImin Date: Wed, 13 Dec 2023 11:22:02 +0800 Subject: [PATCH] remove outdated code --- Cargo.lock | 75 ++------------------------ Cargo.toml | 1 - devtools/keypair/Cargo.toml | 16 ------ devtools/keypair/src/keypair.yml | 18 ------- devtools/keypair/src/main.rs | 91 -------------------------------- 5 files changed, 5 insertions(+), 196 deletions(-) delete mode 100644 devtools/keypair/Cargo.toml delete mode 100644 devtools/keypair/src/keypair.yml delete mode 100644 devtools/keypair/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index fadf3b4c6..532ed6c44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,15 +120,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "0.6.4" @@ -284,19 +275,6 @@ dependencies = [ "core-run", ] -[[package]] -name = "axon-keypair" -version = "0.2.1" -dependencies = [ - "axon-protocol", - "clap 2.34.0", - "common-crypto", - "rand 0.7.3", - "serde", - "serde_json", - "tentacle-secio", -] - [[package]] name = "axon-protocol" version = "0.1.0" @@ -1391,22 +1369,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap 0.11.0", - "unicode-width", - "vec_map", - "yaml-rust 0.3.5", -] - [[package]] name = "clap" version = "3.2.25" @@ -1419,9 +1381,9 @@ dependencies = [ "clap_lex 0.2.4", "indexmap 1.9.3", "once_cell", - "strsim 0.10.0", + "strsim", "termcolor", - "textwrap 0.16.0", + "textwrap", ] [[package]] @@ -1443,7 +1405,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex 0.5.0", - "strsim 0.10.0", + "strsim", ] [[package]] @@ -2300,7 +2262,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim", "syn 1.0.109", ] @@ -6576,7 +6538,7 @@ dependencies = [ "indexmap 1.9.3", "ryu", "serde", - "yaml-rust 0.4.5", + "yaml-rust", ] [[package]] @@ -6815,12 +6777,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "913e7b03d63752f6cdd2df77da36749d82669904798fe8944b9ec3d23f159905" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.10.0" @@ -7122,15 +7078,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "textwrap" version = "0.16.0" @@ -7812,12 +7759,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" @@ -8236,12 +8177,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "yaml-rust" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" - [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/Cargo.toml b/Cargo.toml index 5ed3c0b5c..7e849071f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,6 @@ members = [ "core/storage", "devtools/abi-generator", "devtools/axon-tools", - "devtools/keypair", "protocol", ] diff --git a/devtools/keypair/Cargo.toml b/devtools/keypair/Cargo.toml deleted file mode 100644 index bcbdf57f1..000000000 --- a/devtools/keypair/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "axon-keypair" -version = "0.2.1" -edition = "2021" -include = ["Cargo.toml", "src/*"] -license = "MIT" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -clap = { version = "2.33", features = ["yaml"] } -common-crypto ={ path = "../../common/crypto" } -protocol = { path = "../../protocol", package = "axon-protocol" } -rand = "0.7" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -tentacle-secio = "0.6" diff --git a/devtools/keypair/src/keypair.yml b/devtools/keypair/src/keypair.yml deleted file mode 100644 index 08736ef54..000000000 --- a/devtools/keypair/src/keypair.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: axon_keypair -version: "0.1" -about: a tool to generate keypairs for axon -author: axon Dev - -args: - - number: - help: Number of keypairs to generate - short: n - long: number - default_value: "4" - - - private-key-path: - help: The path to save net and bls private key binary - short: p - long: path - takes_value: true - default_value: "private-binary" diff --git a/devtools/keypair/src/main.rs b/devtools/keypair/src/main.rs deleted file mode 100644 index b00eee442..000000000 --- a/devtools/keypair/src/main.rs +++ /dev/null @@ -1,91 +0,0 @@ -#[macro_use] -extern crate clap; - -use std::{convert::TryFrom, fs, path::PathBuf}; - -use clap::App; -use common_crypto::{BlsPrivateKey, PrivateKey, PublicKey, Secp256k1PrivateKey, ToBlsPublicKey}; -use protocol::{codec::hex_encode, types::Address}; -use rand::rngs::OsRng; -use serde::Serialize; -use tentacle_secio::SecioKeyPair; - -#[derive(Default, Serialize, Debug)] -struct Keypair { - pub index: usize, - pub net_private_key: String, - pub public_key: String, - pub address: String, - pub peer_id: String, - pub bls_private_key: String, - pub bls_public_key: String, -} - -#[derive(Default, Serialize, Debug)] -struct Output { - #[serde(skip)] - pub common_ref: String, - pub keypairs: Vec, -} - -#[allow(clippy::needless_range_loop, clippy::uninlined_format_args)] -pub fn main() { - let yml = load_yaml!("keypair.yml"); - let m = App::from(yml).get_matches(); - let number = value_t!(m, "number", usize).unwrap(); - let path = value_t!(m, "private-key-path", String).unwrap(); - let path = PathBuf::from(path); - let _ = fs::create_dir(path.clone()); - - let mut output = Output { - common_ref: add_0x(String::from("0")), - keypairs: vec![], - }; - - for i in 0..number { - let mut k = Keypair::default(); - let bls_seckey = BlsPrivateKey::generate(&mut OsRng).to_bytes(); - let net_seckey = Secp256k1PrivateKey::generate(&mut OsRng).to_bytes(); - - let keypair = SecioKeyPair::secp256k1_raw_key(&net_seckey).unwrap(); - let pubkey = keypair.public_key().inner(); - let address = Address::from_pubkey_bytes(pubkey.clone()).unwrap(); - - k.net_private_key = add_0x(hex_encode(net_seckey.as_ref())); - k.public_key = add_0x(hex_encode(pubkey)); - k.peer_id = keypair.public_key().peer_id().to_base58(); - k.address = add_0x(hex_encode(address.as_slice())); - - let bls_priv_key = BlsPrivateKey::try_from(bls_seckey.as_ref()).unwrap(); - let bls_pub_key = bls_priv_key.pub_key(&output.common_ref); - k.bls_private_key = add_0x(hex_encode(bls_seckey.as_ref())); - k.bls_public_key = add_0x(hex_encode(bls_pub_key.to_bytes())); - k.index = i; - output.keypairs.push(k); - - write_private_key(path.clone(), bls_seckey.to_vec(), true, i); - write_private_key(path.clone(), net_seckey.to_vec(), false, i); - } - let output_str = serde_json::to_string_pretty(&output).unwrap(); - println!("{}", output_str); -} - -fn add_0x(s: String) -> String { - "0x".to_owned() + &s -} - -fn write_private_key(mut path: PathBuf, key: Vec, is_bls: bool, index: usize) { - use std::fs::File; - use std::io::Write; - - if is_bls { - let file_name = format!("bls_{}.key", index); - path.push(file_name); - } else { - let file_name = format!("net_{}.key", index); - path.push(file_name); - } - - let mut file = File::create(path).unwrap(); - file.write_all(&key).unwrap(); -}