Created
May 24, 2019 01:36
-
-
Save max-mapper/1359aa11ce579f4b709f9547f854cf77 to your computer and use it in GitHub Desktop.
slip-0010 hdkey ed25519 derivation from seed in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ehdKey = require("@hawkingnetwork/ed25519-hd-key-rn") | |
var EdDSA = require('elliptic').eddsa | |
// test vector from https://github.com/satoshilabs/slips/blob/master/slip-0010.md | |
var seed = new Buffer('fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542', 'hex') | |
var ed25519 = new EdDSA('ed25519') | |
var derived = ehdKey.derivePath("m/0'/2147483647'", seed.toString('hex')) | |
var keys = ed25519.keyFromSecret(derived.key) | |
// expected test vector outputs | |
// 138f0b2551bcafeca6ff2aa88ba8ed0ed8de070841f0c4ef0165df8181eaad7f | |
// ea4f5bfe8694d8bb74b7b59404632fd5968b774ed545e810de9c32a4fb4192f4 | |
// 005ba3b9ac6e90e83effcd25ac4e58a1365a9e35a3d3ae5eb07b9e4d90bcf7506d | |
console.log(derived.chainCode.toString('hex')) | |
console.log(derived.key.toString('hex')) | |
console.log('00' + new Buffer(keys.getPublic()).toString('hex')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment