Skip to main content
Module

x/alosaur/src/security/session/src/secp256k1/mod.ts>Point

Alosaur - Deno web framework with many decorators
Very Popular
Go to Latest
class Point
Re-export
import { Point } from "https://deno.land/x/alosaur@v0.38.0/src/security/session/src/secp256k1/mod.ts";

Default Point works in default aka affine coordinates: (x, y)

Constructors

new
Point(x: bigint, y: bigint)

Properties

optional
_WINDOW_SIZE: number

Methods

_setWindowSize(windowSize: number)
add(other: Point)
equals(other: Point): boolean
multiply(scalar: number | bigint)
multiplyAndAddUnsafe(
Q: Point,
a: bigint,
b: bigint,
): Point | undefined

Efficiently calculate aP + bQ. Unsafe, can expose private key, if used incorrectly. TODO: Utilize Shamir's trick

subtract(other: Point)
toHex(isCompressed?): string
toRawBytes(isCompressed?): Uint8Array

Static Properties

BASE: Point

Base point aka generator. public_key = Point.BASE * private_key

ZERO: Point

Identity point aka point at infinity. point = point + zero_point

Static Methods

private
fromCompressedHex(bytes: Uint8Array)

Supports compressed Schnorr (32-byte) and ECDSA (33-byte) points

private
fromUncompressedHex(bytes: Uint8Array)
fromHex(hex: Hex): Point

Converts hash string or Uint8Array to Point.

fromPrivateKey(privateKey: PrivKey)
fromSignature(
msgHash: Hex,
signature: Sig,
recovery: number,
): Point

Recovers public key from ECDSA signature. https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm#Public_key_recovery

recover(r, s, h) where
  u1 = hs^-1 mod n
  u2 = sr^-1 mod n
  Q = u1⋅G + u2⋅R