From 9b7e5f5f95aed97b8e517bfe4db5fd88a6a13348 Mon Sep 17 00:00:00 2001 From: dapplion Date: Mon, 30 Nov 2020 11:43:47 +0000 Subject: [PATCH] Export class interfaces too --- src/index.ts | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9b55c9a..cad6199 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import {IBls} from "./interface"; +import {IBls, IPrivateKey, IPublicKey, ISignature} from "./interface"; import {bls as blsHerumi} from "./herumi"; export type Implementation = "herumi" | "blst-native"; @@ -7,6 +7,7 @@ export * from "./interface"; // TODO: Use a Proxy for example to throw an error if it's not initialized yet export const bls: IBls = {} as IBls; +export default bls; async function getImplementation(impl: Implementation = "herumi"): Promise { switch (impl) { @@ -43,8 +44,32 @@ export declare let aggregatePubkeys: IBls["aggregatePubkeys"]; export declare let verify: IBls["verify"]; export declare let verifyAggregate: IBls["verifyAggregate"]; export declare let verifyMultiple: IBls["verifyMultiple"]; -export declare let PrivateKey: IBls["PrivateKey"]; -export declare let PublicKey: IBls["PublicKey"]; -export declare let Signature: IBls["Signature"]; -export default bls; +export declare class PrivateKey implements IPrivateKey { + static fromBytes(bytes: Uint8Array): PrivateKey; + static fromHex(hex: string): PrivateKey; + static fromKeygen(entropy?: Uint8Array): PrivateKey; + sign(message: Uint8Array): Signature; + toPublicKey(): PublicKey; + toBytes(): Uint8Array; + toHex(): string; +} + +export declare class PublicKey implements IPublicKey { + static fromBytes(bytes: Uint8Array): PublicKey; + static fromHex(hex: string): PublicKey; + static aggregate(pubkeys: PublicKey[]): PublicKey; + toBytes(): Uint8Array; + toHex(): string; +} + +export declare class Signature implements ISignature { + static fromBytes(bytes: Uint8Array): Signature; + static fromHex(hex: string): Signature; + static aggregate(signatures: Signature[]): Signature; + verify(publicKey: PublicKey, message: Uint8Array): boolean; + verifyAggregate(publicKeys: PublicKey[], message: Uint8Array): boolean; + verifyMultiple(publicKeys: PublicKey[], messages: Uint8Array[]): boolean; + toBytes(): Uint8Array; + toHex(): string; +}