diff --git a/package-lock.json b/package-lock.json index ce2cdfc..723368b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24524,6 +24524,7 @@ "socket.io-client": "^4.7.4" }, "devDependencies": { + "@toruslabs/tss-dkls-lib": "^2.3.3", "@types/bn.js": "^5.1.5", "@types/elliptic": "^6.4.18", "rimraf": "^5.0.5", @@ -24546,7 +24547,7 @@ }, "packages/tss-lib": { "name": "@toruslabs/tss-dkls-lib", - "version": "1.0.0", + "version": "2.3.3", "devDependencies": { "ts-loader": "^9.4.2" } diff --git a/packages/tss-client/package.json b/packages/tss-client/package.json index b778831..d1844ca 100644 --- a/packages/tss-client/package.json +++ b/packages/tss-client/package.json @@ -31,7 +31,8 @@ "@types/elliptic": "^6.4.18", "rimraf": "^5.0.5", "rollup-plugin-web-worker-loader": "^1.6.1", - "workerize-loader": "^2.0.2" + "workerize-loader": "^2.0.2", + "@toruslabs/tss-dkls-lib": "^2.3.3" }, "publishConfig": { "access": "public" diff --git a/packages/tss-client/src/client.ts b/packages/tss-client/src/client.ts index c4eebb9..ed85fa4 100644 --- a/packages/tss-client/src/client.ts +++ b/packages/tss-client/src/client.ts @@ -1,11 +1,11 @@ /* eslint-disable no-console */ import { generatePrivate } from "@toruslabs/eccrypto"; +import type TssLib from "@toruslabs/tss-dkls-lib"; import BN from "bn.js"; import { keccak256 } from "ethereum-cryptography/keccak"; import { Socket } from "socket.io-client"; import { DELIMITERS, WEB3_SESSION_HEADER_KEY } from "./constants"; -import type * as TssLib from "./dkls"; import { Msg } from "./interfaces"; import { getEc } from "./utils"; @@ -113,7 +113,7 @@ export class Client { public websocketOnly: boolean; - public tssLib: typeof TssLib; + public tssLib: TssLib; public _startPrecomputeTime: number; @@ -154,7 +154,7 @@ export class Client { _share: string, _pubKey: string, _websocketOnly: boolean, - _tssLib: typeof TssLib + _tssLib: TssLib ) { if (_parties.length !== _sockets.length) { throw new Error("parties and sockets length must be equal, add null for client if necessary"); diff --git a/packages/tss-client/src/dkls.d.ts b/packages/tss-client/src/dkls.d.ts deleted file mode 100644 index 2d0a0fe..0000000 --- a/packages/tss-client/src/dkls.d.ts +++ /dev/null @@ -1,198 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** -* @returns {number} -*/ -export function batch_size(): number; -/** -* @param {string} state -* @returns {number} -*/ -export function random_generator(state: string): number; -/** -* @param {number} rng -*/ -export function random_generator_free(rng: number): void; -/** -* @param {string} session -* @param {number} player_index -* @param {number} player_count -* @param {number} threshold -* @param {string} share -* @param {string} pubkey -* @returns {number} -*/ -export function threshold_signer(session: string, player_index: number, player_count: number, threshold: number, share: string, pubkey: string): number; -/** -* @param {number} signer -*/ -export function threshold_signer_free(signer: number): void; -/** -* @param {number} signer -* @param {number} rng -* @returns {Promise} -*/ -export function setup(signer: number, rng: number): Promise; -/** -* @param {Uint8Array} parties -* @param {number} signer -* @param {number} rng -* @returns {Promise} -*/ -export function precompute(parties: Uint8Array, signer: number, rng: number): Promise; -/** -* @param {string} msg -* @param {boolean} hash_only -* @param {any} precompute -* @returns {any} -*/ -export function local_sign(msg: string, hash_only: boolean, precompute: any): any; -/** -* @param {any} precompute -* @returns {any} -*/ -export function get_r_from_precompute(precompute: any): any; -/** -* @param {string} msg -* @param {boolean} hash_only -* @param {any} r -* @param {any[]} sig_frags -* @param {string} pubkey -* @returns {any} -*/ -export function local_verify(msg: string, hash_only: boolean, r: any, sig_frags: any[], pubkey: string): any; -/** -* @param {Uint8Array} counterparties -* @param {string} msg -* @param {boolean} hash_only -* @param {number} signer -* @param {number} rng -* @returns {Promise} -*/ -export function sign(counterparties: Uint8Array, msg: string, hash_only: boolean, signer: number, rng: number): Promise; -/** -* Handler for `console.log` invocations. -* -* If a test is currently running it takes the `args` array and stringifies -* it and appends it to the current output of the test. Otherwise it passes -* the arguments to the original `console.log` function, psased as -* `original`. -* @param {Array} args -*/ -export function __wbgtest_console_log(args: Array): void; -/** -* Handler for `console.debug` invocations. See above. -* @param {Array} args -*/ -export function __wbgtest_console_debug(args: Array): void; -/** -* Handler for `console.info` invocations. See above. -* @param {Array} args -*/ -export function __wbgtest_console_info(args: Array): void; -/** -* Handler for `console.warn` invocations. See above. -* @param {Array} args -*/ -export function __wbgtest_console_warn(args: Array): void; -/** -* Handler for `console.error` invocations. See above. -* @param {Array} args -*/ -export function __wbgtest_console_error(args: Array): void; -/** -* Runtime test harness support instantiated in JS. -* -* The node.js entry script instantiates a `Context` here which is used to -* drive test execution. -*/ -export class WasmBindgenTestContext { - free(): void; -/** -* Creates a new context ready to run tests. -* -* A `Context` is the main structure through which test execution is -* coordinated, and this will collect output and results for all executed -* tests. -*/ - constructor(); -/** -* Inform this context about runtime arguments passed to the test -* harness. -* -* Eventually this will be used to support flags, but for now it's just -* used to support test filters. -* @param {any[]} args -*/ - args(args: any[]): void; -/** -* Executes a list of tests, returning a promise representing their -* eventual completion. -* -* This is the main entry point for executing tests. All the tests passed -* in are the JS `Function` object that was plucked off the -* `WebAssembly.Instance` exports list. -* -* The promise returned resolves to either `true` if all tests passed or -* `false` if at least one test failed. -* @param {any[]} tests -* @returns {Promise} -*/ - run(tests: any[]): Promise; -} - -export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; - -export interface InitOutput { - readonly memory: WebAssembly.Memory; - readonly batch_size: () => number; - readonly random_generator: (a: number, b: number, c: number) => void; - readonly random_generator_free: (a: number) => void; - readonly threshold_signer: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void; - readonly threshold_signer_free: (a: number) => void; - readonly setup: (a: number, b: number) => number; - readonly precompute: (a: number, b: number, c: number) => number; - readonly local_sign: (a: number, b: number, c: number, d: number, e: number) => void; - readonly get_r_from_precompute: (a: number, b: number) => void; - readonly local_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void; - readonly sign: (a: number, b: number, c: number, d: number, e: number, f: number) => number; - readonly __wbg_wasmbindgentestcontext_free: (a: number) => void; - readonly wasmbindgentestcontext_new: () => number; - readonly wasmbindgentestcontext_args: (a: number, b: number, c: number) => void; - readonly wasmbindgentestcontext_run: (a: number, b: number, c: number) => number; - readonly __wbgtest_console_log: (a: number) => void; - readonly __wbgtest_console_debug: (a: number) => void; - readonly __wbgtest_console_info: (a: number) => void; - readonly __wbgtest_console_warn: (a: number) => void; - readonly __wbgtest_console_error: (a: number) => void; - readonly __wbindgen_malloc: (a: number) => number; - readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; - readonly __wbindgen_export_2: WebAssembly.Table; - readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h7814fecea8304d3b: (a: number, b: number, c: number) => void; - readonly __wbindgen_free: (a: number, b: number) => void; - readonly __wbindgen_exn_store: (a: number) => void; - readonly __wbindgen_add_to_stack_pointer: (a: number) => number; - readonly wasm_bindgen__convert__closures__invoke3_mut__h19a26cc4ddc1d520: (a: number, b: number, c: number, d: number, e: number) => void; - readonly wasm_bindgen__convert__closures__invoke2_mut__hb9efae8f8498f5b8: (a: number, b: number, c: number, d: number) => void; -} - -export type SyncInitInput = BufferSource | WebAssembly.Module; -/** -* Instantiates the given `module`, which can either be bytes or -* a precompiled `WebAssembly.Module`. -* -* @param {SyncInitInput} module -* -* @returns {InitOutput} -*/ -export function initSync(module: SyncInitInput): InitOutput; - -/** -* If `module_or_path` is {RequestInfo} or {URL}, makes a request and -* for everything else, calls `WebAssembly.instantiate` directly. -* -* @param {InitInput | Promise} module_or_path -* -* @returns {Promise} -*/ -export default function init (module_or_path: InitInput | Promise): Promise; diff --git a/packages/tss-client/src/index.ts b/packages/tss-client/src/index.ts index f867b32..544efcd 100644 --- a/packages/tss-client/src/index.ts +++ b/packages/tss-client/src/index.ts @@ -1,9 +1,5 @@ -import type * as WasmLib from "./dkls"; - export * from "./client"; export * from "./constants"; export * from "./db"; export * from "./interfaces"; export * from "./utils"; - -export { WasmLib }; diff --git a/packages/tss-client/torus.config.js b/packages/tss-client/torus.config.js index 9d0fd09..47ad798 100644 --- a/packages/tss-client/torus.config.js +++ b/packages/tss-client/torus.config.js @@ -1,4 +1,3 @@ module.exports = { ...require("@toruslabs/config/torus.config"), - esm: false, }; diff --git a/packages/tss-lib/package.json b/packages/tss-lib/package.json index f5047f7..81b9063 100644 --- a/packages/tss-lib/package.json +++ b/packages/tss-lib/package.json @@ -1,9 +1,9 @@ { "name": "@toruslabs/tss-dkls-lib", - "version": "1.0.0", + "version": "2.3.3", "description": "Packaged WASM library for DKLS threshold signing.", "main": "dist/tssDklsLib.cjs.js", - "unpkg": "dist/tssDklsLib.umd.min.js", + "unpkg": "dist/n.umd.min.js", "jsdelivr": "dist/tssDklsLib.umd.min.js", "types": "dist/types/index.d.ts", "files": [