/** * Data container for extended points (much faster to operate on than affine points) */ export type Point4 = { x: T; y: T; z: T; t: T; }; export type CubicFieldExt = { F: FieldWithOps; V3: T; ZERO: [T, T, T]; ONE: [T, T, T]; add(a: [T, T, T], b: [T, T, T]): [T, T, T]; scale(a: [T, T, T], s: bigint): [T, T, T]; equals(a: [T, T, T], b: [T, T, T]): boolean; multiply(a: [T, T, T], b: [T, T, T]): [T, T, T]; invert(x: [T, T, T]): [T, T, T]; }; export type _CubicFielExtExtendsField = AssertExtends, CubicFieldExt>; /** * Abstraction of an additive group * * ZERO: additive identity * * add two points to form a new point * * scale: add a point to itself * * equals: compares two points * * isValidPoint: returns true if point lies on curve * * For scale we'll always be using the double-and-add algorithm */ export type Curve = { ZERO: T; add: (a: T, b: T) => T; negate: (a: T) => T; equals: (a: T, b: T) => boolean; isValidPoint: (p: T) => boolean; }; export type CurveWithOps = Curve & { isZero(point: T): boolean; subtract(a: T, b: T): T; scale(point: T, s: bigint): T; }; export type CurveWithFromToAffine = CurveWithOps & { toAffine: (point: T) => Point2; fromAffine: (point: Point2) => T; }; export type ShortAffineCurve = Curve> & { F: FieldWithOps; b: T; double(point: Point2): Point2; }; export type ShortAffine = CurveWithFromToAffine> & { b: T; }; export type ShortProjectedCurve = Curve> & { F: FieldWithOps; }; export type ShortProjected = CurveWithFromToAffine>; export type Ed25519Curve = CurveWithOps & { toAffine: (point: T) => Point2; fromAffine: (point: Point2) => T; }; export type FieldElement2 = [bigint, bigint]; export type FieldElement6 = [[bigint, bigint], [bigint, bigint], [bigint, bigint]]; /** * A Field is an abstraction of a collection of numbers. * Fields used in Elliptic Curve Cryptography must define the following operations: * * add two Field elements (TODO: accept any number of elements to add) * * scale a Field element (i.e. add to itself), this defines how additive negation works * * multiply two Field elements * * pow (i.e. multiply by itself) * * equals, compare to Field elements * * invert (i.e. solve the equation x*x^-1 = 1 for x^-1) * * sqrt (i.e. solve the equation y*y = x for y) * * The following Field elements must also be defined: * * ZERO (i.e. additive identity) * * ONE (i.e. multiplicative identity) * * The following operations can then be derived from the base operations: * * subtract * * negate * * divide * * square * * A Field should be usable without knowing the number used for modulo operations. */ export type Field = { ZERO: T; ONE: T; add: (a: T, ...b: T[]) => T; scale: (a: T, s: bigint) => T; multiply: (a: T, b: T) => T; equals: (a: T, b: T) => boolean; invert: (a: T) => T; }; export type FieldWithOps = Field & { isZero(a: T): boolean; isOne(a: T): boolean; mod(a: T): T; subtract(a: T, b: T): T; negate(a: T): T; square(a: T): T; cube(a: T): T; divide(a: T, b: T): T; pow(a: T, p: bigint): T; halve(a: T): T; }; export type ScalarField = Field & { modulo: bigint; }; export type QuadraticFieldExt = Field<[T, T]> & { F: FieldWithOps; U2: T; }; export type FieldWithSqrt = FieldWithOps & { sqrt(a: bigint): bigint; }; export type _Field12WithExtendedOpsExtendsFieldWithOps = AssertExtends, Field12WithExtendedOps>; export type _AffineCurve1ExtendsShortAffine = AssertExtends, AffineCurve1>; export type _AffineCurve2ExtendsShortAffine = AssertExtends, AffineCurve2>; export type _ProjectedCurve1ExtendsShortProjected = AssertExtends, ProjectedCurve1>; export type _ProjectedCurve2ExtendsShortProjected = AssertExtends, ProjectedCurve2>; import type { AssertExtends } from "@helios-lang/type-utils"; import type { Point2 } from "./index.js"; import type { Point3 } from "./index.js"; import type { FieldElement12 } from "./index.js"; import type { Field12WithExtendedOps } from "./index.js"; import type { AffineCurve1 } from "./index.js"; import type { AffineCurve2 } from "./index.js"; import type { ProjectedCurve1 } from "./index.js"; import type { ProjectedCurve2 } from "./index.js"; //# sourceMappingURL=internal.d.ts.map