Skip to content

Commit

Permalink
chore: switch key type from ed25519 to secp256k1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma233 committed Aug 19, 2024
1 parent 4074899 commit 7c1d52a
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 21 deletions.
160 changes: 145 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async-trait = "0.1.81"
clap = "4.5.4"
futures = "0.3.30"
hex = "0.4.3"
libp2p = { version = "0.53.2", features = ["tokio", "macros", "yamux", "noise", "tcp", "request-response", "relay"] }
libp2p = { version = "0.53.2", features = ["tokio", "macros", "yamux", "noise", "tcp", "request-response", "relay", "secp256k1"] }
prost = "0.13.1"
reqwest = { version = "0.12.5", features = ["json", "rustls-tls"], default-features = false }
serde = { version = "1.0.207", features = ["derive"] }
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn parse_args() -> Command {
.long("key")
.num_args(1)
.action(ArgAction::Set)
.help("Ed25519 key. If not set, a random key will be generated"),
.help("Secp256k1 key. If not set, a random key will be generated"),
)
.arg(
Arg::new("SERVER_ADDR")
Expand Down Expand Up @@ -118,12 +118,12 @@ async fn serve(args: &ArgMatches) {
let key = args
.get_one::<String>("KEY")
.map(|key| {
identity::ed25519::SecretKey::try_from_bytes(hex::decode(key).expect("Invalid key"))
identity::secp256k1::SecretKey::try_from_bytes(hex::decode(key).expect("Invalid key"))
.expect("Invalid key")
})
.unwrap_or_else(|| {
let key = identity::ed25519::SecretKey::generate();
println!("Generated key: {}", hex::encode(&key));
let key = identity::secp256k1::SecretKey::generate();
println!("Generated key: {}", hex::encode(key.to_bytes()));
key
});
let server_addr = args
Expand All @@ -147,7 +147,7 @@ async fn serve(args: &ArgMatches) {
println!("commander_server_addr: {}", commander_server_addr);

let (pproxy, pproxy_handle) = PProxy::new(
identity::ed25519::Keypair::from(key).into(),
identity::secp256k1::Keypair::from(key).into(),
server_addr,
proxy_addr,
access_server_endpoint,
Expand Down

0 comments on commit 7c1d52a

Please sign in to comment.