|
1 | 1 | import { fromAscii, fromBase64, fromHex } from "@cosmjs/encoding"; |
2 | 2 |
|
3 | | -import { Bip39, EnglishMnemonic, entropyToMnemonic, mnemonicToEntropy } from "./bip39"; |
| 3 | +import { Bip39, EnglishMnemonic } from "./bip39"; |
4 | 4 | import { sha256 } from "./sha"; |
5 | 5 | import bip39Vectors from "./testdata/bip39.json"; |
6 | 6 | import wordlists from "./testdata/bip39_wordlists.json"; |
7 | 7 |
|
8 | | -describe("entropyToMnemonic", () => { |
9 | | - it("works", () => { |
10 | | - // From https://iancoleman.io/bip39/ |
11 | | - expect(entropyToMnemonic(fromHex("a323224e6b13d31942509dc4e2e579be3d5bb7f2"))).toEqual( |
12 | | - "permit boil near stomach diamond million announce beauty shaft blame fury ladder stick swim slab", |
13 | | - ); |
14 | | - }); |
15 | | - |
16 | | - it("works for all the test vectors", () => { |
17 | | - // Test vectors from https://github.com/trezor/python-mnemonic/blob/b502451a33a440783926e04428115e0bed87d01f/vectors.json |
18 | | - // plus similar vectors generated for the missing lengths 15 and 21 words |
19 | | - const { "12": vec12, "15": vec15, "18": vec18, "21": vec21, "24": vec24 } = bip39Vectors.encoding; |
20 | | - for (const vectors of [vec12, vec15, vec18, vec21, vec24]) { |
21 | | - for (const { entropy, mnemonic } of vectors) { |
22 | | - expect(entropyToMnemonic(fromHex(entropy))).toEqual(mnemonic); |
23 | | - } |
24 | | - } |
25 | | - }); |
26 | | -}); |
27 | | - |
28 | | -describe("mnemonicToEntropy", () => { |
29 | | - it("works", () => { |
30 | | - // From https://iancoleman.io/bip39/ |
31 | | - expect( |
32 | | - mnemonicToEntropy( |
33 | | - "permit boil near stomach diamond million announce beauty shaft blame fury ladder stick swim slab", |
34 | | - ), |
35 | | - ).toEqual(fromHex("a323224e6b13d31942509dc4e2e579be3d5bb7f2")); |
36 | | - }); |
37 | | - |
38 | | - it("works for all the test vectors", () => { |
39 | | - const { "12": vec12, "15": vec15, "18": vec18, "21": vec21, "24": vec24 } = bip39Vectors.encoding; |
40 | | - for (const vectors of [vec12, vec15, vec18, vec21, vec24]) { |
41 | | - for (const { entropy, mnemonic } of vectors) { |
42 | | - expect(mnemonicToEntropy(mnemonic)).toEqual(fromHex(entropy)); |
43 | | - } |
44 | | - } |
45 | | - }); |
46 | | -}); |
47 | | - |
48 | 8 | describe("Bip39", () => { |
49 | 9 | describe("encode", () => { |
50 | 10 | it("can encode to mnemonic", () => { |
|
0 commit comments