]> git.codecow.com Git - libnemo.git/commitdiff
Use secp256k1 N from class so it is only defined once.
authorChris Duncan <chris@zoso.dev>
Mon, 1 Dec 2025 06:22:16 +0000 (22:22 -0800)
committerChris Duncan <chris@zoso.dev>
Mon, 1 Dec 2025 06:22:16 +0000 (22:22 -0800)
src/lib/crypto/bip44.ts

index 2e08cead9bdc28f49228f442e984f400915c70e2..006f7d4210385911ec84ad8081f940e7a497699d 100644 (file)
@@ -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')
                                        }