repl.it
@anonymous/

AdequateCandidCoolingfan

Nodejs

No description

fork
loading
Files
  • index.js
  • Packager files
  • package-lock.json
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const Bitcoin = require('bitcoinjs-lib');
const Bip39 = require("bip39");
const Bip32 = require("bip32");
const assert = require('assert');

// from https://github.com/trezor/python-mnemonic/blob/master/vectors.json
const testVector = [
  "ffffffffffffffffffffffffffffffff",
  "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong",
  "ac27495480225222079d7be181583751e86f571027b0497b5b5d11218e0a8a13332572917f0f8e5a589620c6f15b11c61dee327651a14c34e18231052e48c069",
  "xprv9s21ZrQH143K2V4oox4M8Zmhi2Fjx5XK4Lf7GKRvPSgydU3mjZuKGCTg7UPiBUD7ydVPvSLtg9hjp7MQTYsW67rZHAXeccqYqrsx8LcXnyd"
];

const MNEMONIC = testVector[1];
const seed = Bip39.mnemonicToSeed(MNEMONIC,"TREZOR");
console.log("Seed =", seed.toString("hex"));
assert(seed.toString("hex") === testVector[2])


const rootNode = Bip32.fromSeed(seed, Bitcoin.networks.bitcoin);
console.log("Bip32 Root key =", rootNode.toBase58());
assert(rootNode.toBase58() === testVector[3]);
console.log("WIF = ", rootNode.toWIF());