-
Notifications
You must be signed in to change notification settings - Fork 25
feat(keysplit): Split multiple validator keys into one file #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: unstable
Are you sure you want to change the base?
Changes from 8 commits
036ba55
6f28556
496c980
596ac3b
db11848
fc26113
18fffcf
f8de81f
efb5b1a
908a362
09714b6
802098b
3936fef
0269b07
c1eee10
fbb25e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,10 +65,11 @@ pub struct Manual { | |
| pub struct SharedKeygenOptions { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something I thought of is that we should probably adjust our cli names here to match their docs https://docs.ssv.network/stakers/tools/ssv-keys-cli/
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of our flags function differently, e.g. My point is that matching the names (IMO) only has value if we also match the behavior. |
||
| #[clap( | ||
| long, | ||
| help = "Path to the validator keystore file", | ||
| help = "Path(s) to the validator keystore file", | ||
dknopik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| num_args = 1.., | ||
| value_name = "PATH" | ||
| )] | ||
| pub keystore_path: String, | ||
| pub keystore_paths: Vec<String>, | ||
|
|
||
| #[clap( | ||
| long, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,12 @@ use bls_lagrange::{KeyId, split}; | |
| use openssl::{encrypt::Encrypter, pkey::PKey}; | ||
| use types::SecretKey; | ||
|
|
||
| use crate::{EncryptedKeyShare, KeyShare, KeysplitError, cli::SharedKeygenOptions}; | ||
| use crate::{EncryptedKeyShare, KeyShare, KeysplitError, cli::SharedKeygenOptions, split::Split}; | ||
|
|
||
| // Given a secret key, split it into parts | ||
| pub fn split_keys( | ||
| pub fn split_key( | ||
| shared: &SharedKeygenOptions, | ||
| sk: SecretKey, | ||
| sk: &SecretKey, | ||
| ) -> Result<Vec<(KeyId, SecretKey)>, KeysplitError> { | ||
| let num_operators = shared.operators.0.len(); | ||
| let threshold = num_operators - ((num_operators - 1) / 3); | ||
|
|
@@ -19,15 +19,16 @@ pub fn split_keys( | |
| .iter() | ||
| .map(|id| KeyId::try_from(*id).unwrap()); | ||
dknopik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
dknopik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| split(&sk, threshold as u64, key_ids) | ||
| split(sk, threshold as u64, key_ids) | ||
| .map_err(|e| KeysplitError::SplitFailure(format!("Failed to split key: {e:?}"))) | ||
| } | ||
|
|
||
| // Encrypt the keyshare with the operators rsa public key | ||
| pub fn encrypt_keyshares( | ||
| key_shares: Vec<KeyShare>, | ||
| ) -> Result<Vec<EncryptedKeyShare>, KeysplitError> { | ||
| key_shares | ||
| split: Split<KeyShare>, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, it's not clear to me what the difference between
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a comment |
||
| ) -> Result<Split<EncryptedKeyShare>, KeysplitError> { | ||
| let key_shares = split | ||
| .key_shares | ||
| .into_iter() | ||
| .map(|share| { | ||
| let pkey = PKey::from_rsa(share.public_key.clone()) | ||
|
|
@@ -58,5 +59,10 @@ pub fn encrypt_keyshares( | |
| share_public_key: share.keyshare.public_key(), | ||
| }) | ||
| }) | ||
| .collect() | ||
| .collect::<Result<Vec<_>, _>>()?; | ||
|
|
||
| Ok(Split { | ||
| nonce: split.nonce, | ||
| key_shares, | ||
| }) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.