Fix lint errors
This commit is contained in:
parent
1e92f6311b
commit
c354386dab
|
@ -8,10 +8,10 @@ export * from "../constants";
|
|||
|
||||
export {Keypair, PrivateKey, PublicKey, Signature};
|
||||
|
||||
export async function initBLS() {
|
||||
export async function initBLS(): Promise<void> {
|
||||
// Native bindings require no init() call
|
||||
}
|
||||
export function destroy() {
|
||||
export function destroy(): void {
|
||||
// Native bindings require no destroy() call
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,14 @@ export class Signature {
|
|||
);
|
||||
}
|
||||
|
||||
toBytes(): Buffer {
|
||||
return Buffer.from(this.affine.toBytes());
|
||||
}
|
||||
|
||||
toHex(): string {
|
||||
return bytesToHex(this.toBytes());
|
||||
}
|
||||
|
||||
private aggregateVerify(msgs: Uint8Array[], pks: blst.PublicKey[]): boolean {
|
||||
// If this set is simply an infinity signature and infinity pubkey then skip verification.
|
||||
// This has the effect of always declaring that this sig/pubkey combination is valid.
|
||||
|
@ -52,12 +60,4 @@ export class Signature {
|
|||
|
||||
return blst.aggregateVerify(msgs, pks, this.affine);
|
||||
}
|
||||
|
||||
toBytes(): Buffer {
|
||||
return Buffer.from(this.affine.toBytes());
|
||||
}
|
||||
|
||||
toHex(): string {
|
||||
return bytesToHex(this.toBytes());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ import {PrivateKey} from "./privateKey";
|
|||
import {PublicKey} from "./publicKey";
|
||||
import {Signature} from "./signature";
|
||||
import {initBLS, destroy} from "./context";
|
||||
import {PUBLIC_KEY_LENGTH} from "../constants";
|
||||
import assert from "assert";
|
||||
import {toBuffer} from "../helpers/utils";
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ export function runBenchmark<T, R>({
|
|||
testRunner: (input: T) => R;
|
||||
runs?: number;
|
||||
id: string;
|
||||
}) {
|
||||
}): void {
|
||||
const diffsNanoSec: bigint[] = [];
|
||||
|
||||
for (let i = 0; i < runs; i++) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import herumi from "../src/herumi";
|
|||
export type Implementation = "blst" | "herumi";
|
||||
export const implementations: Implementation[] = ["blst", "herumi"];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export function getBls(implementation: Implementation) {
|
||||
switch (implementation) {
|
||||
case "blst":
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
import {expect} from "chai";
|
||||
import {forEachImplementation} from "../switch";
|
||||
import {getRandomBytes} from "../../src/helpers/utils";
|
||||
|
||||
function randomMessage(): Uint8Array {
|
||||
return getRandomBytes(32);
|
||||
}
|
||||
|
||||
function getN<T>(n: number, getter: () => T): T[] {
|
||||
return Array.from({length: n}, () => getter());
|
||||
}
|
||||
import {getN, randomMessage} from "../util";
|
||||
|
||||
forEachImplementation((bls) => {
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
function getRandomData() {
|
||||
const sk = bls.PrivateKey.fromKeygen();
|
||||
const pk = sk.toPublicKey();
|
||||
|
@ -53,7 +46,7 @@ forEachImplementation((bls) => {
|
|||
});
|
||||
|
||||
describe("verify multiple", () => {
|
||||
it(`should verify aggregated signatures`, () => {
|
||||
it("should verify aggregated signatures", () => {
|
||||
const sks = getN(4, () => bls.PrivateKey.fromKeygen());
|
||||
const msgs = getN(2, () => randomMessage());
|
||||
const pks = sks.map((sk) => sk.toPublicKey());
|
||||
|
|
10
test/util.ts
10
test/util.ts
|
@ -1,3 +1,5 @@
|
|||
import {getRandomBytes} from "../src/helpers/utils";
|
||||
|
||||
export function fromHexString(hex: string): Buffer {
|
||||
return Buffer.from(hex.replace("0x", ""), "hex");
|
||||
}
|
||||
|
@ -5,3 +7,11 @@ export function fromHexString(hex: string): Buffer {
|
|||
export function toHexString(bytes: Buffer | Uint8Array): string {
|
||||
return `0x${Buffer.from(bytes).toString("hex")}`;
|
||||
}
|
||||
|
||||
export function randomMessage(): Uint8Array {
|
||||
return getRandomBytes(32);
|
||||
}
|
||||
|
||||
export function getN<T>(n: number, getter: () => T): T[] {
|
||||
return Array.from({length: n}, () => getter());
|
||||
}
|
||||
|
|
Reference in New Issue