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
@@ -0,0 +1,45 @@
import { _0n, BN, bnToU8a, hasBigInt, isU8a, nToU8a, u8aToBigInt } from '@pezkuwi/util';
import { BigInt } from '@pezkuwi/x-bigint';
import { BN_BE_256_OPTS, BN_BE_OPTS } from '../bn.js';
const N = 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141'.replace(/ /g, '');
const N_BI = BigInt(`0x${N}`);
const N_BN = new BN(N, 'hex');
function addBi(seckey, tweak) {
let res = u8aToBigInt(tweak, BN_BE_OPTS);
if (res >= N_BI) {
throw new Error('Tweak parameter is out of range');
}
res += u8aToBigInt(seckey, BN_BE_OPTS);
if (res >= N_BI) {
res -= N_BI;
}
if (res === _0n) {
throw new Error('Invalid resulting private key');
}
return nToU8a(res, BN_BE_256_OPTS);
}
function addBn(seckey, tweak) {
const res = new BN(tweak);
if (res.cmp(N_BN) >= 0) {
throw new Error('Tweak parameter is out of range');
}
res.iadd(new BN(seckey));
if (res.cmp(N_BN) >= 0) {
res.isub(N_BN);
}
if (res.isZero()) {
throw new Error('Invalid resulting private key');
}
return bnToU8a(res, BN_BE_256_OPTS);
}
export function secp256k1PrivateKeyTweakAdd(seckey, tweak, onlyBn) {
if (!isU8a(seckey) || seckey.length !== 32) {
throw new Error('Expected seckey to be an Uint8Array with length 32');
}
else if (!isU8a(tweak) || tweak.length !== 32) {
throw new Error('Expected tweak to be an Uint8Array with length 32');
}
return !hasBigInt || onlyBn
? addBn(seckey, tweak)
: addBi(seckey, tweak);
}