@bsv/sdk 1.1.12 → 1.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/primitives/Point.js +28 -8
  3. package/dist/cjs/src/primitives/Point.js.map +1 -1
  4. package/dist/cjs/src/primitives/Polynomial.js +81 -0
  5. package/dist/cjs/src/primitives/Polynomial.js.map +1 -0
  6. package/dist/cjs/src/primitives/PrivateKey.js +165 -0
  7. package/dist/cjs/src/primitives/PrivateKey.js.map +1 -1
  8. package/dist/cjs/src/primitives/PublicKey.js +16 -2
  9. package/dist/cjs/src/primitives/PublicKey.js.map +1 -1
  10. package/dist/cjs/src/primitives/index.js +5 -1
  11. package/dist/cjs/src/primitives/index.js.map +1 -1
  12. package/dist/cjs/src/primitives/utils.js +1 -1
  13. package/dist/cjs/src/script/templates/P2PKH.js.map +1 -1
  14. package/dist/cjs/src/script/templates/RPuzzle.js.map +1 -1
  15. package/dist/cjs/src/transaction/Transaction.js +9 -4
  16. package/dist/cjs/src/transaction/Transaction.js.map +1 -1
  17. package/dist/cjs/src/transaction/broadcasters/ARC.js +4 -4
  18. package/dist/cjs/src/transaction/broadcasters/ARC.js.map +1 -1
  19. package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
  20. package/dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js +3 -3
  21. package/dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -1
  22. package/dist/cjs/src/transaction/chaintrackers/DefaultChainTracker.js.map +1 -1
  23. package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js +2 -2
  24. package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -1
  25. package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
  26. package/dist/cjs/src/transaction/http/DefaultHttpClient.js +2 -2
  27. package/dist/cjs/src/transaction/http/DefaultHttpClient.js.map +1 -1
  28. package/dist/cjs/src/transaction/http/FetchHttpClient.js +2 -2
  29. package/dist/cjs/src/transaction/http/FetchHttpClient.js.map +1 -1
  30. package/dist/cjs/src/transaction/http/NodejsHttpClient.js +2 -2
  31. package/dist/cjs/src/transaction/http/NodejsHttpClient.js.map +1 -1
  32. package/dist/cjs/src/transaction/http/index.js.map +1 -1
  33. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  34. package/dist/esm/src/primitives/Point.js +28 -8
  35. package/dist/esm/src/primitives/Point.js.map +1 -1
  36. package/dist/esm/src/primitives/Polynomial.js +77 -0
  37. package/dist/esm/src/primitives/Polynomial.js.map +1 -0
  38. package/dist/esm/src/primitives/PrivateKey.js +143 -0
  39. package/dist/esm/src/primitives/PrivateKey.js.map +1 -1
  40. package/dist/esm/src/primitives/PublicKey.js +16 -2
  41. package/dist/esm/src/primitives/PublicKey.js.map +1 -1
  42. package/dist/esm/src/primitives/index.js +2 -1
  43. package/dist/esm/src/primitives/index.js.map +1 -1
  44. package/dist/esm/src/primitives/utils.js +1 -1
  45. package/dist/esm/src/script/templates/P2PKH.js.map +1 -1
  46. package/dist/esm/src/script/templates/RPuzzle.js.map +1 -1
  47. package/dist/esm/src/transaction/Transaction.js +9 -4
  48. package/dist/esm/src/transaction/Transaction.js.map +1 -1
  49. package/dist/esm/src/transaction/broadcasters/ARC.js +7 -7
  50. package/dist/esm/src/transaction/broadcasters/ARC.js.map +1 -1
  51. package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js +1 -1
  52. package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
  53. package/dist/esm/src/transaction/broadcasters/WhatsOnChainBroadcaster.js +4 -4
  54. package/dist/esm/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -1
  55. package/dist/esm/src/transaction/chaintrackers/DefaultChainTracker.js +1 -1
  56. package/dist/esm/src/transaction/chaintrackers/DefaultChainTracker.js.map +1 -1
  57. package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js +3 -3
  58. package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -1
  59. package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
  60. package/dist/esm/src/transaction/http/DefaultHttpClient.js +2 -2
  61. package/dist/esm/src/transaction/http/DefaultHttpClient.js.map +1 -1
  62. package/dist/esm/src/transaction/http/FetchHttpClient.js +2 -2
  63. package/dist/esm/src/transaction/http/FetchHttpClient.js.map +1 -1
  64. package/dist/esm/src/transaction/http/NodejsHttpClient.js +2 -2
  65. package/dist/esm/src/transaction/http/NodejsHttpClient.js.map +1 -1
  66. package/dist/esm/src/transaction/http/index.js.map +1 -1
  67. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  68. package/dist/types/src/primitives/Point.d.ts +19 -1
  69. package/dist/types/src/primitives/Point.d.ts.map +1 -1
  70. package/dist/types/src/primitives/Polynomial.d.ts +32 -0
  71. package/dist/types/src/primitives/Polynomial.d.ts.map +1 -0
  72. package/dist/types/src/primitives/PrivateKey.d.ts +72 -0
  73. package/dist/types/src/primitives/PrivateKey.d.ts.map +1 -1
  74. package/dist/types/src/primitives/PublicKey.d.ts +12 -1
  75. package/dist/types/src/primitives/PublicKey.d.ts.map +1 -1
  76. package/dist/types/src/primitives/index.d.ts +2 -1
  77. package/dist/types/src/primitives/index.d.ts.map +1 -1
  78. package/dist/types/src/primitives/utils.d.ts +1 -1
  79. package/dist/types/src/script/templates/P2PKH.d.ts.map +1 -1
  80. package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
  81. package/dist/types/src/transaction/broadcasters/ARC.d.ts +1 -1
  82. package/dist/types/src/transaction/broadcasters/ARC.d.ts.map +1 -1
  83. package/dist/types/src/transaction/broadcasters/DefaultBroadcaster.d.ts +1 -1
  84. package/dist/types/src/transaction/broadcasters/DefaultBroadcaster.d.ts.map +1 -1
  85. package/dist/types/src/transaction/broadcasters/WhatsOnChainBroadcaster.d.ts +1 -1
  86. package/dist/types/src/transaction/broadcasters/WhatsOnChainBroadcaster.d.ts.map +1 -1
  87. package/dist/types/src/transaction/chaintrackers/DefaultChainTracker.d.ts +1 -1
  88. package/dist/types/src/transaction/chaintrackers/DefaultChainTracker.d.ts.map +1 -1
  89. package/dist/types/src/transaction/chaintrackers/WhatsOnChain.d.ts +2 -2
  90. package/dist/types/src/transaction/chaintrackers/WhatsOnChain.d.ts.map +1 -1
  91. package/dist/types/src/transaction/fee-models/SatoshisPerKilobyte.d.ts.map +1 -1
  92. package/dist/types/src/transaction/http/DefaultHttpClient.d.ts.map +1 -1
  93. package/dist/types/src/transaction/http/FetchHttpClient.d.ts +7 -9
  94. package/dist/types/src/transaction/http/FetchHttpClient.d.ts.map +1 -1
  95. package/dist/types/src/transaction/http/HttpClient.d.ts +5 -5
  96. package/dist/types/src/transaction/http/HttpClient.d.ts.map +1 -1
  97. package/dist/types/src/transaction/http/NodejsHttpClient.d.ts +5 -6
  98. package/dist/types/src/transaction/http/NodejsHttpClient.d.ts.map +1 -1
  99. package/dist/types/src/transaction/http/index.d.ts.map +1 -1
  100. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  101. package/docs/primitives.md +231 -16
  102. package/docs/transaction.md +38 -37
  103. package/package.json +1 -1
  104. package/src/compat/__tests/BSM.test.ts +37 -37
  105. package/src/compat/__tests/ECIES.test.ts +71 -71
  106. package/src/compat/__tests/HD.test.ts +362 -362
  107. package/src/compat/__tests/Mnemonic.test.ts +147 -148
  108. package/src/compat/__tests/Mnemonic.vectors.ts +170 -170
  109. package/src/messages/__tests/EncryptedMessage.test.ts +16 -16
  110. package/src/primitives/Point.ts +29 -10
  111. package/src/primitives/Polynomial.ts +89 -0
  112. package/src/primitives/PrivateKey.ts +147 -1
  113. package/src/primitives/PublicKey.ts +17 -2
  114. package/src/primitives/__tests/AESGCM.test.ts +20 -20
  115. package/src/primitives/__tests/Hash.test.ts +2 -2
  116. package/src/primitives/__tests/PBKDF2.vectors.ts +93 -93
  117. package/src/primitives/__tests/PrivateKey.split.test.ts +70 -0
  118. package/src/primitives/__tests/PublicKey.test.ts +14 -1
  119. package/src/primitives/__tests/bug-31.test.ts +24 -26
  120. package/src/primitives/__tests/utils.test.ts +13 -13
  121. package/src/primitives/index.ts +2 -1
  122. package/src/primitives/utils.ts +1 -1
  123. package/src/script/__tests/Script.test.ts +1 -1
  124. package/src/script/__tests/SpendComplex.test.ts +6 -6
  125. package/src/script/__tests/script.invalid.vectors.ts +1464 -1464
  126. package/src/script/__tests/script.valid.vectors.ts +1962 -1962
  127. package/src/script/__tests/spend.valid.vectors.ts +1369 -1369
  128. package/src/script/templates/P2PKH.ts +6 -6
  129. package/src/script/templates/RPuzzle.ts +1 -1
  130. package/src/transaction/Transaction.ts +13 -7
  131. package/src/transaction/__tests/Transaction.test.ts +14 -5
  132. package/src/transaction/__tests/bump.invalid.vectors.ts +1 -1
  133. package/src/transaction/__tests/bump.valid.vectors.ts +3 -3
  134. package/src/transaction/broadcasters/ARC.ts +20 -21
  135. package/src/transaction/broadcasters/DefaultBroadcaster.ts +3 -3
  136. package/src/transaction/broadcasters/WhatsOnChainBroadcaster.ts +10 -10
  137. package/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.ts +7 -10
  138. package/src/transaction/chaintrackers/DefaultChainTracker.ts +3 -3
  139. package/src/transaction/chaintrackers/WhatsOnChain.ts +10 -12
  140. package/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.ts +13 -17
  141. package/src/transaction/fee-models/SatoshisPerKilobyte.ts +2 -2
  142. package/src/transaction/http/DefaultHttpClient.ts +13 -13
  143. package/src/transaction/http/FetchHttpClient.ts +14 -16
  144. package/src/transaction/http/HttpClient.ts +22 -23
  145. package/src/transaction/http/NodejsHttpClient.ts +23 -25
  146. package/src/transaction/http/index.ts +6 -6
@@ -6,172 +6,171 @@ import HD from '../../../dist/cjs/src/compat/HD'
6
6
  import { toBase58Check, toHex, toArray } from '../../../dist/cjs/src/primitives/utils'
7
7
 
8
8
  describe('Mnemonic', function () {
9
- it('should initialize the class', () => {
10
- expect(Mnemonic).toBeDefined()
11
- expect(new Mnemonic()).toBeDefined()
9
+ it('should initialize the class', () => {
10
+ expect(Mnemonic).toBeDefined()
11
+ expect(new Mnemonic()).toBeDefined()
12
+ })
13
+
14
+ it('should have a wordlist of length 2048', () => {
15
+ expect(enWordList.value.length).toEqual(2048)
16
+ })
17
+
18
+ it('should handle this community-derived test vector', () => {
19
+ // There was a bug in Copay and bip32jp about deriving addresses with Mnemonic
20
+ // and bip44. This confirms we are handling the situation correctly and
21
+ // derive the correct value.
22
+ //
23
+ // More information here:
24
+ // https://github.com/iancoleman/bip39/issues/58
25
+ const seed = Mnemonic.fromString('fruit wave dwarf banana earth journey tattoo true farm silk olive fence').toSeed(
26
+ 'banana'
27
+ )
28
+ let bip32 = HD.fromSeed(seed)
29
+ bip32 = bip32.derive("m/44'/0'/0'/0/0")
30
+ const pkh = bip32.pubKey.toHash()
31
+ const addr = toBase58Check(pkh)
32
+ expect(addr).toEqual('17rxURoF96VhmkcEGCj5LNQkmN9HVhWb7F')
33
+ })
34
+
35
+ it('should generate a mnemonic phrase that passes the check', () => {
36
+ let mnemonic
37
+
38
+ // should be able to make a mnemonic with or without the default wordlist
39
+ let m = new Mnemonic().fromRandom(128)
40
+ expect(m.check()).toEqual(true)
41
+ m = new Mnemonic().fromRandom(128)
42
+ expect(m.check()).toEqual(true)
43
+
44
+ const entropy = Array(32)
45
+ entropy.fill(0)
46
+ m = new Mnemonic().fromEntropy(entropy)
47
+ expect(m.check()).toEqual(true)
48
+
49
+ mnemonic = m.mnemonic
50
+
51
+ // mnemonics with extra whitespace do not pass the check
52
+ m = new Mnemonic().fromString(mnemonic + ' ')
53
+ expect(m.check()).toEqual(false)
54
+
55
+ // mnemonics with a word replaced do not pass the check
56
+ const words = mnemonic.split(' ')
57
+ expect(words[words.length - 1]).not.toEqual('zoo')
58
+ words[words.length - 1] = 'zoo'
59
+ mnemonic = words.join(' ')
60
+ expect(new Mnemonic().fromString(mnemonic).check()).toEqual(false)
61
+ })
62
+
63
+ describe('#toBinary', () => {
64
+ it('should convert to a binary array', () => {
65
+ const m = new Mnemonic().fromRandom()
66
+ expect(m.seed).toBeDefined()
67
+ expect(m.mnemonic).toBeDefined()
68
+ const buf = m.toBinary()
69
+ expect(buf.length).toBeGreaterThan(512 / 8 + 1 + 1)
12
70
  })
13
-
14
- it('should have a wordlist of length 2048', () => {
15
- expect(enWordList.value.length).toEqual(2048)
71
+ })
72
+
73
+ describe('#fromBinary', () => {
74
+ it('should convert from a binary array', () => {
75
+ const mA = new Mnemonic().fromRandom()
76
+ const mB = new Mnemonic().fromBinary(mA.toBinary())
77
+ expect(mA.mnemonic).toEqual(mB.mnemonic)
78
+ expect(toHex(mA.seed)).toEqual(toHex(mB.seed))
16
79
  })
80
+ })
17
81
 
18
- it('should handle this community-derived test vector', () => {
19
- // There was a bug in Copay and bip32jp about deriving addresses with Mnemonic
20
- // and bip44. This confirms we are handling the situation correctly and
21
- // derive the correct value.
22
- //
23
- // More information here:
24
- // https://github.com/iancoleman/bip39/issues/58
25
- const seed = Mnemonic.fromString('fruit wave dwarf banana earth journey tattoo true farm silk olive fence').toSeed(
26
- 'banana'
27
- )
28
- let bip32 = HD.fromSeed(seed)
29
- bip32 = bip32.derive("m/44'/0'/0'/0/0")
30
- const pkh = bip32.pubKey.toHash()
31
- const addr = toBase58Check(pkh)
32
- expect(addr).toEqual('17rxURoF96VhmkcEGCj5LNQkmN9HVhWb7F')
82
+ describe('#fromRandom', () => {
83
+ it('should throw an error if bits is too low', () => {
84
+ expect(() => {
85
+ new Mnemonic().fromRandom(127)
86
+ }).toThrow('bits must be multiple of 32')
33
87
  })
34
88
 
35
- it('should generate a mnemonic phrase that passes the check', () => {
36
- let mnemonic
37
-
38
- // should be able to make a mnemonic with or without the default wordlist
39
- let m = new Mnemonic().fromRandom(128)
40
- expect(m.check()).toEqual(true)
41
- m = new Mnemonic().fromRandom(128)
42
- expect(m.check()).toEqual(true)
43
-
44
- const entropy = Array(32)
45
- entropy.fill(0)
46
- m = new Mnemonic().fromEntropy(entropy)
47
- expect(m.check()).toEqual(true)
48
-
49
- mnemonic = m.mnemonic
50
-
51
- // mnemonics with extra whitespace do not pass the check
52
- m = new Mnemonic().fromString(mnemonic + ' ')
53
- expect(m.check()).toEqual(false)
54
-
55
- // mnemonics with a word replaced do not pass the check
56
- const words = mnemonic.split(' ')
57
- expect(words[words.length - 1]).not.toEqual('zoo')
58
- words[words.length - 1] = 'zoo'
59
- mnemonic = words.join(' ')
60
- expect(new Mnemonic().fromString(mnemonic).check()).toEqual(false)
89
+ it('should throw an error if bits is not a multiple of 32', () => {
90
+ expect(() => {
91
+ new Mnemonic().fromRandom(256 - 1)
92
+ }).toThrow('bits must be multiple of 32')
61
93
  })
94
+ })
62
95
 
63
- describe('#toBinary', () => {
64
- it('should convert to a binary array', () => {
65
- const m = new Mnemonic().fromRandom()
66
- expect(m.seed).toBeDefined()
67
- expect(m.mnemonic).toBeDefined()
68
- const buf = m.toBinary()
69
- expect(buf.length).toBeGreaterThan(512 / 8 + 1 + 1)
70
- })
96
+ describe('@fromRandom', () => {
97
+ it('should throw an error if bits is too low', () => {
98
+ expect(() => {
99
+ Mnemonic.fromRandom(127)
100
+ }).toThrow('bits must be multiple of 32')
71
101
  })
72
102
 
73
- describe('#fromBinary', () => {
74
- it('should convert from a binary array', () => {
75
- const mA = new Mnemonic().fromRandom()
76
- const mB = new Mnemonic().fromBinary(mA.toBinary())
77
- expect(mA.mnemonic).toEqual(mB.mnemonic)
78
- expect(toHex(mA.seed as number[])).toEqual(toHex(mB.seed as number[]))
79
- })
103
+ it('should throw an error if bits is not a multiple of 32', () => {
104
+ expect(() => {
105
+ Mnemonic.fromRandom(256 - 1)
106
+ }).toThrow('bits must be multiple of 32')
80
107
  })
108
+ })
81
109
 
82
- describe('#fromRandom', () => {
83
- it('should throw an error if bits is too low', () => {
84
- expect(() => {
85
- new Mnemonic().fromRandom(127)
86
- }).toThrow('bits must be multiple of 32')
87
- })
88
-
89
- it('should throw an error if bits is not a multiple of 32', () => {
90
- expect(() => {
91
- new Mnemonic().fromRandom(256 - 1)
92
- }).toThrow('bits must be multiple of 32')
93
- })
110
+ describe('#fromEntropy', () => {
111
+ it('should build from entropy', () => {
112
+ const m = new Mnemonic().fromEntropy(Random(32))
113
+ expect(m).toBeDefined()
94
114
  })
115
+ })
95
116
 
96
- describe('@fromRandom', () => {
97
- it('should throw an error if bits is too low', () => {
98
- expect(() => {
99
- Mnemonic.fromRandom(127)
100
- }).toThrow('bits must be multiple of 32')
101
- })
102
-
103
- it('should throw an error if bits is not a multiple of 32', () => {
104
- expect(() => {
105
- Mnemonic.fromRandom(256 - 1)
106
- }).toThrow('bits must be multiple of 32')
107
- })
117
+ describe('@fromEntropy', () => {
118
+ it('should build from entropy', () => {
119
+ const m = Mnemonic.fromEntropy(Random(32))
120
+ expect(m).toBeDefined()
108
121
  })
109
-
110
- describe('#fromEntropy', () => {
111
- it('should build from entropy', () => {
112
- const m = new Mnemonic().fromEntropy(Random(32))
113
- expect(m).toBeDefined()
114
- })
115
- })
116
-
117
- describe('@fromEntropy', () => {
118
- it('should build from entropy', () => {
119
- const m = Mnemonic.fromEntropy(Random(32))
120
- expect(m).toBeDefined()
121
- })
122
+ })
123
+
124
+ describe('#entropy2Mnemonic', () => {
125
+ it('should throw an error if you do not use enough entropy', () => {
126
+ const buf = Buffer.alloc(128 / 8 - 1)
127
+ buf.fill(0)
128
+ expect(() => {
129
+ new Mnemonic().entropy2Mnemonic([...buf])
130
+ }).toThrow('Entropy is less than 128 bits. It must be 128 bits or more.')
122
131
  })
123
-
124
- describe('#entropy2Mnemonic', () => {
125
- it('should throw an error if you do not use enough entropy', () => {
126
- const buf = Buffer.alloc(128 / 8 - 1)
127
- buf.fill(0)
128
- expect(() => {
129
- new Mnemonic().entropy2Mnemonic([...buf])
130
- }).toThrow('Entropy is less than 128 bits. It must be 128 bits or more.')
131
- })
132
+ })
133
+
134
+ describe('#fromString', () => {
135
+ it('should throw an error in invalid mnemonic', () => {
136
+ expect(() => {
137
+ new Mnemonic().fromString('invalid mnemonic').toSeed()
138
+ }).toThrow(
139
+ 'Mnemonic does not pass the check - was the mnemonic typed incorrectly? Are there extra spaces?'
140
+ )
132
141
  })
133
-
134
- describe('#fromString', () => {
135
- it('should throw an error in invalid mnemonic', () => {
136
- expect(() => {
137
- new Mnemonic().fromString('invalid mnemonic').toSeed()
138
- }).toThrow(
139
- 'Mnemonic does not pass the check - was the mnemonic typed incorrectly? Are there extra spaces?'
140
- )
141
- })
142
+ })
143
+
144
+ describe('@isValid', () => {
145
+ it('should know this is valid', () => {
146
+ const isValid = Mnemonic.isValid(
147
+ 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
148
+ 'TREZOR'
149
+ )
150
+ expect(isValid).toBe(true)
142
151
  })
143
152
 
144
- describe('@isValid', () => {
145
- it('should know this is valid', () => {
146
- const isValid = Mnemonic.isValid(
147
- 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
148
- 'TREZOR'
149
- )
150
- expect(isValid).toBe(true)
151
- })
152
-
153
- it('should know this is invalid', () => {
154
- const isValid = Mnemonic.isValid(
155
- 'abandonnnnnnn abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
156
- 'TREZOR'
157
- )
158
- expect(isValid).toEqual(false)
159
- })
153
+ it('should know this is invalid', () => {
154
+ const isValid = Mnemonic.isValid(
155
+ 'abandonnnnnnn abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
156
+ 'TREZOR'
157
+ )
158
+ expect(isValid).toEqual(false)
160
159
  })
161
-
162
- describe('vectors', () => {
163
- // eslint-disable-next-line ban/ban
164
- vectors.english.forEach((vector, v) => {
165
- it('should pass english test vector ' + v, () => {
166
- const entropy = toArray(vector.entropy, 'hex')
167
- const m = new Mnemonic().fromEntropy(entropy)
168
- expect(m.toString()).toEqual(vector.mnemonic)
169
- expect(m.check()).toEqual(true)
170
- const seed = m.toSeed(vector.passphrase)
171
- expect(toHex(seed)).toEqual(vector.seed)
172
- expect(HD.fromSeed(seed).toString()).toEqual(vector.bip32_xprv)
173
- })
174
- })
175
-
160
+ })
161
+
162
+ describe('vectors', () => {
163
+ // eslint-disable-next-line ban/ban
164
+ vectors.english.forEach((vector, v) => {
165
+ it('should pass english test vector ' + v, () => {
166
+ const entropy = toArray(vector.entropy, 'hex')
167
+ const m = new Mnemonic().fromEntropy(entropy)
168
+ expect(m.toString()).toEqual(vector.mnemonic)
169
+ expect(m.check()).toEqual(true)
170
+ const seed = m.toSeed(vector.passphrase)
171
+ expect(toHex(seed)).toEqual(vector.seed)
172
+ expect(HD.fromSeed(seed).toString()).toEqual(vector.bip32_xprv)
173
+ })
176
174
  })
175
+ })
177
176
  })