-
Notifications
You must be signed in to change notification settings - Fork 2
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
Derive the threshold account keypair and x25519 keypair from mnemonic using HKDF #709
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need more clarity on the changing keys in the chain_spec, other than that looks good
} | ||
|
||
/// For testing where we sometimes don't have access to the kvdb, derive directly from the mnemnic | ||
#[cfg(test)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move this to the bottom of the file plz
@@ -63,17 +63,17 @@ pub mod tss_account_id { | |||
/// The `DEFAULT_ALICE_MNEMONIC` is used to derive the following `AccountId`. | |||
/// Mnemonic: "alarm mutual concert decrease hurry invest culture survey diagram crash snap click" | |||
pub static ref ALICE: sp_runtime::AccountId32 = | |||
super::hex!["e0543c102def9f6ef0e8b8ffa31aa259167a9391566929fd718a1ccdaabdb876"].into(); | |||
super::hex!["306bdb49cbbe7104e3621abab3c9d31698b159f48dafe567abb7ea5d872ed329"].into(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get why the others are changing but why are these changing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They change because we now use the mnemonic as input for the key derivation function, and derive the sr25519 keypair from it. This means we can still recover both sr25519 and x25519 keypairs from the same mnemonic. We could keep these the same by continuing to use sr25519::Pair::from_phrase
and also using the mnemonic as input to HKDF. But i'm not sure whether the auditors would like it.
let sig_recovery = <sr25519::Pair as Pair>::verify( | ||
&signing_result.clone().unwrap().1, | ||
BASE64_STANDARD.decode(signing_result.unwrap().0).unwrap(), | ||
&sr25519::Public(sk.public().0), | ||
&sr25519::Public(TSS_ACCOUNTS[i].0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh ya, this is way less hacky lol
@@ -24,25 +24,37 @@ lazy_static! { | |||
pub static ref BOB_STASH_ADDRESS: AccountId32 = | |||
hex!["fe65717dad0447d715f660a0a58411de509b42e6efb8375f562f58a554d5860e"].into(); // subkey inspect //Bob//stash | |||
pub static ref TSS_ACCOUNTS: Vec<AccountId32> = vec![ | |||
hex!["e0543c102def9f6ef0e8b8ffa31aa259167a9391566929fd718a1ccdaabdb876"].into(), | |||
hex!["2a8200850770290c7ea3b50a8ff64c6761c882ff8393dc95fccb5d1475eff17f"].into() | |||
hex!["306bdb49cbbe7104e3621abab3c9d31698b159f48dafe567abb7ea5d872ed329"].into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean same here, why are these changing
]; | ||
pub static ref X25519_PUBLIC_KEYS: Vec<[u8; 32]> = vec![ | ||
vec![ | ||
10, 192, 41, 240, 184, 83, 178, 59, 237, 101, 45, 109, 13, 230, 155, 124, 195, 141, | ||
148, 249, 55, 50, 238, 252, 133, 181, 134, 30, 144, 247, 58, 34, | ||
8, 22, 19, 230, 107, 217, 249, 190, 14, 142, 155, 252, 156, 229, 120, 11, 180, 35, 83, 245, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually now that I think about it, these should not change either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These one change because they are also now derived from the mnemonic. Before they were derived from the hash of the sr25519 secret key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok this makes sense I now understand this, but not the account IDs
This addresses TOB-ENTROPY-13 by deriving both sr25519 and x25519 keypairs from a common secret, rather than one from the other.
It uses HKDF. TLDR - take a look at the functions in
helpers/validator
- that is the important thing thats changed.