]> git.codecow.com Git - libnemo.git/commitdiff
Deprecate validation method since it's already checked when deriving the public key...
authorChris Duncan <chris@zoso.dev>
Thu, 4 Dec 2025 19:42:37 +0000 (11:42 -0800)
committerChris Duncan <chris@zoso.dev>
Thu, 4 Dec 2025 19:42:37 +0000 (11:42 -0800)
src/lib/crypto/secp256k1.ts

index ae978b51ef5c04d557648bf296978c51bd6ffae7..7e1e44809b404eea837293b5f2640bab62be33dc 100644 (file)
@@ -329,13 +329,6 @@ export class Secp256k1 {
                return this.G.multiply(this.secretKeyToScalar(privKey)).toBytes(isCompressed)
        }
 
-       static isValidSecretKey (secretKey: Bytes): boolean {
-               try {
-                       return !!this.secretKeyToScalar(secretKey)
-               } catch (error) {
-                       return false
-               }
-       }
        static isValidPublicKey (publicKey: Bytes, isCompressed?: boolean): boolean {
                const { publicKey: comp, publicKeyUncompressed } = this.lengths
                try {
@@ -348,7 +341,16 @@ export class Secp256k1 {
                }
        }
 
-       /** Precomputes */
+       /**
+        * Precomputes give 12x faster getPublicKey(), 10x sign(), 2x verify() by
+        * caching multiples of G (base point). Cache is stored in 32MB of RAM.
+        * Any time `G.multiply` is done, precomputes are used.
+        *
+        * w-ary non-adjacent form (wNAF) precomputation method is 10% slower than windowed method,
+        * but takes 2x less RAM. RAM reduction is possible by utilizing subtraction.
+        *
+        * !! Precomputes can be disabled by commenting-out call of the wNAF() inside Point#multiply().
+        */
        static Gpows: Point[] | undefined = undefined // precomputes for base point G
        static W = 8 // W is window size
        static scalarBits = 256
@@ -374,17 +376,6 @@ export class Secp256k1 {
                const n = p.negate()
                return cnd ? n : p
        }
-
-       /**
-        * Precomputes give 12x faster getPublicKey(), 10x sign(), 2x verify() by
-        * caching multiples of G (base point). Cache is stored in 32MB of RAM.
-        * Any time `G.multiply` is done, precomputes are used.
-        *
-        * w-ary non-adjacent form (wNAF) precomputation method is 10% slower than windowed method,
-        * but takes 2x less RAM. RAM reduction is possible by utilizing subtraction.
-        *
-        * !! Precomputes can be disabled by commenting-out call of the wNAF() inside Point#multiply().
-        */
        static wNAF (n: bigint): { p: Point; f: Point } {
                const comp = this.Gpows || (this.Gpows = this.precompute())
                let p = this.I