fix lint
This commit is contained in:
parent
135625ccc0
commit
c153de6e24
|
@ -1,4 +1,3 @@
|
||||||
import herumi from "bls-eth-wasm";
|
|
||||||
import {herumiToIBls} from "./herumi";
|
import {herumiToIBls} from "./herumi";
|
||||||
import {IBls} from "./interface";
|
import {IBls} from "./interface";
|
||||||
|
|
||||||
|
@ -11,11 +10,14 @@ let context: IBls|undefined = undefined;
|
||||||
export async function init(backing: Backing = "herumi"): Promise<IBls> {
|
export async function init(backing: Backing = "herumi"): Promise<IBls> {
|
||||||
if (!context) {
|
if (!context) {
|
||||||
switch (backing) {
|
switch (backing) {
|
||||||
case "herumi": {
|
case "herumi":
|
||||||
|
{
|
||||||
context = await herumiToIBls();
|
context = await herumiToIBls();
|
||||||
contextBacking = backing;
|
contextBacking = backing;
|
||||||
} break;
|
}
|
||||||
default: throw new Error(`Unsupported backing - ${backing}`)
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unsupported backing - ${backing}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await context.init();
|
await context.init();
|
||||||
|
@ -37,7 +39,6 @@ export function getContext(): IBls {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function getContextBacking(): Backing {
|
export function getContextBacking(): Backing {
|
||||||
if (!context) {
|
if (!context) {
|
||||||
throw new Error("BLS not initialized");
|
throw new Error("BLS not initialized");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import herumi from "bls-eth-wasm";
|
import herumi from "bls-eth-wasm";
|
||||||
import {init as initHerumi, destroy, getContext} from "./context";
|
import {init as initHerumi, destroy, getContext} from "./context";
|
||||||
import { IBls, IPrivateKeyValue, IPublicKeyValue, ISignatureValue } from '../interface';
|
import {IBls, IPrivateKeyValue, IPublicKeyValue, ISignatureValue} from "../interface";
|
||||||
|
|
||||||
export async function herumiToIBls(): Promise<IBls> {
|
export async function herumiToIBls(): Promise<IBls> {
|
||||||
await initHerumi();
|
await initHerumi();
|
||||||
|
@ -27,7 +27,7 @@ export async function herumiToIBls(): Promise<IBls> {
|
||||||
},
|
},
|
||||||
destroy: () => {
|
destroy: () => {
|
||||||
destroy();
|
destroy();
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
|
@ -1,12 +1,11 @@
|
||||||
interface Common {
|
interface ICommon {
|
||||||
|
|
||||||
new (): this;
|
new (): this;
|
||||||
|
|
||||||
deserializeHexStr(s: string): void;
|
deserializeHexStr(s: string): void;
|
||||||
|
|
||||||
serializeToHexStr(): string;
|
serializeToHexStr(): string;
|
||||||
|
|
||||||
isEqual(rhs: this): boolean
|
isEqual(rhs: this): boolean;
|
||||||
|
|
||||||
deserialize(v: Uint8Array): void;
|
deserialize(v: Uint8Array): void;
|
||||||
|
|
||||||
|
@ -21,8 +20,7 @@ interface Common {
|
||||||
clone(): this;
|
clone(): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPrivateKeyValue extends Common {
|
export interface IPrivateKeyValue extends ICommon {
|
||||||
|
|
||||||
setInt(x: number): void;
|
setInt(x: number): void;
|
||||||
|
|
||||||
setHashOf(a: Uint8Array): void;
|
setHashOf(a: Uint8Array): void;
|
||||||
|
@ -34,11 +32,9 @@ export interface IPrivateKeyValue extends Common {
|
||||||
getPublicKey(): IPublicKeyValue;
|
getPublicKey(): IPublicKeyValue;
|
||||||
|
|
||||||
sign(m: string | Uint8Array): ISignatureValue;
|
sign(m: string | Uint8Array): ISignatureValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPublicKeyValue extends Common {
|
export interface IPublicKeyValue extends ICommon {
|
||||||
|
|
||||||
verify(signature: ISignatureValue, m: Uint8Array | string): boolean;
|
verify(signature: ISignatureValue, m: Uint8Array | string): boolean;
|
||||||
isValidOrder(): boolean;
|
isValidOrder(): boolean;
|
||||||
deserializeUncompressed(s: Uint8Array): void;
|
deserializeUncompressed(s: Uint8Array): void;
|
||||||
|
@ -47,8 +43,7 @@ export interface IPublicKeyValue extends Common {
|
||||||
serializeUncompressedToHexStr(): string;
|
serializeUncompressedToHexStr(): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISignatureValue extends Common {
|
export interface ISignatureValue extends ICommon {
|
||||||
|
|
||||||
deserializeUncompressed(s: Uint8Array): void;
|
deserializeUncompressed(s: Uint8Array): void;
|
||||||
serializeUncompressed(): Uint8Array;
|
serializeUncompressed(): Uint8Array;
|
||||||
deserializeUncompressedHexStr(s: string): void;
|
deserializeUncompressedHexStr(s: string): void;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {PUBLIC_KEY_LENGTH} from "./constants";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import {Signature} from "./signature";
|
import {Signature} from "./signature";
|
||||||
import {EMPTY_PUBLIC_KEY} from "./helpers/utils";
|
import {EMPTY_PUBLIC_KEY} from "./helpers/utils";
|
||||||
import { IPublicKeyValue } from './interface';
|
import {IPublicKeyValue} from "./interface";
|
||||||
import {getContext} from "./context";
|
import {getContext} from "./context";
|
||||||
|
|
||||||
export class PublicKey {
|
export class PublicKey {
|
||||||
|
@ -31,7 +31,7 @@ export class PublicKey {
|
||||||
assert(value.length === PUBLIC_KEY_LENGTH * 2);
|
assert(value.length === PUBLIC_KEY_LENGTH * 2);
|
||||||
const context = getContext();
|
const context = getContext();
|
||||||
const pubkeyValue = new context.PublicKey();
|
const pubkeyValue = new context.PublicKey();
|
||||||
pubkeyValue.deserializeHexStr(value)
|
pubkeyValue.deserializeHexStr(value);
|
||||||
return new PublicKey(pubkeyValue);
|
return new PublicKey(pubkeyValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import assert from "assert";
|
||||||
import {FP_POINT_LENGTH} from "./constants";
|
import {FP_POINT_LENGTH} from "./constants";
|
||||||
import {getContext} from "./context";
|
import {getContext} from "./context";
|
||||||
import {EMPTY_SIGNATURE} from "./helpers/utils";
|
import {EMPTY_SIGNATURE} from "./helpers/utils";
|
||||||
import { ISignatureValue } from './interface';
|
import {ISignatureValue} from "./interface";
|
||||||
import {PublicKey} from "./publicKey";
|
import {PublicKey} from "./publicKey";
|
||||||
|
|
||||||
export class Signature {
|
export class Signature {
|
||||||
|
|
Reference in New Issue