From 2e7cd451ecd461acfc17ffe93a29d564cbc06fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Thu, 18 Mar 2021 15:05:32 +0000 Subject: [PATCH] Feature/mix contract identity key (#533) * Added identity_key field to mixnodes * Printing out required bond information on mixnode startup --- clients/validator/src/types.ts | 1 + common/mixnet-contract/src/lib.rs | 4 ++++ contracts/mixnet/src/support/tests.rs | 2 ++ mixnode/src/commands/run.rs | 25 +++++++++++++++++-------- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/clients/validator/src/types.ts b/clients/validator/src/types.ts index e7245a0bbd..d753e047cc 100644 --- a/clients/validator/src/types.ts +++ b/clients/validator/src/types.ts @@ -12,6 +12,7 @@ export type MixNode = { layer: number, location: string, sphinx_key: string, // TODO: camelCase this later once everything else works + identity_key: string, version: string, } diff --git a/common/mixnet-contract/src/lib.rs b/common/mixnet-contract/src/lib.rs index b91a76443c..c32f358fa9 100644 --- a/common/mixnet-contract/src/lib.rs +++ b/common/mixnet-contract/src/lib.rs @@ -9,6 +9,8 @@ pub struct MixNode { pub(crate) layer: u64, pub(crate) location: String, pub(crate) sphinx_key: String, + /// Base58 encoded ed25519 EdDSA public key. + pub(crate) identity_key: String, pub(crate) version: String, } @@ -18,6 +20,7 @@ impl MixNode { layer: u64, location: String, sphinx_key: String, + identity_key: String, version: String, ) -> Self { MixNode { @@ -25,6 +28,7 @@ impl MixNode { layer, location, sphinx_key, + identity_key, version, } } diff --git a/contracts/mixnet/src/support/tests.rs b/contracts/mixnet/src/support/tests.rs index b83f8565b4..d8e135e902 100644 --- a/contracts/mixnet/src/support/tests.rs +++ b/contracts/mixnet/src/support/tests.rs @@ -89,6 +89,7 @@ pub mod helpers { 1, "Sweden".to_string(), "sphinx".to_string(), + "identity".to_string(), "0.10.0".to_string(), ) } @@ -99,6 +100,7 @@ pub mod helpers { 1, "London".to_string(), "1234".to_string(), + "aaaa".to_string(), "0.10.0".to_string(), ); MixNodeBond::new(coins(50, "unym"), HumanAddr::from("foo"), mix_node) diff --git a/mixnode/src/commands/run.rs b/mixnode/src/commands/run.rs index 6c27287951..17c6c9d6de 100644 --- a/mixnode/src/commands/run.rs +++ b/mixnode/src/commands/run.rs @@ -92,10 +92,6 @@ fn load_identity_keys(pathfinder: &MixNodePathfinder) -> identity::KeyPair { pathfinder.public_identity_key().to_owned(), )) .expect("Failed to read stored identity key files"); - println!( - "Public identity key: {}\n", - identity_keypair.public_key().to_base58_string() - ); identity_keypair } @@ -105,10 +101,6 @@ fn load_sphinx_keys(pathfinder: &MixNodePathfinder) -> encryption::KeyPair { pathfinder.public_encryption_key().to_owned(), )) .expect("Failed to read stored sphinx key files"); - println!( - "Public sphinx key: {}\n", - sphinx_keypair.public_key().to_base58_string() - ); sphinx_keypair } @@ -178,5 +170,22 @@ pub fn execute(matches: &ArgMatches) { config.get_announce_address() ); + println!( + "\nTo bond your mixnode you will need to provide the following: + Identity key: {} + Sphinx key: {} + Host: {} + Layer: {} + Location: {} + Version: {} + ", + identity_keypair.public_key().to_base58_string(), + sphinx_keypair.public_key().to_base58_string(), + config.get_announce_address(), + config.get_layer(), + config.get_location(), + config.get_version(), + ); + MixNode::new(config, identity_keypair, sphinx_keypair).run(); }