Skip to content

Commit

Permalink
feat(iota-keys): Support the Shimmer coin type for the derivation pat…
Browse files Browse the repository at this point in the history
…h validation (#1742)

* feat(iota-keys): support Shimmer coin type for derivation path validation

* fix(iota-keys): comment
  • Loading branch information
miker83z authored Aug 13, 2024
1 parent fc4678f commit b6ce1cc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/iota-keys/src/key_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use iota_types::{
use slip10_ed25519::derive_ed25519_private_key;

pub const DERIVATION_PATH_COIN_TYPE: u32 = 4218;
pub const DERIVATION_PATH_COIN_TYPE_SHIMMER: u32 = 4219;
pub const DERVIATION_PATH_PURPOSE_ED25519: u32 = 44;
pub const DERVIATION_PATH_PURPOSE_SECP256K1: u32 = 54;
pub const DERVIATION_PATH_PURPOSE_SECP256R1: u32 = 74;
Expand Down Expand Up @@ -78,12 +79,16 @@ pub fn validate_path(
match path {
Some(p) => {
// The derivation path must be hardened at all levels with purpose = 44,
// coin_type = 4218
// coin_type = 4218 (coin_type = 4219 is valid too, in order to allow Shimmer
// addresses)
if let &[purpose, coin_type, account, change, address] = p.as_ref() {
if Some(purpose)
== ChildNumber::new(DERVIATION_PATH_PURPOSE_ED25519, true).ok()
&& Some(coin_type)
&& (Some(coin_type)
== ChildNumber::new(DERIVATION_PATH_COIN_TYPE, true).ok()
|| Some(coin_type)
== ChildNumber::new(DERIVATION_PATH_COIN_TYPE_SHIMMER, true)
.ok())
&& account.is_hardened()
&& change.is_hardened()
&& address.is_hardened()
Expand Down

0 comments on commit b6ce1cc

Please sign in to comment.