From 5e52ccb5d757d4b8348f8677cbfc13c4f5668255 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 4 Dec 2025 11:42:37 -0800 Subject: [PATCH] Deprecate validation method since it's already checked when deriving the public key and we won't redundantly recheck in wallet. --- src/lib/crypto/secp256k1.ts | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/lib/crypto/secp256k1.ts b/src/lib/crypto/secp256k1.ts index ae978b5..7e1e448 100644 --- a/src/lib/crypto/secp256k1.ts +++ b/src/lib/crypto/secp256k1.ts @@ -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 -- 2.47.3