From 1236f7a2cc90e1bf919219d8b872250b08808aeb Mon Sep 17 00:00:00 2001 From: dapplion <35266934+dapplion@users.noreply.github.com> Date: Mon, 5 Apr 2021 19:47:25 +0200 Subject: [PATCH] Document default value of optional params --- src/blst/publicKey.ts | 1 + src/blst/signature.ts | 1 + src/interface.ts | 23 +++++++---------------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/blst/publicKey.ts b/src/blst/publicKey.ts index 641c1b9..d0ecff2 100644 --- a/src/blst/publicKey.ts +++ b/src/blst/publicKey.ts @@ -8,6 +8,7 @@ export class PublicKey extends blst.PublicKey implements IPublicKey { super(value); } + /** @param type Defaults to `CoordType.jacobian` */ static fromBytes(bytes: Uint8Array, type?: blst.CoordType): PublicKey { const pk = blst.PublicKey.fromBytes(bytes, type); if (pk.value.is_inf()) { diff --git a/src/blst/signature.ts b/src/blst/signature.ts index ae38270..fd11b7b 100644 --- a/src/blst/signature.ts +++ b/src/blst/signature.ts @@ -9,6 +9,7 @@ export class Signature extends blst.Signature implements ISignature { super(value); } + /** @param type Defaults to `CoordType.affine` */ static fromBytes(bytes: Uint8Array, type?: blst.CoordType, validate?: boolean): Signature { const sig = blst.Signature.fromBytes(bytes, type); if (validate) sig.sigValidate(); diff --git a/src/interface.ts b/src/interface.ts index 2687776..069c88d 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -1,21 +1,8 @@ export interface IBls { implementation: Implementation; - SecretKey: { - fromBytes(bytes: Uint8Array): SecretKey; - fromHex(hex: string): SecretKey; - fromKeygen(ikm?: Uint8Array): SecretKey; - }; - PublicKey: { - fromBytes(bytes: Uint8Array, type?: CoordType): PublicKey; - fromHex(hex: string): PublicKey; - aggregate(publicKeys: PublicKey[]): PublicKey; - }; - Signature: { - fromBytes(bytes: Uint8Array, type?: CoordType, validate?: boolean): Signature; - fromHex(hex: string): Signature; - aggregate(signatures: Signature[]): Signature; - verifyMultipleSignatures(sets: {publicKey: PublicKey; message: Uint8Array; signature: Signature}[]): boolean; - }; + SecretKey: typeof SecretKey; + PublicKey: typeof PublicKey; + Signature: typeof Signature; sign(secretKey: Uint8Array, message: Uint8Array): Uint8Array; aggregatePublicKeys(publicKeys: Uint8Array[]): Uint8Array; @@ -41,14 +28,17 @@ export declare class SecretKey { } export declare class PublicKey { + /** @param type Only for impl `blst-native`. Defaults to `CoordType.jacobian` */ static fromBytes(bytes: Uint8Array, type?: CoordType): PublicKey; static fromHex(hex: string): PublicKey; static aggregate(publicKeys: PublicKey[]): PublicKey; + /** @param format Defaults to `PointFormat.compressed` */ toBytes(format?: PointFormat): Uint8Array; toHex(format?: PointFormat): string; } export declare class Signature { + /** @param type Only for impl `blst-native`. Defaults to `CoordType.affine` */ static fromBytes(bytes: Uint8Array, type?: CoordType, validate?: boolean): Signature; static fromHex(hex: string): Signature; static aggregate(signatures: Signature[]): Signature; @@ -56,6 +46,7 @@ export declare class Signature { verify(publicKey: PublicKey, message: Uint8Array): boolean; verifyAggregate(publicKeys: PublicKey[], message: Uint8Array): boolean; verifyMultiple(publicKeys: PublicKey[], messages: Uint8Array[]): boolean; + /** @param format Defaults to `PointFormat.compressed` */ toBytes(format?: PointFormat): Uint8Array; toHex(format?: PointFormat): string; }