Skip to content

Commit

Permalink
crypto: Load keypairs from file path (MystenLabs#7011)
Browse files Browse the repository at this point in the history
tested with 
```
cargo build --bin sui
target/debug/sui genesis -f
target/debug/sui start 
```
  • Loading branch information
joyqvq authored Dec 30, 2022
1 parent 5ad8e2a commit aa5fe5b
Show file tree
Hide file tree
Showing 16 changed files with 698 additions and 455 deletions.
587 changes: 293 additions & 294 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ move-prover-boogie-backend = { git = "https://github.com/move-language/move", re
move-stackless-bytecode = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }
move-symbol-pool = { git = "https://github.com/move-language/move", rev = "265e8792ff2935db8246ddb308b36b893d507851" }

fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "2dcf24facddfd15e83325ab714e3b6cb9cd63afe" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "2dcf24facddfd15e83325ab714e3b6cb9cd63afe", package = "fastcrypto-zkp" }
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "8d07cc5a60856163829911e5aeedede35e90174a" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "8d07cc5a60856163829911e5aeedede35e90174a", package = "fastcrypto-zkp" }

# anemo dependencies
anemo = { git = "https://github.com/mystenlabs/anemo.git", rev = "ccfb77628ec1883121079f1ae9c65e9c716709c8" }
Expand Down
1 change: 1 addition & 0 deletions crates/sui-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ narwhal-crypto = { path = "../../narwhal/crypto" }
sui-framework = { path = "../sui-framework" }
sui-adapter = { path = "../sui-adapter" }
sui-types = { path = "../sui-types" }
sui-keys = { path = "../sui-keys" }
workspace-hack.workspace = true

[target.'cfg(msim)'.dependencies]
Expand Down
8 changes: 8 additions & 0 deletions crates/sui-config/data/fullnode-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ enable-event-processing: true
genesis:
# Update this to the location of where the genesis file is stored
genesis-file-location: "genesis.blob"
protocol-key-pair:
path: "protocol.key"
network-key-pair:
path: "network.key"
account-key-pair:
path: "account.key"
worker-key-pair:
path: "worker.key"
18 changes: 11 additions & 7 deletions crates/sui-config/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::node::default_checkpoints_per_epoch;
use crate::node::{default_checkpoints_per_epoch, AuthorityKeyPairWithPath, KeyPairWithPath};
use crate::{
genesis,
genesis_config::{GenesisConfig, ValidatorConfigInfo, ValidatorGenesisInfo},
Expand All @@ -16,7 +16,6 @@ use rand::rngs::OsRng;
use std::{
num::NonZeroUsize,
path::{Path, PathBuf},
sync::Arc,
};
use sui_types::crypto::{
generate_proof_of_possession, get_key_pair_from_rng, AccountKeyPair, AuthorityKeyPair,
Expand Down Expand Up @@ -309,10 +308,16 @@ impl<R: rand::RngCore + rand::CryptoRng> ConfigBuilder<R> {
};

NodeConfig {
protocol_key_pair: Arc::new(validator.genesis_info.key_pair),
worker_key_pair: Arc::new(validator.genesis_info.worker_key_pair),
account_key_pair: Arc::new(validator.genesis_info.account_key_pair),
network_key_pair: Arc::new(validator.genesis_info.network_key_pair),
protocol_key_pair: AuthorityKeyPairWithPath::new(
validator.genesis_info.key_pair,
),
network_key_pair: KeyPairWithPath::new(SuiKeyPair::Ed25519(
validator.genesis_info.network_key_pair,
)),
account_key_pair: KeyPairWithPath::new(validator.genesis_info.account_key_pair),
worker_key_pair: KeyPairWithPath::new(SuiKeyPair::Ed25519(
validator.genesis_info.worker_key_pair,
)),
db_path,
network_address,
metrics_address: utils::available_local_socket_address(),
Expand All @@ -332,7 +337,6 @@ impl<R: rand::RngCore + rand::CryptoRng> ConfigBuilder<R> {
}
})
.collect();

NetworkConfig {
validator_configs,
genesis,
Expand Down
Loading

0 comments on commit aa5fe5b

Please sign in to comment.