Skip to content

Commit cc57bd4

Browse files
committed
Add progress on integration
1 parent 9e25d66 commit cc57bd4

36 files changed

+117
-198
lines changed

Cargo.lock

+21-103
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

account_manager/src/upgrade_legacy_keypairs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn upgrade_keypair<P: AsRef<Path>>(
136136
.to_json_writer(&mut file)
137137
.map_err(|e| format!("Cannot write keystore to {:?}: {:?}", keystore_path, e))?;
138138

139-
let password_path = secrets_dir.join(format!("{}", keypair.pk.as_hex_string()));
139+
let password_path = secrets_dir.join(format!("{}", keypair.pk.to_hex_string()));
140140

141141
if password_path.exists() {
142142
return Err(format!("{:?} already exists", password_path));

common/eth2_interop_keypairs/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ lazy_static = "1.4.0"
1111
num-bigint = "0.2.6"
1212
eth2_hashing = "0.1.0"
1313
hex = "0.4.2"
14-
milagro_bls = { git = "https://github.com/sigp/milagro_bls", tag = "v1.1.0" }
1514
serde_yaml = "0.8.11"
1615
serde = "1.0.110"
1716
serde_derive = "1.0.110"
17+
bls = { path = "../../crypto/bls" }
1818

1919
[dev-dependencies]
2020
base64 = "0.12.1"

common/eth2_interop_keypairs/src/lib.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#[macro_use]
2020
extern crate lazy_static;
2121

22+
use bls::{Keypair, PublicKey, SecretKey};
2223
use eth2_hashing::hash;
23-
use milagro_bls::{Keypair, PublicKey, SecretKey};
2424
use num_bigint::BigUint;
2525
use serde_derive::{Deserialize, Serialize};
2626
use std::convert::TryInto;
@@ -58,17 +58,14 @@ pub fn be_private_key(validator_index: usize) -> [u8; PRIVATE_KEY_BYTES] {
5858

5959
/// Return a public and private keypair for a given `validator_index`.
6060
pub fn keypair(validator_index: usize) -> Keypair {
61-
let sk = SecretKey::from_bytes(&be_private_key(validator_index)).unwrap_or_else(|_| {
61+
let sk = SecretKey::deserialize(&be_private_key(validator_index)).unwrap_or_else(|_| {
6262
panic!(
6363
"Should build valid private key for validator index {}",
6464
validator_index
6565
)
6666
});
6767

68-
Keypair {
69-
pk: PublicKey::from_secret_key(&sk),
70-
sk,
71-
}
68+
Keypair::from_components(sk.public_key(), sk)
7269
}
7370

7471
#[derive(Serialize, Deserialize)]
@@ -93,18 +90,18 @@ impl TryInto<Keypair> for YamlKeypair {
9390
let sk = {
9491
let mut bytes = vec![0; PRIVATE_KEY_BYTES - privkey.len()];
9592
bytes.extend_from_slice(&privkey);
96-
SecretKey::from_bytes(&bytes)
93+
SecretKey::deserialize(&bytes)
9794
.map_err(|e| format!("Failed to decode bytes into secret key: {:?}", e))?
9895
};
9996

10097
let pk = {
10198
let mut bytes = vec![0; PUBLIC_KEY_BYTES - pubkey.len()];
10299
bytes.extend_from_slice(&pubkey);
103-
PublicKey::from_bytes(&bytes)
100+
PublicKey::deserialize(&bytes)
104101
.map_err(|e| format!("Failed to decode bytes into public key: {:?}", e))?
105102
};
106103

107-
Ok(Keypair { pk, sk })
104+
Ok(Keypair::from_components(pk, sk))
108105
}
109106
}
110107

common/validator_dir/src/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl<'a> Builder<'a> {
170170
pubkey: voting_keypair.pk.clone().into(),
171171
withdrawal_credentials,
172172
amount,
173-
signature: Signature::empty_signature().into(),
173+
signature: Signature::empty().into(),
174174
};
175175

176176
deposit_data.signature = deposit_data.create_signature(&voting_keypair.sk, &spec);
@@ -220,7 +220,7 @@ impl<'a> Builder<'a> {
220220
// Write the withdrawal password to file.
221221
write_password_to_file(
222222
self.password_dir
223-
.join(withdrawal_keypair.pk.as_hex_string()),
223+
.join(withdrawal_keypair.pk.to_hex_string()),
224224
withdrawal_password.as_bytes(),
225225
)?;
226226

common/validator_dir/src/manager.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ impl Manager {
107107
info!(
108108
log,
109109
"Decrypted validator keystore";
110-
"voting_pubkey" => kp.pk.as_hex_string()
110+
"voting_pubkey" => kp.pk.to_hex_string()
111111
);
112112
if lockfile_existed {
113113
warn!(
114114
log,
115115
"Lockfile already existed";
116116
"msg" => "ensure no other validator client is running on this host",
117-
"voting_pubkey" => kp.pk.as_hex_string()
117+
"voting_pubkey" => kp.pk.to_hex_string()
118118
);
119119
}
120120
}
@@ -147,7 +147,7 @@ impl Manager {
147147
info!(
148148
log,
149149
"Decrypted validator keystore";
150-
"voting_pubkey" => kp.pk.as_hex_string()
150+
"voting_pubkey" => kp.pk.to_hex_string()
151151
)
152152
}
153153
(kp, v)

0 commit comments

Comments
 (0)