export type Bytes = Uint8Array<ArrayBuffer>
/** Signature instance, which allows recovering pubkey from it. */
export type RecoveredSignature = Signature & { recovery: number }
-/** Weierstrass elliptic curve options. */
-export type WeierstrassOpts<T> = Readonly<{
- p: bigint
- n: bigint
- h: bigint
- a: T
- b: T
- Gx: T
- Gy: T
-}>
/** Point in 2d xy affine coordinates. */
export type AffinePoint = {
x: bigint
static N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n
static h = 1n
static a = 0n
- static _b = 7n
+ static b = 7n
static Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n
static Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n
- static CURVE: WeierstrassOpts<bigint> = {
- p: this.P,
- n: this.N,
- h: 1n,
- a: 0n,
- b: this._b,
- Gx: this.Gx,
- Gy: this.Gy,
- }
-
static L: 32 = 32 // field / group byte length
static L2: 64 = 64
static lengths: Secp256k1Lengths = {
// -----------------
/** secp256k1 formula. Koblitz curves are subclass of weierstrass curves with a=0, making it x³+b */
- static koblitz = (x: bigint) => this.modP(this.modP(x * x) * x + this._b)
+ static koblitz = (x: bigint) => this.modP(this.modP(x * x) * x + this.b)
/** assert is element of field mod P (incl. 0) */
static FpIsValid = (n: bigint) => this.bigintInRange(n, 0n, this.P)
/** assert is element of field mod P (excl. 0) */
const { X: X1, Y: Y1, Z: Z1 } = { X, Y, Z }
const { X: X2, Y: Y2, Z: Z2 } = other
const a = 0n
- const b = secp256k1.CURVE.b
+ const b = secp256k1.b
const b3 = M(b * 3n)
let X3 = 0n, Y3 = 0n, Z3 = 0n
let t0 = M(X1 * X2), t1 = M(Y1 * Y2), t2 = M(Z1 * Z2), t3 = M(X1 + Y1) // step 1