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 {
}
}
- /** 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
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