Skip to content

Commit

Permalink
fix: Fix derivation path (#2672)
Browse files Browse the repository at this point in the history
* Fix derivation path

* Update known seed for test

Co-authored-by: Linwei Shang <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 10, 2022
1 parent 8e67974 commit ce9ac3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions e2e/tests-dfx/identity_command.bash
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ XXX
}

@test "identity: consistently imports a known seed phrase" {
echo "hollow damage this yard journey anchor tool fat action school cash ridge oval beef tribe magnet apology cabbage leisure group sign around object exact">seed.txt
echo "display dawn estate night naive stomach receive lock expose boring square boy deposit mistake volume soldier coil rocket match diamond repair opinion action paddle">seed.txt
assert_command dfx identity import alice --seed-file seed.txt --disable-encryption
assert_command dfx identity get-principal --identity alice
assert_eq "zs7ty-uv4vo-rvgkk-srfjo-hjaxr-w55wx-ybo5x-qx7k3-noknf-wzwe5-pqe"
assert_eq "qimd7-lqrvx-kdvsm-7zeqn-bgoix-ukjfi-hgmfg-ur2he-odgb2-joms4-nae"
}
2 changes: 1 addition & 1 deletion src/dfx/src/lib/identity/identity_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ pub(super) fn generate_key() -> DfxResult<(Vec<u8>, Mnemonic)> {
}

pub fn mnemonic_to_key(mnemonic: &Mnemonic) -> DfxResult<SecretKey> {
const DEFAULT_DERIVATION_PATH: &str = "m/44'/60'/0'/0/0";
const DEFAULT_DERIVATION_PATH: &str = "m/44'/223'/0'/0/0";
let seed = Seed::new(mnemonic, "");
let pk = XPrv::derive_from_path(seed.as_bytes(), &DEFAULT_DERIVATION_PATH.parse()?)?;
Ok(SecretKey::from(pk.private_key()))
Expand Down

0 comments on commit ce9ac3d

Please sign in to comment.