@agentaos/crypto 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pkg/agentaos_mpc_wasm.d.ts +95 -0
- package/pkg/agentaos_mpc_wasm_bg.wasm +0 -0
- package/pkg/agentaos_mpc_wasm_bg.wasm.d.ts +22 -0
- package/pkg/package.json +13 -0
- package/pkg-web/agentaos_mpc_wasm.d.ts +142 -0
- package/pkg-web/agentaos_mpc_wasm.js +754 -0
- package/pkg-web/agentaos_mpc_wasm_bg.wasm +0 -0
- package/pkg-web/agentaos_mpc_wasm_bg.wasm.d.ts +22 -0
- package/pkg-web/package.json +17 -0
package/package.json
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Combine a CoreKeyShare (from keygen) with AuxInfo (from aux_info_gen)
|
|
6
|
+
* into a full KeyShare suitable for signing.
|
|
7
|
+
*
|
|
8
|
+
* Returns the serialised KeyShare bytes.
|
|
9
|
+
*/
|
|
10
|
+
export function combine_key_share(core_key_share: Uint8Array, aux_info: Uint8Array): Uint8Array;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Extract the shared public key from a serialised KeyShare or CoreKeyShare.
|
|
14
|
+
*
|
|
15
|
+
* Returns 33-byte compressed secp256k1 public key.
|
|
16
|
+
*/
|
|
17
|
+
export function extract_public_key(key_share_bytes: Uint8Array): Uint8Array;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Initialise the WASM module (called once from JS).
|
|
21
|
+
*/
|
|
22
|
+
export function init(): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Pre-generate Paillier primes for aux_info_gen.
|
|
26
|
+
*
|
|
27
|
+
* This is the expensive part (~30-60s). Call this ahead of time
|
|
28
|
+
* and store the result. Pass serialised primes to speed up DKG.
|
|
29
|
+
*
|
|
30
|
+
* Returns serialised PregeneratedPrimes.
|
|
31
|
+
*/
|
|
32
|
+
export function pregenerate_paillier_primes(): Uint8Array;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Run a complete two-phase DKG ceremony for `n` parties with threshold `t`.
|
|
36
|
+
*
|
|
37
|
+
* Phase A: Auxiliary info generation (Paillier primes — computationally expensive)
|
|
38
|
+
* Phase B: Key generation (lightweight ECDSA key shares)
|
|
39
|
+
*
|
|
40
|
+
* All parties run locally via protocol simulation. Returns a JSON object
|
|
41
|
+
* containing key shares for each party and the shared public key.
|
|
42
|
+
*
|
|
43
|
+
* The caller (server) distributes shares:
|
|
44
|
+
* - Share[0] → signer (encrypted .share.enc file)
|
|
45
|
+
* - Share[1] → server (stored in Vault)
|
|
46
|
+
* - Share[2] → user (wallet-encrypted, returned to browser)
|
|
47
|
+
*/
|
|
48
|
+
export function run_dkg(eid_bytes: Uint8Array, n: number, threshold: number): any;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Run a complete two-phase DKG ceremony using pre-generated Paillier primes.
|
|
52
|
+
*
|
|
53
|
+
* This is the FAST path — Paillier prime generation (~30-60s per party) is
|
|
54
|
+
* skipped because primes were generated ahead of time (e.g. during server
|
|
55
|
+
* startup in a background worker thread).
|
|
56
|
+
*
|
|
57
|
+
* `serialized_primes` is a JS array of `Uint8Array`, one per party,
|
|
58
|
+
* each being the serde_json serialization of `PregeneratedPrimes`.
|
|
59
|
+
*/
|
|
60
|
+
export function run_dkg_with_primes(eid_bytes: Uint8Array, n: number, threshold: number, serialized_primes: any): any;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Create an interactive signing session for one party.
|
|
64
|
+
*
|
|
65
|
+
* # Arguments
|
|
66
|
+
* - `core_share`: serialised CoreKeyShare (serde_json bytes)
|
|
67
|
+
* - `aux_info`: serialised AuxInfo (serde_json bytes)
|
|
68
|
+
* - `message_hash`: 32-byte hash to sign
|
|
69
|
+
* - `party_index`: this party's index at keygen time (0-based)
|
|
70
|
+
* - `parties_at_keygen`: array of party indices participating in signing
|
|
71
|
+
* - `eid`: execution ID bytes (32 bytes)
|
|
72
|
+
*
|
|
73
|
+
* # Returns
|
|
74
|
+
* JS object: `{ session_id: string, messages: WasmSignMessage[] }`
|
|
75
|
+
*/
|
|
76
|
+
export function sign_create_session(core_share: Uint8Array, aux_info: Uint8Array, message_hash: Uint8Array, party_index: number, parties_at_keygen: Uint16Array, eid: Uint8Array): any;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Destroy a signing session and free all resources.
|
|
80
|
+
*
|
|
81
|
+
* Returns `true` if the session existed and was destroyed.
|
|
82
|
+
*/
|
|
83
|
+
export function sign_destroy_session(session_id: string): boolean;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Process a round of incoming messages for an existing signing session.
|
|
87
|
+
*
|
|
88
|
+
* # Arguments
|
|
89
|
+
* - `session_id`: the session ID returned by `sign_create_session`
|
|
90
|
+
* - `incoming_messages`: JS array of `WasmSignMessage` objects
|
|
91
|
+
*
|
|
92
|
+
* # Returns
|
|
93
|
+
* JS object: `{ messages: WasmSignMessage[], complete: bool, signature?: { r, s } }`
|
|
94
|
+
*/
|
|
95
|
+
export function sign_process_round(session_id: string, incoming_messages: any): any;
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const _critical_section_1_0_acquire: () => void;
|
|
5
|
+
export const combine_key_share: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
6
|
+
export const extract_public_key: (a: number, b: number) => [number, number, number, number];
|
|
7
|
+
export const pregenerate_paillier_primes: () => [number, number, number, number];
|
|
8
|
+
export const run_dkg: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
9
|
+
export const run_dkg_with_primes: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
10
|
+
export const sign_create_session: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number];
|
|
11
|
+
export const sign_destroy_session: (a: number, b: number) => number;
|
|
12
|
+
export const sign_process_round: (a: number, b: number, c: any) => [number, number, number];
|
|
13
|
+
export const _critical_section_1_0_release: () => void;
|
|
14
|
+
export const init: () => void;
|
|
15
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
16
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
17
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
18
|
+
export const __externref_table_alloc: () => number;
|
|
19
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
20
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
21
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
22
|
+
export const __wbindgen_start: () => void;
|
package/pkg/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agentaos-mpc-wasm",
|
|
3
|
+
"description": "WASM wrapper for CGGMP24 threshold ECDSA — keygen, signing, presignatures",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"files": [
|
|
7
|
+
"agentaos_mpc_wasm_bg.wasm",
|
|
8
|
+
"agentaos_mpc_wasm.js",
|
|
9
|
+
"agentaos_mpc_wasm.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"main": "agentaos_mpc_wasm.js",
|
|
12
|
+
"types": "agentaos_mpc_wasm.d.ts"
|
|
13
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Combine a CoreKeyShare (from keygen) with AuxInfo (from aux_info_gen)
|
|
6
|
+
* into a full KeyShare suitable for signing.
|
|
7
|
+
*
|
|
8
|
+
* Returns the serialised KeyShare bytes.
|
|
9
|
+
*/
|
|
10
|
+
export function combine_key_share(core_key_share: Uint8Array, aux_info: Uint8Array): Uint8Array;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Extract the shared public key from a serialised KeyShare or CoreKeyShare.
|
|
14
|
+
*
|
|
15
|
+
* Returns 33-byte compressed secp256k1 public key.
|
|
16
|
+
*/
|
|
17
|
+
export function extract_public_key(key_share_bytes: Uint8Array): Uint8Array;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Initialise the WASM module (called once from JS).
|
|
21
|
+
*/
|
|
22
|
+
export function init(): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Pre-generate Paillier primes for aux_info_gen.
|
|
26
|
+
*
|
|
27
|
+
* This is the expensive part (~30-60s). Call this ahead of time
|
|
28
|
+
* and store the result. Pass serialised primes to speed up DKG.
|
|
29
|
+
*
|
|
30
|
+
* Returns serialised PregeneratedPrimes.
|
|
31
|
+
*/
|
|
32
|
+
export function pregenerate_paillier_primes(): Uint8Array;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Run a complete two-phase DKG ceremony for `n` parties with threshold `t`.
|
|
36
|
+
*
|
|
37
|
+
* Phase A: Auxiliary info generation (Paillier primes — computationally expensive)
|
|
38
|
+
* Phase B: Key generation (lightweight ECDSA key shares)
|
|
39
|
+
*
|
|
40
|
+
* All parties run locally via protocol simulation. Returns a JSON object
|
|
41
|
+
* containing key shares for each party and the shared public key.
|
|
42
|
+
*
|
|
43
|
+
* The caller (server) distributes shares:
|
|
44
|
+
* - Share[0] → signer (encrypted .share.enc file)
|
|
45
|
+
* - Share[1] → server (stored in Vault)
|
|
46
|
+
* - Share[2] → user (wallet-encrypted, returned to browser)
|
|
47
|
+
*/
|
|
48
|
+
export function run_dkg(eid_bytes: Uint8Array, n: number, threshold: number): any;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Run a complete two-phase DKG ceremony using pre-generated Paillier primes.
|
|
52
|
+
*
|
|
53
|
+
* This is the FAST path — Paillier prime generation (~30-60s per party) is
|
|
54
|
+
* skipped because primes were generated ahead of time (e.g. during server
|
|
55
|
+
* startup in a background worker thread).
|
|
56
|
+
*
|
|
57
|
+
* `serialized_primes` is a JS array of `Uint8Array`, one per party,
|
|
58
|
+
* each being the serde_json serialization of `PregeneratedPrimes`.
|
|
59
|
+
*/
|
|
60
|
+
export function run_dkg_with_primes(eid_bytes: Uint8Array, n: number, threshold: number, serialized_primes: any): any;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Create an interactive signing session for one party.
|
|
64
|
+
*
|
|
65
|
+
* # Arguments
|
|
66
|
+
* - `core_share`: serialised CoreKeyShare (serde_json bytes)
|
|
67
|
+
* - `aux_info`: serialised AuxInfo (serde_json bytes)
|
|
68
|
+
* - `message_hash`: 32-byte hash to sign
|
|
69
|
+
* - `party_index`: this party's index at keygen time (0-based)
|
|
70
|
+
* - `parties_at_keygen`: array of party indices participating in signing
|
|
71
|
+
* - `eid`: execution ID bytes (32 bytes)
|
|
72
|
+
*
|
|
73
|
+
* # Returns
|
|
74
|
+
* JS object: `{ session_id: string, messages: WasmSignMessage[] }`
|
|
75
|
+
*/
|
|
76
|
+
export function sign_create_session(core_share: Uint8Array, aux_info: Uint8Array, message_hash: Uint8Array, party_index: number, parties_at_keygen: Uint16Array, eid: Uint8Array): any;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Destroy a signing session and free all resources.
|
|
80
|
+
*
|
|
81
|
+
* Returns `true` if the session existed and was destroyed.
|
|
82
|
+
*/
|
|
83
|
+
export function sign_destroy_session(session_id: string): boolean;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Process a round of incoming messages for an existing signing session.
|
|
87
|
+
*
|
|
88
|
+
* # Arguments
|
|
89
|
+
* - `session_id`: the session ID returned by `sign_create_session`
|
|
90
|
+
* - `incoming_messages`: JS array of `WasmSignMessage` objects
|
|
91
|
+
*
|
|
92
|
+
* # Returns
|
|
93
|
+
* JS object: `{ messages: WasmSignMessage[], complete: bool, signature?: { r, s } }`
|
|
94
|
+
*/
|
|
95
|
+
export function sign_process_round(session_id: string, incoming_messages: any): any;
|
|
96
|
+
|
|
97
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
98
|
+
|
|
99
|
+
export interface InitOutput {
|
|
100
|
+
readonly memory: WebAssembly.Memory;
|
|
101
|
+
readonly _critical_section_1_0_acquire: () => void;
|
|
102
|
+
readonly combine_key_share: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
103
|
+
readonly extract_public_key: (a: number, b: number) => [number, number, number, number];
|
|
104
|
+
readonly pregenerate_paillier_primes: () => [number, number, number, number];
|
|
105
|
+
readonly run_dkg: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
106
|
+
readonly run_dkg_with_primes: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
107
|
+
readonly sign_create_session: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number];
|
|
108
|
+
readonly sign_destroy_session: (a: number, b: number) => number;
|
|
109
|
+
readonly sign_process_round: (a: number, b: number, c: any) => [number, number, number];
|
|
110
|
+
readonly _critical_section_1_0_release: () => void;
|
|
111
|
+
readonly init: () => void;
|
|
112
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
113
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
114
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
115
|
+
readonly __externref_table_alloc: () => number;
|
|
116
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
117
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
118
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
119
|
+
readonly __wbindgen_start: () => void;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
126
|
+
* a precompiled `WebAssembly.Module`.
|
|
127
|
+
*
|
|
128
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
129
|
+
*
|
|
130
|
+
* @returns {InitOutput}
|
|
131
|
+
*/
|
|
132
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
136
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
137
|
+
*
|
|
138
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
139
|
+
*
|
|
140
|
+
* @returns {Promise<InitOutput>}
|
|
141
|
+
*/
|
|
142
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,754 @@
|
|
|
1
|
+
/* @ts-self-types="./agentaos_mpc_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Combine a CoreKeyShare (from keygen) with AuxInfo (from aux_info_gen)
|
|
5
|
+
* into a full KeyShare suitable for signing.
|
|
6
|
+
*
|
|
7
|
+
* Returns the serialised KeyShare bytes.
|
|
8
|
+
* @param {Uint8Array} core_key_share
|
|
9
|
+
* @param {Uint8Array} aux_info
|
|
10
|
+
* @returns {Uint8Array}
|
|
11
|
+
*/
|
|
12
|
+
export function combine_key_share(core_key_share, aux_info) {
|
|
13
|
+
const ptr0 = passArray8ToWasm0(core_key_share, wasm.__wbindgen_malloc);
|
|
14
|
+
const len0 = WASM_VECTOR_LEN;
|
|
15
|
+
const ptr1 = passArray8ToWasm0(aux_info, wasm.__wbindgen_malloc);
|
|
16
|
+
const len1 = WASM_VECTOR_LEN;
|
|
17
|
+
const ret = wasm.combine_key_share(ptr0, len0, ptr1, len1);
|
|
18
|
+
if (ret[3]) {
|
|
19
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
20
|
+
}
|
|
21
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
22
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
23
|
+
return v3;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Extract the shared public key from a serialised KeyShare or CoreKeyShare.
|
|
28
|
+
*
|
|
29
|
+
* Returns 33-byte compressed secp256k1 public key.
|
|
30
|
+
* @param {Uint8Array} key_share_bytes
|
|
31
|
+
* @returns {Uint8Array}
|
|
32
|
+
*/
|
|
33
|
+
export function extract_public_key(key_share_bytes) {
|
|
34
|
+
const ptr0 = passArray8ToWasm0(key_share_bytes, wasm.__wbindgen_malloc);
|
|
35
|
+
const len0 = WASM_VECTOR_LEN;
|
|
36
|
+
const ret = wasm.extract_public_key(ptr0, len0);
|
|
37
|
+
if (ret[3]) {
|
|
38
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
39
|
+
}
|
|
40
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
41
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
42
|
+
return v2;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Initialise the WASM module (called once from JS).
|
|
47
|
+
*/
|
|
48
|
+
export function init() {
|
|
49
|
+
wasm._critical_section_1_0_acquire();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Pre-generate Paillier primes for aux_info_gen.
|
|
54
|
+
*
|
|
55
|
+
* This is the expensive part (~30-60s). Call this ahead of time
|
|
56
|
+
* and store the result. Pass serialised primes to speed up DKG.
|
|
57
|
+
*
|
|
58
|
+
* Returns serialised PregeneratedPrimes.
|
|
59
|
+
* @returns {Uint8Array}
|
|
60
|
+
*/
|
|
61
|
+
export function pregenerate_paillier_primes() {
|
|
62
|
+
const ret = wasm.pregenerate_paillier_primes();
|
|
63
|
+
if (ret[3]) {
|
|
64
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
65
|
+
}
|
|
66
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
67
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
68
|
+
return v1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Run a complete two-phase DKG ceremony for `n` parties with threshold `t`.
|
|
73
|
+
*
|
|
74
|
+
* Phase A: Auxiliary info generation (Paillier primes — computationally expensive)
|
|
75
|
+
* Phase B: Key generation (lightweight ECDSA key shares)
|
|
76
|
+
*
|
|
77
|
+
* All parties run locally via protocol simulation. Returns a JSON object
|
|
78
|
+
* containing key shares for each party and the shared public key.
|
|
79
|
+
*
|
|
80
|
+
* The caller (server) distributes shares:
|
|
81
|
+
* - Share[0] → signer (encrypted .share.enc file)
|
|
82
|
+
* - Share[1] → server (stored in Vault)
|
|
83
|
+
* - Share[2] → user (wallet-encrypted, returned to browser)
|
|
84
|
+
* @param {Uint8Array} eid_bytes
|
|
85
|
+
* @param {number} n
|
|
86
|
+
* @param {number} threshold
|
|
87
|
+
* @returns {any}
|
|
88
|
+
*/
|
|
89
|
+
export function run_dkg(eid_bytes, n, threshold) {
|
|
90
|
+
const ptr0 = passArray8ToWasm0(eid_bytes, wasm.__wbindgen_malloc);
|
|
91
|
+
const len0 = WASM_VECTOR_LEN;
|
|
92
|
+
const ret = wasm.run_dkg(ptr0, len0, n, threshold);
|
|
93
|
+
if (ret[2]) {
|
|
94
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
95
|
+
}
|
|
96
|
+
return takeFromExternrefTable0(ret[0]);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Run a complete two-phase DKG ceremony using pre-generated Paillier primes.
|
|
101
|
+
*
|
|
102
|
+
* This is the FAST path — Paillier prime generation (~30-60s per party) is
|
|
103
|
+
* skipped because primes were generated ahead of time (e.g. during server
|
|
104
|
+
* startup in a background worker thread).
|
|
105
|
+
*
|
|
106
|
+
* `serialized_primes` is a JS array of `Uint8Array`, one per party,
|
|
107
|
+
* each being the serde_json serialization of `PregeneratedPrimes`.
|
|
108
|
+
* @param {Uint8Array} eid_bytes
|
|
109
|
+
* @param {number} n
|
|
110
|
+
* @param {number} threshold
|
|
111
|
+
* @param {any} serialized_primes
|
|
112
|
+
* @returns {any}
|
|
113
|
+
*/
|
|
114
|
+
export function run_dkg_with_primes(eid_bytes, n, threshold, serialized_primes) {
|
|
115
|
+
const ptr0 = passArray8ToWasm0(eid_bytes, wasm.__wbindgen_malloc);
|
|
116
|
+
const len0 = WASM_VECTOR_LEN;
|
|
117
|
+
const ret = wasm.run_dkg_with_primes(ptr0, len0, n, threshold, serialized_primes);
|
|
118
|
+
if (ret[2]) {
|
|
119
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
120
|
+
}
|
|
121
|
+
return takeFromExternrefTable0(ret[0]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Create an interactive signing session for one party.
|
|
126
|
+
*
|
|
127
|
+
* # Arguments
|
|
128
|
+
* - `core_share`: serialised CoreKeyShare (serde_json bytes)
|
|
129
|
+
* - `aux_info`: serialised AuxInfo (serde_json bytes)
|
|
130
|
+
* - `message_hash`: 32-byte hash to sign
|
|
131
|
+
* - `party_index`: this party's index at keygen time (0-based)
|
|
132
|
+
* - `parties_at_keygen`: array of party indices participating in signing
|
|
133
|
+
* - `eid`: execution ID bytes (32 bytes)
|
|
134
|
+
*
|
|
135
|
+
* # Returns
|
|
136
|
+
* JS object: `{ session_id: string, messages: WasmSignMessage[] }`
|
|
137
|
+
* @param {Uint8Array} core_share
|
|
138
|
+
* @param {Uint8Array} aux_info
|
|
139
|
+
* @param {Uint8Array} message_hash
|
|
140
|
+
* @param {number} party_index
|
|
141
|
+
* @param {Uint16Array} parties_at_keygen
|
|
142
|
+
* @param {Uint8Array} eid
|
|
143
|
+
* @returns {any}
|
|
144
|
+
*/
|
|
145
|
+
export function sign_create_session(core_share, aux_info, message_hash, party_index, parties_at_keygen, eid) {
|
|
146
|
+
const ptr0 = passArray8ToWasm0(core_share, wasm.__wbindgen_malloc);
|
|
147
|
+
const len0 = WASM_VECTOR_LEN;
|
|
148
|
+
const ptr1 = passArray8ToWasm0(aux_info, wasm.__wbindgen_malloc);
|
|
149
|
+
const len1 = WASM_VECTOR_LEN;
|
|
150
|
+
const ptr2 = passArray8ToWasm0(message_hash, wasm.__wbindgen_malloc);
|
|
151
|
+
const len2 = WASM_VECTOR_LEN;
|
|
152
|
+
const ptr3 = passArray16ToWasm0(parties_at_keygen, wasm.__wbindgen_malloc);
|
|
153
|
+
const len3 = WASM_VECTOR_LEN;
|
|
154
|
+
const ptr4 = passArray8ToWasm0(eid, wasm.__wbindgen_malloc);
|
|
155
|
+
const len4 = WASM_VECTOR_LEN;
|
|
156
|
+
const ret = wasm.sign_create_session(ptr0, len0, ptr1, len1, ptr2, len2, party_index, ptr3, len3, ptr4, len4);
|
|
157
|
+
if (ret[2]) {
|
|
158
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
159
|
+
}
|
|
160
|
+
return takeFromExternrefTable0(ret[0]);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Destroy a signing session and free all resources.
|
|
165
|
+
*
|
|
166
|
+
* Returns `true` if the session existed and was destroyed.
|
|
167
|
+
* @param {string} session_id
|
|
168
|
+
* @returns {boolean}
|
|
169
|
+
*/
|
|
170
|
+
export function sign_destroy_session(session_id) {
|
|
171
|
+
const ptr0 = passStringToWasm0(session_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
172
|
+
const len0 = WASM_VECTOR_LEN;
|
|
173
|
+
const ret = wasm.sign_destroy_session(ptr0, len0);
|
|
174
|
+
return ret !== 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Process a round of incoming messages for an existing signing session.
|
|
179
|
+
*
|
|
180
|
+
* # Arguments
|
|
181
|
+
* - `session_id`: the session ID returned by `sign_create_session`
|
|
182
|
+
* - `incoming_messages`: JS array of `WasmSignMessage` objects
|
|
183
|
+
*
|
|
184
|
+
* # Returns
|
|
185
|
+
* JS object: `{ messages: WasmSignMessage[], complete: bool, signature?: { r, s } }`
|
|
186
|
+
* @param {string} session_id
|
|
187
|
+
* @param {any} incoming_messages
|
|
188
|
+
* @returns {any}
|
|
189
|
+
*/
|
|
190
|
+
export function sign_process_round(session_id, incoming_messages) {
|
|
191
|
+
const ptr0 = passStringToWasm0(session_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
192
|
+
const len0 = WASM_VECTOR_LEN;
|
|
193
|
+
const ret = wasm.sign_process_round(ptr0, len0, incoming_messages);
|
|
194
|
+
if (ret[2]) {
|
|
195
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
196
|
+
}
|
|
197
|
+
return takeFromExternrefTable0(ret[0]);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function __wbg_get_imports() {
|
|
201
|
+
const import0 = {
|
|
202
|
+
__proto__: null,
|
|
203
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
204
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
205
|
+
return ret;
|
|
206
|
+
},
|
|
207
|
+
__wbg_Number_04624de7d0e8332d: function(arg0) {
|
|
208
|
+
const ret = Number(arg0);
|
|
209
|
+
return ret;
|
|
210
|
+
},
|
|
211
|
+
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
212
|
+
const ret = String(arg1);
|
|
213
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
214
|
+
const len1 = WASM_VECTOR_LEN;
|
|
215
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
216
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
217
|
+
},
|
|
218
|
+
__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
|
|
219
|
+
const v = arg0;
|
|
220
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
221
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
222
|
+
},
|
|
223
|
+
__wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
|
|
224
|
+
const ret = debugString(arg1);
|
|
225
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
226
|
+
const len1 = WASM_VECTOR_LEN;
|
|
227
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
228
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
229
|
+
},
|
|
230
|
+
__wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
|
|
231
|
+
const ret = arg0 in arg1;
|
|
232
|
+
return ret;
|
|
233
|
+
},
|
|
234
|
+
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
235
|
+
const ret = typeof(arg0) === 'function';
|
|
236
|
+
return ret;
|
|
237
|
+
},
|
|
238
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
239
|
+
const val = arg0;
|
|
240
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
241
|
+
return ret;
|
|
242
|
+
},
|
|
243
|
+
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
|
|
244
|
+
const ret = typeof(arg0) === 'string';
|
|
245
|
+
return ret;
|
|
246
|
+
},
|
|
247
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
248
|
+
const ret = arg0 === undefined;
|
|
249
|
+
return ret;
|
|
250
|
+
},
|
|
251
|
+
__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
|
|
252
|
+
const ret = arg0 == arg1;
|
|
253
|
+
return ret;
|
|
254
|
+
},
|
|
255
|
+
__wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
|
|
256
|
+
const obj = arg1;
|
|
257
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
258
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
259
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
260
|
+
},
|
|
261
|
+
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
262
|
+
const obj = arg1;
|
|
263
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
264
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
265
|
+
var len1 = WASM_VECTOR_LEN;
|
|
266
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
267
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
268
|
+
},
|
|
269
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
270
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
271
|
+
},
|
|
272
|
+
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
|
|
273
|
+
const ret = arg0.call(arg1);
|
|
274
|
+
return ret;
|
|
275
|
+
}, arguments); },
|
|
276
|
+
__wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
|
|
277
|
+
const ret = arg0.call(arg1, arg2);
|
|
278
|
+
return ret;
|
|
279
|
+
}, arguments); },
|
|
280
|
+
__wbg_crypto_86f2631e91b51511: function(arg0) {
|
|
281
|
+
const ret = arg0.crypto;
|
|
282
|
+
return ret;
|
|
283
|
+
},
|
|
284
|
+
__wbg_done_57b39ecd9addfe81: function(arg0) {
|
|
285
|
+
const ret = arg0.done;
|
|
286
|
+
return ret;
|
|
287
|
+
},
|
|
288
|
+
__wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
|
|
289
|
+
arg0.getRandomValues(arg1);
|
|
290
|
+
}, arguments); },
|
|
291
|
+
__wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
|
|
292
|
+
const ret = arg0[arg1 >>> 0];
|
|
293
|
+
return ret;
|
|
294
|
+
},
|
|
295
|
+
__wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
|
|
296
|
+
const ret = Reflect.get(arg0, arg1);
|
|
297
|
+
return ret;
|
|
298
|
+
}, arguments); },
|
|
299
|
+
__wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
|
|
300
|
+
const ret = arg0[arg1];
|
|
301
|
+
return ret;
|
|
302
|
+
},
|
|
303
|
+
__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
|
|
304
|
+
let result;
|
|
305
|
+
try {
|
|
306
|
+
result = arg0 instanceof ArrayBuffer;
|
|
307
|
+
} catch (_) {
|
|
308
|
+
result = false;
|
|
309
|
+
}
|
|
310
|
+
const ret = result;
|
|
311
|
+
return ret;
|
|
312
|
+
},
|
|
313
|
+
__wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
|
|
314
|
+
let result;
|
|
315
|
+
try {
|
|
316
|
+
result = arg0 instanceof Uint8Array;
|
|
317
|
+
} catch (_) {
|
|
318
|
+
result = false;
|
|
319
|
+
}
|
|
320
|
+
const ret = result;
|
|
321
|
+
return ret;
|
|
322
|
+
},
|
|
323
|
+
__wbg_isArray_d314bb98fcf08331: function(arg0) {
|
|
324
|
+
const ret = Array.isArray(arg0);
|
|
325
|
+
return ret;
|
|
326
|
+
},
|
|
327
|
+
__wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
|
|
328
|
+
const ret = Number.isSafeInteger(arg0);
|
|
329
|
+
return ret;
|
|
330
|
+
},
|
|
331
|
+
__wbg_iterator_6ff6560ca1568e55: function() {
|
|
332
|
+
const ret = Symbol.iterator;
|
|
333
|
+
return ret;
|
|
334
|
+
},
|
|
335
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
336
|
+
const ret = arg0.length;
|
|
337
|
+
return ret;
|
|
338
|
+
},
|
|
339
|
+
__wbg_length_35a7bace40f36eac: function(arg0) {
|
|
340
|
+
const ret = arg0.length;
|
|
341
|
+
return ret;
|
|
342
|
+
},
|
|
343
|
+
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
344
|
+
const ret = arg0.msCrypto;
|
|
345
|
+
return ret;
|
|
346
|
+
},
|
|
347
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
348
|
+
const ret = new Object();
|
|
349
|
+
return ret;
|
|
350
|
+
},
|
|
351
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
352
|
+
const ret = new Array();
|
|
353
|
+
return ret;
|
|
354
|
+
},
|
|
355
|
+
__wbg_new_dd2b680c8bf6ae29: function(arg0) {
|
|
356
|
+
const ret = new Uint8Array(arg0);
|
|
357
|
+
return ret;
|
|
358
|
+
},
|
|
359
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
360
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
361
|
+
return ret;
|
|
362
|
+
},
|
|
363
|
+
__wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
|
|
364
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
365
|
+
return ret;
|
|
366
|
+
},
|
|
367
|
+
__wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
|
|
368
|
+
const ret = arg0.next();
|
|
369
|
+
return ret;
|
|
370
|
+
}, arguments); },
|
|
371
|
+
__wbg_next_418f80d8f5303233: function(arg0) {
|
|
372
|
+
const ret = arg0.next;
|
|
373
|
+
return ret;
|
|
374
|
+
},
|
|
375
|
+
__wbg_node_e1f24f89a7336c2e: function(arg0) {
|
|
376
|
+
const ret = arg0.node;
|
|
377
|
+
return ret;
|
|
378
|
+
},
|
|
379
|
+
__wbg_process_3975fd6c72f520aa: function(arg0) {
|
|
380
|
+
const ret = arg0.process;
|
|
381
|
+
return ret;
|
|
382
|
+
},
|
|
383
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
384
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
385
|
+
},
|
|
386
|
+
__wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
|
|
387
|
+
arg0.randomFillSync(arg1);
|
|
388
|
+
}, arguments); },
|
|
389
|
+
__wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
|
|
390
|
+
const ret = module.require;
|
|
391
|
+
return ret;
|
|
392
|
+
}, arguments); },
|
|
393
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
394
|
+
arg0[arg1] = arg2;
|
|
395
|
+
},
|
|
396
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
397
|
+
arg0[arg1 >>> 0] = arg2;
|
|
398
|
+
},
|
|
399
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
400
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
401
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
402
|
+
},
|
|
403
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
404
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
405
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
406
|
+
},
|
|
407
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
408
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
409
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
410
|
+
},
|
|
411
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
412
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
413
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
414
|
+
},
|
|
415
|
+
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
|
|
416
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
417
|
+
return ret;
|
|
418
|
+
},
|
|
419
|
+
__wbg_value_0546255b415e96c1: function(arg0) {
|
|
420
|
+
const ret = arg0.value;
|
|
421
|
+
return ret;
|
|
422
|
+
},
|
|
423
|
+
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
424
|
+
const ret = arg0.versions;
|
|
425
|
+
return ret;
|
|
426
|
+
},
|
|
427
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
428
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
429
|
+
const ret = arg0;
|
|
430
|
+
return ret;
|
|
431
|
+
},
|
|
432
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
433
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
434
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
435
|
+
return ret;
|
|
436
|
+
},
|
|
437
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
438
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
439
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
440
|
+
return ret;
|
|
441
|
+
},
|
|
442
|
+
__wbindgen_init_externref_table: function() {
|
|
443
|
+
const table = wasm.__wbindgen_externrefs;
|
|
444
|
+
const offset = table.grow(4);
|
|
445
|
+
table.set(0, undefined);
|
|
446
|
+
table.set(offset + 0, undefined);
|
|
447
|
+
table.set(offset + 1, null);
|
|
448
|
+
table.set(offset + 2, true);
|
|
449
|
+
table.set(offset + 3, false);
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
return {
|
|
453
|
+
__proto__: null,
|
|
454
|
+
"./agentaos_mpc_wasm_bg.js": import0,
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function addToExternrefTable0(obj) {
|
|
459
|
+
const idx = wasm.__externref_table_alloc();
|
|
460
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
461
|
+
return idx;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function debugString(val) {
|
|
465
|
+
// primitive types
|
|
466
|
+
const type = typeof val;
|
|
467
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
468
|
+
return `${val}`;
|
|
469
|
+
}
|
|
470
|
+
if (type == 'string') {
|
|
471
|
+
return `"${val}"`;
|
|
472
|
+
}
|
|
473
|
+
if (type == 'symbol') {
|
|
474
|
+
const description = val.description;
|
|
475
|
+
if (description == null) {
|
|
476
|
+
return 'Symbol';
|
|
477
|
+
} else {
|
|
478
|
+
return `Symbol(${description})`;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (type == 'function') {
|
|
482
|
+
const name = val.name;
|
|
483
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
484
|
+
return `Function(${name})`;
|
|
485
|
+
} else {
|
|
486
|
+
return 'Function';
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
// objects
|
|
490
|
+
if (Array.isArray(val)) {
|
|
491
|
+
const length = val.length;
|
|
492
|
+
let debug = '[';
|
|
493
|
+
if (length > 0) {
|
|
494
|
+
debug += debugString(val[0]);
|
|
495
|
+
}
|
|
496
|
+
for(let i = 1; i < length; i++) {
|
|
497
|
+
debug += ', ' + debugString(val[i]);
|
|
498
|
+
}
|
|
499
|
+
debug += ']';
|
|
500
|
+
return debug;
|
|
501
|
+
}
|
|
502
|
+
// Test for built-in
|
|
503
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
504
|
+
let className;
|
|
505
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
506
|
+
className = builtInMatches[1];
|
|
507
|
+
} else {
|
|
508
|
+
// Failed to match the standard '[object ClassName]'
|
|
509
|
+
return toString.call(val);
|
|
510
|
+
}
|
|
511
|
+
if (className == 'Object') {
|
|
512
|
+
// we're a user defined class or Object
|
|
513
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
514
|
+
// easier than looping through ownProperties of `val`.
|
|
515
|
+
try {
|
|
516
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
517
|
+
} catch (_) {
|
|
518
|
+
return 'Object';
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
// errors
|
|
522
|
+
if (val instanceof Error) {
|
|
523
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
524
|
+
}
|
|
525
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
526
|
+
return className;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
530
|
+
ptr = ptr >>> 0;
|
|
531
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
let cachedDataViewMemory0 = null;
|
|
535
|
+
function getDataViewMemory0() {
|
|
536
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
537
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
538
|
+
}
|
|
539
|
+
return cachedDataViewMemory0;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function getStringFromWasm0(ptr, len) {
|
|
543
|
+
ptr = ptr >>> 0;
|
|
544
|
+
return decodeText(ptr, len);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
let cachedUint16ArrayMemory0 = null;
|
|
548
|
+
function getUint16ArrayMemory0() {
|
|
549
|
+
if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
|
|
550
|
+
cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
|
|
551
|
+
}
|
|
552
|
+
return cachedUint16ArrayMemory0;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
let cachedUint8ArrayMemory0 = null;
|
|
556
|
+
function getUint8ArrayMemory0() {
|
|
557
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
558
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
559
|
+
}
|
|
560
|
+
return cachedUint8ArrayMemory0;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function handleError(f, args) {
|
|
564
|
+
try {
|
|
565
|
+
return f.apply(this, args);
|
|
566
|
+
} catch (e) {
|
|
567
|
+
const idx = addToExternrefTable0(e);
|
|
568
|
+
wasm.__wbindgen_exn_store(idx);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
function isLikeNone(x) {
|
|
573
|
+
return x === undefined || x === null;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
function passArray16ToWasm0(arg, malloc) {
|
|
577
|
+
const ptr = malloc(arg.length * 2, 2) >>> 0;
|
|
578
|
+
getUint16ArrayMemory0().set(arg, ptr / 2);
|
|
579
|
+
WASM_VECTOR_LEN = arg.length;
|
|
580
|
+
return ptr;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
584
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
585
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
586
|
+
WASM_VECTOR_LEN = arg.length;
|
|
587
|
+
return ptr;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
591
|
+
if (realloc === undefined) {
|
|
592
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
593
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
594
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
595
|
+
WASM_VECTOR_LEN = buf.length;
|
|
596
|
+
return ptr;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
let len = arg.length;
|
|
600
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
601
|
+
|
|
602
|
+
const mem = getUint8ArrayMemory0();
|
|
603
|
+
|
|
604
|
+
let offset = 0;
|
|
605
|
+
|
|
606
|
+
for (; offset < len; offset++) {
|
|
607
|
+
const code = arg.charCodeAt(offset);
|
|
608
|
+
if (code > 0x7F) break;
|
|
609
|
+
mem[ptr + offset] = code;
|
|
610
|
+
}
|
|
611
|
+
if (offset !== len) {
|
|
612
|
+
if (offset !== 0) {
|
|
613
|
+
arg = arg.slice(offset);
|
|
614
|
+
}
|
|
615
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
616
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
617
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
618
|
+
|
|
619
|
+
offset += ret.written;
|
|
620
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
WASM_VECTOR_LEN = offset;
|
|
624
|
+
return ptr;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function takeFromExternrefTable0(idx) {
|
|
628
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
629
|
+
wasm.__externref_table_dealloc(idx);
|
|
630
|
+
return value;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
634
|
+
cachedTextDecoder.decode();
|
|
635
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
636
|
+
let numBytesDecoded = 0;
|
|
637
|
+
function decodeText(ptr, len) {
|
|
638
|
+
numBytesDecoded += len;
|
|
639
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
640
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
641
|
+
cachedTextDecoder.decode();
|
|
642
|
+
numBytesDecoded = len;
|
|
643
|
+
}
|
|
644
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
const cachedTextEncoder = new TextEncoder();
|
|
648
|
+
|
|
649
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
650
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
651
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
652
|
+
view.set(buf);
|
|
653
|
+
return {
|
|
654
|
+
read: arg.length,
|
|
655
|
+
written: buf.length
|
|
656
|
+
};
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
let WASM_VECTOR_LEN = 0;
|
|
661
|
+
|
|
662
|
+
let wasmModule, wasm;
|
|
663
|
+
function __wbg_finalize_init(instance, module) {
|
|
664
|
+
wasm = instance.exports;
|
|
665
|
+
wasmModule = module;
|
|
666
|
+
cachedDataViewMemory0 = null;
|
|
667
|
+
cachedUint16ArrayMemory0 = null;
|
|
668
|
+
cachedUint8ArrayMemory0 = null;
|
|
669
|
+
wasm.__wbindgen_start();
|
|
670
|
+
return wasm;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
async function __wbg_load(module, imports) {
|
|
674
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
675
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
676
|
+
try {
|
|
677
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
678
|
+
} catch (e) {
|
|
679
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
680
|
+
|
|
681
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
682
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
683
|
+
|
|
684
|
+
} else { throw e; }
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
const bytes = await module.arrayBuffer();
|
|
689
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
690
|
+
} else {
|
|
691
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
692
|
+
|
|
693
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
694
|
+
return { instance, module };
|
|
695
|
+
} else {
|
|
696
|
+
return instance;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function expectedResponseType(type) {
|
|
701
|
+
switch (type) {
|
|
702
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
703
|
+
}
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
function initSync(module) {
|
|
709
|
+
if (wasm !== undefined) return wasm;
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
if (module !== undefined) {
|
|
713
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
714
|
+
({module} = module)
|
|
715
|
+
} else {
|
|
716
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const imports = __wbg_get_imports();
|
|
721
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
722
|
+
module = new WebAssembly.Module(module);
|
|
723
|
+
}
|
|
724
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
725
|
+
return __wbg_finalize_init(instance, module);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
async function __wbg_init(module_or_path) {
|
|
729
|
+
if (wasm !== undefined) return wasm;
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
if (module_or_path !== undefined) {
|
|
733
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
734
|
+
({module_or_path} = module_or_path)
|
|
735
|
+
} else {
|
|
736
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if (module_or_path === undefined) {
|
|
741
|
+
module_or_path = new URL('agentaos_mpc_wasm_bg.wasm', import.meta.url);
|
|
742
|
+
}
|
|
743
|
+
const imports = __wbg_get_imports();
|
|
744
|
+
|
|
745
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
746
|
+
module_or_path = fetch(module_or_path);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
750
|
+
|
|
751
|
+
return __wbg_finalize_init(instance, module);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const _critical_section_1_0_acquire: () => void;
|
|
5
|
+
export const combine_key_share: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
6
|
+
export const extract_public_key: (a: number, b: number) => [number, number, number, number];
|
|
7
|
+
export const pregenerate_paillier_primes: () => [number, number, number, number];
|
|
8
|
+
export const run_dkg: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
9
|
+
export const run_dkg_with_primes: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
10
|
+
export const sign_create_session: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number];
|
|
11
|
+
export const sign_destroy_session: (a: number, b: number) => number;
|
|
12
|
+
export const sign_process_round: (a: number, b: number, c: any) => [number, number, number];
|
|
13
|
+
export const _critical_section_1_0_release: () => void;
|
|
14
|
+
export const init: () => void;
|
|
15
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
16
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
17
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
18
|
+
export const __externref_table_alloc: () => number;
|
|
19
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
20
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
21
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
22
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agentaos-mpc-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "WASM wrapper for CGGMP24 threshold ECDSA — keygen, signing, presignatures",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"files": [
|
|
8
|
+
"agentaos_mpc_wasm_bg.wasm",
|
|
9
|
+
"agentaos_mpc_wasm.js",
|
|
10
|
+
"agentaos_mpc_wasm.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"main": "agentaos_mpc_wasm.js",
|
|
13
|
+
"types": "agentaos_mpc_wasm.d.ts",
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"./snippets/*"
|
|
16
|
+
]
|
|
17
|
+
}
|