Skip to content

Commit

Permalink
hdkeychain: Add new test vector 3 tests.
Browse files Browse the repository at this point in the history
This adds the new test vectors added to BIP32 on 2017-02-24 which test
hardened derivation with leading zeros.
  • Loading branch information
davecgh committed May 10, 2017
1 parent 1fb0120 commit 66871da
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hdkeychain/extendedkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestBIP0032Vectors(t *testing.T) {
// The master seeds for each of the two test vectors in [BIP32].
testVec1MasterHex := "000102030405060708090a0b0c0d0e0f"
testVec2MasterHex := "fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542"
testVec3MasterHex := "4b381541583be4423346c643850da4b320e46a87ae3d2a4e6da11eba819cd4acba45d239319ac14f863b8d5ab5a0d0c64d2e8a1e7d1457df2e5a3c51c73235be"
hkStart := uint32(0x80000000)

tests := []struct {
Expand Down Expand Up @@ -135,6 +136,24 @@ func TestBIP0032Vectors(t *testing.T) {
net: &chaincfg.MainNetParams,
},

// Test vector 3
{
name: "test vector 3 chain m",
master: testVec3MasterHex,
path: []uint32{},
wantPub: "xpub661MyMwAqRbcEZVB4dScxMAdx6d4nFc9nvyvH3v4gJL378CSRZiYmhRoP7mBy6gSPSCYk6SzXPTf3ND1cZAceL7SfJ1Z3GC8vBgp2epUt13",
wantPriv: "xprv9s21ZrQH143K25QhxbucbDDuQ4naNntJRi4KUfWT7xo4EKsHt2QJDu7KXp1A3u7Bi1j8ph3EGsZ9Xvz9dGuVrtHHs7pXeTzjuxBrCmmhgC6",
net: &chaincfg.MainNetParams,
},
{
name: "test vector 3 chain m/0H",
master: testVec3MasterHex,
path: []uint32{hkStart},
wantPub: "xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y",
wantPriv: "xprv9uPDJpEQgRQfDcW7BkF7eTya6RPxXeJCqCJGHuCJ4GiRVLzkTXBAJMu2qaMWPrS7AANYqdq6vcBcBUdJCVVFceUvJFjaPdGZ2y9WACViL4L",
net: &chaincfg.MainNetParams,
},

// Test vector 1 - Testnet
{
name: "test vector 1 chain m - testnet",
Expand Down

0 comments on commit 66871da

Please sign in to comment.