-
Notifications
You must be signed in to change notification settings - Fork 0
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
HD derivation: add ed25519 support #9
Conversation
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
CI isn't working due to new org settings. Hopefully that will be soon fixed. |
Signed-off-by: Denis Varlakov <[email protected]>
@maurges this is PR for using new |
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
/// Derives an HD child key using `HdAlgo` algorithm | ||
/// | ||
/// It's not desirable to use this function. In the tests, we should rather use other libraries | ||
/// from what we use in `givre` implementation itself. However, not all derivation methods have | ||
/// other libraries than `hd_wallet` | ||
pub fn derive_child_key<E: Curve, HdAlgo: givre::hd_wallet::HdWallet<E>>( |
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.
Why don't we use libraries native derivations for those that support it? Also I'm not sure I understand this comment correctly: it means that some derivations methods (like Edwards) don't have alternative implementations other than our one?
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.
Ah, I see we already do use external libraries's derivations where possible
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.
it means that some derivations methods (like Edwards) don't have alternative implementations other than our one?
Yes exactly
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.
Well, there's one but in C
#[cfg(feature = "hd-wallet")] | ||
pub fn derive_additive_shift<E: generic_ec::Curve, Hd: hd_wallet::DeriveShift<E>, Index>( | ||
mut epub: hd_wallet::ExtendedPublicKey<E>, | ||
path: impl IntoIterator<Item = Index>, | ||
) -> Result<Scalar<E>, <Index as TryInto<slip_10::NonHardenedIndex>>::Error> | ||
) -> Result<Scalar<E>, <Index as TryInto<hd_wallet::NonHardenedIndex>>::Error> | ||
where | ||
slip_10::NonHardenedIndex: TryFrom<Index>, | ||
hd_wallet::NonHardenedIndex: TryFrom<Index>, | ||
{ | ||
let mut additive_shift = Scalar::<E>::zero(); | ||
|
||
for child_index in path { | ||
let child_index: slip_10::NonHardenedIndex = child_index.try_into()?; | ||
let shift = slip_10::derive_public_shift(&epub, child_index); | ||
let child_index: hd_wallet::NonHardenedIndex = child_index.try_into()?; | ||
let shift = Hd::derive_public_shift(&epub, child_index); |
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.
Well, the api of hd_wallet library looks good here. It's what we build on top of it that I want to complain about, with my usual song about <Hd,_ >
signatures. =) But since it's completely internal, I'll let it be
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.
There's no <Hd, _>
though, is there?
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.
Ah the functions that use this function might have underscores, right. It's a feature of Rust, difficult to avoid it
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.
There's no <Hd, _> though, is there?
Not here, but in usage of this function I mean
Looks good |
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
Signed-off-by: Denis Varlakov <[email protected]>
@maurges I updated the deps |
No description provided.