@rolly-dev/wasm-signer 0.3.1 → 0.5.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/dist/node/rolly_wasm_signer.d.ts +13 -0
- package/dist/node/rolly_wasm_signer.js +203 -21
- package/dist/node/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/node/rolly_wasm_signer_bg.wasm.d.ts +5 -3
- package/dist/web/rolly_wasm_signer.d.ts +18 -3
- package/dist/web/rolly_wasm_signer.js +202 -21
- package/dist/web/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/web/rolly_wasm_signer_bg.wasm.d.ts +5 -3
- package/js/browser.d.mts +1 -0
- package/js/browser.mjs +1 -0
- package/js/index.d.ts +1 -0
- package/js/node.cjs +1 -0
- package/js/node.mjs +1 -0
- package/js/react.d.mts +13 -12
- package/js/react.mjs +26 -17
- package/package.json +1 -1
|
@@ -59,6 +59,19 @@ export function create_bet_auth(session_key: BigUint64Array, bet_amount: bigint,
|
|
|
59
59
|
*/
|
|
60
60
|
export function derive_session_key(sig_bytes: Uint8Array): BigUint64Array;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Generate a random user seed — 10 alphanumeric characters.
|
|
64
|
+
*
|
|
65
|
+
* Uses `getrandom` (backed by `crypto.getRandomValues` in the browser
|
|
66
|
+
* and OS entropy on Node.js) for cryptographically secure randomness.
|
|
67
|
+
*
|
|
68
|
+
* ```js
|
|
69
|
+
* const seed = generate_user_seed();
|
|
70
|
+
* // e.g. "k7Qm2xW9aB"
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function generate_user_seed(): string;
|
|
74
|
+
|
|
62
75
|
/**
|
|
63
76
|
* Convert any Goldilocks field elements to a hex string.
|
|
64
77
|
*
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
function compute_server_seed_hash(server_seed) {
|
|
16
16
|
try {
|
|
17
17
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
18
|
-
const ptr0 = passArray64ToWasm0(server_seed, wasm.
|
|
18
|
+
const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export2);
|
|
19
19
|
const len0 = WASM_VECTOR_LEN;
|
|
20
20
|
wasm.compute_server_seed_hash(retptr, ptr0, len0);
|
|
21
21
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
22
22
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
23
23
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
24
|
-
wasm.
|
|
24
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
25
25
|
return v2;
|
|
26
26
|
} finally {
|
|
27
27
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -62,13 +62,13 @@ exports.compute_server_seed_hash = compute_server_seed_hash;
|
|
|
62
62
|
function create_bet_auth(session_key, bet_amount, nonce) {
|
|
63
63
|
try {
|
|
64
64
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
65
|
-
const ptr0 = passArray64ToWasm0(session_key, wasm.
|
|
65
|
+
const ptr0 = passArray64ToWasm0(session_key, wasm.__wbindgen_export2);
|
|
66
66
|
const len0 = WASM_VECTOR_LEN;
|
|
67
67
|
wasm.create_bet_auth(retptr, ptr0, len0, bet_amount, nonce);
|
|
68
68
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
69
69
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
70
70
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
71
|
-
wasm.
|
|
71
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
72
72
|
return v2;
|
|
73
73
|
} finally {
|
|
74
74
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -97,13 +97,13 @@ exports.create_bet_auth = create_bet_auth;
|
|
|
97
97
|
function derive_session_key(sig_bytes) {
|
|
98
98
|
try {
|
|
99
99
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
100
|
-
const ptr0 = passArray8ToWasm0(sig_bytes, wasm.
|
|
100
|
+
const ptr0 = passArray8ToWasm0(sig_bytes, wasm.__wbindgen_export2);
|
|
101
101
|
const len0 = WASM_VECTOR_LEN;
|
|
102
102
|
wasm.derive_session_key(retptr, ptr0, len0);
|
|
103
103
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
104
104
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
105
105
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
106
|
-
wasm.
|
|
106
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
107
107
|
return v2;
|
|
108
108
|
} finally {
|
|
109
109
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -111,6 +111,36 @@ function derive_session_key(sig_bytes) {
|
|
|
111
111
|
}
|
|
112
112
|
exports.derive_session_key = derive_session_key;
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Generate a random user seed — 10 alphanumeric characters.
|
|
116
|
+
*
|
|
117
|
+
* Uses `getrandom` (backed by `crypto.getRandomValues` in the browser
|
|
118
|
+
* and OS entropy on Node.js) for cryptographically secure randomness.
|
|
119
|
+
*
|
|
120
|
+
* ```js
|
|
121
|
+
* const seed = generate_user_seed();
|
|
122
|
+
* // e.g. "k7Qm2xW9aB"
|
|
123
|
+
* ```
|
|
124
|
+
* @returns {string}
|
|
125
|
+
*/
|
|
126
|
+
function generate_user_seed() {
|
|
127
|
+
let deferred1_0;
|
|
128
|
+
let deferred1_1;
|
|
129
|
+
try {
|
|
130
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
131
|
+
wasm.generate_user_seed(retptr);
|
|
132
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
133
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
134
|
+
deferred1_0 = r0;
|
|
135
|
+
deferred1_1 = r1;
|
|
136
|
+
return getStringFromWasm0(r0, r1);
|
|
137
|
+
} finally {
|
|
138
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
139
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.generate_user_seed = generate_user_seed;
|
|
143
|
+
|
|
114
144
|
/**
|
|
115
145
|
* Convert any Goldilocks field elements to a hex string.
|
|
116
146
|
*
|
|
@@ -128,7 +158,7 @@ function goldilocks_fields_to_hex(fields) {
|
|
|
128
158
|
let deferred2_1;
|
|
129
159
|
try {
|
|
130
160
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
131
|
-
const ptr0 = passArray64ToWasm0(fields, wasm.
|
|
161
|
+
const ptr0 = passArray64ToWasm0(fields, wasm.__wbindgen_export2);
|
|
132
162
|
const len0 = WASM_VECTOR_LEN;
|
|
133
163
|
wasm.goldilocks_fields_to_hex(retptr, ptr0, len0);
|
|
134
164
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
@@ -138,7 +168,7 @@ function goldilocks_fields_to_hex(fields) {
|
|
|
138
168
|
return getStringFromWasm0(r0, r1);
|
|
139
169
|
} finally {
|
|
140
170
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
141
|
-
wasm.
|
|
171
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
142
172
|
}
|
|
143
173
|
}
|
|
144
174
|
exports.goldilocks_fields_to_hex = goldilocks_fields_to_hex;
|
|
@@ -186,13 +216,13 @@ exports.goldilocks_reduce = goldilocks_reduce;
|
|
|
186
216
|
function poseidon2_hash(input) {
|
|
187
217
|
try {
|
|
188
218
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
189
|
-
const ptr0 = passArray64ToWasm0(input, wasm.
|
|
219
|
+
const ptr0 = passArray64ToWasm0(input, wasm.__wbindgen_export2);
|
|
190
220
|
const len0 = WASM_VECTOR_LEN;
|
|
191
221
|
wasm.poseidon2_hash(retptr, ptr0, len0);
|
|
192
222
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
193
223
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
194
224
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
195
|
-
wasm.
|
|
225
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
196
226
|
return v2;
|
|
197
227
|
} finally {
|
|
198
228
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -214,15 +244,15 @@ exports.poseidon2_hash = poseidon2_hash;
|
|
|
214
244
|
function poseidon2_two_to_one(left, right) {
|
|
215
245
|
try {
|
|
216
246
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
217
|
-
const ptr0 = passArray64ToWasm0(left, wasm.
|
|
247
|
+
const ptr0 = passArray64ToWasm0(left, wasm.__wbindgen_export2);
|
|
218
248
|
const len0 = WASM_VECTOR_LEN;
|
|
219
|
-
const ptr1 = passArray64ToWasm0(right, wasm.
|
|
249
|
+
const ptr1 = passArray64ToWasm0(right, wasm.__wbindgen_export2);
|
|
220
250
|
const len1 = WASM_VECTOR_LEN;
|
|
221
251
|
wasm.poseidon2_two_to_one(retptr, ptr0, len0, ptr1, len1);
|
|
222
252
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
223
253
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
224
254
|
var v3 = getArrayU64FromWasm0(r0, r1).slice();
|
|
225
|
-
wasm.
|
|
255
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
226
256
|
return v3;
|
|
227
257
|
} finally {
|
|
228
258
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -244,13 +274,13 @@ exports.poseidon2_two_to_one = poseidon2_two_to_one;
|
|
|
244
274
|
function seed_hash_truncated(server_seed) {
|
|
245
275
|
try {
|
|
246
276
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
247
|
-
const ptr0 = passArray64ToWasm0(server_seed, wasm.
|
|
277
|
+
const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export2);
|
|
248
278
|
const len0 = WASM_VECTOR_LEN;
|
|
249
279
|
wasm.seed_hash_truncated(retptr, ptr0, len0);
|
|
250
280
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
251
281
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
252
282
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
253
|
-
wasm.
|
|
283
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
254
284
|
return v2;
|
|
255
285
|
} finally {
|
|
256
286
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -271,13 +301,13 @@ exports.seed_hash_truncated = seed_hash_truncated;
|
|
|
271
301
|
function session_public_key(session_key) {
|
|
272
302
|
try {
|
|
273
303
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
274
|
-
const ptr0 = passArray64ToWasm0(session_key, wasm.
|
|
304
|
+
const ptr0 = passArray64ToWasm0(session_key, wasm.__wbindgen_export2);
|
|
275
305
|
const len0 = WASM_VECTOR_LEN;
|
|
276
306
|
wasm.session_public_key(retptr, ptr0, len0);
|
|
277
307
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
278
308
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
279
309
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
280
|
-
wasm.
|
|
310
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
281
311
|
return v2;
|
|
282
312
|
} finally {
|
|
283
313
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -304,13 +334,13 @@ exports.session_public_key = session_public_key;
|
|
|
304
334
|
function string_to_user_seed(input) {
|
|
305
335
|
try {
|
|
306
336
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
307
|
-
const ptr0 = passStringToWasm0(input, wasm.
|
|
337
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
308
338
|
const len0 = WASM_VECTOR_LEN;
|
|
309
339
|
wasm.string_to_user_seed(retptr, ptr0, len0);
|
|
310
340
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
311
341
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
312
342
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
313
|
-
wasm.
|
|
343
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
314
344
|
return v2;
|
|
315
345
|
} finally {
|
|
316
346
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -336,7 +366,7 @@ function string_to_user_seed_hex(input) {
|
|
|
336
366
|
let deferred2_1;
|
|
337
367
|
try {
|
|
338
368
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
339
|
-
const ptr0 = passStringToWasm0(input, wasm.
|
|
369
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
340
370
|
const len0 = WASM_VECTOR_LEN;
|
|
341
371
|
wasm.string_to_user_seed_hex(retptr, ptr0, len0);
|
|
342
372
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
@@ -346,7 +376,7 @@ function string_to_user_seed_hex(input) {
|
|
|
346
376
|
return getStringFromWasm0(r0, r1);
|
|
347
377
|
} finally {
|
|
348
378
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
349
|
-
wasm.
|
|
379
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
350
380
|
}
|
|
351
381
|
}
|
|
352
382
|
exports.string_to_user_seed_hex = string_to_user_seed_hex;
|
|
@@ -354,9 +384,116 @@ exports.string_to_user_seed_hex = string_to_user_seed_hex;
|
|
|
354
384
|
function __wbg_get_imports() {
|
|
355
385
|
const import0 = {
|
|
356
386
|
__proto__: null,
|
|
387
|
+
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
388
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
389
|
+
return ret;
|
|
390
|
+
},
|
|
391
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
392
|
+
const val = getObject(arg0);
|
|
393
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
394
|
+
return ret;
|
|
395
|
+
},
|
|
396
|
+
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
|
|
397
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
398
|
+
return ret;
|
|
399
|
+
},
|
|
400
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
401
|
+
const ret = getObject(arg0) === undefined;
|
|
402
|
+
return ret;
|
|
403
|
+
},
|
|
357
404
|
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
358
405
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
359
406
|
},
|
|
407
|
+
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
|
|
408
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
409
|
+
return addHeapObject(ret);
|
|
410
|
+
}, arguments); },
|
|
411
|
+
__wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
|
|
412
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
413
|
+
return addHeapObject(ret);
|
|
414
|
+
}, arguments); },
|
|
415
|
+
__wbg_crypto_86f2631e91b51511: function(arg0) {
|
|
416
|
+
const ret = getObject(arg0).crypto;
|
|
417
|
+
return addHeapObject(ret);
|
|
418
|
+
},
|
|
419
|
+
__wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
|
|
420
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
421
|
+
}, arguments); },
|
|
422
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
423
|
+
const ret = getObject(arg0).length;
|
|
424
|
+
return ret;
|
|
425
|
+
},
|
|
426
|
+
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
427
|
+
const ret = getObject(arg0).msCrypto;
|
|
428
|
+
return addHeapObject(ret);
|
|
429
|
+
},
|
|
430
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
431
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
432
|
+
return addHeapObject(ret);
|
|
433
|
+
},
|
|
434
|
+
__wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
|
|
435
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
436
|
+
return addHeapObject(ret);
|
|
437
|
+
},
|
|
438
|
+
__wbg_node_e1f24f89a7336c2e: function(arg0) {
|
|
439
|
+
const ret = getObject(arg0).node;
|
|
440
|
+
return addHeapObject(ret);
|
|
441
|
+
},
|
|
442
|
+
__wbg_process_3975fd6c72f520aa: function(arg0) {
|
|
443
|
+
const ret = getObject(arg0).process;
|
|
444
|
+
return addHeapObject(ret);
|
|
445
|
+
},
|
|
446
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
447
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
448
|
+
},
|
|
449
|
+
__wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
|
|
450
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
451
|
+
}, arguments); },
|
|
452
|
+
__wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
|
|
453
|
+
const ret = module.require;
|
|
454
|
+
return addHeapObject(ret);
|
|
455
|
+
}, arguments); },
|
|
456
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
457
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
458
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
459
|
+
},
|
|
460
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
461
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
462
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
463
|
+
},
|
|
464
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
465
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
466
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
467
|
+
},
|
|
468
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
469
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
470
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
471
|
+
},
|
|
472
|
+
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
|
|
473
|
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
474
|
+
return addHeapObject(ret);
|
|
475
|
+
},
|
|
476
|
+
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
477
|
+
const ret = getObject(arg0).versions;
|
|
478
|
+
return addHeapObject(ret);
|
|
479
|
+
},
|
|
480
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
481
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
482
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
483
|
+
return addHeapObject(ret);
|
|
484
|
+
},
|
|
485
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
486
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
487
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
488
|
+
return addHeapObject(ret);
|
|
489
|
+
},
|
|
490
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
491
|
+
const ret = getObject(arg0);
|
|
492
|
+
return addHeapObject(ret);
|
|
493
|
+
},
|
|
494
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
495
|
+
takeObject(arg0);
|
|
496
|
+
},
|
|
360
497
|
};
|
|
361
498
|
return {
|
|
362
499
|
__proto__: null,
|
|
@@ -364,11 +501,31 @@ function __wbg_get_imports() {
|
|
|
364
501
|
};
|
|
365
502
|
}
|
|
366
503
|
|
|
504
|
+
function addHeapObject(obj) {
|
|
505
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
506
|
+
const idx = heap_next;
|
|
507
|
+
heap_next = heap[idx];
|
|
508
|
+
|
|
509
|
+
heap[idx] = obj;
|
|
510
|
+
return idx;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function dropObject(idx) {
|
|
514
|
+
if (idx < 132) return;
|
|
515
|
+
heap[idx] = heap_next;
|
|
516
|
+
heap_next = idx;
|
|
517
|
+
}
|
|
518
|
+
|
|
367
519
|
function getArrayU64FromWasm0(ptr, len) {
|
|
368
520
|
ptr = ptr >>> 0;
|
|
369
521
|
return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
370
522
|
}
|
|
371
523
|
|
|
524
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
525
|
+
ptr = ptr >>> 0;
|
|
526
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
527
|
+
}
|
|
528
|
+
|
|
372
529
|
let cachedBigUint64ArrayMemory0 = null;
|
|
373
530
|
function getBigUint64ArrayMemory0() {
|
|
374
531
|
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
@@ -398,6 +555,25 @@ function getUint8ArrayMemory0() {
|
|
|
398
555
|
return cachedUint8ArrayMemory0;
|
|
399
556
|
}
|
|
400
557
|
|
|
558
|
+
function getObject(idx) { return heap[idx]; }
|
|
559
|
+
|
|
560
|
+
function handleError(f, args) {
|
|
561
|
+
try {
|
|
562
|
+
return f.apply(this, args);
|
|
563
|
+
} catch (e) {
|
|
564
|
+
wasm.__wbindgen_export(addHeapObject(e));
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
let heap = new Array(128).fill(undefined);
|
|
569
|
+
heap.push(undefined, null, true, false);
|
|
570
|
+
|
|
571
|
+
let heap_next = heap.length;
|
|
572
|
+
|
|
573
|
+
function isLikeNone(x) {
|
|
574
|
+
return x === undefined || x === null;
|
|
575
|
+
}
|
|
576
|
+
|
|
401
577
|
function passArray64ToWasm0(arg, malloc) {
|
|
402
578
|
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
403
579
|
getBigUint64ArrayMemory0().set(arg, ptr / 8);
|
|
@@ -449,6 +625,12 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
449
625
|
return ptr;
|
|
450
626
|
}
|
|
451
627
|
|
|
628
|
+
function takeObject(idx) {
|
|
629
|
+
const ret = getObject(idx);
|
|
630
|
+
dropObject(idx);
|
|
631
|
+
return ret;
|
|
632
|
+
}
|
|
633
|
+
|
|
452
634
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
453
635
|
cachedTextDecoder.decode();
|
|
454
636
|
function decodeText(ptr, len) {
|
|
Binary file
|
|
@@ -4,6 +4,7 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
5
5
|
export const create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
|
6
6
|
export const derive_session_key: (a: number, b: number, c: number) => void;
|
|
7
|
+
export const generate_user_seed: (a: number) => void;
|
|
7
8
|
export const goldilocks_fields_to_hex: (a: number, b: number, c: number) => void;
|
|
8
9
|
export const goldilocks_reduce: (a: bigint) => bigint;
|
|
9
10
|
export const poseidon2_hash: (a: number, b: number, c: number) => void;
|
|
@@ -13,7 +14,8 @@ export const session_public_key: (a: number, b: number, c: number) => void;
|
|
|
13
14
|
export const string_to_user_seed: (a: number, b: number, c: number) => void;
|
|
14
15
|
export const string_to_user_seed_hex: (a: number, b: number, c: number) => void;
|
|
15
16
|
export const goldilocks_modulus: () => bigint;
|
|
17
|
+
export const __wbindgen_export: (a: number) => void;
|
|
16
18
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
19
|
+
export const __wbindgen_export2: (a: number, b: number) => number;
|
|
20
|
+
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
21
|
+
export const __wbindgen_export4: (a: number, b: number, c: number, d: number) => number;
|
|
@@ -59,6 +59,19 @@ export function create_bet_auth(session_key: BigUint64Array, bet_amount: bigint,
|
|
|
59
59
|
*/
|
|
60
60
|
export function derive_session_key(sig_bytes: Uint8Array): BigUint64Array;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Generate a random user seed — 10 alphanumeric characters.
|
|
64
|
+
*
|
|
65
|
+
* Uses `getrandom` (backed by `crypto.getRandomValues` in the browser
|
|
66
|
+
* and OS entropy on Node.js) for cryptographically secure randomness.
|
|
67
|
+
*
|
|
68
|
+
* ```js
|
|
69
|
+
* const seed = generate_user_seed();
|
|
70
|
+
* // e.g. "k7Qm2xW9aB"
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function generate_user_seed(): string;
|
|
74
|
+
|
|
62
75
|
/**
|
|
63
76
|
* Convert any Goldilocks field elements to a hex string.
|
|
64
77
|
*
|
|
@@ -167,6 +180,7 @@ export interface InitOutput {
|
|
|
167
180
|
readonly compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
168
181
|
readonly create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
|
169
182
|
readonly derive_session_key: (a: number, b: number, c: number) => void;
|
|
183
|
+
readonly generate_user_seed: (a: number) => void;
|
|
170
184
|
readonly goldilocks_fields_to_hex: (a: number, b: number, c: number) => void;
|
|
171
185
|
readonly goldilocks_reduce: (a: bigint) => bigint;
|
|
172
186
|
readonly poseidon2_hash: (a: number, b: number, c: number) => void;
|
|
@@ -176,10 +190,11 @@ export interface InitOutput {
|
|
|
176
190
|
readonly string_to_user_seed: (a: number, b: number, c: number) => void;
|
|
177
191
|
readonly string_to_user_seed_hex: (a: number, b: number, c: number) => void;
|
|
178
192
|
readonly goldilocks_modulus: () => bigint;
|
|
193
|
+
readonly __wbindgen_export: (a: number) => void;
|
|
179
194
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
180
|
-
readonly
|
|
181
|
-
readonly
|
|
182
|
-
readonly
|
|
195
|
+
readonly __wbindgen_export2: (a: number, b: number) => number;
|
|
196
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
197
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number, d: number) => number;
|
|
183
198
|
}
|
|
184
199
|
|
|
185
200
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
export function compute_server_seed_hash(server_seed) {
|
|
16
16
|
try {
|
|
17
17
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
18
|
-
const ptr0 = passArray64ToWasm0(server_seed, wasm.
|
|
18
|
+
const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export2);
|
|
19
19
|
const len0 = WASM_VECTOR_LEN;
|
|
20
20
|
wasm.compute_server_seed_hash(retptr, ptr0, len0);
|
|
21
21
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
22
22
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
23
23
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
24
|
-
wasm.
|
|
24
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
25
25
|
return v2;
|
|
26
26
|
} finally {
|
|
27
27
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -61,13 +61,13 @@ export function compute_server_seed_hash(server_seed) {
|
|
|
61
61
|
export function create_bet_auth(session_key, bet_amount, nonce) {
|
|
62
62
|
try {
|
|
63
63
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
64
|
-
const ptr0 = passArray64ToWasm0(session_key, wasm.
|
|
64
|
+
const ptr0 = passArray64ToWasm0(session_key, wasm.__wbindgen_export2);
|
|
65
65
|
const len0 = WASM_VECTOR_LEN;
|
|
66
66
|
wasm.create_bet_auth(retptr, ptr0, len0, bet_amount, nonce);
|
|
67
67
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
68
68
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
69
69
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
70
|
-
wasm.
|
|
70
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
71
71
|
return v2;
|
|
72
72
|
} finally {
|
|
73
73
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -95,19 +95,48 @@ export function create_bet_auth(session_key, bet_amount, nonce) {
|
|
|
95
95
|
export function derive_session_key(sig_bytes) {
|
|
96
96
|
try {
|
|
97
97
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
98
|
-
const ptr0 = passArray8ToWasm0(sig_bytes, wasm.
|
|
98
|
+
const ptr0 = passArray8ToWasm0(sig_bytes, wasm.__wbindgen_export2);
|
|
99
99
|
const len0 = WASM_VECTOR_LEN;
|
|
100
100
|
wasm.derive_session_key(retptr, ptr0, len0);
|
|
101
101
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
102
102
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
103
103
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
104
|
-
wasm.
|
|
104
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
105
105
|
return v2;
|
|
106
106
|
} finally {
|
|
107
107
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Generate a random user seed — 10 alphanumeric characters.
|
|
113
|
+
*
|
|
114
|
+
* Uses `getrandom` (backed by `crypto.getRandomValues` in the browser
|
|
115
|
+
* and OS entropy on Node.js) for cryptographically secure randomness.
|
|
116
|
+
*
|
|
117
|
+
* ```js
|
|
118
|
+
* const seed = generate_user_seed();
|
|
119
|
+
* // e.g. "k7Qm2xW9aB"
|
|
120
|
+
* ```
|
|
121
|
+
* @returns {string}
|
|
122
|
+
*/
|
|
123
|
+
export function generate_user_seed() {
|
|
124
|
+
let deferred1_0;
|
|
125
|
+
let deferred1_1;
|
|
126
|
+
try {
|
|
127
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
128
|
+
wasm.generate_user_seed(retptr);
|
|
129
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
130
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
131
|
+
deferred1_0 = r0;
|
|
132
|
+
deferred1_1 = r1;
|
|
133
|
+
return getStringFromWasm0(r0, r1);
|
|
134
|
+
} finally {
|
|
135
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
136
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
111
140
|
/**
|
|
112
141
|
* Convert any Goldilocks field elements to a hex string.
|
|
113
142
|
*
|
|
@@ -125,7 +154,7 @@ export function goldilocks_fields_to_hex(fields) {
|
|
|
125
154
|
let deferred2_1;
|
|
126
155
|
try {
|
|
127
156
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
128
|
-
const ptr0 = passArray64ToWasm0(fields, wasm.
|
|
157
|
+
const ptr0 = passArray64ToWasm0(fields, wasm.__wbindgen_export2);
|
|
129
158
|
const len0 = WASM_VECTOR_LEN;
|
|
130
159
|
wasm.goldilocks_fields_to_hex(retptr, ptr0, len0);
|
|
131
160
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
@@ -135,7 +164,7 @@ export function goldilocks_fields_to_hex(fields) {
|
|
|
135
164
|
return getStringFromWasm0(r0, r1);
|
|
136
165
|
} finally {
|
|
137
166
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
138
|
-
wasm.
|
|
167
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
139
168
|
}
|
|
140
169
|
}
|
|
141
170
|
|
|
@@ -180,13 +209,13 @@ export function goldilocks_reduce(value) {
|
|
|
180
209
|
export function poseidon2_hash(input) {
|
|
181
210
|
try {
|
|
182
211
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
183
|
-
const ptr0 = passArray64ToWasm0(input, wasm.
|
|
212
|
+
const ptr0 = passArray64ToWasm0(input, wasm.__wbindgen_export2);
|
|
184
213
|
const len0 = WASM_VECTOR_LEN;
|
|
185
214
|
wasm.poseidon2_hash(retptr, ptr0, len0);
|
|
186
215
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
187
216
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
188
217
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
189
|
-
wasm.
|
|
218
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
190
219
|
return v2;
|
|
191
220
|
} finally {
|
|
192
221
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -207,15 +236,15 @@ export function poseidon2_hash(input) {
|
|
|
207
236
|
export function poseidon2_two_to_one(left, right) {
|
|
208
237
|
try {
|
|
209
238
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
210
|
-
const ptr0 = passArray64ToWasm0(left, wasm.
|
|
239
|
+
const ptr0 = passArray64ToWasm0(left, wasm.__wbindgen_export2);
|
|
211
240
|
const len0 = WASM_VECTOR_LEN;
|
|
212
|
-
const ptr1 = passArray64ToWasm0(right, wasm.
|
|
241
|
+
const ptr1 = passArray64ToWasm0(right, wasm.__wbindgen_export2);
|
|
213
242
|
const len1 = WASM_VECTOR_LEN;
|
|
214
243
|
wasm.poseidon2_two_to_one(retptr, ptr0, len0, ptr1, len1);
|
|
215
244
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
216
245
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
217
246
|
var v3 = getArrayU64FromWasm0(r0, r1).slice();
|
|
218
|
-
wasm.
|
|
247
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
219
248
|
return v3;
|
|
220
249
|
} finally {
|
|
221
250
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -236,13 +265,13 @@ export function poseidon2_two_to_one(left, right) {
|
|
|
236
265
|
export function seed_hash_truncated(server_seed) {
|
|
237
266
|
try {
|
|
238
267
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
239
|
-
const ptr0 = passArray64ToWasm0(server_seed, wasm.
|
|
268
|
+
const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export2);
|
|
240
269
|
const len0 = WASM_VECTOR_LEN;
|
|
241
270
|
wasm.seed_hash_truncated(retptr, ptr0, len0);
|
|
242
271
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
243
272
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
244
273
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
245
|
-
wasm.
|
|
274
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
246
275
|
return v2;
|
|
247
276
|
} finally {
|
|
248
277
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -262,13 +291,13 @@ export function seed_hash_truncated(server_seed) {
|
|
|
262
291
|
export function session_public_key(session_key) {
|
|
263
292
|
try {
|
|
264
293
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
265
|
-
const ptr0 = passArray64ToWasm0(session_key, wasm.
|
|
294
|
+
const ptr0 = passArray64ToWasm0(session_key, wasm.__wbindgen_export2);
|
|
266
295
|
const len0 = WASM_VECTOR_LEN;
|
|
267
296
|
wasm.session_public_key(retptr, ptr0, len0);
|
|
268
297
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
269
298
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
270
299
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
271
|
-
wasm.
|
|
300
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
272
301
|
return v2;
|
|
273
302
|
} finally {
|
|
274
303
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -294,13 +323,13 @@ export function session_public_key(session_key) {
|
|
|
294
323
|
export function string_to_user_seed(input) {
|
|
295
324
|
try {
|
|
296
325
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
297
|
-
const ptr0 = passStringToWasm0(input, wasm.
|
|
326
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
298
327
|
const len0 = WASM_VECTOR_LEN;
|
|
299
328
|
wasm.string_to_user_seed(retptr, ptr0, len0);
|
|
300
329
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
301
330
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
302
331
|
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
303
|
-
wasm.
|
|
332
|
+
wasm.__wbindgen_export3(r0, r1 * 8, 8);
|
|
304
333
|
return v2;
|
|
305
334
|
} finally {
|
|
306
335
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -325,7 +354,7 @@ export function string_to_user_seed_hex(input) {
|
|
|
325
354
|
let deferred2_1;
|
|
326
355
|
try {
|
|
327
356
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
328
|
-
const ptr0 = passStringToWasm0(input, wasm.
|
|
357
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export4);
|
|
329
358
|
const len0 = WASM_VECTOR_LEN;
|
|
330
359
|
wasm.string_to_user_seed_hex(retptr, ptr0, len0);
|
|
331
360
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
@@ -335,16 +364,123 @@ export function string_to_user_seed_hex(input) {
|
|
|
335
364
|
return getStringFromWasm0(r0, r1);
|
|
336
365
|
} finally {
|
|
337
366
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
338
|
-
wasm.
|
|
367
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
339
368
|
}
|
|
340
369
|
}
|
|
341
370
|
|
|
342
371
|
function __wbg_get_imports() {
|
|
343
372
|
const import0 = {
|
|
344
373
|
__proto__: null,
|
|
374
|
+
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
375
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
376
|
+
return ret;
|
|
377
|
+
},
|
|
378
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
379
|
+
const val = getObject(arg0);
|
|
380
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
381
|
+
return ret;
|
|
382
|
+
},
|
|
383
|
+
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
|
|
384
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
385
|
+
return ret;
|
|
386
|
+
},
|
|
387
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
388
|
+
const ret = getObject(arg0) === undefined;
|
|
389
|
+
return ret;
|
|
390
|
+
},
|
|
345
391
|
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
346
392
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
347
393
|
},
|
|
394
|
+
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
|
|
395
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
396
|
+
return addHeapObject(ret);
|
|
397
|
+
}, arguments); },
|
|
398
|
+
__wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
|
|
399
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
400
|
+
return addHeapObject(ret);
|
|
401
|
+
}, arguments); },
|
|
402
|
+
__wbg_crypto_86f2631e91b51511: function(arg0) {
|
|
403
|
+
const ret = getObject(arg0).crypto;
|
|
404
|
+
return addHeapObject(ret);
|
|
405
|
+
},
|
|
406
|
+
__wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
|
|
407
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
408
|
+
}, arguments); },
|
|
409
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
410
|
+
const ret = getObject(arg0).length;
|
|
411
|
+
return ret;
|
|
412
|
+
},
|
|
413
|
+
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
414
|
+
const ret = getObject(arg0).msCrypto;
|
|
415
|
+
return addHeapObject(ret);
|
|
416
|
+
},
|
|
417
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
418
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
419
|
+
return addHeapObject(ret);
|
|
420
|
+
},
|
|
421
|
+
__wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
|
|
422
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
423
|
+
return addHeapObject(ret);
|
|
424
|
+
},
|
|
425
|
+
__wbg_node_e1f24f89a7336c2e: function(arg0) {
|
|
426
|
+
const ret = getObject(arg0).node;
|
|
427
|
+
return addHeapObject(ret);
|
|
428
|
+
},
|
|
429
|
+
__wbg_process_3975fd6c72f520aa: function(arg0) {
|
|
430
|
+
const ret = getObject(arg0).process;
|
|
431
|
+
return addHeapObject(ret);
|
|
432
|
+
},
|
|
433
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
434
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
435
|
+
},
|
|
436
|
+
__wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
|
|
437
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
438
|
+
}, arguments); },
|
|
439
|
+
__wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
|
|
440
|
+
const ret = module.require;
|
|
441
|
+
return addHeapObject(ret);
|
|
442
|
+
}, arguments); },
|
|
443
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
444
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
445
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
446
|
+
},
|
|
447
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
448
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
449
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
450
|
+
},
|
|
451
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
452
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
453
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
454
|
+
},
|
|
455
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
456
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
457
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
458
|
+
},
|
|
459
|
+
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
|
|
460
|
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
461
|
+
return addHeapObject(ret);
|
|
462
|
+
},
|
|
463
|
+
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
464
|
+
const ret = getObject(arg0).versions;
|
|
465
|
+
return addHeapObject(ret);
|
|
466
|
+
},
|
|
467
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
468
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
469
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
470
|
+
return addHeapObject(ret);
|
|
471
|
+
},
|
|
472
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
473
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
474
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
475
|
+
return addHeapObject(ret);
|
|
476
|
+
},
|
|
477
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
478
|
+
const ret = getObject(arg0);
|
|
479
|
+
return addHeapObject(ret);
|
|
480
|
+
},
|
|
481
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
482
|
+
takeObject(arg0);
|
|
483
|
+
},
|
|
348
484
|
};
|
|
349
485
|
return {
|
|
350
486
|
__proto__: null,
|
|
@@ -352,11 +488,31 @@ function __wbg_get_imports() {
|
|
|
352
488
|
};
|
|
353
489
|
}
|
|
354
490
|
|
|
491
|
+
function addHeapObject(obj) {
|
|
492
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
493
|
+
const idx = heap_next;
|
|
494
|
+
heap_next = heap[idx];
|
|
495
|
+
|
|
496
|
+
heap[idx] = obj;
|
|
497
|
+
return idx;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function dropObject(idx) {
|
|
501
|
+
if (idx < 132) return;
|
|
502
|
+
heap[idx] = heap_next;
|
|
503
|
+
heap_next = idx;
|
|
504
|
+
}
|
|
505
|
+
|
|
355
506
|
function getArrayU64FromWasm0(ptr, len) {
|
|
356
507
|
ptr = ptr >>> 0;
|
|
357
508
|
return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
358
509
|
}
|
|
359
510
|
|
|
511
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
512
|
+
ptr = ptr >>> 0;
|
|
513
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
514
|
+
}
|
|
515
|
+
|
|
360
516
|
let cachedBigUint64ArrayMemory0 = null;
|
|
361
517
|
function getBigUint64ArrayMemory0() {
|
|
362
518
|
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
@@ -386,6 +542,25 @@ function getUint8ArrayMemory0() {
|
|
|
386
542
|
return cachedUint8ArrayMemory0;
|
|
387
543
|
}
|
|
388
544
|
|
|
545
|
+
function getObject(idx) { return heap[idx]; }
|
|
546
|
+
|
|
547
|
+
function handleError(f, args) {
|
|
548
|
+
try {
|
|
549
|
+
return f.apply(this, args);
|
|
550
|
+
} catch (e) {
|
|
551
|
+
wasm.__wbindgen_export(addHeapObject(e));
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
let heap = new Array(128).fill(undefined);
|
|
556
|
+
heap.push(undefined, null, true, false);
|
|
557
|
+
|
|
558
|
+
let heap_next = heap.length;
|
|
559
|
+
|
|
560
|
+
function isLikeNone(x) {
|
|
561
|
+
return x === undefined || x === null;
|
|
562
|
+
}
|
|
563
|
+
|
|
389
564
|
function passArray64ToWasm0(arg, malloc) {
|
|
390
565
|
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
391
566
|
getBigUint64ArrayMemory0().set(arg, ptr / 8);
|
|
@@ -437,6 +612,12 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
437
612
|
return ptr;
|
|
438
613
|
}
|
|
439
614
|
|
|
615
|
+
function takeObject(idx) {
|
|
616
|
+
const ret = getObject(idx);
|
|
617
|
+
dropObject(idx);
|
|
618
|
+
return ret;
|
|
619
|
+
}
|
|
620
|
+
|
|
440
621
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
441
622
|
cachedTextDecoder.decode();
|
|
442
623
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
Binary file
|
|
@@ -4,6 +4,7 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
5
5
|
export const create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
|
6
6
|
export const derive_session_key: (a: number, b: number, c: number) => void;
|
|
7
|
+
export const generate_user_seed: (a: number) => void;
|
|
7
8
|
export const goldilocks_fields_to_hex: (a: number, b: number, c: number) => void;
|
|
8
9
|
export const goldilocks_reduce: (a: bigint) => bigint;
|
|
9
10
|
export const poseidon2_hash: (a: number, b: number, c: number) => void;
|
|
@@ -13,7 +14,8 @@ export const session_public_key: (a: number, b: number, c: number) => void;
|
|
|
13
14
|
export const string_to_user_seed: (a: number, b: number, c: number) => void;
|
|
14
15
|
export const string_to_user_seed_hex: (a: number, b: number, c: number) => void;
|
|
15
16
|
export const goldilocks_modulus: () => bigint;
|
|
17
|
+
export const __wbindgen_export: (a: number) => void;
|
|
16
18
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
19
|
+
export const __wbindgen_export2: (a: number, b: number) => number;
|
|
20
|
+
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
21
|
+
export const __wbindgen_export4: (a: number, b: number, c: number, d: number) => number;
|
package/js/browser.d.mts
CHANGED
package/js/browser.mjs
CHANGED
package/js/index.d.ts
CHANGED
package/js/node.cjs
CHANGED
|
@@ -12,6 +12,7 @@ module.exports = {
|
|
|
12
12
|
seed_hash_truncated: wasm.seed_hash_truncated,
|
|
13
13
|
string_to_user_seed: wasm.string_to_user_seed,
|
|
14
14
|
string_to_user_seed_hex: wasm.string_to_user_seed_hex,
|
|
15
|
+
generate_user_seed: wasm.generate_user_seed,
|
|
15
16
|
goldilocks_fields_to_hex: wasm.goldilocks_fields_to_hex,
|
|
16
17
|
goldilocks_modulus: wasm.goldilocks_modulus,
|
|
17
18
|
goldilocks_reduce: wasm.goldilocks_reduce,
|
package/js/node.mjs
CHANGED
package/js/react.d.mts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
export interface RollyWasmResult {
|
|
2
2
|
ready: boolean;
|
|
3
3
|
error: Error | null;
|
|
4
|
-
poseidon2_hash: (
|
|
5
|
-
poseidon2_two_to_one: (
|
|
6
|
-
derive_session_key: (
|
|
7
|
-
session_public_key: (
|
|
8
|
-
create_bet_auth: (
|
|
9
|
-
compute_server_seed_hash: (
|
|
10
|
-
seed_hash_truncated: (
|
|
11
|
-
string_to_user_seed: (
|
|
12
|
-
string_to_user_seed_hex: (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
poseidon2_hash: (input: BigUint64Array) => BigUint64Array;
|
|
5
|
+
poseidon2_two_to_one: (left: BigUint64Array, right: BigUint64Array) => BigUint64Array;
|
|
6
|
+
derive_session_key: (sig_bytes: Uint8Array) => BigUint64Array;
|
|
7
|
+
session_public_key: (session_key: BigUint64Array) => BigUint64Array;
|
|
8
|
+
create_bet_auth: (session_key: BigUint64Array, bet_amount: bigint, nonce: bigint) => BigUint64Array;
|
|
9
|
+
compute_server_seed_hash: (server_seed: BigUint64Array) => BigUint64Array;
|
|
10
|
+
seed_hash_truncated: (server_seed: BigUint64Array) => BigUint64Array;
|
|
11
|
+
string_to_user_seed: (input: string) => BigUint64Array;
|
|
12
|
+
string_to_user_seed_hex: (input: string) => string;
|
|
13
|
+
generate_user_seed: () => string;
|
|
14
|
+
goldilocks_fields_to_hex: (fields: BigUint64Array) => string;
|
|
15
|
+
goldilocks_modulus: () => bigint;
|
|
16
|
+
goldilocks_reduce: (value: bigint) => bigint;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export function useRollyWasm(): RollyWasmResult;
|
package/js/react.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import init, {
|
|
|
9
9
|
seed_hash_truncated,
|
|
10
10
|
string_to_user_seed,
|
|
11
11
|
string_to_user_seed_hex,
|
|
12
|
+
generate_user_seed,
|
|
12
13
|
goldilocks_fields_to_hex,
|
|
13
14
|
goldilocks_modulus,
|
|
14
15
|
goldilocks_reduce,
|
|
@@ -17,11 +18,34 @@ import init, {
|
|
|
17
18
|
let _ready = false;
|
|
18
19
|
let _promise = null;
|
|
19
20
|
|
|
21
|
+
function guard(fn) {
|
|
22
|
+
return (...args) => {
|
|
23
|
+
if (!_ready) throw new Error('@rolly-dev/wasm-signer: WASM not initialized yet. Check ready === true before calling.');
|
|
24
|
+
return fn(...args);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const fns = {
|
|
29
|
+
poseidon2_hash: guard(poseidon2_hash),
|
|
30
|
+
poseidon2_two_to_one: guard(poseidon2_two_to_one),
|
|
31
|
+
derive_session_key: guard(derive_session_key),
|
|
32
|
+
session_public_key: guard(session_public_key),
|
|
33
|
+
create_bet_auth: guard(create_bet_auth),
|
|
34
|
+
compute_server_seed_hash: guard(compute_server_seed_hash),
|
|
35
|
+
seed_hash_truncated: guard(seed_hash_truncated),
|
|
36
|
+
string_to_user_seed: guard(string_to_user_seed),
|
|
37
|
+
string_to_user_seed_hex: guard(string_to_user_seed_hex),
|
|
38
|
+
generate_user_seed: guard(generate_user_seed),
|
|
39
|
+
goldilocks_fields_to_hex: guard(goldilocks_fields_to_hex),
|
|
40
|
+
goldilocks_modulus: guard(goldilocks_modulus),
|
|
41
|
+
goldilocks_reduce: guard(goldilocks_reduce),
|
|
42
|
+
};
|
|
43
|
+
|
|
20
44
|
/**
|
|
21
45
|
* React hook that initialises the WASM module once (singleton) and
|
|
22
46
|
* returns `{ ready, error, ...wasmFunctions }`.
|
|
23
47
|
*
|
|
24
|
-
* Functions are
|
|
48
|
+
* Functions are always available but will throw if called before `ready === true`.
|
|
25
49
|
*
|
|
26
50
|
* ```jsx
|
|
27
51
|
* const { ready, poseidon2_hash } = useRollyWasm();
|
|
@@ -44,20 +68,5 @@ export function useRollyWasm() {
|
|
|
44
68
|
_promise.then(() => setReady(true)).catch(setError);
|
|
45
69
|
}, []);
|
|
46
70
|
|
|
47
|
-
return {
|
|
48
|
-
ready,
|
|
49
|
-
error,
|
|
50
|
-
poseidon2_hash: ready ? poseidon2_hash : null,
|
|
51
|
-
poseidon2_two_to_one: ready ? poseidon2_two_to_one : null,
|
|
52
|
-
derive_session_key: ready ? derive_session_key : null,
|
|
53
|
-
session_public_key: ready ? session_public_key : null,
|
|
54
|
-
create_bet_auth: ready ? create_bet_auth : null,
|
|
55
|
-
compute_server_seed_hash: ready ? compute_server_seed_hash : null,
|
|
56
|
-
seed_hash_truncated: ready ? seed_hash_truncated : null,
|
|
57
|
-
string_to_user_seed: ready ? string_to_user_seed : null,
|
|
58
|
-
string_to_user_seed_hex: ready ? string_to_user_seed_hex : null,
|
|
59
|
-
goldilocks_fields_to_hex: ready ? goldilocks_fields_to_hex : null,
|
|
60
|
-
goldilocks_modulus: ready ? goldilocks_modulus : null,
|
|
61
|
-
goldilocks_reduce: ready ? goldilocks_reduce : null,
|
|
62
|
-
};
|
|
71
|
+
return { ready, error, ...fns };
|
|
63
72
|
}
|