@xyo-network/bip39 3.14.0 → 3.14.2

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.
@@ -1,83 +1,6 @@
1
1
  // src/index.ts
2
- import { abytes } from "@noble/hashes/_assert";
3
- import { pbkdf2, pbkdf2Async } from "@noble/hashes/pbkdf2";
4
- import { sha256 } from "@noble/hashes/sha256";
5
- import { sha512 } from "@noble/hashes/sha512";
6
- import { utils as baseUtils } from "@scure/base";
7
-
8
- // src/wordlists/index.ts
9
- import { wordlist as czech } from "@scure/bip39/wordlists/czech";
10
- import { wordlist as english } from "@scure/bip39/wordlists/english";
11
- import { wordlist as french } from "@scure/bip39/wordlists/french";
12
- import { wordlist as italian } from "@scure/bip39/wordlists/italian";
13
- import { wordlist as japanese } from "@scure/bip39/wordlists/japanese";
14
- import { wordlist as korean } from "@scure/bip39/wordlists/korean";
15
- import { wordlist as simplifiedChinese } from "@scure/bip39/wordlists/simplified-chinese";
16
- import { wordlist as spanish } from "@scure/bip39/wordlists/spanish";
17
- import { wordlist as traditionalChinese } from "@scure/bip39/wordlists/traditional-chinese";
18
- var wordlists = {
19
- czech,
20
- english,
21
- french,
22
- italian,
23
- japanese,
24
- korean,
25
- simplifiedChinese,
26
- spanish,
27
- traditionalChinese
28
- };
29
-
30
- // src/index.ts
31
- var isJapanese = (wordlist) => wordlist[0] === "\u3042\u3044\u3053\u304F\u3057\u3093";
32
- function nfkd(str) {
33
- if (typeof str !== "string") throw new TypeError(`Invalid mnemonic type: ${typeof str}`);
34
- return str.normalize("NFKD");
35
- }
36
- function normalize(str) {
37
- const norm = nfkd(str);
38
- const words = norm.split(" ");
39
- if (![12, 15, 18, 21, 24].includes(words.length)) throw new Error("Invalid mnemonic");
40
- return { nfkd: norm, words };
41
- }
42
- function assertEntropy(entropy) {
43
- abytes(entropy, 16, 20, 24, 28, 32);
44
- }
45
- var calcChecksum = (entropy) => {
46
- const bitsLeft = 8 - entropy.length / 4;
47
- return new Uint8Array([sha256(entropy)[0] >> bitsLeft << bitsLeft]);
48
- };
49
- function getCoder(wordlist) {
50
- if (!Array.isArray(wordlist) || wordlist.length !== 2048 || typeof wordlist[0] !== "string")
51
- throw new Error("Wordlist: expected array of 2048 strings");
52
- for (const i of wordlist) {
53
- if (typeof i !== "string") throw new Error(`Wordlist: non-string element: ${i}`);
54
- }
55
- return baseUtils.chain(baseUtils.checksum(1, calcChecksum), baseUtils.radix2(11, true), baseUtils.alphabet(wordlist));
56
- }
57
- function mnemonicToEntropy(mnemonic, wordlist) {
58
- const { words } = normalize(mnemonic);
59
- const entropy = getCoder(wordlist).decode(words);
60
- assertEntropy(entropy);
61
- return entropy;
62
- }
63
- function entropyToMnemonic(entropy, wordlist) {
64
- assertEntropy(entropy);
65
- const words = getCoder(wordlist).encode(entropy);
66
- return words.join(isJapanese(wordlist) ? "\u3000" : " ");
67
- }
68
- var salt = (passphrase) => nfkd(`mnemonic${passphrase}`);
69
- function mnemonicToSeed(mnemonic, passphrase = "") {
70
- return pbkdf2Async(sha512, normalize(mnemonic).nfkd, salt(passphrase), { c: 2048, dkLen: 64 });
71
- }
72
- function mnemonicToSeedSync(mnemonic, passphrase = "") {
73
- return pbkdf2(sha512, normalize(mnemonic).nfkd, salt(passphrase), { c: 2048, dkLen: 64 });
74
- }
2
+ var index_default = {};
75
3
  export {
76
- entropyToMnemonic,
77
- mnemonicToEntropy,
78
- mnemonicToSeed,
79
- mnemonicToSeedSync,
80
- wordlists
4
+ index_default as default
81
5
  };
82
- /*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */
83
6
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/wordlists/index.ts"],"sourcesContent":["/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */\nimport { abytes } from '@noble/hashes/_assert'\nimport { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2'\nimport { sha256 } from '@noble/hashes/sha256'\nimport { sha512 } from '@noble/hashes/sha512'\nimport { utils as baseUtils } from '@scure/base'\n\nexport * from './wordlists/index.ts'\n\n// Japanese wordlist\nconst isJapanese = (wordlist: string[]) => wordlist[0] === '\\u3042\\u3044\\u3053\\u304F\\u3057\\u3093'\n\n// Normalization replaces equivalent sequences of characters\n// so that any two texts that are equivalent will be reduced\n// to the same sequence of code points, called the normal form of the original text.\nfunction nfkd(str: string) {\n if (typeof str !== 'string') throw new TypeError(`Invalid mnemonic type: ${typeof str}`)\n return str.normalize('NFKD')\n}\n\nfunction normalize(str: string) {\n const norm = nfkd(str)\n const words = norm.split(' ')\n if (![12, 15, 18, 21, 24].includes(words.length)) throw new Error('Invalid mnemonic')\n return { nfkd: norm, words }\n}\n\nfunction assertEntropy(entropy: Uint8Array) {\n abytes(entropy, 16, 20, 24, 28, 32)\n}\n\nconst calcChecksum = (entropy: Uint8Array) => {\n // Checksum is ent.length/4 bits long\n const bitsLeft = 8 - entropy.length / 4\n // Zero rightmost \"bitsLeft\" bits in byte\n // For example: bitsLeft=4 val=10111101 -> 10110000\n return new Uint8Array([(sha256(entropy)[0] >> bitsLeft) << bitsLeft])\n}\n\nfunction getCoder(wordlist: string[]) {\n if (!Array.isArray(wordlist) || wordlist.length !== 2048 || typeof wordlist[0] !== 'string')\n throw new Error('Wordlist: expected array of 2048 strings')\n for (const i of wordlist) {\n if (typeof i !== 'string') throw new Error(`Wordlist: non-string element: ${i}`)\n }\n return baseUtils.chain(baseUtils.checksum(1, calcChecksum), baseUtils.radix2(11, true), baseUtils.alphabet(wordlist))\n}\n\n/**\n * Reversible: Converts mnemonic string to raw entropy in form of byte array.\n * @param mnemonic 12-24 words\n * @param wordlist imported wordlist for specific language\n * @example\n * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';\n * mnemonicToEntropy(mnem, wordlist)\n * // Produces\n * new Uint8Array([\n * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,\n * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f\n * ])\n */\n\n/** @deprecated use @scure/bip39 instead */\nexport function mnemonicToEntropy(mnemonic: string, wordlist: string[]): Uint8Array {\n const { words } = normalize(mnemonic)\n const entropy = getCoder(wordlist).decode(words)\n assertEntropy(entropy)\n return entropy\n}\n\n/**\n * Reversible: Converts raw entropy in form of byte array to mnemonic string.\n * @param entropy byte array\n * @param wordlist imported wordlist for specific language\n * @returns 12-24 words\n * @example\n * const ent = new Uint8Array([\n * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,\n * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f\n * ]);\n * entropyToMnemonic(ent, wordlist);\n * // 'legal winner thank year wave sausage worth useful legal winner thank yellow'\n */\n\n/** @deprecated use @scure/bip39 instead */\nexport function entropyToMnemonic(entropy: Uint8Array, wordlist: string[]): string {\n assertEntropy(entropy)\n const words = getCoder(wordlist).encode(entropy)\n return words.join(isJapanese(wordlist) ? '\\u3000' : ' ')\n}\n\nconst salt = (passphrase: string) => nfkd(`mnemonic${passphrase}`)\n\n/**\n * Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.\n * @param mnemonic 12-24 words\n * @param passphrase string that will additionally protect the key\n * @returns 64 bytes of key data\n * @example\n * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';\n * await mnemonicToSeed(mnem, 'password');\n * // new Uint8Array([...64 bytes])\n */\n\n/** @deprecated use @scure/bip39 instead */\nexport function mnemonicToSeed(mnemonic: string, passphrase = '') {\n return pbkdf2Async(sha512, normalize(mnemonic).nfkd, salt(passphrase), { c: 2048, dkLen: 64 })\n}\n\n/**\n * Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.\n * @param mnemonic 12-24 words\n * @param passphrase string that will additionally protect the key\n * @returns 64 bytes of key data\n * @example\n * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';\n * mnemonicToSeedSync(mnem, 'password');\n * // new Uint8Array([...64 bytes])\n */\n\n/** @deprecated use @scure/bip39 instead */\nexport function mnemonicToSeedSync(mnemonic: string, passphrase = '') {\n return pbkdf2(sha512, normalize(mnemonic).nfkd, salt(passphrase), { c: 2048, dkLen: 64 })\n}\n","import { wordlist as czech } from '@scure/bip39/wordlists/czech'\nimport { wordlist as english } from '@scure/bip39/wordlists/english'\nimport { wordlist as french } from '@scure/bip39/wordlists/french'\nimport { wordlist as italian } from '@scure/bip39/wordlists/italian'\nimport { wordlist as japanese } from '@scure/bip39/wordlists/japanese'\nimport { wordlist as korean } from '@scure/bip39/wordlists/korean'\nimport { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese'\nimport { wordlist as spanish } from '@scure/bip39/wordlists/spanish'\nimport { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese'\n\n/** @deprecated use @scure/bip39 instead */\nexport const wordlists = {\n czech,\n english,\n french,\n italian,\n japanese,\n korean,\n simplifiedChinese,\n spanish,\n traditionalChinese,\n}\n"],"mappings":";AACA,SAAS,cAAc;AACvB,SAAS,QAAQ,mBAAmB;AACpC,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,SAAS,iBAAiB;;;ACLnC,SAAS,YAAY,aAAa;AAClC,SAAS,YAAY,eAAe;AACpC,SAAS,YAAY,cAAc;AACnC,SAAS,YAAY,eAAe;AACpC,SAAS,YAAY,gBAAgB;AACrC,SAAS,YAAY,cAAc;AACnC,SAAS,YAAY,yBAAyB;AAC9C,SAAS,YAAY,eAAe;AACpC,SAAS,YAAY,0BAA0B;AAGxC,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ADXA,IAAM,aAAa,CAAC,aAAuB,SAAS,CAAC,MAAM;AAK3D,SAAS,KAAK,KAAa;AACzB,MAAI,OAAO,QAAQ,SAAU,OAAM,IAAI,UAAU,0BAA0B,OAAO,GAAG,EAAE;AACvF,SAAO,IAAI,UAAU,MAAM;AAC7B;AAEA,SAAS,UAAU,KAAa;AAC9B,QAAM,OAAO,KAAK,GAAG;AACrB,QAAM,QAAQ,KAAK,MAAM,GAAG;AAC5B,MAAI,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,EAAE,EAAE,SAAS,MAAM,MAAM,EAAG,OAAM,IAAI,MAAM,kBAAkB;AACpF,SAAO,EAAE,MAAM,MAAM,MAAM;AAC7B;AAEA,SAAS,cAAc,SAAqB;AAC1C,SAAO,SAAS,IAAI,IAAI,IAAI,IAAI,EAAE;AACpC;AAEA,IAAM,eAAe,CAAC,YAAwB;AAE5C,QAAM,WAAW,IAAI,QAAQ,SAAS;AAGtC,SAAO,IAAI,WAAW,CAAE,OAAO,OAAO,EAAE,CAAC,KAAK,YAAa,QAAQ,CAAC;AACtE;AAEA,SAAS,SAAS,UAAoB;AACpC,MAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,SAAS,WAAW,QAAQ,OAAO,SAAS,CAAC,MAAM;AACjF,UAAM,IAAI,MAAM,0CAA0C;AAC5D,aAAW,KAAK,UAAU;AACxB,QAAI,OAAO,MAAM,SAAU,OAAM,IAAI,MAAM,iCAAiC,CAAC,EAAE;AAAA,EACjF;AACA,SAAO,UAAU,MAAM,UAAU,SAAS,GAAG,YAAY,GAAG,UAAU,OAAO,IAAI,IAAI,GAAG,UAAU,SAAS,QAAQ,CAAC;AACtH;AAiBO,SAAS,kBAAkB,UAAkB,UAAgC;AAClF,QAAM,EAAE,MAAM,IAAI,UAAU,QAAQ;AACpC,QAAM,UAAU,SAAS,QAAQ,EAAE,OAAO,KAAK;AAC/C,gBAAc,OAAO;AACrB,SAAO;AACT;AAiBO,SAAS,kBAAkB,SAAqB,UAA4B;AACjF,gBAAc,OAAO;AACrB,QAAM,QAAQ,SAAS,QAAQ,EAAE,OAAO,OAAO;AAC/C,SAAO,MAAM,KAAK,WAAW,QAAQ,IAAI,WAAW,GAAG;AACzD;AAEA,IAAM,OAAO,CAAC,eAAuB,KAAK,WAAW,UAAU,EAAE;AAc1D,SAAS,eAAe,UAAkB,aAAa,IAAI;AAChE,SAAO,YAAY,QAAQ,UAAU,QAAQ,EAAE,MAAM,KAAK,UAAU,GAAG,EAAE,GAAG,MAAM,OAAO,GAAG,CAAC;AAC/F;AAcO,SAAS,mBAAmB,UAAkB,aAAa,IAAI;AACpE,SAAO,OAAO,QAAQ,UAAU,QAAQ,EAAE,MAAM,KAAK,UAAU,GAAG,EAAE,GAAG,MAAM,OAAO,GAAG,CAAC;AAC1F;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export default {}\n"],"mappings":";AAAA,IAAO,gBAAQ,CAAC;","names":[]}
@@ -1,56 +1,3 @@
1
- export * from './wordlists/index.ts';
2
- /**
3
- * Reversible: Converts mnemonic string to raw entropy in form of byte array.
4
- * @param mnemonic 12-24 words
5
- * @param wordlist imported wordlist for specific language
6
- * @example
7
- * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
8
- * mnemonicToEntropy(mnem, wordlist)
9
- * // Produces
10
- * new Uint8Array([
11
- * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
12
- * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
13
- * ])
14
- */
15
- /** @deprecated use @scure/bip39 instead */
16
- export declare function mnemonicToEntropy(mnemonic: string, wordlist: string[]): Uint8Array;
17
- /**
18
- * Reversible: Converts raw entropy in form of byte array to mnemonic string.
19
- * @param entropy byte array
20
- * @param wordlist imported wordlist for specific language
21
- * @returns 12-24 words
22
- * @example
23
- * const ent = new Uint8Array([
24
- * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
25
- * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
26
- * ]);
27
- * entropyToMnemonic(ent, wordlist);
28
- * // 'legal winner thank year wave sausage worth useful legal winner thank yellow'
29
- */
30
- /** @deprecated use @scure/bip39 instead */
31
- export declare function entropyToMnemonic(entropy: Uint8Array, wordlist: string[]): string;
32
- /**
33
- * Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
34
- * @param mnemonic 12-24 words
35
- * @param passphrase string that will additionally protect the key
36
- * @returns 64 bytes of key data
37
- * @example
38
- * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
39
- * await mnemonicToSeed(mnem, 'password');
40
- * // new Uint8Array([...64 bytes])
41
- */
42
- /** @deprecated use @scure/bip39 instead */
43
- export declare function mnemonicToSeed(mnemonic: string, passphrase?: string): Promise<Uint8Array<ArrayBufferLike>>;
44
- /**
45
- * Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
46
- * @param mnemonic 12-24 words
47
- * @param passphrase string that will additionally protect the key
48
- * @returns 64 bytes of key data
49
- * @example
50
- * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
51
- * mnemonicToSeedSync(mnem, 'password');
52
- * // new Uint8Array([...64 bytes])
53
- */
54
- /** @deprecated use @scure/bip39 instead */
55
- export declare function mnemonicToSeedSync(mnemonic: string, passphrase?: string): Uint8Array<ArrayBufferLike>;
1
+ declare const _default: {};
2
+ export default _default;
56
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,sBAAsB,CAAA;AAyCpC;;;;;;;;;;;;GAYG;AAEH,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,CAKlF;AAED;;;;;;;;;;;;GAYG;AAEH,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAIjF;AAID;;;;;;;;;GASG;AAEH,2CAA2C;AAC3C,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,SAAK,wCAE/D;AAED;;;;;;;;;GASG;AAEH,2CAA2C;AAC3C,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,SAAK,+BAEnE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,wBAAiB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/bip39",
3
- "version": "3.14.0",
3
+ "version": "3.14.2",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -28,11 +28,6 @@
28
28
  },
29
29
  "module": "dist/neutral/index.mjs",
30
30
  "types": "dist/types/index.d.ts",
31
- "dependencies": {
32
- "@noble/hashes": "^1.8.0",
33
- "@scure/base": "^1.2.5",
34
- "@scure/bip39": "^1.6.0"
35
- },
36
31
  "devDependencies": {
37
32
  "@xylabs/ts-scripts-yarn3": "^6.3.5",
38
33
  "@xylabs/tsconfig": "^6.3.5",
package/src/index.ts CHANGED
@@ -1,124 +1 @@
1
- /*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */
2
- import { abytes } from '@noble/hashes/_assert'
3
- import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2'
4
- import { sha256 } from '@noble/hashes/sha256'
5
- import { sha512 } from '@noble/hashes/sha512'
6
- import { utils as baseUtils } from '@scure/base'
7
-
8
- export * from './wordlists/index.ts'
9
-
10
- // Japanese wordlist
11
- const isJapanese = (wordlist: string[]) => wordlist[0] === '\u3042\u3044\u3053\u304F\u3057\u3093'
12
-
13
- // Normalization replaces equivalent sequences of characters
14
- // so that any two texts that are equivalent will be reduced
15
- // to the same sequence of code points, called the normal form of the original text.
16
- function nfkd(str: string) {
17
- if (typeof str !== 'string') throw new TypeError(`Invalid mnemonic type: ${typeof str}`)
18
- return str.normalize('NFKD')
19
- }
20
-
21
- function normalize(str: string) {
22
- const norm = nfkd(str)
23
- const words = norm.split(' ')
24
- if (![12, 15, 18, 21, 24].includes(words.length)) throw new Error('Invalid mnemonic')
25
- return { nfkd: norm, words }
26
- }
27
-
28
- function assertEntropy(entropy: Uint8Array) {
29
- abytes(entropy, 16, 20, 24, 28, 32)
30
- }
31
-
32
- const calcChecksum = (entropy: Uint8Array) => {
33
- // Checksum is ent.length/4 bits long
34
- const bitsLeft = 8 - entropy.length / 4
35
- // Zero rightmost "bitsLeft" bits in byte
36
- // For example: bitsLeft=4 val=10111101 -> 10110000
37
- return new Uint8Array([(sha256(entropy)[0] >> bitsLeft) << bitsLeft])
38
- }
39
-
40
- function getCoder(wordlist: string[]) {
41
- if (!Array.isArray(wordlist) || wordlist.length !== 2048 || typeof wordlist[0] !== 'string')
42
- throw new Error('Wordlist: expected array of 2048 strings')
43
- for (const i of wordlist) {
44
- if (typeof i !== 'string') throw new Error(`Wordlist: non-string element: ${i}`)
45
- }
46
- return baseUtils.chain(baseUtils.checksum(1, calcChecksum), baseUtils.radix2(11, true), baseUtils.alphabet(wordlist))
47
- }
48
-
49
- /**
50
- * Reversible: Converts mnemonic string to raw entropy in form of byte array.
51
- * @param mnemonic 12-24 words
52
- * @param wordlist imported wordlist for specific language
53
- * @example
54
- * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
55
- * mnemonicToEntropy(mnem, wordlist)
56
- * // Produces
57
- * new Uint8Array([
58
- * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
59
- * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
60
- * ])
61
- */
62
-
63
- /** @deprecated use @scure/bip39 instead */
64
- export function mnemonicToEntropy(mnemonic: string, wordlist: string[]): Uint8Array {
65
- const { words } = normalize(mnemonic)
66
- const entropy = getCoder(wordlist).decode(words)
67
- assertEntropy(entropy)
68
- return entropy
69
- }
70
-
71
- /**
72
- * Reversible: Converts raw entropy in form of byte array to mnemonic string.
73
- * @param entropy byte array
74
- * @param wordlist imported wordlist for specific language
75
- * @returns 12-24 words
76
- * @example
77
- * const ent = new Uint8Array([
78
- * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
79
- * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
80
- * ]);
81
- * entropyToMnemonic(ent, wordlist);
82
- * // 'legal winner thank year wave sausage worth useful legal winner thank yellow'
83
- */
84
-
85
- /** @deprecated use @scure/bip39 instead */
86
- export function entropyToMnemonic(entropy: Uint8Array, wordlist: string[]): string {
87
- assertEntropy(entropy)
88
- const words = getCoder(wordlist).encode(entropy)
89
- return words.join(isJapanese(wordlist) ? '\u3000' : ' ')
90
- }
91
-
92
- const salt = (passphrase: string) => nfkd(`mnemonic${passphrase}`)
93
-
94
- /**
95
- * Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
96
- * @param mnemonic 12-24 words
97
- * @param passphrase string that will additionally protect the key
98
- * @returns 64 bytes of key data
99
- * @example
100
- * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
101
- * await mnemonicToSeed(mnem, 'password');
102
- * // new Uint8Array([...64 bytes])
103
- */
104
-
105
- /** @deprecated use @scure/bip39 instead */
106
- export function mnemonicToSeed(mnemonic: string, passphrase = '') {
107
- return pbkdf2Async(sha512, normalize(mnemonic).nfkd, salt(passphrase), { c: 2048, dkLen: 64 })
108
- }
109
-
110
- /**
111
- * Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
112
- * @param mnemonic 12-24 words
113
- * @param passphrase string that will additionally protect the key
114
- * @returns 64 bytes of key data
115
- * @example
116
- * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
117
- * mnemonicToSeedSync(mnem, 'password');
118
- * // new Uint8Array([...64 bytes])
119
- */
120
-
121
- /** @deprecated use @scure/bip39 instead */
122
- export function mnemonicToSeedSync(mnemonic: string, passphrase = '') {
123
- return pbkdf2(sha512, normalize(mnemonic).nfkd, salt(passphrase), { c: 2048, dkLen: 64 })
124
- }
1
+ export default {}
@@ -1,13 +0,0 @@
1
- /** @deprecated use @scure/bip39 instead */
2
- export declare const wordlists: {
3
- czech: string[];
4
- english: string[];
5
- french: string[];
6
- italian: string[];
7
- japanese: string[];
8
- korean: string[];
9
- simplifiedChinese: string[];
10
- spanish: string[];
11
- traditionalChinese: string[];
12
- };
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wordlists/index.ts"],"names":[],"mappings":"AAUA,2CAA2C;AAC3C,eAAO,MAAM,SAAS;;;;;;;;;;CAUrB,CAAA"}
@@ -1,22 +0,0 @@
1
- import { wordlist as czech } from '@scure/bip39/wordlists/czech'
2
- import { wordlist as english } from '@scure/bip39/wordlists/english'
3
- import { wordlist as french } from '@scure/bip39/wordlists/french'
4
- import { wordlist as italian } from '@scure/bip39/wordlists/italian'
5
- import { wordlist as japanese } from '@scure/bip39/wordlists/japanese'
6
- import { wordlist as korean } from '@scure/bip39/wordlists/korean'
7
- import { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese'
8
- import { wordlist as spanish } from '@scure/bip39/wordlists/spanish'
9
- import { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese'
10
-
11
- /** @deprecated use @scure/bip39 instead */
12
- export const wordlists = {
13
- czech,
14
- english,
15
- french,
16
- italian,
17
- japanese,
18
- korean,
19
- simplifiedChinese,
20
- spanish,
21
- traditionalChinese,
22
- }