From: Chris Duncan Date: Thu, 11 Dec 2025 05:13:28 +0000 (-0800) Subject: Formatting. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=7e18e48b9432cf7baefae9e47b908870a6f014c2;p=libnemo.git Formatting. --- 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)