From: Chris Duncan Date: Mon, 1 Dec 2025 06:22:16 +0000 (-0800) Subject: Use secp256k1 N from class so it is only defined once. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=19989cea485813b36cf2eee98b8133419ab23f99;p=libnemo.git Use secp256k1 N from class so it is only defined once. --- diff --git a/src/lib/crypto/bip44.ts b/src/lib/crypto/bip44.ts index 2e08cea..006f7d4 100644 --- a/src/lib/crypto/bip44.ts +++ b/src/lib/crypto/bip44.ts @@ -14,9 +14,6 @@ type Curve = 'Bitcoin seed' | 'ed25519 seed' export class Bip44 { static get BIP44_PURPOSE (): 44 { return 44 } static get HARDENED_OFFSET (): 0x80000000 { return 0x80000000 } - static get SECP256K1_N (): bigint { - return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141n - } /** * Derives a private child key for a coin by following the specified BIP-32 and @@ -95,11 +92,11 @@ export class Bip44 { return ({ privateKey: IL, chainCode: IR }) } else { const ILparsed = this.parse256(new Uint8Array(IL)) - if (ILparsed >= this.SECP256K1_N) { + if (ILparsed >= Secp256k1.N) { throw new Error('Invalid child key is greater than the order of the curve') } const pkParsed = this.parse256(pk) - const childKey = (ILparsed + pkParsed) % this.SECP256K1_N + const childKey = (ILparsed + pkParsed) % Secp256k1.N if (childKey === 0n) { throw new Error('Invalid child key is zero') }