@leather.io/crypto 1.0.2 → 1.0.3
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.
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +7 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -11,7 +11,8 @@ declare enum DerivationPathDepth {
|
|
|
11
11
|
declare const extractAccountIndexFromPath: (path: string) => number;
|
|
12
12
|
declare const extractAddressIndexFromPath: (path: string) => number;
|
|
13
13
|
|
|
14
|
+
declare function generateMnemonic(): string;
|
|
14
15
|
declare function deriveBip39MnemonicFromSeed(mnemonic: string): Promise<Uint8Array>;
|
|
15
16
|
declare function deriveRootBip32Keychain(seed: Uint8Array): HDKey;
|
|
16
17
|
|
|
17
|
-
export { DerivationPathDepth, deriveBip39MnemonicFromSeed, deriveRootBip32Keychain, extractAccountIndexFromPath, extractAddressIndexFromPath };
|
|
18
|
+
export { DerivationPathDepth, deriveBip39MnemonicFromSeed, deriveRootBip32Keychain, extractAccountIndexFromPath, extractAddressIndexFromPath, generateMnemonic };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { HDKey } from "@scure/bip32";
|
|
3
|
-
import { mnemonicToSeed } from "@scure/bip39";
|
|
3
|
+
import { mnemonicToSeed, generateMnemonic as scureGenerateMnemonic } from "@scure/bip39";
|
|
4
|
+
import { wordlist } from "@scure/bip39/wordlists/english";
|
|
4
5
|
|
|
5
6
|
// src/derivation-path-utils.ts
|
|
6
7
|
var DerivationPathDepth = /* @__PURE__ */ ((DerivationPathDepth2) => {
|
|
@@ -28,6 +29,9 @@ var extractAddressIndexFromPath = extractSectionFromDerivationPath(
|
|
|
28
29
|
);
|
|
29
30
|
|
|
30
31
|
// src/index.ts
|
|
32
|
+
function generateMnemonic() {
|
|
33
|
+
return scureGenerateMnemonic(wordlist, 256);
|
|
34
|
+
}
|
|
31
35
|
async function deriveBip39MnemonicFromSeed(mnemonic) {
|
|
32
36
|
return mnemonicToSeed(mnemonic);
|
|
33
37
|
}
|
|
@@ -39,6 +43,7 @@ export {
|
|
|
39
43
|
deriveBip39MnemonicFromSeed,
|
|
40
44
|
deriveRootBip32Keychain,
|
|
41
45
|
extractAccountIndexFromPath,
|
|
42
|
-
extractAddressIndexFromPath
|
|
46
|
+
extractAddressIndexFromPath,
|
|
47
|
+
generateMnemonic
|
|
43
48
|
};
|
|
44
49
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/derivation-path-utils.ts"],"sourcesContent":["import { HDKey } from '@scure/bip32';\nimport { mnemonicToSeed } from '@scure/bip39';\n\nexport * from './derivation-path-utils';\n\nexport async function deriveBip39MnemonicFromSeed(mnemonic: string) {\n return mnemonicToSeed(mnemonic);\n}\n\nexport function deriveRootBip32Keychain(seed: Uint8Array) {\n return HDKey.fromMasterSeed(seed);\n}\n","export enum DerivationPathDepth {\n Root = 0,\n Purpose = 1,\n CoinType = 2,\n Account = 3,\n ChangeReceive = 4,\n AddressIndex = 5,\n}\n\nfunction extractSectionFromDerivationPath(depth: DerivationPathDepth) {\n return (path: string) => {\n const segments = path.split('/');\n const accountNum = parseInt(segments[depth].replaceAll(\"'\", ''), 10);\n if (isNaN(accountNum)) throw new Error(`Cannot parse ${DerivationPathDepth[depth]} from path`);\n return accountNum;\n };\n}\n\nexport const extractAccountIndexFromPath = extractSectionFromDerivationPath(\n DerivationPathDepth.Account\n);\n\nexport const extractAddressIndexFromPath = extractSectionFromDerivationPath(\n DerivationPathDepth.AddressIndex\n);\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/derivation-path-utils.ts"],"sourcesContent":["import { HDKey } from '@scure/bip32';\nimport { mnemonicToSeed, generateMnemonic as scureGenerateMnemonic } from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english';\n\nexport * from './derivation-path-utils';\n\nexport function generateMnemonic() {\n return scureGenerateMnemonic(wordlist, 256);\n}\n\nexport async function deriveBip39MnemonicFromSeed(mnemonic: string) {\n return mnemonicToSeed(mnemonic);\n}\n\nexport function deriveRootBip32Keychain(seed: Uint8Array) {\n return HDKey.fromMasterSeed(seed);\n}\n","export enum DerivationPathDepth {\n Root = 0,\n Purpose = 1,\n CoinType = 2,\n Account = 3,\n ChangeReceive = 4,\n AddressIndex = 5,\n}\n\nfunction extractSectionFromDerivationPath(depth: DerivationPathDepth) {\n return (path: string) => {\n const segments = path.split('/');\n const accountNum = parseInt(segments[depth].replaceAll(\"'\", ''), 10);\n if (isNaN(accountNum)) throw new Error(`Cannot parse ${DerivationPathDepth[depth]} from path`);\n return accountNum;\n };\n}\n\nexport const extractAccountIndexFromPath = extractSectionFromDerivationPath(\n DerivationPathDepth.Account\n);\n\nexport const extractAddressIndexFromPath = extractSectionFromDerivationPath(\n DerivationPathDepth.AddressIndex\n);\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,gBAAgB,oBAAoB,6BAA6B;AAC1E,SAAS,gBAAgB;;;ACFlB,IAAK,sBAAL,kBAAKA,yBAAL;AACL,EAAAA,0CAAA,UAAO,KAAP;AACA,EAAAA,0CAAA,aAAU,KAAV;AACA,EAAAA,0CAAA,cAAW,KAAX;AACA,EAAAA,0CAAA,aAAU,KAAV;AACA,EAAAA,0CAAA,mBAAgB,KAAhB;AACA,EAAAA,0CAAA,kBAAe,KAAf;AANU,SAAAA;AAAA,GAAA;AASZ,SAAS,iCAAiC,OAA4B;AACpE,SAAO,CAAC,SAAiB;AACvB,UAAM,WAAW,KAAK,MAAM,GAAG;AAC/B,UAAM,aAAa,SAAS,SAAS,KAAK,EAAE,WAAW,KAAK,EAAE,GAAG,EAAE;AACnE,QAAI,MAAM,UAAU,EAAG,OAAM,IAAI,MAAM,gBAAgB,oBAAoB,KAAK,CAAC,YAAY;AAC7F,WAAO;AAAA,EACT;AACF;AAEO,IAAM,8BAA8B;AAAA,EACzC;AACF;AAEO,IAAM,8BAA8B;AAAA,EACzC;AACF;;;ADlBO,SAAS,mBAAmB;AACjC,SAAO,sBAAsB,UAAU,GAAG;AAC5C;AAEA,eAAsB,4BAA4B,UAAkB;AAClE,SAAO,eAAe,QAAQ;AAChC;AAEO,SAAS,wBAAwB,MAAkB;AACxD,SAAO,MAAM,eAAe,IAAI;AAClC;","names":["DerivationPathDepth"]}
|
package/package.json
CHANGED