import { type CurveLengths } from './curve.ts'; import { type H2CHasher, type H2CHashOpts, type H2COpts, type MapToCurve } from './hash-to-curve.ts'; import { type IField } from './modular.ts'; import type { Fp12, Fp12Bls, Fp2, Fp2Bls, Fp6Bls } from './tower.ts'; import { type WeierstrassPoint, type WeierstrassPointCons } from './weierstrass.ts'; type Fp = bigint; export type BlsTwistType = 'multiplicative' | 'divisive'; export type BlsShortSignatureCoder = { fromBytes(bytes: Uint8Array): WeierstrassPoint; fromHex(hex: string): WeierstrassPoint; toBytes(point: WeierstrassPoint): Uint8Array; toHex(point: WeierstrassPoint): string; }; export type BlsLongSignatureCoder = { fromBytes(bytes: Uint8Array): WeierstrassPoint; fromHex(hex: string): WeierstrassPoint; toBytes(point: WeierstrassPoint): Uint8Array; toHex(point: WeierstrassPoint): string; }; export type BlsFields = { Fp: IField; Fr: IField; Fp2: Fp2Bls; Fp6: Fp6Bls; Fp12: Fp12Bls; }; export type BlsPostPrecomputePointAddFn = (Rx: Fp2, Ry: Fp2, Rz: Fp2, Qx: Fp2, Qy: Fp2) => { Rx: Fp2; Ry: Fp2; Rz: Fp2; }; export type BlsPostPrecomputeFn = (Rx: Fp2, Ry: Fp2, Rz: Fp2, Qx: Fp2, Qy: Fp2, pointAdd: BlsPostPrecomputePointAddFn) => void; export type BlsPairing = { lengths: CurveLengths; Fr: IField; Fp12: Fp12Bls; calcPairingPrecomputes: (p: WeierstrassPoint) => Precompute; millerLoopBatch: (pairs: [Precompute, Fp, Fp][]) => Fp12; pairing: (P: WeierstrassPoint, Q: WeierstrassPoint, withFinalExponent?: boolean) => Fp12; pairingBatch: (pairs: { g1: WeierstrassPoint; g2: WeierstrassPoint; }[], withFinalExponent?: boolean) => Fp12; randomSecretKey: (seed?: Uint8Array) => Uint8Array; }; export type BlsPairingParams = { ateLoopSize: bigint; xNegative: boolean; twistType: BlsTwistType; randomBytes?: (len?: number) => Uint8Array; postPrecompute?: BlsPostPrecomputeFn; }; export type BlsHasherParams = { mapToG1?: MapToCurve; mapToG2?: MapToCurve; hasherOpts: H2COpts; hasherOptsG1: H2COpts; hasherOptsG2: H2COpts; }; type PrecomputeSingle = [Fp2, Fp2, Fp2][]; type Precompute = PrecomputeSingle[]; /** * BLS consists of two curves: G1 and G2: * - G1 is a subgroup of (x, y) E(Fq) over y² = x³ + 4. * - G2 is a subgroup of ((x₁, x₂+i), (y₁, y₂+i)) E(Fq²) over y² = x³ + 4(1 + i) where i is √-1 */ export interface BlsCurvePair { lengths: CurveLengths; millerLoopBatch: BlsPairing['millerLoopBatch']; pairing: BlsPairing['pairing']; pairingBatch: BlsPairing['pairingBatch']; G1: { Point: WeierstrassPointCons; }; G2: { Point: WeierstrassPointCons; }; fields: { Fp: IField; Fp2: Fp2Bls; Fp6: Fp6Bls; Fp12: Fp12Bls; Fr: IField; }; utils: { randomSecretKey: (seed?: Uint8Array) => Uint8Array; calcPairingPrecomputes: BlsPairing['calcPairingPrecomputes']; }; params: { ateLoopSize: bigint; twistType: BlsTwistType; }; } export interface BlsCurvePairWithHashers extends BlsCurvePair { G1: H2CHasher>; G2: H2CHasher>; } export interface BlsCurvePairWithSignatures extends BlsCurvePairWithHashers { longSignatures: BlsSigs; shortSignatures: BlsSigs; } type BLSInput = Uint8Array; export interface BlsSigs { lengths: CurveLengths; keygen(seed?: Uint8Array): { secretKey: Uint8Array; publicKey: WeierstrassPoint

; }; getPublicKey(secretKey: Uint8Array): WeierstrassPoint

; sign(hashedMessage: WeierstrassPoint, secretKey: Uint8Array): WeierstrassPoint; verify(signature: WeierstrassPoint | BLSInput, message: WeierstrassPoint, publicKey: WeierstrassPoint

| BLSInput): boolean; verifyBatch: (signature: WeierstrassPoint | BLSInput, items: { message: WeierstrassPoint; publicKey: WeierstrassPoint

| BLSInput; }[]) => boolean; aggregatePublicKeys(publicKeys: (WeierstrassPoint

| BLSInput)[]): WeierstrassPoint

; aggregateSignatures(signatures: (WeierstrassPoint | BLSInput)[]): WeierstrassPoint; hash(message: Uint8Array, DST?: string | Uint8Array, hashOpts?: H2CHashOpts): WeierstrassPoint; Signature: BlsLongSignatureCoder; } type BlsSignatureCoders = Partial<{ LongSignature: BlsLongSignatureCoder; ShortSignature: BlsShortSignatureCoder; }>; export declare function blsBasic(fields: BlsFields, G1_Point: WeierstrassPointCons, G2_Point: WeierstrassPointCons, params: BlsPairingParams): BlsCurvePair; export declare function bls(fields: BlsFields, G1_Point: WeierstrassPointCons, G2_Point: WeierstrassPointCons, params: BlsPairingParams, hasherParams: BlsHasherParams, signatureCoders: BlsSignatureCoders): BlsCurvePairWithSignatures; export {}; //# sourceMappingURL=bls.d.ts.map