chore: update to version 14.0.11 and align website URLs

This commit is contained in:
2026-01-11 11:34:13 +03:00
parent ef74383349
commit 19c8d69bd8
1499 changed files with 53633 additions and 89 deletions
+2
View File
@@ -0,0 +1,2 @@
import type { Keypair } from '../../types.js';
export declare function hdEthereum(seed: Uint8Array, path?: string): Keypair;
@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hdEthereum = hdEthereum;
const util_1 = require("@pezkuwi/util");
const bn_js_1 = require("../../bn.js");
const index_js_1 = require("../../hmac/index.js");
const index_js_2 = require("../../secp256k1/index.js");
const validatePath_js_1 = require("../validatePath.js");
const MASTER_SECRET = (0, util_1.stringToU8a)('Bitcoin seed');
function createCoded(secretKey, chainCode) {
return {
chainCode,
publicKey: (0, index_js_2.secp256k1PairFromSeed)(secretKey).publicKey,
secretKey
};
}
function deriveChild(hd, index) {
const indexBuffer = (0, util_1.bnToU8a)(index, bn_js_1.BN_BE_32_OPTS);
const data = index >= validatePath_js_1.HARDENED
? (0, util_1.u8aConcat)(new Uint8Array(1), hd.secretKey, indexBuffer)
: (0, util_1.u8aConcat)(hd.publicKey, indexBuffer);
try {
const I = (0, index_js_1.hmacShaAsU8a)(hd.chainCode, data, 512);
return createCoded((0, index_js_2.secp256k1PrivateKeyTweakAdd)(hd.secretKey, I.slice(0, 32)), I.slice(32));
}
catch {
// In case parse256(IL) >= n or ki == 0, proceed with the next value for i
return deriveChild(hd, index + 1);
}
}
function hdEthereum(seed, path = '') {
const I = (0, index_js_1.hmacShaAsU8a)(MASTER_SECRET, seed, 512);
let hd = createCoded(I.slice(0, 32), I.slice(32));
if (!path || path === 'm' || path === 'M' || path === "m'" || path === "M'") {
return hd;
}
if (!(0, validatePath_js_1.hdValidatePath)(path)) {
throw new Error('Invalid derivation path');
}
const parts = path.split('/').slice(1);
for (const p of parts) {
hd = deriveChild(hd, parseInt(p, 10) + ((p.length > 1) && p.endsWith("'")
? validatePath_js_1.HARDENED
: 0));
}
return hd;
}
+3
View File
@@ -0,0 +1,3 @@
export { hdEthereum } from './ethereum/index.js';
export { hdLedger } from './ledger/index.js';
export { hdValidatePath } from './validatePath.js';
+9
View File
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hdValidatePath = exports.hdLedger = exports.hdEthereum = void 0;
var index_js_1 = require("./ethereum/index.js");
Object.defineProperty(exports, "hdEthereum", { enumerable: true, get: function () { return index_js_1.hdEthereum; } });
var index_js_2 = require("./ledger/index.js");
Object.defineProperty(exports, "hdLedger", { enumerable: true, get: function () { return index_js_2.hdLedger; } });
var validatePath_js_1 = require("./validatePath.js");
Object.defineProperty(exports, "hdValidatePath", { enumerable: true, get: function () { return validatePath_js_1.hdValidatePath; } });
+1
View File
@@ -0,0 +1 @@
export declare function ledgerDerivePrivate(xprv: Uint8Array, index: number): Uint8Array;
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ledgerDerivePrivate = ledgerDerivePrivate;
const util_1 = require("@pezkuwi/util");
const bn_js_1 = require("../../bn.js");
const index_js_1 = require("../../hmac/index.js");
function ledgerDerivePrivate(xprv, index) {
const kl = xprv.subarray(0, 32);
const kr = xprv.subarray(32, 64);
const cc = xprv.subarray(64, 96);
const data = (0, util_1.u8aConcat)([0], kl, kr, (0, util_1.bnToU8a)(index, bn_js_1.BN_LE_32_OPTS));
const z = (0, index_js_1.hmacShaAsU8a)(cc, data, 512);
data[0] = 0x01;
return (0, util_1.u8aConcat)((0, util_1.bnToU8a)((0, util_1.u8aToBn)(kl, bn_js_1.BN_LE_OPTS).iadd((0, util_1.u8aToBn)(z.subarray(0, 28), bn_js_1.BN_LE_OPTS).imul(util_1.BN_EIGHT)), bn_js_1.BN_LE_512_OPTS).subarray(0, 32), (0, util_1.bnToU8a)((0, util_1.u8aToBn)(kr, bn_js_1.BN_LE_OPTS).iadd((0, util_1.u8aToBn)(z.subarray(32, 64), bn_js_1.BN_LE_OPTS)), bn_js_1.BN_LE_512_OPTS).subarray(0, 32), (0, index_js_1.hmacShaAsU8a)(cc, data, 512).subarray(32, 64));
}
+2
View File
@@ -0,0 +1,2 @@
import type { Keypair } from '../../types.js';
export declare function hdLedger(_mnemonic: string, path: string): Keypair;
@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hdLedger = hdLedger;
const index_js_1 = require("../../ed25519/index.js");
const index_js_2 = require("../../mnemonic/index.js");
const validatePath_js_1 = require("../validatePath.js");
const derivePrivate_js_1 = require("./derivePrivate.js");
const master_js_1 = require("./master.js");
function hdLedger(_mnemonic, path) {
const words = _mnemonic
.split(' ')
.map((s) => s.trim())
.filter((s) => s);
if (![12, 24, 25].includes(words.length)) {
throw new Error('Expected a mnemonic with 24 words (or 25 including a password)');
}
const [mnemonic, password] = words.length === 25
? [words.slice(0, 24).join(' '), words[24]]
: [words.join(' '), ''];
if (!(0, index_js_2.mnemonicValidate)(mnemonic)) {
throw new Error('Invalid mnemonic passed to ledger derivation');
}
else if (!(0, validatePath_js_1.hdValidatePath)(path)) {
throw new Error('Invalid derivation path');
}
const parts = path.split('/').slice(1);
let seed = (0, master_js_1.ledgerMaster)(mnemonic, password);
for (const p of parts) {
const n = parseInt(p.replace(/'$/, ''), 10);
seed = (0, derivePrivate_js_1.ledgerDerivePrivate)(seed, (n < validatePath_js_1.HARDENED) ? (n + validatePath_js_1.HARDENED) : n);
}
return (0, index_js_1.ed25519PairFromSeed)(seed.slice(0, 32));
}
+1
View File
@@ -0,0 +1 @@
export declare function ledgerMaster(mnemonic: string, password?: string): Uint8Array;
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ledgerMaster = ledgerMaster;
const util_1 = require("@pezkuwi/util");
const index_js_1 = require("../../hmac/index.js");
const bip39_js_1 = require("../../mnemonic/bip39.js");
const ED25519_CRYPTO = 'ed25519 seed';
function ledgerMaster(mnemonic, password) {
const seed = (0, bip39_js_1.mnemonicToSeedSync)(mnemonic, password);
const chainCode = (0, index_js_1.hmacShaAsU8a)(ED25519_CRYPTO, new Uint8Array([1, ...seed]), 256);
let priv;
while (!priv || (priv[31] & 0b0010_0000)) {
priv = (0, index_js_1.hmacShaAsU8a)(ED25519_CRYPTO, priv || seed, 512);
}
priv[0] &= 0b1111_1000;
priv[31] &= 0b0111_1111;
priv[31] |= 0b0100_0000;
return (0, util_1.u8aConcat)(priv, chainCode);
}
+2
View File
@@ -0,0 +1,2 @@
export declare const HARDENED = 2147483648;
export declare function hdValidatePath(path: string): boolean;
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HARDENED = void 0;
exports.hdValidatePath = hdValidatePath;
exports.HARDENED = 0x80000000;
function hdValidatePath(path) {
if (!path.startsWith('m/')) {
return false;
}
const parts = path.split('/').slice(1);
for (const p of parts) {
const n = /^\d+'?$/.test(p)
? parseInt(p.replace(/'$/, ''), 10)
: Number.NaN;
if (isNaN(n) || (n >= exports.HARDENED) || (n < 0)) {
return false;
}
}
return true;
}