@interest-protocol/vortex-sdk 0.0.1-alpha.0 → 1.1.0
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/.eslingignore +1 -0
- package/dist/__tests__/entities/keypair.spec.d.ts +2 -0
- package/dist/__tests__/entities/keypair.spec.d.ts.map +1 -0
- package/dist/__tests__/test-utils.d.ts +25 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -0
- package/dist/__tests__/types.d.ts +3 -0
- package/dist/__tests__/types.d.ts.map +1 -0
- package/dist/__tests__/vortex.test.d.ts +2 -0
- package/dist/__tests__/vortex.test.d.ts.map +1 -0
- package/dist/constants.d.ts +44 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/crypto/ff/f1field.d.ts +76 -0
- package/dist/crypto/ff/f1field.d.ts.map +1 -0
- package/dist/crypto/ff/index.d.ts +6 -0
- package/dist/crypto/ff/index.d.ts.map +1 -0
- package/dist/crypto/ff/random.d.ts +2 -0
- package/dist/crypto/ff/random.d.ts.map +1 -0
- package/dist/crypto/ff/scalar.d.ts +45 -0
- package/dist/crypto/ff/scalar.d.ts.map +1 -0
- package/dist/crypto/ff/utils.d.ts +6 -0
- package/dist/crypto/ff/utils.d.ts.map +1 -0
- package/dist/crypto/index.d.ts +6 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/poseidon/index.d.ts +2 -0
- package/dist/crypto/poseidon/index.d.ts.map +1 -0
- package/dist/crypto/poseidon/poseidon-constants-opt.d.ts +7 -0
- package/dist/crypto/poseidon/poseidon-constants-opt.d.ts.map +1 -0
- package/dist/crypto/poseidon/poseidon-opt.d.ts +16 -0
- package/dist/crypto/poseidon/poseidon-opt.d.ts.map +1 -0
- package/dist/deposit.d.ts +4 -0
- package/dist/deposit.d.ts.map +1 -0
- package/dist/entities/index.d.ts +4 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/keypair.d.ts +29 -0
- package/dist/entities/keypair.d.ts.map +1 -0
- package/dist/entities/merkle-tree.d.ts +81 -0
- package/dist/entities/merkle-tree.d.ts.map +1 -0
- package/dist/entities/utxo.d.ts +24 -0
- package/dist/entities/utxo.d.ts.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38280 -4459
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38244 -4453
- package/dist/index.mjs.map +1 -1
- package/dist/jest-setup.d.ts +2 -0
- package/dist/jest-setup.d.ts.map +1 -0
- package/dist/keys/index.d.ts +3 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/pkg/nodejs/vortex.d.ts +11 -0
- package/dist/pkg/nodejs/vortex.d.ts.map +1 -0
- package/dist/pkg/web/vortex.d.ts +44 -0
- package/dist/pkg/web/vortex.d.ts.map +1 -0
- package/dist/utils/decrypt.d.ts +12 -0
- package/dist/utils/decrypt.d.ts.map +1 -0
- package/dist/utils/env.d.ts +2 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/events.d.ts +7 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/ext-data.d.ts +3 -0
- package/dist/utils/ext-data.d.ts.map +1 -0
- package/dist/utils/index.d.ts +50 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/prove.d.ts +3 -0
- package/dist/utils/prove.d.ts.map +1 -0
- package/dist/vortex.d.ts +51 -21
- package/dist/vortex.d.ts.map +1 -1
- package/dist/vortex.types.d.ts +74 -50
- package/dist/vortex.types.d.ts.map +1 -1
- package/dist/vortex_bg.wasm +0 -0
- package/dist/withdraw.d.ts +4 -0
- package/dist/withdraw.d.ts.map +1 -0
- package/jest.config.js +31 -0
- package/package.json +22 -7
- package/src/__tests__/entities/keypair.spec.ts +191 -0
- package/src/__tests__/test-utils.ts +76 -0
- package/src/__tests__/types.ts +3 -0
- package/src/__tests__/vortex.test.ts +25 -0
- package/src/constants.ts +104 -0
- package/src/crypto/ff/f1field.ts +464 -0
- package/src/crypto/ff/index.ts +6 -0
- package/src/crypto/ff/random.ts +32 -0
- package/src/crypto/ff/readme.md +8 -0
- package/src/crypto/ff/scalar.ts +264 -0
- package/src/crypto/ff/utils.ts +121 -0
- package/src/crypto/index.ts +8 -0
- package/src/crypto/poseidon/index.ts +1 -0
- package/src/crypto/poseidon/poseidon-constants-opt.ts +24806 -0
- package/src/crypto/poseidon/poseidon-opt.ts +184 -0
- package/src/deposit.ts +168 -0
- package/src/entities/index.ts +3 -0
- package/src/entities/keypair.ts +262 -0
- package/src/entities/merkle-tree.ts +256 -0
- package/src/entities/utxo.ts +52 -0
- package/src/index.ts +6 -2
- package/src/jest-setup.ts +2 -0
- package/src/keys/index.ts +5 -0
- package/src/pkg/nodejs/vortex.d.ts +36 -0
- package/src/pkg/nodejs/vortex.js +332 -0
- package/src/pkg/nodejs/vortex_bg.wasm +0 -0
- package/src/pkg/nodejs/vortex_bg.wasm.d.ts +12 -0
- package/src/pkg/web/vortex.d.ts +72 -0
- package/src/pkg/web/vortex.js +442 -0
- package/src/pkg/web/vortex_bg.wasm +0 -0
- package/src/pkg/web/vortex_bg.wasm.d.ts +12 -0
- package/src/utils/decrypt.ts +46 -0
- package/src/utils/env.ts +18 -0
- package/src/utils/events.ts +16 -0
- package/src/utils/ext-data.ts +43 -0
- package/src/utils/index.ts +152 -0
- package/src/utils/prove.ts +18 -0
- package/src/vortex.ts +235 -111
- package/src/vortex.types.ts +74 -54
- package/src/withdraw.ts +159 -0
- package/tsconfig.json +4 -2
- package/dist/admin.d.ts +0 -17
- package/dist/admin.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -11
- package/dist/utils.d.ts.map +0 -1
- package/src/admin.ts +0 -124
- package/src/utils.ts +0 -66
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function main(): void;
|
|
4
|
+
/**
|
|
5
|
+
* Generates a zero-knowledge proof for a privacy-preserving transaction
|
|
6
|
+
*
|
|
7
|
+
* # Arguments
|
|
8
|
+
* * `input_json` - JSON string containing all circuit inputs
|
|
9
|
+
* * `proving_key_hex` - Hex-encoded proving key (generated during setup)
|
|
10
|
+
*
|
|
11
|
+
* # Returns
|
|
12
|
+
* JSON string containing the proof and public inputs
|
|
13
|
+
*
|
|
14
|
+
* # Example
|
|
15
|
+
* ```javascript
|
|
16
|
+
* const input = {
|
|
17
|
+
* root: "12345...",
|
|
18
|
+
* publicAmount: "1000",
|
|
19
|
+
* // ... other inputs
|
|
20
|
+
* };
|
|
21
|
+
* const proof = prove(JSON.stringify(input), provingKeyHex);
|
|
22
|
+
* const { proofA, proofB, proofC, publicInputs } = JSON.parse(proof);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function prove(input_json: string, proving_key_hex: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Verifies a proof (useful for testing before submitting to chain)
|
|
28
|
+
*
|
|
29
|
+
* # Arguments
|
|
30
|
+
* * `proof_json` - JSON string containing proof output from `prove()`
|
|
31
|
+
* * `verifying_key_hex` - Hex-encoded verifying key
|
|
32
|
+
*
|
|
33
|
+
* # Returns
|
|
34
|
+
* "true" if proof is valid, "false" otherwise
|
|
35
|
+
*/
|
|
36
|
+
export function verify(proof_json: string, verifying_key_hex: string): boolean;
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
let imports = {};
|
|
3
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
|
+
|
|
5
|
+
function debugString(val) {
|
|
6
|
+
// primitive types
|
|
7
|
+
const type = typeof val;
|
|
8
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
9
|
+
return `${val}`;
|
|
10
|
+
}
|
|
11
|
+
if (type == 'string') {
|
|
12
|
+
return `"${val}"`;
|
|
13
|
+
}
|
|
14
|
+
if (type == 'symbol') {
|
|
15
|
+
const description = val.description;
|
|
16
|
+
if (description == null) {
|
|
17
|
+
return 'Symbol';
|
|
18
|
+
} else {
|
|
19
|
+
return `Symbol(${description})`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (type == 'function') {
|
|
23
|
+
const name = val.name;
|
|
24
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
25
|
+
return `Function(${name})`;
|
|
26
|
+
} else {
|
|
27
|
+
return 'Function';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// objects
|
|
31
|
+
if (Array.isArray(val)) {
|
|
32
|
+
const length = val.length;
|
|
33
|
+
let debug = '[';
|
|
34
|
+
if (length > 0) {
|
|
35
|
+
debug += debugString(val[0]);
|
|
36
|
+
}
|
|
37
|
+
for (let i = 1; i < length; i++) {
|
|
38
|
+
debug += ', ' + debugString(val[i]);
|
|
39
|
+
}
|
|
40
|
+
debug += ']';
|
|
41
|
+
return debug;
|
|
42
|
+
}
|
|
43
|
+
// Test for built-in
|
|
44
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
45
|
+
let className;
|
|
46
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
47
|
+
className = builtInMatches[1];
|
|
48
|
+
} else {
|
|
49
|
+
// Failed to match the standard '[object ClassName]'
|
|
50
|
+
return toString.call(val);
|
|
51
|
+
}
|
|
52
|
+
if (className == 'Object') {
|
|
53
|
+
// we're a user defined class or Object
|
|
54
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
55
|
+
// easier than looping through ownProperties of `val`.
|
|
56
|
+
try {
|
|
57
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
58
|
+
} catch (_) {
|
|
59
|
+
return 'Object';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// errors
|
|
63
|
+
if (val instanceof Error) {
|
|
64
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
65
|
+
}
|
|
66
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
67
|
+
return className;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let WASM_VECTOR_LEN = 0;
|
|
71
|
+
|
|
72
|
+
let cachedUint8ArrayMemory0 = null;
|
|
73
|
+
|
|
74
|
+
function getUint8ArrayMemory0() {
|
|
75
|
+
if (
|
|
76
|
+
cachedUint8ArrayMemory0 === null ||
|
|
77
|
+
cachedUint8ArrayMemory0.byteLength === 0
|
|
78
|
+
) {
|
|
79
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
80
|
+
}
|
|
81
|
+
return cachedUint8ArrayMemory0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const cachedTextEncoder = new TextEncoder();
|
|
85
|
+
|
|
86
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
87
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
88
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
89
|
+
view.set(buf);
|
|
90
|
+
return {
|
|
91
|
+
read: arg.length,
|
|
92
|
+
written: buf.length,
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
98
|
+
if (realloc === undefined) {
|
|
99
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
100
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
101
|
+
getUint8ArrayMemory0()
|
|
102
|
+
.subarray(ptr, ptr + buf.length)
|
|
103
|
+
.set(buf);
|
|
104
|
+
WASM_VECTOR_LEN = buf.length;
|
|
105
|
+
return ptr;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let len = arg.length;
|
|
109
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
110
|
+
|
|
111
|
+
const mem = getUint8ArrayMemory0();
|
|
112
|
+
|
|
113
|
+
let offset = 0;
|
|
114
|
+
|
|
115
|
+
for (; offset < len; offset++) {
|
|
116
|
+
const code = arg.charCodeAt(offset);
|
|
117
|
+
if (code > 0x7f) break;
|
|
118
|
+
mem[ptr + offset] = code;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (offset !== len) {
|
|
122
|
+
if (offset !== 0) {
|
|
123
|
+
arg = arg.slice(offset);
|
|
124
|
+
}
|
|
125
|
+
ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0;
|
|
126
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
127
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
128
|
+
|
|
129
|
+
offset += ret.written;
|
|
130
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
WASM_VECTOR_LEN = offset;
|
|
134
|
+
return ptr;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let cachedDataViewMemory0 = null;
|
|
138
|
+
|
|
139
|
+
function getDataViewMemory0() {
|
|
140
|
+
if (
|
|
141
|
+
cachedDataViewMemory0 === null ||
|
|
142
|
+
cachedDataViewMemory0.buffer.detached === true ||
|
|
143
|
+
(cachedDataViewMemory0.buffer.detached === undefined &&
|
|
144
|
+
cachedDataViewMemory0.buffer !== wasm.memory.buffer)
|
|
145
|
+
) {
|
|
146
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
147
|
+
}
|
|
148
|
+
return cachedDataViewMemory0;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let cachedTextDecoder = new TextDecoder('utf-8', {
|
|
152
|
+
ignoreBOM: true,
|
|
153
|
+
fatal: true,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
cachedTextDecoder.decode();
|
|
157
|
+
|
|
158
|
+
function decodeText(ptr, len) {
|
|
159
|
+
return cachedTextDecoder.decode(
|
|
160
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + len)
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function getStringFromWasm0(ptr, len) {
|
|
165
|
+
ptr = ptr >>> 0;
|
|
166
|
+
return decodeText(ptr, len);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
exports.main = function () {
|
|
170
|
+
wasm.main();
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
function takeFromExternrefTable0(idx) {
|
|
174
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
175
|
+
wasm.__externref_table_dealloc(idx);
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Generates a zero-knowledge proof for a privacy-preserving transaction
|
|
180
|
+
*
|
|
181
|
+
* # Arguments
|
|
182
|
+
* * `input_json` - JSON string containing all circuit inputs
|
|
183
|
+
* * `proving_key_hex` - Hex-encoded proving key (generated during setup)
|
|
184
|
+
*
|
|
185
|
+
* # Returns
|
|
186
|
+
* JSON string containing the proof and public inputs
|
|
187
|
+
*
|
|
188
|
+
* # Example
|
|
189
|
+
* ```javascript
|
|
190
|
+
* const input = {
|
|
191
|
+
* root: "12345...",
|
|
192
|
+
* publicAmount: "1000",
|
|
193
|
+
* // ... other inputs
|
|
194
|
+
* };
|
|
195
|
+
* const proof = prove(JSON.stringify(input), provingKeyHex);
|
|
196
|
+
* const { proofA, proofB, proofC, publicInputs } = JSON.parse(proof);
|
|
197
|
+
* ```
|
|
198
|
+
* @param {string} input_json
|
|
199
|
+
* @param {string} proving_key_hex
|
|
200
|
+
* @returns {string}
|
|
201
|
+
*/
|
|
202
|
+
exports.prove = function (input_json, proving_key_hex) {
|
|
203
|
+
let deferred4_0;
|
|
204
|
+
let deferred4_1;
|
|
205
|
+
try {
|
|
206
|
+
const ptr0 = passStringToWasm0(
|
|
207
|
+
input_json,
|
|
208
|
+
wasm.__wbindgen_malloc,
|
|
209
|
+
wasm.__wbindgen_realloc
|
|
210
|
+
);
|
|
211
|
+
const len0 = WASM_VECTOR_LEN;
|
|
212
|
+
const ptr1 = passStringToWasm0(
|
|
213
|
+
proving_key_hex,
|
|
214
|
+
wasm.__wbindgen_malloc,
|
|
215
|
+
wasm.__wbindgen_realloc
|
|
216
|
+
);
|
|
217
|
+
const len1 = WASM_VECTOR_LEN;
|
|
218
|
+
const ret = wasm.prove(ptr0, len0, ptr1, len1);
|
|
219
|
+
var ptr3 = ret[0];
|
|
220
|
+
var len3 = ret[1];
|
|
221
|
+
if (ret[3]) {
|
|
222
|
+
ptr3 = 0;
|
|
223
|
+
len3 = 0;
|
|
224
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
225
|
+
}
|
|
226
|
+
deferred4_0 = ptr3;
|
|
227
|
+
deferred4_1 = len3;
|
|
228
|
+
return getStringFromWasm0(ptr3, len3);
|
|
229
|
+
} finally {
|
|
230
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Verifies a proof (useful for testing before submitting to chain)
|
|
236
|
+
*
|
|
237
|
+
* # Arguments
|
|
238
|
+
* * `proof_json` - JSON string containing proof output from `prove()`
|
|
239
|
+
* * `verifying_key_hex` - Hex-encoded verifying key
|
|
240
|
+
*
|
|
241
|
+
* # Returns
|
|
242
|
+
* "true" if proof is valid, "false" otherwise
|
|
243
|
+
* @param {string} proof_json
|
|
244
|
+
* @param {string} verifying_key_hex
|
|
245
|
+
* @returns {boolean}
|
|
246
|
+
*/
|
|
247
|
+
exports.verify = function (proof_json, verifying_key_hex) {
|
|
248
|
+
const ptr0 = passStringToWasm0(
|
|
249
|
+
proof_json,
|
|
250
|
+
wasm.__wbindgen_malloc,
|
|
251
|
+
wasm.__wbindgen_realloc
|
|
252
|
+
);
|
|
253
|
+
const len0 = WASM_VECTOR_LEN;
|
|
254
|
+
const ptr1 = passStringToWasm0(
|
|
255
|
+
verifying_key_hex,
|
|
256
|
+
wasm.__wbindgen_malloc,
|
|
257
|
+
wasm.__wbindgen_realloc
|
|
258
|
+
);
|
|
259
|
+
const len1 = WASM_VECTOR_LEN;
|
|
260
|
+
const ret = wasm.verify(ptr0, len0, ptr1, len1);
|
|
261
|
+
if (ret[2]) {
|
|
262
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
263
|
+
}
|
|
264
|
+
return ret[0] !== 0;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
exports.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function (arg0, arg1) {
|
|
268
|
+
const ret = debugString(arg1);
|
|
269
|
+
const ptr1 = passStringToWasm0(
|
|
270
|
+
ret,
|
|
271
|
+
wasm.__wbindgen_malloc,
|
|
272
|
+
wasm.__wbindgen_realloc
|
|
273
|
+
);
|
|
274
|
+
const len1 = WASM_VECTOR_LEN;
|
|
275
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
276
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
exports.__wbg_error_7534b8e9a36f1ab4 = function (arg0, arg1) {
|
|
280
|
+
let deferred0_0;
|
|
281
|
+
let deferred0_1;
|
|
282
|
+
try {
|
|
283
|
+
deferred0_0 = arg0;
|
|
284
|
+
deferred0_1 = arg1;
|
|
285
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
286
|
+
} finally {
|
|
287
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
exports.__wbg_new_8a6f238a6ece86ea = function () {
|
|
292
|
+
const ret = new Error();
|
|
293
|
+
return ret;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
exports.__wbg_stack_0ed75d68575b0f3c = function (arg0, arg1) {
|
|
297
|
+
const ret = arg1.stack;
|
|
298
|
+
const ptr1 = passStringToWasm0(
|
|
299
|
+
ret,
|
|
300
|
+
wasm.__wbindgen_malloc,
|
|
301
|
+
wasm.__wbindgen_realloc
|
|
302
|
+
);
|
|
303
|
+
const len1 = WASM_VECTOR_LEN;
|
|
304
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
305
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
exports.__wbindgen_cast_2241b6af4c4b2941 = function (arg0, arg1) {
|
|
309
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
310
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
311
|
+
return ret;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
exports.__wbindgen_init_externref_table = function () {
|
|
315
|
+
const table = wasm.__wbindgen_externrefs;
|
|
316
|
+
const offset = table.grow(4);
|
|
317
|
+
table.set(0, undefined);
|
|
318
|
+
table.set(offset + 0, undefined);
|
|
319
|
+
table.set(offset + 1, null);
|
|
320
|
+
table.set(offset + 2, true);
|
|
321
|
+
table.set(offset + 3, false);
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const wasmPath = `${__dirname}/vortex_bg.wasm`;
|
|
325
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
326
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
327
|
+
const wasm = (exports.__wasm = new WebAssembly.Instance(
|
|
328
|
+
wasmModule,
|
|
329
|
+
imports
|
|
330
|
+
).exports);
|
|
331
|
+
|
|
332
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const prove: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
5
|
+
export const verify: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
6
|
+
export const main: () => void;
|
|
7
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
8
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
9
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
10
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
11
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
12
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function main(): void;
|
|
4
|
+
/**
|
|
5
|
+
* Generates a zero-knowledge proof for a privacy-preserving transaction
|
|
6
|
+
*
|
|
7
|
+
* # Arguments
|
|
8
|
+
* * `input_json` - JSON string containing all circuit inputs
|
|
9
|
+
* * `proving_key_hex` - Hex-encoded proving key (generated during setup)
|
|
10
|
+
*
|
|
11
|
+
* # Returns
|
|
12
|
+
* JSON string containing the proof and public inputs
|
|
13
|
+
*
|
|
14
|
+
* # Example
|
|
15
|
+
* ```javascript
|
|
16
|
+
* const input = {
|
|
17
|
+
* root: "12345...",
|
|
18
|
+
* publicAmount: "1000",
|
|
19
|
+
* // ... other inputs
|
|
20
|
+
* };
|
|
21
|
+
* const proof = prove(JSON.stringify(input), provingKeyHex);
|
|
22
|
+
* const { proofA, proofB, proofC, publicInputs } = JSON.parse(proof);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function prove(input_json: string, proving_key_hex: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Verifies a proof (useful for testing before submitting to chain)
|
|
28
|
+
*
|
|
29
|
+
* # Arguments
|
|
30
|
+
* * `proof_json` - JSON string containing proof output from `prove()`
|
|
31
|
+
* * `verifying_key_hex` - Hex-encoded verifying key
|
|
32
|
+
*
|
|
33
|
+
* # Returns
|
|
34
|
+
* "true" if proof is valid, "false" otherwise
|
|
35
|
+
*/
|
|
36
|
+
export function verify(proof_json: string, verifying_key_hex: string): boolean;
|
|
37
|
+
|
|
38
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
39
|
+
|
|
40
|
+
export interface InitOutput {
|
|
41
|
+
readonly memory: WebAssembly.Memory;
|
|
42
|
+
readonly prove: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
43
|
+
readonly verify: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
44
|
+
readonly main: () => void;
|
|
45
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
46
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
47
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
48
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
49
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
50
|
+
readonly __wbindgen_start: () => void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
54
|
+
/**
|
|
55
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
56
|
+
* a precompiled `WebAssembly.Module`.
|
|
57
|
+
*
|
|
58
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
59
|
+
*
|
|
60
|
+
* @returns {InitOutput}
|
|
61
|
+
*/
|
|
62
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
66
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
67
|
+
*
|
|
68
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
69
|
+
*
|
|
70
|
+
* @returns {Promise<InitOutput>}
|
|
71
|
+
*/
|
|
72
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|