From 104d6dd2695c12829ad16d03b1cc3a8d824777dc Mon Sep 17 00:00:00 2001 From: dapplion Date: Sat, 28 Nov 2020 19:05:34 +0000 Subject: [PATCH] Use upstream types for bls-eth-wasm --- package.json | 2 +- tsconfig.json | 8 ++- types/bls-eth-wasm/index.d.ts | 97 ----------------------------------- yarn.lock | 8 +-- 4 files changed, 8 insertions(+), 107 deletions(-) delete mode 100644 types/bls-eth-wasm/index.d.ts diff --git a/package.json b/package.json index 8491d2f..6f6d581 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "dependencies": { "@chainsafe/bls-keygen": "^0.3.0", - "bls-eth-wasm": "^0.4.1" + "bls-eth-wasm": "^0.4.4" }, "devDependencies": { "@babel/cli": "^7.8.4", diff --git a/tsconfig.json b/tsconfig.json index dd24356..a15932d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,11 +4,9 @@ "target": "esnext", "module": "commonjs", "pretty": true, - "lib": [ - "esnext.bigint" - ], - "typeRoots": ["./node_modules/@types", "./types"], - "declaration": true, + "lib": ["esnext.bigint"], + "typeRoots": ["./node_modules/@types"], + "declaration": true, "strict": true, "strictNullChecks": false, "esModuleInterop": true diff --git a/types/bls-eth-wasm/index.d.ts b/types/bls-eth-wasm/index.d.ts deleted file mode 100644 index 4b92724..0000000 --- a/types/bls-eth-wasm/index.d.ts +++ /dev/null @@ -1,97 +0,0 @@ -declare module "bls-eth-wasm" { - export class Common { - constructor(size: number); - - deserializeHexStr(s: string): void; - serializeToHexStr(): string; - dump(msg?: string): string; - clear(): void; - clone(): this; - isEqual(rhs: this): boolean; - deserialize(v: Uint8Array): void; - serialize(): Uint8Array; - add(rhs: this): void; - } - - export class SecretKeyType extends Common { - constructor(); - - setInt(x: number): void; - isZero(): boolean; - setHashOf(a: Uint8Array): void; - setLittleEndian(a: Uint8Array): void; - setLittleEndianMod(a: Uint8Array): void; - setByCSPRNG(): void; - getPublicKey(): PublicKeyType; - sign(m: string | Uint8Array): SignatureType; - } - - export class PublicKeyType extends Common { - constructor(); - - isZero(): boolean; - deserializeUncompressed(s: Uint8Array): void; - serializeUncompressed(): Uint8Array; - isValidOrder(): boolean; - verify(signature: SignatureType, m: Uint8Array | string): boolean; - } - - export class SignatureType extends Common { - constructor(); - - deserializeUncompressed(s: Uint8Array): void; - serializeUncompressed(): Uint8Array; - isValidOrder(): boolean; - aggregate(others: SignatureType[]): boolean; - fastAggregateVerify(publicKeys: PublicKeyType[], message: Uint8Array): boolean; - aggregateVerifyNoCheck(publicKeys: PublicKeyType[], messages: Uint8Array): boolean; - } - - export function init(curveType: CurveType): Promise; - export function blsInit(curveType: CurveType): void; - export function setETHmode(mode: EthMode): void; - - export function toHex(a: Uint8Array, start: number, length: number): string; - export function toHexStr(a: Uint8Array): string; - export function fromHexStr(s: string): Uint8Array; - export function deserializeHexStrToSecretKey(s: string): SecretKeyType; - export function deserializeHexStrToPublicKey(s: string): PublicKeyType; - export function deserializeHexStrToSignature(s: string): SignatureType; - - export function getCurveOrder(): string; - export function getFieldOrder(): string; - export function verifySignatureOrder(doVerify: boolean): void; - export function verifyPublicKeyOrder(doVerify: boolean): void; - - /** - * - * @param msgs single array with concatenated messages - * @param msgSize defaults to MSG_SIZE - */ - export function areAllMsgDifferent(msgs: Uint8Array, msgSize?: number): boolean; - - /** - * return true if all pub[i].verify(sigs[i], msgs[i]) - * @param msgs msgs is a concatenation of arrays of 32-byte Uint8Array - */ - export function multiVerify(pubs: PublicKeyType[], sigs: SignatureType[], msgs: Uint8Array[]): boolean; - - export const SecretKey: typeof SecretKeyType; - export const PublicKey: typeof PublicKeyType; - export const Signature: typeof SignatureType; - - export enum EthMode { - DRAFT_07 = 3, - } - - export enum CurveType { - BN254 = 0, - BLS12_381 = 5, - } - - export const BN254 = CurveType.BN254; - export const BLS12_381 = CurveType.BLS12_381; - export const ethMode = true; - export const ETH_MODE_DRAFT_07 = EthMode.DRAFT_07; - export const MSG_SIZE = 32; -} diff --git a/yarn.lock b/yarn.lock index fb7d8a9..9c3d741 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1488,10 +1488,10 @@ blob@0.0.5: resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.5.tgz#d680eeef25f8cd91ad533f5b01eed48e64caf683" integrity sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig== -bls-eth-wasm@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/bls-eth-wasm/-/bls-eth-wasm-0.4.1.tgz#7a1bac9d36f117ad4a8c7e741d667b51a6c31e68" - integrity sha512-BBM+t/RNZSOZKiLmz+wmz58kzK9CDjH6K2o2QuUKUkJNUaDo8g4vsqay0SvbmxinhpSxL/epkVel9+KNXcFnlw== +bls-eth-wasm@^0.4.4: + version "0.4.4" + resolved "https://registry.yarnpkg.com/bls-eth-wasm/-/bls-eth-wasm-0.4.4.tgz#3d4c99f8ddee6df23e188dc756125268a0f4d525" + integrity sha512-S6XwscKuxxYTANHZX8tZQxZKvj9IhG3aOCEuy1EnNdsAOfuH2pdRIgWrORwpKd4SLdvmPWap9I+TbJRnFx1Yng== bluebird@^3.3.0, bluebird@^3.5.5: version "3.7.2"