]> git.codecow.com Git - libnemo.git/commitdiff
Remove paramenter since unsafe multiplication was deprecated.
authorChris Duncan <chris@zoso.dev>
Fri, 5 Dec 2025 16:20:30 +0000 (08:20 -0800)
committerChris Duncan <chris@zoso.dev>
Fri, 5 Dec 2025 16:20:30 +0000 (08:20 -0800)
src/lib/crypto/secp256k1.ts

index 9c95e4d4009946b5c2b8978ccffcfdc43f065d8b..0d56660970ba50063db48daca0d64b0e07b64781 100644 (file)
@@ -19,7 +19,7 @@ type Point = {
        negate: () => Point
        double: () => Point
        add: (other: Point) => Point
-       multiply: (n: bigint, safe?: boolean) => Point
+       multiply: (n: bigint) => Point
        toAffine: () => AffinePoint
        assertValidity: () => Point
        toBytes: (isCompressed?: boolean) => Bytes
@@ -224,10 +224,8 @@ export class Secp256k1 {
                         * @param n scalar by which point is multiplied
                         * @param safe safe mode guards against timing attacks; unsafe mode is faster
                         */
-                       multiply (n: bigint, safe = true): Point {
-                               if (!safe && n === 0n) return secp256k1.I
-                               secp256k1.bigintInRange(n, 1n, secp256k1.N)
-                               if (n === 1n) return this
+                       multiply (n: bigint): Point {
+                               if (secp256k1.bigintInRange(n, 1n, secp256k1.N) === 1n) return this
                                if (this.equals(secp256k1.G)) return secp256k1.wNAF(n).p
                                // init result point & fake point
                                let p = secp256k1.I
@@ -236,7 +234,7 @@ export class Secp256k1 {
                                        // if bit is present, add to point
                                        // if not present, add to fake, for timing safety
                                        if (n & 1n) p = p.add(d)
-                                       else if (safe) f = f.add(d)
+                                       else f = f.add(d)
                                }
                                return p
                        },