rosetta-client
rosetta-client copied to clipboard
Wrong address from private key
import HDKey from 'hdkey';
import { mnemonicToSeedSync } from 'bip39';
import {
address_to_hex,
key_new,
key_to_pub_key,
pub_key_to_address,
seed_from_pem,
} from '@dfinity/rosetta-client';
const seed = mnemonicToSeedSync(
'open jelly jeans corn ketchup supreme brief element armed lens vault weather original scissors rug priority vicious lesson raven spot gossip powder person volcano'
);
//ICP SLIP44
//m/44'/223'/0
const SLIP_PATH = `m/44'/${223}'/0'/0/${0}`;
const node = HDKey.fromMasterSeed(seed);
const childNode = node.derive(SLIP_PATH);
const address = address_to_hex(
pub_key_to_address(key_to_pub_key(key_new(childNode.privateKey)))
);
console.log(address)
//54885152852e8464176ea2199c8f885155483dbb112a7568895387f2c915933e
Address is generated as 54885152852e8464176ea2199c8f885155483dbb112a7568895387f2c915933e when it should be 02f2326544f2040d3985e31db5e7021402c541d3cde911cd20e951852ee4da47
different curve applied to the keypair, in keysmith, uses ecdsa/secp256k1, here uses ed25519. Which would make things vague and causing confusion.