From 7e18e48b9432cf7baefae9e47b908870a6f014c2 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Wed, 10 Dec 2025 21:13:28 -0800 Subject: [PATCH] Formatting. --- src/lib/crypto/secp256k1.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/crypto/secp256k1.ts b/src/lib/crypto/secp256k1.ts index cb78163..8ac2a4a 100644 --- a/src/lib/crypto/secp256k1.ts +++ b/src/lib/crypto/secp256k1.ts @@ -79,10 +79,12 @@ export class Secp256k1 { return r >= 0n ? r : p + r } - /** Modular inversion using eucledian GCD (non-CT). No negative exponent for now. */ - // prettier-ignore + /** + * Modular inversion using euclidean GCD (non-constant-time). + * No negative exponent for now. + */ static invert (num: bigint): bigint { - if (num === 0n || this.P <= 0n) this.err('no inverse n=' + num + ' mod=' + this.P) + if (num === 0n || this.P <= 0n) this.err(`no inverse n=${num} mod=${this.P}`) let a = this.M(num), b = this.P, x = 0n, y = 1n, u = 1n, v = 0n while (a !== 0n) { const q = b / a, r = b % a @@ -93,7 +95,6 @@ export class Secp256k1 { } // ## End of Helpers - // ----------------- /** secp256k1 formula. Koblitz curves are subclass of weierstrass curves with a=0, making it x³+b */ static koblitz = (x: bigint): bigint => this.M(this.M(x * x) * x + this.b) -- 2.47.3