5e7394efc2482195d0e101b9b3c9fc2610da9f8de3935de7a7c16840af506e58.json raw

   1  {"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.deriveSeedFromMnemonic = exports.generateNewMnemonic = exports.deriveBlindingFactor = exports.deriveSecret = void 0;\nconst bip32_1 = require(\"@scure/bip32\");\nconst index_js_1 = require(\"../common/index.js\");\nconst bip39_1 = require(\"@scure/bip39\");\nconst english_1 = require(\"@scure/bip39/wordlists/english\");\nconst STANDARD_DERIVATION_PATH = `m/129372'/0'`;\nvar DerivationType = /*#__PURE__*/function (DerivationType) {\n  DerivationType[DerivationType[\"SECRET\"] = 0] = \"SECRET\";\n  DerivationType[DerivationType[\"BLINDING_FACTOR\"] = 1] = \"BLINDING_FACTOR\";\n  return DerivationType;\n}(DerivationType || {});\nconst deriveSecret = (seed, keysetId, counter) => {\n  return derive(seed, keysetId, counter, DerivationType.SECRET);\n};\nexports.deriveSecret = deriveSecret;\nconst deriveBlindingFactor = (seed, keysetId, counter) => {\n  return derive(seed, keysetId, counter, DerivationType.BLINDING_FACTOR);\n};\nexports.deriveBlindingFactor = deriveBlindingFactor;\nconst derive = (seed, keysetId, counter, secretOrBlinding) => {\n  const hdkey = bip32_1.HDKey.fromMasterSeed(seed);\n  const keysetIdInt = (0, index_js_1.getKeysetIdInt)(keysetId);\n  const derivationPath = `${STANDARD_DERIVATION_PATH}/${keysetIdInt}'/${counter}'/${secretOrBlinding}`;\n  const derived = hdkey.derive(derivationPath);\n  if (derived.privateKey === null) {\n    throw new Error('Could not derive private key');\n  }\n  return derived.privateKey;\n};\nconst generateNewMnemonic = () => {\n  const mnemonic = (0, bip39_1.generateMnemonic)(english_1.wordlist, 128);\n  return mnemonic;\n};\nexports.generateNewMnemonic = generateNewMnemonic;\nconst deriveSeedFromMnemonic = mnemonic => {\n  const seed = (0, bip39_1.mnemonicToSeedSync)(mnemonic);\n  return seed;\n};\nexports.deriveSeedFromMnemonic = deriveSeedFromMnemonic;\n//# sourceMappingURL=NUT09.js.map","map":null,"metadata":{},"sourceType":"script","externalDependencies":[]}