• Interaction between classes from different curves should fail: k256.Point.BASE.add(p256.Point.BASE)
  • For this purpose we want to use instanceof operator, which is fast and works during runtime
  • Different calls of curve() would return different classes - curve(params) !== curve(params): if somebody decided to monkey-patch their curve, it won't affect others

TypeScript can't infer types for classes created inside a function. Classes is one instance of nominative types in TypeScript and interfaces only check for shape, so it's hard to create unique type for every function call.

We can use generic types via some param, like curve opts, but that would: 1. Enable interaction between curve(params) and curve(params) (curves of same params) which is hard to debug. 2. Params can be generic and we can't enforce them to be constant value: if somebody creates curve from non-constant params, it would be allowed to interact with other curves with non-constant params

TODO: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#unique-symbol

interface ProjPointType<T> {
    px: T;
    py: T;
    pz: T;
    get x(): T;
    get y(): T;
    _setWindowSize(windowSize: number): void;
    add(other: ProjPointType): ProjPointType;
    assertValidity(): void;
    clearCofactor(): ProjPointType<T>;
    double(): ProjPointType;
    equals(other: ProjPointType): boolean;
    hasEvenY(): boolean;
    isTorsionFree(): boolean;
    multiply(scalar: bigint): ProjPointType<T>;
    multiplyAndAddUnsafe(
        Q: ProjPointType<T>,
        a: bigint,
        b: bigint,
    ): undefined | ProjPointType<T>;
    multiplyUnsafe(scalar: bigint): ProjPointType<T>;
    negate(): ProjPointType;
    subtract(other: ProjPointType): ProjPointType;
    toAffine(iz?: T): AffinePoint<T>;
    toHex(isCompressed?: boolean): string;
    toRawBytes(isCompressed?: boolean): Uint8Array;
}

Type Parameters

  • T

Hierarchy (View Summary)

Accessors

  • get x(): T

    Returns T

  • get y(): T

    Returns T

Methods

  • Parameters

    • windowSize: number

    Returns void

  • Returns void

  • Returns ProjPointType<T>

  • Parameters

    Returns boolean

  • Returns boolean

  • Returns boolean

  • Parameters

    • scalar: bigint

    Returns ProjPointType<T>

  • Parameters

    Returns undefined | ProjPointType<T>

  • Parameters

    • scalar: bigint

    Returns ProjPointType<T>

  • Parameters

    • Optionaliz: T

    Returns AffinePoint<T>

  • Parameters

    • OptionalisCompressed: boolean

    Returns string

  • Parameters

    • OptionalisCompressed: boolean

    Returns Uint8Array

Properties

px: T
py: T
pz: T
MMNEPVFCICPMFPCPTTAAATR