@rolly-dev/wasm-signer 1.31.0 → 1.31.2

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.
@@ -1,1909 +0,0 @@
1
- /* @ts-self-types="./rolly_wasm_signer.d.ts" */
2
-
3
- /**
4
- * Split a u64 amount into (lo, hi) u32 pair matching the circuit representation.
5
- *
6
- * Returns `[amount_lo, amount_hi]` as a `Uint32Array` of length 2.
7
- *
8
- * ```js
9
- * const [lo, hi] = amount_split(123456789n);
10
- * ```
11
- * @param {bigint} amount
12
- * @returns {Uint32Array}
13
- */
14
- export function amount_split(amount) {
15
- try {
16
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
17
- wasm.amount_split(retptr, amount);
18
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
19
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
20
- var v1 = getArrayU32FromWasm0(r0, r1).slice();
21
- wasm.__wbindgen_export4(r0, r1 * 4, 4);
22
- return v1;
23
- } finally {
24
- wasm.__wbindgen_add_to_stack_pointer(16);
25
- }
26
- }
27
-
28
- /**
29
- * Backward-compatible alias for `crash_rtp_percent`.
30
- * @returns {number}
31
- */
32
- export function aviato_rtp_percent() {
33
- const ret = wasm.aviato_rtp_percent();
34
- return ret >>> 0;
35
- }
36
-
37
- /**
38
- * Reconstruct the 30 dealt Blackjack rank codes from the fairness seeds.
39
- *
40
- * This is the SINGLE client/backend-side mirror of the native shoe unfold in
41
- * `tx_validator::blackjack::unfold_shoe` and the in-circuit shuffle: it computes
42
- * `mix = Poseidon2(server_seed ‖ user_secret_random)` and the per-step swap
43
- * randomness `low32(Poseidon2(mix ‖ k))`, then defers the deterministic
44
- * 30-swap partial Fisher–Yates over the fixed 416-card layout to the pure
45
- * `rolly_game_core::blackjack::deal_shoe`. Mixing the player-chosen
46
- * `user_secret_random` into the seed makes the shuffle a mutual commit–reveal,
47
- * so neither the operator nor the player can pre-grind a shoe.
48
- *
49
- * `server_seed` must be 8 elements (the full fairness preimage); `user_secret_random`
50
- * must be 4 elements (`string_to_user_seed(user_seed_source)`).
51
- *
52
- * **Output**: `Uint8Array` of length 30 — rank codes `0..=12` (Ace=0, 2..9=1..8,
53
- * 10/J/Q/K=9..12). Suits are cosmetic and restored off-engine.
54
- *
55
- * ```js
56
- * const shoe = blackjack_deal_shoe(serverSeed8, userSecret4); // length 30
57
- * ```
58
- * @param {BigUint64Array} server_seed
59
- * @param {BigUint64Array} user_secret_random
60
- * @returns {Uint8Array}
61
- */
62
- export function blackjack_deal_shoe(server_seed, user_secret_random) {
63
- try {
64
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
65
- const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export);
66
- const len0 = WASM_VECTOR_LEN;
67
- const ptr1 = passArray64ToWasm0(user_secret_random, wasm.__wbindgen_export);
68
- const len1 = WASM_VECTOR_LEN;
69
- wasm.blackjack_deal_shoe(retptr, ptr0, len0, ptr1, len1);
70
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
71
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
72
- var v3 = getArrayU8FromWasm0(r0, r1).slice();
73
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
74
- return v3;
75
- } finally {
76
- wasm.__wbindgen_add_to_stack_pointer(16);
77
- }
78
- }
79
-
80
- /**
81
- * Pack a Blackjack action sequence into the two base-8 halves the rollup records
82
- * as `prediction_lo` / `prediction_hi` (`actions[0..10]` → lo, `actions[10..20]`
83
- * → hi). Single-sources `rolly_game_core::blackjack::pack_actions` so the
84
- * backend feeds the WitnessEngine exactly what the circuit re-derives.
85
- *
86
- * `actions` are the `ACTION_*` codes (1..=6). **Output**: `Uint32Array` of
87
- * length 2 = `[prediction_lo, prediction_hi]`.
88
- * @param {Uint8Array} actions
89
- * @returns {Uint32Array}
90
- */
91
- export function blackjack_pack_actions(actions) {
92
- try {
93
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
94
- const ptr0 = passArray8ToWasm0(actions, wasm.__wbindgen_export);
95
- const len0 = WASM_VECTOR_LEN;
96
- wasm.blackjack_pack_actions(retptr, ptr0, len0);
97
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
98
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
99
- var v2 = getArrayU32FromWasm0(r0, r1).slice();
100
- wasm.__wbindgen_export4(r0, r1 * 4, 4);
101
- return v2;
102
- } finally {
103
- wasm.__wbindgen_add_to_stack_pointer(16);
104
- }
105
- }
106
-
107
- /**
108
- * CoinFlip multiplier × 10000 (19800 = 1.98×). Canonical source for backend/frontend.
109
- * @returns {number}
110
- */
111
- export function coinflip_multiplier_x10000() {
112
- const ret = wasm.coinflip_multiplier_x10000();
113
- return ret >>> 0;
114
- }
115
-
116
- /**
117
- * CoinFlip RTP percent (99). Canonical source for backend/frontend.
118
- * @returns {number}
119
- */
120
- export function coinflip_rtp_percent() {
121
- const ret = wasm.aviato_rtp_percent();
122
- return ret >>> 0;
123
- }
124
-
125
- /**
126
- * Compute address_hash = Poseidon2(addr_byte_0, ..., addr_byte_19).
127
- * Takes a hex address string (with or without 0x prefix), returns [u64; 4].
128
- * @param {string} address_hex
129
- * @returns {BigUint64Array}
130
- */
131
- export function compute_address_hash(address_hex) {
132
- try {
133
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
134
- const ptr0 = passStringToWasm0(address_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
135
- const len0 = WASM_VECTOR_LEN;
136
- wasm.compute_address_hash(retptr, ptr0, len0);
137
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
138
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
139
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
140
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
141
- return v2;
142
- } finally {
143
- wasm.__wbindgen_add_to_stack_pointer(16);
144
- }
145
- }
146
-
147
- /**
148
- * Backward-compatible alias for `compute_crash_point`.
149
- * @param {BigUint64Array} random
150
- * @returns {number}
151
- */
152
- export function compute_aviato_point(random) {
153
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
154
- const len0 = WASM_VECTOR_LEN;
155
- const ret = wasm.compute_aviato_point(ptr0, len0);
156
- return ret >>> 0;
157
- }
158
-
159
- /**
160
- * Extract crash point (×100) from raw server seed fields.
161
- *
162
- * `random` must be exactly 4 elements (first 4 fields of server_seed).
163
- * Returns the clamped crash multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
164
- * @param {BigUint64Array} random
165
- * @returns {number}
166
- */
167
- export function compute_crash_point(random) {
168
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
169
- const len0 = WASM_VECTOR_LEN;
170
- const ret = wasm.compute_crash_point(ptr0, len0);
171
- return ret >>> 0;
172
- }
173
-
174
- /**
175
- * Extract the 10 drawn numbers from Poseidon2 random output using
176
- * the combinatorial number system: `combo_index = random[0] % C(40,10)`.
177
- *
178
- * `random` must be exactly 4 elements.
179
- * Returns `Uint8Array` of length 10 (sorted ascending, each in [0, 39]).
180
- * @param {BigUint64Array} random
181
- * @returns {Uint8Array}
182
- */
183
- export function compute_drawn_keno(random) {
184
- try {
185
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
186
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
187
- const len0 = WASM_VECTOR_LEN;
188
- wasm.compute_drawn_keno(retptr, ptr0, len0);
189
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
190
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
191
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
192
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
193
- return v2;
194
- } finally {
195
- wasm.__wbindgen_add_to_stack_pointer(16);
196
- }
197
- }
198
-
199
- /**
200
- * Compute dice multiplier × 10000 from win_numbers count.
201
- *
202
- * Formula: `9_900_000 / win_numbers` (integer division = floor).
203
- * `win_numbers` must be in [1, 950].
204
- * @param {number} win_numbers
205
- * @returns {bigint}
206
- */
207
- export function compute_multi_dice(win_numbers) {
208
- const ret = wasm.compute_multi_dice(win_numbers);
209
- return BigInt.asUintN(64, ret);
210
- }
211
-
212
- /**
213
- * Backward-compatible alias for `compute_payout_crash`.
214
- * @param {BigUint64Array} random
215
- * @param {bigint} bet_atomic
216
- * @param {number} cashout_x100
217
- * @returns {BigUint64Array}
218
- */
219
- export function compute_payout_aviato(random, bet_atomic, cashout_x100) {
220
- try {
221
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
222
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
223
- const len0 = WASM_VECTOR_LEN;
224
- wasm.compute_payout_aviato(retptr, ptr0, len0, bet_atomic, cashout_x100);
225
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
226
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
227
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
228
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
229
- return v2;
230
- } finally {
231
- wasm.__wbindgen_add_to_stack_pointer(16);
232
- }
233
- }
234
-
235
- /**
236
- * Client-side provably-fair verification of a full Blackjack round.
237
- *
238
- * Reconstructs the fair shoe from `(server_seed ‖ user_secret_random)` (see
239
- * [`blackjack_deal_shoe`]), decodes the base-8 `prediction_lo` / `prediction_hi`
240
- * action halves, and replays the exact same state machine the circuit and the
241
- * tx-validator run (`rolly_game_core::blackjack::replay_full`). This lets a
242
- * player independently confirm the settled `win`/`bet` off-chain; it is NOT on
243
- * the tx/settlement path.
244
- *
245
- * `server_seed` must be 8 elements (the revealed fairness preimage);
246
- * `user_secret_random` must be 4 elements (`string_to_user_seed(...)`).
247
- * `base_bet` is the base stake in atomic units. The returned `total_staked`
248
- * grows with double/split/insurance exactly as the engine books them.
249
- *
250
- * **Output**: a JS object matching [`BlackjackVerifyResult`].
251
- *
252
- * Returns an error if the decoded action list contains an invalid code
253
- * (outside `1..=6`), mirroring the tx-validator's typed rejection.
254
- *
255
- * ```js
256
- * const res = compute_payout_blackjack(serverSeed8, userSecret4, lo, hi, betAtomic);
257
- * // res.win_amount, res.total_staked, res.shoe (length 30),
258
- * // res.first_cards / res.second_cards / res.dealer_cards (rank codes), ...
259
- * ```
260
- * @param {BigUint64Array} server_seed
261
- * @param {BigUint64Array} user_secret_random
262
- * @param {number} prediction_lo
263
- * @param {number} prediction_hi
264
- * @param {bigint} base_bet
265
- * @returns {any}
266
- */
267
- export function compute_payout_blackjack(server_seed, user_secret_random, prediction_lo, prediction_hi, base_bet) {
268
- try {
269
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
270
- const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export);
271
- const len0 = WASM_VECTOR_LEN;
272
- const ptr1 = passArray64ToWasm0(user_secret_random, wasm.__wbindgen_export);
273
- const len1 = WASM_VECTOR_LEN;
274
- wasm.compute_payout_blackjack(retptr, ptr0, len0, ptr1, len1, prediction_lo, prediction_hi, base_bet);
275
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
276
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
277
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
278
- if (r2) {
279
- throw takeObject(r1);
280
- }
281
- return takeObject(r0);
282
- } finally {
283
- wasm.__wbindgen_add_to_stack_pointer(16);
284
- }
285
- }
286
-
287
- /**
288
- * Full coinflip payout computation — pure integer arithmetic, zero floats.
289
- *
290
- * `random`: 4 Goldilocks field elements (Poseidon2 output).
291
- * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
292
- * `prediction`: 0 or 1.
293
- *
294
- * Returns `BigUint64Array[4]`: `[win_amount, roll (0|1), is_win (0|1), multiplier×10000]`.
295
- * @param {BigUint64Array} random
296
- * @param {bigint} bet_atomic
297
- * @param {number} prediction
298
- * @returns {BigUint64Array}
299
- */
300
- export function compute_payout_coinflip(random, bet_atomic, prediction) {
301
- try {
302
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
303
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
304
- const len0 = WASM_VECTOR_LEN;
305
- wasm.compute_payout_coinflip(retptr, ptr0, len0, bet_atomic, prediction);
306
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
307
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
308
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
309
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
310
- return v2;
311
- } finally {
312
- wasm.__wbindgen_add_to_stack_pointer(16);
313
- }
314
- }
315
-
316
- /**
317
- * Full crash payout computation — pure integer arithmetic, zero floats.
318
- *
319
- * `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
320
- * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
321
- * `cashout_x100`: multiplier at which the user cashed out (×100).
322
- * - 0 = user did NOT cash out (loss).
323
- * - 100..=1_000_000 = user stopped at this multiplier.
324
- *
325
- * Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
326
- * @param {BigUint64Array} random
327
- * @param {bigint} bet_atomic
328
- * @param {number} cashout_x100
329
- * @returns {BigUint64Array}
330
- */
331
- export function compute_payout_crash(random, bet_atomic, cashout_x100) {
332
- try {
333
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
334
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
335
- const len0 = WASM_VECTOR_LEN;
336
- wasm.compute_payout_crash(retptr, ptr0, len0, bet_atomic, cashout_x100);
337
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
338
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
339
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
340
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
341
- return v2;
342
- } finally {
343
- wasm.__wbindgen_add_to_stack_pointer(16);
344
- }
345
- }
346
-
347
- /**
348
- * Full dice payout computation — pure integer arithmetic, zero floats.
349
- *
350
- * `random`: 4 Goldilocks field elements (Poseidon2 output).
351
- * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
352
- * `game_mode`: 0=Under, 1=Over, 2=In, 3=Out.
353
- * `prediction_lo` / `prediction_hi`: prediction range bounds (0..999).
354
- *
355
- * Returns `BigUint64Array[4]`: `[win_amount, roll_number, is_win (0|1), multiplier×10000]`.
356
- * @param {BigUint64Array} random
357
- * @param {bigint} bet_atomic
358
- * @param {number} game_mode
359
- * @param {number} prediction_lo
360
- * @param {number} prediction_hi
361
- * @returns {BigUint64Array}
362
- */
363
- export function compute_payout_dice(random, bet_atomic, game_mode, prediction_lo, prediction_hi) {
364
- try {
365
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
366
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
367
- const len0 = WASM_VECTOR_LEN;
368
- wasm.compute_payout_dice(retptr, ptr0, len0, bet_atomic, game_mode, prediction_lo, prediction_hi);
369
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
370
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
371
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
372
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
373
- return v2;
374
- } finally {
375
- wasm.__wbindgen_add_to_stack_pointer(16);
376
- }
377
- }
378
-
379
- /**
380
- * Full keno payout computation — pure integer arithmetic, zero floats.
381
- *
382
- * `random`: 4 Goldilocks field elements (Poseidon2 output).
383
- * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
384
- * `risk`: 0=low, 1=medium, 2=high.
385
- * `selected`: player-chosen numbers (0-indexed, each in [0, 39]).
386
- *
387
- * Returns `BigUint64Array[4]`: `[win_amount, match_count, is_win (0|1), multiplier×10000]`.
388
- * @param {BigUint64Array} random
389
- * @param {bigint} bet_atomic
390
- * @param {number} risk
391
- * @param {Uint8Array} selected
392
- * @returns {BigUint64Array}
393
- */
394
- export function compute_payout_keno(random, bet_atomic, risk, selected) {
395
- try {
396
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
397
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
398
- const len0 = WASM_VECTOR_LEN;
399
- const ptr1 = passArray8ToWasm0(selected, wasm.__wbindgen_export);
400
- const len1 = WASM_VECTOR_LEN;
401
- wasm.compute_payout_keno(retptr, ptr0, len0, bet_atomic, risk, ptr1, len1);
402
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
403
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
404
- var v3 = getArrayU64FromWasm0(r0, r1).slice();
405
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
406
- return v3;
407
- } finally {
408
- wasm.__wbindgen_add_to_stack_pointer(16);
409
- }
410
- }
411
-
412
- /**
413
- * Full limbo payout computation — pure integer arithmetic, zero floats.
414
- *
415
- * `random`: 4 Goldilocks field elements (Poseidon2 output).
416
- * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
417
- * `prediction_x100`: target multiplier x 100 (101..999999, i.e. 1.01x-9999.99x).
418
- *
419
- * Returns `BigUint64Array[4]`: `[win_amount, multiplier_x100, is_win (0|1), payout_multiplier x10000]`.
420
- * @param {BigUint64Array} random
421
- * @param {bigint} bet_atomic
422
- * @param {number} prediction_x100
423
- * @returns {BigUint64Array}
424
- */
425
- export function compute_payout_limbo(random, bet_atomic, prediction_x100) {
426
- try {
427
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
428
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
429
- const len0 = WASM_VECTOR_LEN;
430
- wasm.compute_payout_limbo(retptr, ptr0, len0, bet_atomic, prediction_x100);
431
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
432
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
433
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
434
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
435
- return v2;
436
- } finally {
437
- wasm.__wbindgen_add_to_stack_pointer(16);
438
- }
439
- }
440
-
441
- /**
442
- * Full plinko payout computation — pure integer arithmetic, zero floats.
443
- *
444
- * `random`: 4 Goldilocks field elements (Poseidon2 output).
445
- * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
446
- * `sector`: risk profile (0=low, 1=medium, 2=high).
447
- * `rows`: number of pin rows (8..16).
448
- * `is_extreme`: whether extreme mode is active.
449
- *
450
- * Returns `BigUint64Array[4]`: `[win_amount, bucket_index, is_win (0|1), multiplier×10000]`.
451
- * @param {BigUint64Array} random
452
- * @param {bigint} bet_atomic
453
- * @param {number} sector
454
- * @param {number} rows
455
- * @param {boolean} is_extreme
456
- * @returns {BigUint64Array}
457
- */
458
- export function compute_payout_plinko(random, bet_atomic, sector, rows, is_extreme) {
459
- try {
460
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
461
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
462
- const len0 = WASM_VECTOR_LEN;
463
- wasm.compute_payout_plinko(retptr, ptr0, len0, bet_atomic, sector, rows, is_extreme);
464
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
465
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
466
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
467
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
468
- return v2;
469
- } finally {
470
- wasm.__wbindgen_add_to_stack_pointer(16);
471
- }
472
- }
473
-
474
- /**
475
- * Compute prediction hash: `Poseidon2(game_id, p0, p1, p2)` → 4 field elements.
476
- *
477
- * Matches `compute_prediction_hash_native` in the circuit (`games/shared.rs`)
478
- * and the in-circuit `build_prediction_hash`.
479
- *
480
- * Semantics of p0–p2 depend on the game:
481
- * Limbo: `(98, prediction_x100, 0)` — RTP hardcoded at 98
482
- * Dice: `(mode, pred_lo, pred_hi)`
483
- * Plinko: `(sector, rows, is_extreme)`
484
- * CoinFlip: `(prediction, 0, 0)`
485
- * @param {number} game_id
486
- * @param {number} p0
487
- * @param {number} p1
488
- * @param {number} p2
489
- * @returns {BigUint64Array}
490
- */
491
- export function compute_prediction_hash(game_id, p0, p1, p2) {
492
- try {
493
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
494
- wasm.compute_prediction_hash(retptr, game_id, p0, p1, p2);
495
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
496
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
497
- var v1 = getArrayU64FromWasm0(r0, r1).slice();
498
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
499
- return v1;
500
- } finally {
501
- wasm.__wbindgen_add_to_stack_pointer(16);
502
- }
503
- }
504
-
505
- /**
506
- * Compute Keno prediction hash with extended 13-input format:
507
- * `Poseidon2(game_id, risk, pick_count, selected[0], …, selected[9])`.
508
- *
509
- * Selected numbers are sorted internally for deterministic output.
510
- * Unused slots (when pick_count < 10) are filled with 0.
511
- *
512
- * Returns `BigUint64Array` of length 4 (one `HashOut`).
513
- * @param {number} game_id
514
- * @param {number} risk
515
- * @param {number} pick_count
516
- * @param {Uint8Array} selected
517
- * @returns {BigUint64Array}
518
- */
519
- export function compute_prediction_hash_keno(game_id, risk, pick_count, selected) {
520
- try {
521
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
522
- const ptr0 = passArray8ToWasm0(selected, wasm.__wbindgen_export);
523
- const len0 = WASM_VECTOR_LEN;
524
- wasm.compute_prediction_hash_keno(retptr, game_id, risk, pick_count, ptr0, len0);
525
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
526
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
527
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
528
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
529
- return v2;
530
- } finally {
531
- wasm.__wbindgen_add_to_stack_pointer(16);
532
- }
533
- }
534
-
535
- /**
536
- * Extract coinflip roll (0 or 1) from Poseidon2 random output.
537
- *
538
- * `random` must be exactly 4 elements. Returns `random[0] % 2`.
539
- * @param {BigUint64Array} random
540
- * @returns {number}
541
- */
542
- export function compute_roll_coinflip(random) {
543
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
544
- const len0 = WASM_VECTOR_LEN;
545
- const ret = wasm.compute_roll_coinflip(ptr0, len0);
546
- return ret >>> 0;
547
- }
548
-
549
- /**
550
- * Extract dice roll number [0, 1000) from Poseidon2 random output.
551
- *
552
- * `random` must be exactly 4 elements. Returns `random[0] % 1000`.
553
- * @param {BigUint64Array} random
554
- * @returns {number}
555
- */
556
- export function compute_roll_dice(random) {
557
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
558
- const len0 = WASM_VECTOR_LEN;
559
- const ret = wasm.compute_roll_dice(ptr0, len0);
560
- return ret >>> 0;
561
- }
562
-
563
- /**
564
- * Extract limbo result multiplier x 100 from Poseidon2 random output.
565
- *
566
- * `random` must be exactly 4 elements.
567
- * Returns the clamped multiplier x 100 (101..999999).
568
- * @param {BigUint64Array} random
569
- * @returns {number}
570
- */
571
- export function compute_roll_limbo(random) {
572
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
573
- const len0 = WASM_VECTOR_LEN;
574
- const ret = wasm.compute_roll_limbo(ptr0, len0);
575
- return ret >>> 0;
576
- }
577
-
578
- /**
579
- * Extract plinko bucket index from Poseidon2 random output.
580
- *
581
- * `random` must be exactly 4 elements.
582
- * `rows` must be in [8, 16].
583
- * Returns the bucket index (0..=rows) = popcount of first `rows` bits of random[0].
584
- * @param {BigUint64Array} random
585
- * @param {number} rows
586
- * @returns {number}
587
- */
588
- export function compute_roll_plinko(random, rows) {
589
- const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
590
- const len0 = WASM_VECTOR_LEN;
591
- const ret = wasm.compute_roll_plinko(ptr0, len0, rows);
592
- return ret >>> 0;
593
- }
594
-
595
- /**
596
- * Full Poseidon2 hash of an 8-element server seed.
597
- *
598
- * Returns all 4 hash elements. Note: the circuit stores only the
599
- * **first 3 elements** as the leaf commitment (see `seed_hash_truncated`).
600
- * This full variant is useful for client-side verification where all
601
- * 4 elements may be needed.
602
- *
603
- * `server_seed` must be exactly 8 elements.
604
- * @param {BigUint64Array} server_seed
605
- * @returns {BigUint64Array}
606
- */
607
- export function compute_server_seed_hash(server_seed) {
608
- try {
609
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
610
- const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export);
611
- const len0 = WASM_VECTOR_LEN;
612
- wasm.compute_server_seed_hash(retptr, ptr0, len0);
613
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
614
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
615
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
616
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
617
- return v2;
618
- } finally {
619
- wasm.__wbindgen_add_to_stack_pointer(16);
620
- }
621
- }
622
-
623
- /**
624
- * Compute user seed with bet-parameter binding:
625
- * `Poseidon2(game_id, bet, pred_hash[4], secret[4])` → 4 field elements.
626
- *
627
- * Matches the circuit constraint in `slot/fairness.rs`.
628
- * Prevents the operator from swapping bet parameters after the user commits.
629
- *
630
- * `bet` is the full bet amount in atomic units (u64).
631
- * `pred_hash` must be 4 elements (output of `compute_prediction_hash`).
632
- * `secret` must be 4 elements (output of `generate_user_secret`).
633
- * @param {number} game_id
634
- * @param {bigint} bet
635
- * @param {BigUint64Array} pred_hash
636
- * @param {BigUint64Array} secret
637
- * @returns {BigUint64Array}
638
- */
639
- export function compute_user_seed_binding(game_id, bet, pred_hash, secret) {
640
- try {
641
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
642
- const ptr0 = passArray64ToWasm0(pred_hash, wasm.__wbindgen_export);
643
- const len0 = WASM_VECTOR_LEN;
644
- const ptr1 = passArray64ToWasm0(secret, wasm.__wbindgen_export);
645
- const len1 = WASM_VECTOR_LEN;
646
- wasm.compute_user_seed_binding(retptr, game_id, bet, ptr0, len0, ptr1, len1);
647
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
648
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
649
- var v3 = getArrayU64FromWasm0(r0, r1).slice();
650
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
651
- return v3;
652
- } finally {
653
- wasm.__wbindgen_add_to_stack_pointer(16);
654
- }
655
- }
656
-
657
- /**
658
- * Crash RTP percent (99). Canonical source for backend/frontend.
659
- * @returns {number}
660
- */
661
- export function crash_rtp_percent() {
662
- const ret = wasm.aviato_rtp_percent();
663
- return ret >>> 0;
664
- }
665
-
666
- /**
667
- * Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
668
- *
669
- * **Algorithm**: split 32 bytes into 4 × 8 bytes, interpret each chunk as
670
- * little-endian u64, reduce mod p, then hash:
671
- * `session_key = Poseidon2(reduced_chunks)`
672
- *
673
- * The reduction via `from_noncanonical_u64` is necessary because raw
674
- * signature bytes can produce values >= p.
675
- *
676
- * ```js
677
- * const sig = ethers.getBytes(metaMaskSignature).slice(0, 32);
678
- * const sk = derive_session_key(new Uint8Array(sig));
679
- * // sk.length === 4
680
- * ```
681
- * @param {Uint8Array} sig_bytes
682
- * @returns {BigUint64Array}
683
- */
684
- export function derive_session_key(sig_bytes) {
685
- try {
686
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
687
- const ptr0 = passArray8ToWasm0(sig_bytes, wasm.__wbindgen_export);
688
- const len0 = WASM_VECTOR_LEN;
689
- wasm.derive_session_key(retptr, ptr0, len0);
690
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
691
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
692
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
693
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
694
- return v2;
695
- } finally {
696
- wasm.__wbindgen_add_to_stack_pointer(16);
697
- }
698
- }
699
-
700
- /**
701
- * Dice RTP percent (99). Canonical source for backend/frontend.
702
- * @returns {number}
703
- */
704
- export function dice_rtp_percent() {
705
- const ret = wasm.aviato_rtp_percent();
706
- return ret >>> 0;
707
- }
708
-
709
- /**
710
- * Encode 1-indexed Keno selected numbers into a bitmask pair `[lo, hi]`.
711
- *
712
- * `selected_1indexed`: player-chosen numbers as they come from the frontend (1..40).
713
- * Returns `Uint32Array[2]`: `[lo, hi]` where `lo` covers numbers 0..29 and `hi` covers 30..39
714
- * (0-indexed bit positions).
715
- * @param {Uint8Array} selected_1indexed
716
- * @returns {Uint32Array}
717
- */
718
- export function encode_keno_selected(selected_1indexed) {
719
- try {
720
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
721
- const ptr0 = passArray8ToWasm0(selected_1indexed, wasm.__wbindgen_export);
722
- const len0 = WASM_VECTOR_LEN;
723
- wasm.encode_keno_selected(retptr, ptr0, len0);
724
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
725
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
726
- var v2 = getArrayU32FromWasm0(r0, r1).slice();
727
- wasm.__wbindgen_export4(r0, r1 * 4, 4);
728
- return v2;
729
- } finally {
730
- wasm.__wbindgen_add_to_stack_pointer(16);
731
- }
732
- }
733
-
734
- /**
735
- * Generate a cryptographically random user secret — 4 Goldilocks field elements.
736
- *
737
- * Each element is reduced mod p for canonical representation (safe for circuit use).
738
- * Uses `getrandom` (`crypto.getRandomValues` in browser, OS entropy in Node.js).
739
- *
740
- * ```js
741
- * const secret = generate_user_secret();
742
- * // secret.length === 4, each < GOLDILOCKS_P
743
- * ```
744
- * @returns {BigUint64Array}
745
- */
746
- export function generate_user_secret() {
747
- try {
748
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
749
- wasm.generate_user_secret(retptr);
750
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
751
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
752
- var v1 = getArrayU64FromWasm0(r0, r1).slice();
753
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
754
- return v1;
755
- } finally {
756
- wasm.__wbindgen_add_to_stack_pointer(16);
757
- }
758
- }
759
-
760
- /**
761
- * Generate a random user seed — 10 alphanumeric characters.
762
- *
763
- * Uses `getrandom` (backed by `crypto.getRandomValues` in the browser
764
- * and OS entropy on Node.js) for cryptographically secure randomness.
765
- *
766
- * ```js
767
- * const seed = generate_user_seed();
768
- * // e.g. "k7Qm2xW9aB"
769
- * ```
770
- * @returns {string}
771
- */
772
- export function generate_user_seed() {
773
- let deferred1_0;
774
- let deferred1_1;
775
- try {
776
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
777
- wasm.generate_user_seed(retptr);
778
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
779
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
780
- deferred1_0 = r0;
781
- deferred1_1 = r1;
782
- return getStringFromWasm0(r0, r1);
783
- } finally {
784
- wasm.__wbindgen_add_to_stack_pointer(16);
785
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
786
- }
787
- }
788
-
789
- /**
790
- * Convert any Goldilocks field elements to a hex string.
791
- *
792
- * Each u64 is encoded as 8 little-endian bytes → 16 hex chars.
793
- * For 4 elements: 64 hex chars (32 bytes).
794
- *
795
- * ```js
796
- * const hex = goldilocks_fields_to_hex(BigUint64Array.from([1n, 2n, 3n, 4n]));
797
- * ```
798
- * @param {BigUint64Array} fields
799
- * @returns {string}
800
- */
801
- export function goldilocks_fields_to_hex(fields) {
802
- let deferred2_0;
803
- let deferred2_1;
804
- try {
805
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
806
- const ptr0 = passArray64ToWasm0(fields, wasm.__wbindgen_export);
807
- const len0 = WASM_VECTOR_LEN;
808
- wasm.goldilocks_fields_to_hex(retptr, ptr0, len0);
809
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
810
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
811
- deferred2_0 = r0;
812
- deferred2_1 = r1;
813
- return getStringFromWasm0(r0, r1);
814
- } finally {
815
- wasm.__wbindgen_add_to_stack_pointer(16);
816
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
817
- }
818
- }
819
-
820
- /**
821
- * Returns the Goldilocks prime: p = 2^64 - 2^32 + 1.
822
- * @returns {bigint}
823
- */
824
- export function goldilocks_modulus() {
825
- const ret = wasm.goldilocks_modulus();
826
- return BigInt.asUintN(64, ret);
827
- }
828
-
829
- /**
830
- * Reduce an arbitrary u64 to its canonical representative mod p.
831
- *
832
- * Values already < p are returned unchanged. Values >= p are reduced.
833
- * This uses `from_noncanonical_u64` internally (no panic on large values).
834
- * @param {bigint} value
835
- * @returns {bigint}
836
- */
837
- export function goldilocks_reduce(value) {
838
- const ret = wasm.goldilocks_reduce(value);
839
- return BigInt.asUintN(64, ret);
840
- }
841
-
842
- /**
843
- * Hash a raw 7-element balance leaf → 4-element Merkle node.
844
- *
845
- * Raw layout: `[balance_lo, balance_hi, seed_hash_0, seed_hash_1, seed_hash_2, credit_lo, credit_hi]`
846
- *
847
- * Identical to `hash_balance_leaf` in `prover/circuit/src/helpers/leaf_ops.rs`.
848
- *
849
- * **Input** : `BigUint64Array` of exactly 7 elements (each < `GOLDILOCKS_P`).
850
- * **Output**: `BigUint64Array` of length 4 (one `HashOut`).
851
- *
852
- * ```js
853
- * const raw = BigUint64Array.from([balLo, balHi, seed0, seed1, seed2, credLo, credHi]);
854
- * const balanceHash = hash_balance_leaf(raw); // length 4
855
- * ```
856
- * @param {BigUint64Array} raw
857
- * @returns {BigUint64Array}
858
- */
859
- export function hash_balance_leaf(raw) {
860
- try {
861
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
862
- const ptr0 = passArray64ToWasm0(raw, wasm.__wbindgen_export);
863
- const len0 = WASM_VECTOR_LEN;
864
- wasm.hash_balance_leaf(retptr, ptr0, len0);
865
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
866
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
867
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
868
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
869
- return v2;
870
- } finally {
871
- wasm.__wbindgen_add_to_stack_pointer(16);
872
- }
873
- }
874
-
875
- /**
876
- * RTP × 100 for ALL valid Keno configs.
877
- * Returns JS object: `{ "0_1": 9450, "0_2": 9712, ..., "2_10": 9580 }`
878
- * Keys: `"{risk}_{pick_count}"`.
879
- * @returns {any}
880
- */
881
- export function keno_all_rtp_x100() {
882
- const ret = wasm.keno_all_rtp_x100();
883
- return takeObject(ret);
884
- }
885
-
886
- /**
887
- * @returns {number}
888
- */
889
- export function keno_draw_count() {
890
- const ret = wasm.keno_draw_count();
891
- return ret >>> 0;
892
- }
893
-
894
- /**
895
- * Whether a (risk, pick_count) pair is a valid Keno config.
896
- * @param {number} risk
897
- * @param {number} pick_count
898
- * @returns {boolean}
899
- */
900
- export function keno_is_valid_config(risk, pick_count) {
901
- const ret = wasm.keno_is_valid_config(risk, pick_count);
902
- return ret !== 0;
903
- }
904
-
905
- /**
906
- * @returns {number}
907
- */
908
- export function keno_max_picks() {
909
- const ret = wasm.keno_draw_count();
910
- return ret >>> 0;
911
- }
912
-
913
- /**
914
- * Returns the multiplier table (×10000) for the given Keno config.
915
- * `risk`: 0=low, 1=medium, 2=high. `pick_count`: 1..10.
916
- * Length = pick_count + 1. Returns empty vec for invalid combos.
917
- * @param {number} risk
918
- * @param {number} pick_count
919
- * @returns {BigUint64Array}
920
- */
921
- export function keno_multiplier_table(risk, pick_count) {
922
- try {
923
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
924
- wasm.keno_multiplier_table(retptr, risk, pick_count);
925
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
926
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
927
- var v1 = getArrayU64FromWasm0(r0, r1).slice();
928
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
929
- return v1;
930
- } finally {
931
- wasm.__wbindgen_add_to_stack_pointer(16);
932
- }
933
- }
934
-
935
- /**
936
- * @returns {number}
937
- */
938
- export function keno_numbers_range() {
939
- const ret = wasm.keno_numbers_range();
940
- return ret >>> 0;
941
- }
942
-
943
- /**
944
- * RTP × 100 for a Keno config (e.g. 9800 = 98.00%). Returns 0 for invalid combos.
945
- * @param {number} risk
946
- * @param {number} pick_count
947
- * @returns {bigint}
948
- */
949
- export function keno_rtp_x100(risk, pick_count) {
950
- const ret = wasm.keno_rtp_x100(risk, pick_count);
951
- return BigInt.asUintN(64, ret);
952
- }
953
-
954
- /**
955
- * Limbo RTP percent (98). Canonical source for backend/frontend.
956
- * @returns {number}
957
- */
958
- export function limbo_rtp_percent() {
959
- const ret = wasm.limbo_rtp_percent();
960
- return ret >>> 0;
961
- }
962
-
963
- /**
964
- * Build a main Merkle tree leaf from balance_hash, pk_hash, and address_hash.
965
- *
966
- * `main_leaf = Poseidon2(balance_hash[4] || pk_hash[0..2] || address_hash[0..2])`
967
- *
968
- * Uses truncated (128-bit) pk/address hashes to keep the preimage at 8 elements
969
- * (single Poseidon2 permutation round). Identical to `make_main_leaf` in
970
- * `prover/circuit/src/helpers/leaf_ops.rs`.
971
- *
972
- * All three inputs must be exactly 4 elements.
973
- * **Output**: `BigUint64Array` of length 4 (the Merkle leaf hash).
974
- *
975
- * ```js
976
- * const leaf = make_main_leaf(balanceHash, pkHash, addressHash);
977
- * ```
978
- * @param {BigUint64Array} balance_hash
979
- * @param {BigUint64Array} pk_hash
980
- * @param {BigUint64Array} address_hash
981
- * @returns {BigUint64Array}
982
- */
983
- export function make_main_leaf(balance_hash, pk_hash, address_hash) {
984
- try {
985
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
986
- const ptr0 = passArray64ToWasm0(balance_hash, wasm.__wbindgen_export);
987
- const len0 = WASM_VECTOR_LEN;
988
- const ptr1 = passArray64ToWasm0(pk_hash, wasm.__wbindgen_export);
989
- const len1 = WASM_VECTOR_LEN;
990
- const ptr2 = passArray64ToWasm0(address_hash, wasm.__wbindgen_export);
991
- const len2 = WASM_VECTOR_LEN;
992
- wasm.make_main_leaf(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
993
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
994
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
995
- var v4 = getArrayU64FromWasm0(r0, r1).slice();
996
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
997
- return v4;
998
- } finally {
999
- wasm.__wbindgen_add_to_stack_pointer(16);
1000
- }
1001
- }
1002
-
1003
- /**
1004
- * RTP × 100 for ALL valid Plinko configs.
1005
- * Returns JS object: `{ "0_8_normal": 9799, "1_12_extreme": 9881, ... }`
1006
- * @returns {any}
1007
- */
1008
- export function plinko_all_rtp_x100() {
1009
- const ret = wasm.plinko_all_rtp_x100();
1010
- return takeObject(ret);
1011
- }
1012
-
1013
- /**
1014
- * Whether a (sector, rows, is_extreme) triple is a valid Plinko config.
1015
- * @param {number} sector
1016
- * @param {number} rows
1017
- * @param {boolean} is_extreme
1018
- * @returns {boolean}
1019
- */
1020
- export function plinko_is_valid_config(sector, rows, is_extreme) {
1021
- const ret = wasm.plinko_is_valid_config(sector, rows, is_extreme);
1022
- return ret !== 0;
1023
- }
1024
-
1025
- /**
1026
- * Whether rows is within the valid Plinko range [8, 16].
1027
- * @param {number} rows
1028
- * @returns {boolean}
1029
- */
1030
- export function plinko_is_valid_rows(rows) {
1031
- const ret = wasm.plinko_is_valid_rows(rows);
1032
- return ret !== 0;
1033
- }
1034
-
1035
- /**
1036
- * @returns {number}
1037
- */
1038
- export function plinko_max_rows() {
1039
- const ret = wasm.plinko_max_rows();
1040
- return ret >>> 0;
1041
- }
1042
-
1043
- /**
1044
- * @returns {number}
1045
- */
1046
- export function plinko_min_rows() {
1047
- const ret = wasm.plinko_min_rows();
1048
- return ret >>> 0;
1049
- }
1050
-
1051
- /**
1052
- * Returns the multiplier table (×10000) for the given Plinko config.
1053
- * Length = rows + 1. Returns empty vec for invalid combos.
1054
- * @param {number} sector
1055
- * @param {number} rows
1056
- * @param {boolean} is_extreme
1057
- * @returns {BigUint64Array}
1058
- */
1059
- export function plinko_multiplier_table(sector, rows, is_extreme) {
1060
- try {
1061
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1062
- wasm.plinko_multiplier_table(retptr, sector, rows, is_extreme);
1063
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1064
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1065
- var v1 = getArrayU64FromWasm0(r0, r1).slice();
1066
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
1067
- return v1;
1068
- } finally {
1069
- wasm.__wbindgen_add_to_stack_pointer(16);
1070
- }
1071
- }
1072
-
1073
- /**
1074
- * @returns {number}
1075
- */
1076
- export function plinko_num_sectors() {
1077
- const ret = wasm.plinko_num_sectors();
1078
- return ret;
1079
- }
1080
-
1081
- /**
1082
- * RTP × 100 for a Plinko config (e.g. 9799 = 97.99%). Returns 0 for invalid combos.
1083
- * @param {number} sector
1084
- * @param {number} rows
1085
- * @param {boolean} is_extreme
1086
- * @returns {bigint}
1087
- */
1088
- export function plinko_rtp_x100(sector, rows, is_extreme) {
1089
- const ret = wasm.plinko_rtp_x100(sector, rows, is_extreme);
1090
- return BigInt.asUintN(64, ret);
1091
- }
1092
-
1093
- /**
1094
- * Poseidon2 hash of an arbitrary number of Goldilocks field elements.
1095
- *
1096
- * Mirrors `builder.hash_n_to_hash_no_pad::<Poseidon2Hash>(...)` inside
1097
- * the circuit and `Poseidon2Hash::hash_no_pad` in `src/block_builder`.
1098
- *
1099
- * **Input** : `BigUint64Array` — each element must be < `GOLDILOCKS_P`.
1100
- * **Output**: `BigUint64Array` of length 4 (one `HashOut`).
1101
- *
1102
- * ```js
1103
- * const h = poseidon2_hash(BigUint64Array.from([1n, 2n, 3n]));
1104
- * // h.length === 4
1105
- * ```
1106
- * @param {BigUint64Array} input
1107
- * @returns {BigUint64Array}
1108
- */
1109
- export function poseidon2_hash(input) {
1110
- try {
1111
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1112
- const ptr0 = passArray64ToWasm0(input, wasm.__wbindgen_export);
1113
- const len0 = WASM_VECTOR_LEN;
1114
- wasm.poseidon2_hash(retptr, ptr0, len0);
1115
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1116
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1117
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
1118
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
1119
- return v2;
1120
- } finally {
1121
- wasm.__wbindgen_add_to_stack_pointer(16);
1122
- }
1123
- }
1124
-
1125
- /**
1126
- * Merkle-tree hash: Poseidon2(left[4] ‖ right[4]).
1127
- *
1128
- * Identical to `poseidon_hash(left, right)` in `src/merkletree/hash.rs`.
1129
- * Input ordering is critical — `left` concatenated before `right`.
1130
- *
1131
- * Both arrays **must** have exactly 4 elements (one `HashOut` each).
1132
- * @param {BigUint64Array} left
1133
- * @param {BigUint64Array} right
1134
- * @returns {BigUint64Array}
1135
- */
1136
- export function poseidon2_two_to_one(left, right) {
1137
- try {
1138
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1139
- const ptr0 = passArray64ToWasm0(left, wasm.__wbindgen_export);
1140
- const len0 = WASM_VECTOR_LEN;
1141
- const ptr1 = passArray64ToWasm0(right, wasm.__wbindgen_export);
1142
- const len1 = WASM_VECTOR_LEN;
1143
- wasm.poseidon2_two_to_one(retptr, ptr0, len0, ptr1, len1);
1144
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1145
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1146
- var v3 = getArrayU64FromWasm0(r0, r1).slice();
1147
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
1148
- return v3;
1149
- } finally {
1150
- wasm.__wbindgen_add_to_stack_pointer(16);
1151
- }
1152
- }
1153
-
1154
- /**
1155
- * Truncated seed hash — first 3 elements of `Poseidon2(server_seed)`.
1156
- *
1157
- * 192 bits of commitment → ~96-bit collision resistance, which closes the
1158
- * multi-preimage grinding vector that an earlier 128-bit truncation left open.
1159
- * This is the exact format stored in the Merkle-tree leaf and verified
1160
- * by the circuit. Matches `seed_hash_truncated` in
1161
- * `src/block_builder/builder.rs` and `src/circuit/slot/fairness.rs`.
1162
- *
1163
- * Returns `BigUint64Array` of length 3: `[h[0], h[1], h[2]]`.
1164
- * @param {BigUint64Array} server_seed
1165
- * @returns {BigUint64Array}
1166
- */
1167
- export function seed_hash_truncated(server_seed) {
1168
- try {
1169
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1170
- const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export);
1171
- const len0 = WASM_VECTOR_LEN;
1172
- wasm.seed_hash_truncated(retptr, ptr0, len0);
1173
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1174
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1175
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
1176
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
1177
- return v2;
1178
- } finally {
1179
- wasm.__wbindgen_add_to_stack_pointer(16);
1180
- }
1181
- }
1182
-
1183
- /**
1184
- * Compute the public key for a session: `pk_hash = Poseidon2(session_key[4], expiry)`.
1185
- *
1186
- * The public key hash is stored in the user-asset Merkle leaf and verified
1187
- * inside the circuit (the prover must know the preimage `session_key` + `expiry`).
1188
- *
1189
- * `session_key` must be exactly 4 elements (output of `derive_session_key`).
1190
- * `session_expiry` is the Unix timestamp after which the session is invalid.
1191
- * @param {BigUint64Array} session_key
1192
- * @param {bigint} session_expiry
1193
- * @returns {BigUint64Array}
1194
- */
1195
- export function session_public_key(session_key, session_expiry) {
1196
- try {
1197
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1198
- const ptr0 = passArray64ToWasm0(session_key, wasm.__wbindgen_export);
1199
- const len0 = WASM_VECTOR_LEN;
1200
- wasm.session_public_key(retptr, ptr0, len0, session_expiry);
1201
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1202
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1203
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
1204
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
1205
- return v2;
1206
- } finally {
1207
- wasm.__wbindgen_add_to_stack_pointer(16);
1208
- }
1209
- }
1210
-
1211
- /**
1212
- * Convert a user seed string to 4 Goldilocks field elements.
1213
- *
1214
- * `SHA-256(str)` → split into 4 × 8 LE bytes → reduce each mod p.
1215
- *
1216
- * This matches the backend's `stringToUserSeed` and produces the exact
1217
- * field elements used in the provably-fair random computation:
1218
- * `random = Poseidon2(server_seed ‖ user_seed)`
1219
- *
1220
- * ```js
1221
- * const fields = string_to_user_seed("my-seed-123");
1222
- * // fields.length === 4, each < GOLDILOCKS_P
1223
- * ```
1224
- * @param {string} input
1225
- * @returns {BigUint64Array}
1226
- */
1227
- export function string_to_user_seed(input) {
1228
- try {
1229
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1230
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1231
- const len0 = WASM_VECTOR_LEN;
1232
- wasm.string_to_user_seed(retptr, ptr0, len0);
1233
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1234
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1235
- var v2 = getArrayU64FromWasm0(r0, r1).slice();
1236
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
1237
- return v2;
1238
- } finally {
1239
- wasm.__wbindgen_add_to_stack_pointer(16);
1240
- }
1241
- }
1242
-
1243
- /**
1244
- * Convert a user seed string directly to a hex representation.
1245
- *
1246
- * Equivalent to `goldiLocksFieldsToHex(stringToUserSeed(str))`.
1247
- * Returns a 64-character lowercase hex string (32 bytes).
1248
- *
1249
- * ```js
1250
- * const hex = string_to_user_seed_hex("my-seed-123");
1251
- * // hex === "a1b2c3..." (64 chars)
1252
- * ```
1253
- * @param {string} input
1254
- * @returns {string}
1255
- */
1256
- export function string_to_user_seed_hex(input) {
1257
- let deferred2_0;
1258
- let deferred2_1;
1259
- try {
1260
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1261
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1262
- const len0 = WASM_VECTOR_LEN;
1263
- wasm.string_to_user_seed_hex(retptr, ptr0, len0);
1264
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1265
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1266
- deferred2_0 = r0;
1267
- deferred2_1 = r1;
1268
- return getStringFromWasm0(r0, r1);
1269
- } finally {
1270
- wasm.__wbindgen_add_to_stack_pointer(16);
1271
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1272
- }
1273
- }
1274
-
1275
- /**
1276
- * Re-check every per-slot circuit constraint on a candidate witness, returning
1277
- * the post-tx effects on success or a typed rejection reason on failure.
1278
- *
1279
- * Input: a JS object matching `tx_validator::SlotInput` (serde-compatible).
1280
- * Output on success: `{ ok: true, effects: SlotEffects }`.
1281
- * Output on failure: `{ ok: false, reason: string }`.
1282
- * @param {any} input
1283
- * @returns {any}
1284
- */
1285
- export function validate_slot(input) {
1286
- try {
1287
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1288
- wasm.validate_slot(retptr, addHeapObject(input));
1289
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1290
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1291
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1292
- if (r2) {
1293
- throw takeObject(r1);
1294
- }
1295
- return takeObject(r0);
1296
- } finally {
1297
- wasm.__wbindgen_add_to_stack_pointer(16);
1298
- }
1299
- }
1300
-
1301
- function __wbg_get_imports() {
1302
- const import0 = {
1303
- __proto__: null,
1304
- __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
1305
- const ret = Error(getStringFromWasm0(arg0, arg1));
1306
- return addHeapObject(ret);
1307
- },
1308
- __wbg_Number_04624de7d0e8332d: function(arg0) {
1309
- const ret = Number(getObject(arg0));
1310
- return ret;
1311
- },
1312
- __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
1313
- const ret = String(getObject(arg1));
1314
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1315
- const len1 = WASM_VECTOR_LEN;
1316
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1317
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1318
- },
1319
- __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
1320
- const v = getObject(arg1);
1321
- const ret = typeof(v) === 'bigint' ? v : undefined;
1322
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1323
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1324
- },
1325
- __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
1326
- const v = getObject(arg0);
1327
- const ret = typeof(v) === 'boolean' ? v : undefined;
1328
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1329
- },
1330
- __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
1331
- const ret = debugString(getObject(arg1));
1332
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1333
- const len1 = WASM_VECTOR_LEN;
1334
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1335
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1336
- },
1337
- __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
1338
- const ret = getObject(arg0) in getObject(arg1);
1339
- return ret;
1340
- },
1341
- __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
1342
- const ret = typeof(getObject(arg0)) === 'bigint';
1343
- return ret;
1344
- },
1345
- __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
1346
- const ret = typeof(getObject(arg0)) === 'function';
1347
- return ret;
1348
- },
1349
- __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
1350
- const val = getObject(arg0);
1351
- const ret = typeof(val) === 'object' && val !== null;
1352
- return ret;
1353
- },
1354
- __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
1355
- const ret = typeof(getObject(arg0)) === 'string';
1356
- return ret;
1357
- },
1358
- __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
1359
- const ret = getObject(arg0) === undefined;
1360
- return ret;
1361
- },
1362
- __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
1363
- const ret = getObject(arg0) === getObject(arg1);
1364
- return ret;
1365
- },
1366
- __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
1367
- const ret = getObject(arg0) == getObject(arg1);
1368
- return ret;
1369
- },
1370
- __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
1371
- const obj = getObject(arg1);
1372
- const ret = typeof(obj) === 'number' ? obj : undefined;
1373
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1374
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1375
- },
1376
- __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
1377
- const obj = getObject(arg1);
1378
- const ret = typeof(obj) === 'string' ? obj : undefined;
1379
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1380
- var len1 = WASM_VECTOR_LEN;
1381
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1382
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1383
- },
1384
- __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
1385
- throw new Error(getStringFromWasm0(arg0, arg1));
1386
- },
1387
- __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
1388
- const ret = getObject(arg0).call(getObject(arg1));
1389
- return addHeapObject(ret);
1390
- }, arguments); },
1391
- __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
1392
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1393
- return addHeapObject(ret);
1394
- }, arguments); },
1395
- __wbg_crypto_86f2631e91b51511: function(arg0) {
1396
- const ret = getObject(arg0).crypto;
1397
- return addHeapObject(ret);
1398
- },
1399
- __wbg_done_57b39ecd9addfe81: function(arg0) {
1400
- const ret = getObject(arg0).done;
1401
- return ret;
1402
- },
1403
- __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
1404
- getObject(arg0).getRandomValues(getObject(arg1));
1405
- }, arguments); },
1406
- __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
1407
- const ret = getObject(arg0)[arg1 >>> 0];
1408
- return addHeapObject(ret);
1409
- },
1410
- __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
1411
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
1412
- return addHeapObject(ret);
1413
- }, arguments); },
1414
- __wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
1415
- const ret = getObject(arg0)[getObject(arg1)];
1416
- return addHeapObject(ret);
1417
- },
1418
- __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
1419
- let result;
1420
- try {
1421
- result = getObject(arg0) instanceof ArrayBuffer;
1422
- } catch (_) {
1423
- result = false;
1424
- }
1425
- const ret = result;
1426
- return ret;
1427
- },
1428
- __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
1429
- let result;
1430
- try {
1431
- result = getObject(arg0) instanceof Uint8Array;
1432
- } catch (_) {
1433
- result = false;
1434
- }
1435
- const ret = result;
1436
- return ret;
1437
- },
1438
- __wbg_isArray_d314bb98fcf08331: function(arg0) {
1439
- const ret = Array.isArray(getObject(arg0));
1440
- return ret;
1441
- },
1442
- __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
1443
- const ret = Number.isSafeInteger(getObject(arg0));
1444
- return ret;
1445
- },
1446
- __wbg_iterator_6ff6560ca1568e55: function() {
1447
- const ret = Symbol.iterator;
1448
- return addHeapObject(ret);
1449
- },
1450
- __wbg_length_32ed9a279acd054c: function(arg0) {
1451
- const ret = getObject(arg0).length;
1452
- return ret;
1453
- },
1454
- __wbg_length_35a7bace40f36eac: function(arg0) {
1455
- const ret = getObject(arg0).length;
1456
- return ret;
1457
- },
1458
- __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
1459
- const ret = getObject(arg0).msCrypto;
1460
- return addHeapObject(ret);
1461
- },
1462
- __wbg_new_361308b2356cecd0: function() {
1463
- const ret = new Object();
1464
- return addHeapObject(ret);
1465
- },
1466
- __wbg_new_3eb36ae241fe6f44: function() {
1467
- const ret = new Array();
1468
- return addHeapObject(ret);
1469
- },
1470
- __wbg_new_dd2b680c8bf6ae29: function(arg0) {
1471
- const ret = new Uint8Array(getObject(arg0));
1472
- return addHeapObject(ret);
1473
- },
1474
- __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
1475
- const ret = new Function(getStringFromWasm0(arg0, arg1));
1476
- return addHeapObject(ret);
1477
- },
1478
- __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
1479
- const ret = new Uint8Array(arg0 >>> 0);
1480
- return addHeapObject(ret);
1481
- },
1482
- __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
1483
- const ret = getObject(arg0).next();
1484
- return addHeapObject(ret);
1485
- }, arguments); },
1486
- __wbg_next_418f80d8f5303233: function(arg0) {
1487
- const ret = getObject(arg0).next;
1488
- return addHeapObject(ret);
1489
- },
1490
- __wbg_node_e1f24f89a7336c2e: function(arg0) {
1491
- const ret = getObject(arg0).node;
1492
- return addHeapObject(ret);
1493
- },
1494
- __wbg_process_3975fd6c72f520aa: function(arg0) {
1495
- const ret = getObject(arg0).process;
1496
- return addHeapObject(ret);
1497
- },
1498
- __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
1499
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1500
- },
1501
- __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
1502
- getObject(arg0).randomFillSync(takeObject(arg1));
1503
- }, arguments); },
1504
- __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
1505
- const ret = module.require;
1506
- return addHeapObject(ret);
1507
- }, arguments); },
1508
- __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
1509
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1510
- },
1511
- __wbg_set_6cb8631f80447a67: function() { return handleError(function (arg0, arg1, arg2) {
1512
- const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1513
- return ret;
1514
- }, arguments); },
1515
- __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
1516
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1517
- },
1518
- __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
1519
- const ret = typeof global === 'undefined' ? null : global;
1520
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1521
- },
1522
- __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
1523
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
1524
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1525
- },
1526
- __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
1527
- const ret = typeof self === 'undefined' ? null : self;
1528
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1529
- },
1530
- __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
1531
- const ret = typeof window === 'undefined' ? null : window;
1532
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1533
- },
1534
- __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
1535
- const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
1536
- return addHeapObject(ret);
1537
- },
1538
- __wbg_value_0546255b415e96c1: function(arg0) {
1539
- const ret = getObject(arg0).value;
1540
- return addHeapObject(ret);
1541
- },
1542
- __wbg_versions_4e31226f5e8dc909: function(arg0) {
1543
- const ret = getObject(arg0).versions;
1544
- return addHeapObject(ret);
1545
- },
1546
- __wbindgen_cast_0000000000000001: function(arg0) {
1547
- // Cast intrinsic for `F64 -> Externref`.
1548
- const ret = arg0;
1549
- return addHeapObject(ret);
1550
- },
1551
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1552
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1553
- const ret = getArrayU8FromWasm0(arg0, arg1);
1554
- return addHeapObject(ret);
1555
- },
1556
- __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1557
- // Cast intrinsic for `Ref(String) -> Externref`.
1558
- const ret = getStringFromWasm0(arg0, arg1);
1559
- return addHeapObject(ret);
1560
- },
1561
- __wbindgen_cast_0000000000000004: function(arg0) {
1562
- // Cast intrinsic for `U64 -> Externref`.
1563
- const ret = BigInt.asUintN(64, arg0);
1564
- return addHeapObject(ret);
1565
- },
1566
- __wbindgen_object_clone_ref: function(arg0) {
1567
- const ret = getObject(arg0);
1568
- return addHeapObject(ret);
1569
- },
1570
- __wbindgen_object_drop_ref: function(arg0) {
1571
- takeObject(arg0);
1572
- },
1573
- };
1574
- return {
1575
- __proto__: null,
1576
- "./rolly_wasm_signer_bg.js": import0,
1577
- };
1578
- }
1579
-
1580
- function addHeapObject(obj) {
1581
- if (heap_next === heap.length) heap.push(heap.length + 1);
1582
- const idx = heap_next;
1583
- heap_next = heap[idx];
1584
-
1585
- heap[idx] = obj;
1586
- return idx;
1587
- }
1588
-
1589
- function debugString(val) {
1590
- // primitive types
1591
- const type = typeof val;
1592
- if (type == 'number' || type == 'boolean' || val == null) {
1593
- return `${val}`;
1594
- }
1595
- if (type == 'string') {
1596
- return `"${val}"`;
1597
- }
1598
- if (type == 'symbol') {
1599
- const description = val.description;
1600
- if (description == null) {
1601
- return 'Symbol';
1602
- } else {
1603
- return `Symbol(${description})`;
1604
- }
1605
- }
1606
- if (type == 'function') {
1607
- const name = val.name;
1608
- if (typeof name == 'string' && name.length > 0) {
1609
- return `Function(${name})`;
1610
- } else {
1611
- return 'Function';
1612
- }
1613
- }
1614
- // objects
1615
- if (Array.isArray(val)) {
1616
- const length = val.length;
1617
- let debug = '[';
1618
- if (length > 0) {
1619
- debug += debugString(val[0]);
1620
- }
1621
- for(let i = 1; i < length; i++) {
1622
- debug += ', ' + debugString(val[i]);
1623
- }
1624
- debug += ']';
1625
- return debug;
1626
- }
1627
- // Test for built-in
1628
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1629
- let className;
1630
- if (builtInMatches && builtInMatches.length > 1) {
1631
- className = builtInMatches[1];
1632
- } else {
1633
- // Failed to match the standard '[object ClassName]'
1634
- return toString.call(val);
1635
- }
1636
- if (className == 'Object') {
1637
- // we're a user defined class or Object
1638
- // JSON.stringify avoids problems with cycles, and is generally much
1639
- // easier than looping through ownProperties of `val`.
1640
- try {
1641
- return 'Object(' + JSON.stringify(val) + ')';
1642
- } catch (_) {
1643
- return 'Object';
1644
- }
1645
- }
1646
- // errors
1647
- if (val instanceof Error) {
1648
- return `${val.name}: ${val.message}\n${val.stack}`;
1649
- }
1650
- // TODO we could test for more things here, like `Set`s and `Map`s.
1651
- return className;
1652
- }
1653
-
1654
- function dropObject(idx) {
1655
- if (idx < 132) return;
1656
- heap[idx] = heap_next;
1657
- heap_next = idx;
1658
- }
1659
-
1660
- function getArrayU32FromWasm0(ptr, len) {
1661
- ptr = ptr >>> 0;
1662
- return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
1663
- }
1664
-
1665
- function getArrayU64FromWasm0(ptr, len) {
1666
- ptr = ptr >>> 0;
1667
- return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
1668
- }
1669
-
1670
- function getArrayU8FromWasm0(ptr, len) {
1671
- ptr = ptr >>> 0;
1672
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1673
- }
1674
-
1675
- let cachedBigUint64ArrayMemory0 = null;
1676
- function getBigUint64ArrayMemory0() {
1677
- if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
1678
- cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
1679
- }
1680
- return cachedBigUint64ArrayMemory0;
1681
- }
1682
-
1683
- let cachedDataViewMemory0 = null;
1684
- function getDataViewMemory0() {
1685
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1686
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1687
- }
1688
- return cachedDataViewMemory0;
1689
- }
1690
-
1691
- function getStringFromWasm0(ptr, len) {
1692
- ptr = ptr >>> 0;
1693
- return decodeText(ptr, len);
1694
- }
1695
-
1696
- let cachedUint32ArrayMemory0 = null;
1697
- function getUint32ArrayMemory0() {
1698
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
1699
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
1700
- }
1701
- return cachedUint32ArrayMemory0;
1702
- }
1703
-
1704
- let cachedUint8ArrayMemory0 = null;
1705
- function getUint8ArrayMemory0() {
1706
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1707
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1708
- }
1709
- return cachedUint8ArrayMemory0;
1710
- }
1711
-
1712
- function getObject(idx) { return heap[idx]; }
1713
-
1714
- function handleError(f, args) {
1715
- try {
1716
- return f.apply(this, args);
1717
- } catch (e) {
1718
- wasm.__wbindgen_export3(addHeapObject(e));
1719
- }
1720
- }
1721
-
1722
- let heap = new Array(128).fill(undefined);
1723
- heap.push(undefined, null, true, false);
1724
-
1725
- let heap_next = heap.length;
1726
-
1727
- function isLikeNone(x) {
1728
- return x === undefined || x === null;
1729
- }
1730
-
1731
- function passArray64ToWasm0(arg, malloc) {
1732
- const ptr = malloc(arg.length * 8, 8) >>> 0;
1733
- getBigUint64ArrayMemory0().set(arg, ptr / 8);
1734
- WASM_VECTOR_LEN = arg.length;
1735
- return ptr;
1736
- }
1737
-
1738
- function passArray8ToWasm0(arg, malloc) {
1739
- const ptr = malloc(arg.length * 1, 1) >>> 0;
1740
- getUint8ArrayMemory0().set(arg, ptr / 1);
1741
- WASM_VECTOR_LEN = arg.length;
1742
- return ptr;
1743
- }
1744
-
1745
- function passStringToWasm0(arg, malloc, realloc) {
1746
- if (realloc === undefined) {
1747
- const buf = cachedTextEncoder.encode(arg);
1748
- const ptr = malloc(buf.length, 1) >>> 0;
1749
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1750
- WASM_VECTOR_LEN = buf.length;
1751
- return ptr;
1752
- }
1753
-
1754
- let len = arg.length;
1755
- let ptr = malloc(len, 1) >>> 0;
1756
-
1757
- const mem = getUint8ArrayMemory0();
1758
-
1759
- let offset = 0;
1760
-
1761
- for (; offset < len; offset++) {
1762
- const code = arg.charCodeAt(offset);
1763
- if (code > 0x7F) break;
1764
- mem[ptr + offset] = code;
1765
- }
1766
- if (offset !== len) {
1767
- if (offset !== 0) {
1768
- arg = arg.slice(offset);
1769
- }
1770
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1771
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1772
- const ret = cachedTextEncoder.encodeInto(arg, view);
1773
-
1774
- offset += ret.written;
1775
- ptr = realloc(ptr, len, offset, 1) >>> 0;
1776
- }
1777
-
1778
- WASM_VECTOR_LEN = offset;
1779
- return ptr;
1780
- }
1781
-
1782
- function takeObject(idx) {
1783
- const ret = getObject(idx);
1784
- dropObject(idx);
1785
- return ret;
1786
- }
1787
-
1788
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1789
- cachedTextDecoder.decode();
1790
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
1791
- let numBytesDecoded = 0;
1792
- function decodeText(ptr, len) {
1793
- numBytesDecoded += len;
1794
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1795
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1796
- cachedTextDecoder.decode();
1797
- numBytesDecoded = len;
1798
- }
1799
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1800
- }
1801
-
1802
- const cachedTextEncoder = new TextEncoder();
1803
-
1804
- if (!('encodeInto' in cachedTextEncoder)) {
1805
- cachedTextEncoder.encodeInto = function (arg, view) {
1806
- const buf = cachedTextEncoder.encode(arg);
1807
- view.set(buf);
1808
- return {
1809
- read: arg.length,
1810
- written: buf.length
1811
- };
1812
- };
1813
- }
1814
-
1815
- let WASM_VECTOR_LEN = 0;
1816
-
1817
- let wasmModule, wasm;
1818
- function __wbg_finalize_init(instance, module) {
1819
- wasm = instance.exports;
1820
- wasmModule = module;
1821
- cachedBigUint64ArrayMemory0 = null;
1822
- cachedDataViewMemory0 = null;
1823
- cachedUint32ArrayMemory0 = null;
1824
- cachedUint8ArrayMemory0 = null;
1825
- return wasm;
1826
- }
1827
-
1828
- async function __wbg_load(module, imports) {
1829
- if (typeof Response === 'function' && module instanceof Response) {
1830
- if (typeof WebAssembly.instantiateStreaming === 'function') {
1831
- try {
1832
- return await WebAssembly.instantiateStreaming(module, imports);
1833
- } catch (e) {
1834
- const validResponse = module.ok && expectedResponseType(module.type);
1835
-
1836
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1837
- 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);
1838
-
1839
- } else { throw e; }
1840
- }
1841
- }
1842
-
1843
- const bytes = await module.arrayBuffer();
1844
- return await WebAssembly.instantiate(bytes, imports);
1845
- } else {
1846
- const instance = await WebAssembly.instantiate(module, imports);
1847
-
1848
- if (instance instanceof WebAssembly.Instance) {
1849
- return { instance, module };
1850
- } else {
1851
- return instance;
1852
- }
1853
- }
1854
-
1855
- function expectedResponseType(type) {
1856
- switch (type) {
1857
- case 'basic': case 'cors': case 'default': return true;
1858
- }
1859
- return false;
1860
- }
1861
- }
1862
-
1863
- function initSync(module) {
1864
- if (wasm !== undefined) return wasm;
1865
-
1866
-
1867
- if (module !== undefined) {
1868
- if (Object.getPrototypeOf(module) === Object.prototype) {
1869
- ({module} = module)
1870
- } else {
1871
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1872
- }
1873
- }
1874
-
1875
- const imports = __wbg_get_imports();
1876
- if (!(module instanceof WebAssembly.Module)) {
1877
- module = new WebAssembly.Module(module);
1878
- }
1879
- const instance = new WebAssembly.Instance(module, imports);
1880
- return __wbg_finalize_init(instance, module);
1881
- }
1882
-
1883
- async function __wbg_init(module_or_path) {
1884
- if (wasm !== undefined) return wasm;
1885
-
1886
-
1887
- if (module_or_path !== undefined) {
1888
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1889
- ({module_or_path} = module_or_path)
1890
- } else {
1891
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1892
- }
1893
- }
1894
-
1895
- if (module_or_path === undefined) {
1896
- module_or_path = new URL('rolly_wasm_signer_bg.wasm', import.meta.url);
1897
- }
1898
- const imports = __wbg_get_imports();
1899
-
1900
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1901
- module_or_path = fetch(module_or_path);
1902
- }
1903
-
1904
- const { instance, module } = await __wbg_load(await module_or_path, imports);
1905
-
1906
- return __wbg_finalize_init(instance, module);
1907
- }
1908
-
1909
- export { initSync, __wbg_init as default };