@rolly-dev/wasm-signer 1.31.1 → 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.
- package/README.md +10 -55
- package/dist/node/README.md +10 -55
- package/dist/node/rolly_wasm_signer.d.ts +5 -1
- package/dist/node/rolly_wasm_signer.js +5 -1
- package/dist/node/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/node-inline/README.md +10 -55
- package/dist/node-inline/rolly_wasm_signer.d.ts +5 -1
- package/dist/node-inline/rolly_wasm_signer.js +6 -2
- package/dist/node-inline/rolly_wasm_signer.mjs +6 -2
- package/package.json +6 -25
- package/dist/web/README.md +0 -148
- package/dist/web/rolly_wasm_signer.d.ts +0 -663
- package/dist/web/rolly_wasm_signer.js +0 -1913
- package/dist/web/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/web/rolly_wasm_signer_bg.wasm.d.ts +0 -69
- package/js/browser.d.mts +0 -38
- package/js/browser.mjs +0 -65
- package/js/react.d.mts +0 -56
- package/js/react.mjs +0 -162
|
@@ -1,663 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Split a u64 amount into (lo, hi) u32 pair matching the circuit representation.
|
|
6
|
-
*
|
|
7
|
-
* Returns `[amount_lo, amount_hi]` as a `Uint32Array` of length 2.
|
|
8
|
-
*
|
|
9
|
-
* ```js
|
|
10
|
-
* const [lo, hi] = amount_split(123456789n);
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export function amount_split(amount: bigint): Uint32Array;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Backward-compatible alias for `crash_rtp_percent`.
|
|
17
|
-
*/
|
|
18
|
-
export function aviato_rtp_percent(): number;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Reconstruct the 30 dealt Blackjack rank codes from the fairness seeds.
|
|
22
|
-
*
|
|
23
|
-
* This is the SINGLE client/backend-side mirror of the native shoe unfold in
|
|
24
|
-
* `tx_validator::blackjack::unfold_shoe` and the in-circuit shuffle: it computes
|
|
25
|
-
* `mix = Poseidon2(server_seed ‖ user_secret_random)` and the per-step swap
|
|
26
|
-
* randomness `low32(Poseidon2(mix ‖ k))`, then defers the deterministic
|
|
27
|
-
* 30-swap partial Fisher–Yates over the fixed 416-card layout to the pure
|
|
28
|
-
* `rolly_game_core::blackjack::deal_shoe`. Mixing the player-chosen
|
|
29
|
-
* `user_secret_random` into the seed makes the shuffle a mutual commit–reveal,
|
|
30
|
-
* so neither the operator nor the player can pre-grind a shoe.
|
|
31
|
-
*
|
|
32
|
-
* `server_seed` must be 8 elements (the full fairness preimage); `user_secret_random`
|
|
33
|
-
* must be 4 elements (`string_to_user_seed(user_seed_source)`).
|
|
34
|
-
*
|
|
35
|
-
* **Output**: `Uint8Array` of length 30 — rank codes `0..=12` (Ace=0, 2..9=1..8,
|
|
36
|
-
* 10/J/Q/K=9..12). Suits are cosmetic and restored off-engine.
|
|
37
|
-
*
|
|
38
|
-
* ```js
|
|
39
|
-
* const shoe = blackjack_deal_shoe(serverSeed8, userSecret4); // length 30
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export function blackjack_deal_shoe(server_seed: BigUint64Array, user_secret_random: BigUint64Array): Uint8Array;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Pack a Blackjack action sequence into the two base-8 halves the rollup records
|
|
46
|
-
* as `prediction_lo` / `prediction_hi` (`actions[0..10]` → lo, `actions[10..20]`
|
|
47
|
-
* → hi). Single-sources `rolly_game_core::blackjack::pack_actions` so the
|
|
48
|
-
* backend feeds the WitnessEngine exactly what the circuit re-derives.
|
|
49
|
-
*
|
|
50
|
-
* `actions` are the `ACTION_*` codes (1..=6). **Output**: `Uint32Array` of
|
|
51
|
-
* length 2 = `[prediction_lo, prediction_hi]`.
|
|
52
|
-
*/
|
|
53
|
-
export function blackjack_pack_actions(actions: Uint8Array): Uint32Array;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* CoinFlip multiplier × 10000 (19800 = 1.98×). Canonical source for backend/frontend.
|
|
57
|
-
*/
|
|
58
|
-
export function coinflip_multiplier_x10000(): number;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* CoinFlip RTP percent (99). Canonical source for backend/frontend.
|
|
62
|
-
*/
|
|
63
|
-
export function coinflip_rtp_percent(): number;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Compute address_hash = Poseidon2(addr_byte_0, ..., addr_byte_19).
|
|
67
|
-
* Takes a hex address string (with or without 0x prefix), returns [u64; 4].
|
|
68
|
-
*/
|
|
69
|
-
export function compute_address_hash(address_hex: string): BigUint64Array;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Backward-compatible alias for `compute_crash_point`.
|
|
73
|
-
*/
|
|
74
|
-
export function compute_aviato_point(random: BigUint64Array): number;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Extract crash point (×100) from raw server seed fields.
|
|
78
|
-
*
|
|
79
|
-
* `random` must be exactly 4 elements (first 4 fields of server_seed).
|
|
80
|
-
* Returns the clamped crash multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
|
|
81
|
-
*/
|
|
82
|
-
export function compute_crash_point(random: BigUint64Array): number;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Extract the 10 drawn numbers from Poseidon2 random output using
|
|
86
|
-
* the combinatorial number system: `combo_index = random[0] % C(40,10)`.
|
|
87
|
-
*
|
|
88
|
-
* `random` must be exactly 4 elements.
|
|
89
|
-
* Returns `Uint8Array` of length 10 (sorted ascending, each in [0, 39]).
|
|
90
|
-
*/
|
|
91
|
-
export function compute_drawn_keno(random: BigUint64Array): Uint8Array;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Compute dice multiplier × 10000 from win_numbers count.
|
|
95
|
-
*
|
|
96
|
-
* Formula: `9_900_000 / win_numbers` (integer division = floor).
|
|
97
|
-
* `win_numbers` must be in [1, 950].
|
|
98
|
-
*/
|
|
99
|
-
export function compute_multi_dice(win_numbers: number): bigint;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Backward-compatible alias for `compute_payout_crash`.
|
|
103
|
-
*/
|
|
104
|
-
export function compute_payout_aviato(random: BigUint64Array, bet_atomic: bigint, cashout_x100: number): BigUint64Array;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Client-side provably-fair verification of a full Blackjack round.
|
|
108
|
-
*
|
|
109
|
-
* Reconstructs the fair shoe from `(server_seed ‖ user_secret_random)` (see
|
|
110
|
-
* [`blackjack_deal_shoe`]), decodes the base-8 `prediction_lo` / `prediction_hi`
|
|
111
|
-
* action halves, and replays the exact same state machine the circuit and the
|
|
112
|
-
* tx-validator run (`rolly_game_core::blackjack::replay_full`). This lets a
|
|
113
|
-
* player independently confirm the settled `win`/`bet` off-chain; it is NOT on
|
|
114
|
-
* the tx/settlement path.
|
|
115
|
-
*
|
|
116
|
-
* `server_seed` must be 8 elements (the revealed fairness preimage);
|
|
117
|
-
* `user_secret_random` must be 4 elements (`string_to_user_seed(...)`).
|
|
118
|
-
* `base_bet` is the base stake in atomic units. The returned `total_staked`
|
|
119
|
-
* grows with double/split/insurance exactly as the engine books them.
|
|
120
|
-
*
|
|
121
|
-
* **Output**: a JS object matching [`BlackjackVerifyResult`].
|
|
122
|
-
*
|
|
123
|
-
* Returns an error if the decoded action list contains an invalid code
|
|
124
|
-
* (outside `1..=6`), mirroring the tx-validator's typed rejection.
|
|
125
|
-
*
|
|
126
|
-
* ```js
|
|
127
|
-
* const res = compute_payout_blackjack(serverSeed8, userSecret4, lo, hi, betAtomic);
|
|
128
|
-
* // res.win_amount, res.total_staked, res.shoe (length 30),
|
|
129
|
-
* // res.first_cards / res.second_cards / res.dealer_cards (rank codes),
|
|
130
|
-
* // res.first_kind / res.second_kind (per-hand type: 0=bet,1=hit,2=stand,
|
|
131
|
-
* // 3=double,4=split,5=insurance; a closed hand reports 2),
|
|
132
|
-
* // res.first_amount / res.second_amount (per-hand staked, atomic),
|
|
133
|
-
* // res.first_win / res.second_win (per-hand win, atomic, pre-cap), ...
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
export function compute_payout_blackjack(server_seed: BigUint64Array, user_secret_random: BigUint64Array, prediction_lo: number, prediction_hi: number, base_bet: bigint): any;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Full coinflip payout computation — pure integer arithmetic, zero floats.
|
|
140
|
-
*
|
|
141
|
-
* `random`: 4 Goldilocks field elements (Poseidon2 output).
|
|
142
|
-
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
143
|
-
* `prediction`: 0 or 1.
|
|
144
|
-
*
|
|
145
|
-
* Returns `BigUint64Array[4]`: `[win_amount, roll (0|1), is_win (0|1), multiplier×10000]`.
|
|
146
|
-
*/
|
|
147
|
-
export function compute_payout_coinflip(random: BigUint64Array, bet_atomic: bigint, prediction: number): BigUint64Array;
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Full crash payout computation — pure integer arithmetic, zero floats.
|
|
151
|
-
*
|
|
152
|
-
* `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
|
|
153
|
-
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
154
|
-
* `cashout_x100`: multiplier at which the user cashed out (×100).
|
|
155
|
-
* - 0 = user did NOT cash out (loss).
|
|
156
|
-
* - 100..=1_000_000 = user stopped at this multiplier.
|
|
157
|
-
*
|
|
158
|
-
* Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
|
|
159
|
-
*/
|
|
160
|
-
export function compute_payout_crash(random: BigUint64Array, bet_atomic: bigint, cashout_x100: number): BigUint64Array;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Full dice payout computation — pure integer arithmetic, zero floats.
|
|
164
|
-
*
|
|
165
|
-
* `random`: 4 Goldilocks field elements (Poseidon2 output).
|
|
166
|
-
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
167
|
-
* `game_mode`: 0=Under, 1=Over, 2=In, 3=Out.
|
|
168
|
-
* `prediction_lo` / `prediction_hi`: prediction range bounds (0..999).
|
|
169
|
-
*
|
|
170
|
-
* Returns `BigUint64Array[4]`: `[win_amount, roll_number, is_win (0|1), multiplier×10000]`.
|
|
171
|
-
*/
|
|
172
|
-
export function compute_payout_dice(random: BigUint64Array, bet_atomic: bigint, game_mode: number, prediction_lo: number, prediction_hi: number): BigUint64Array;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Full keno payout computation — pure integer arithmetic, zero floats.
|
|
176
|
-
*
|
|
177
|
-
* `random`: 4 Goldilocks field elements (Poseidon2 output).
|
|
178
|
-
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
179
|
-
* `risk`: 0=low, 1=medium, 2=high.
|
|
180
|
-
* `selected`: player-chosen numbers (0-indexed, each in [0, 39]).
|
|
181
|
-
*
|
|
182
|
-
* Returns `BigUint64Array[4]`: `[win_amount, match_count, is_win (0|1), multiplier×10000]`.
|
|
183
|
-
*/
|
|
184
|
-
export function compute_payout_keno(random: BigUint64Array, bet_atomic: bigint, risk: number, selected: Uint8Array): BigUint64Array;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Full limbo payout computation — pure integer arithmetic, zero floats.
|
|
188
|
-
*
|
|
189
|
-
* `random`: 4 Goldilocks field elements (Poseidon2 output).
|
|
190
|
-
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
191
|
-
* `prediction_x100`: target multiplier x 100 (101..999999, i.e. 1.01x-9999.99x).
|
|
192
|
-
*
|
|
193
|
-
* Returns `BigUint64Array[4]`: `[win_amount, multiplier_x100, is_win (0|1), payout_multiplier x10000]`.
|
|
194
|
-
*/
|
|
195
|
-
export function compute_payout_limbo(random: BigUint64Array, bet_atomic: bigint, prediction_x100: number): BigUint64Array;
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Full plinko payout computation — pure integer arithmetic, zero floats.
|
|
199
|
-
*
|
|
200
|
-
* `random`: 4 Goldilocks field elements (Poseidon2 output).
|
|
201
|
-
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
202
|
-
* `sector`: risk profile (0=low, 1=medium, 2=high).
|
|
203
|
-
* `rows`: number of pin rows (8..16).
|
|
204
|
-
* `is_extreme`: whether extreme mode is active.
|
|
205
|
-
*
|
|
206
|
-
* Returns `BigUint64Array[4]`: `[win_amount, bucket_index, is_win (0|1), multiplier×10000]`.
|
|
207
|
-
*/
|
|
208
|
-
export function compute_payout_plinko(random: BigUint64Array, bet_atomic: bigint, sector: number, rows: number, is_extreme: boolean): BigUint64Array;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Compute prediction hash: `Poseidon2(game_id, p0, p1, p2)` → 4 field elements.
|
|
212
|
-
*
|
|
213
|
-
* Matches `compute_prediction_hash_native` in the circuit (`games/shared.rs`)
|
|
214
|
-
* and the in-circuit `build_prediction_hash`.
|
|
215
|
-
*
|
|
216
|
-
* Semantics of p0–p2 depend on the game:
|
|
217
|
-
* Limbo: `(98, prediction_x100, 0)` — RTP hardcoded at 98
|
|
218
|
-
* Dice: `(mode, pred_lo, pred_hi)`
|
|
219
|
-
* Plinko: `(sector, rows, is_extreme)`
|
|
220
|
-
* CoinFlip: `(prediction, 0, 0)`
|
|
221
|
-
*/
|
|
222
|
-
export function compute_prediction_hash(game_id: number, p0: number, p1: number, p2: number): BigUint64Array;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Compute Keno prediction hash with extended 13-input format:
|
|
226
|
-
* `Poseidon2(game_id, risk, pick_count, selected[0], …, selected[9])`.
|
|
227
|
-
*
|
|
228
|
-
* Selected numbers are sorted internally for deterministic output.
|
|
229
|
-
* Unused slots (when pick_count < 10) are filled with 0.
|
|
230
|
-
*
|
|
231
|
-
* Returns `BigUint64Array` of length 4 (one `HashOut`).
|
|
232
|
-
*/
|
|
233
|
-
export function compute_prediction_hash_keno(game_id: number, risk: number, pick_count: number, selected: Uint8Array): BigUint64Array;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Extract coinflip roll (0 or 1) from Poseidon2 random output.
|
|
237
|
-
*
|
|
238
|
-
* `random` must be exactly 4 elements. Returns `random[0] % 2`.
|
|
239
|
-
*/
|
|
240
|
-
export function compute_roll_coinflip(random: BigUint64Array): number;
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Extract dice roll number [0, 1000) from Poseidon2 random output.
|
|
244
|
-
*
|
|
245
|
-
* `random` must be exactly 4 elements. Returns `random[0] % 1000`.
|
|
246
|
-
*/
|
|
247
|
-
export function compute_roll_dice(random: BigUint64Array): number;
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Extract limbo result multiplier x 100 from Poseidon2 random output.
|
|
251
|
-
*
|
|
252
|
-
* `random` must be exactly 4 elements.
|
|
253
|
-
* Returns the clamped multiplier x 100 (101..999999).
|
|
254
|
-
*/
|
|
255
|
-
export function compute_roll_limbo(random: BigUint64Array): number;
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Extract plinko bucket index from Poseidon2 random output.
|
|
259
|
-
*
|
|
260
|
-
* `random` must be exactly 4 elements.
|
|
261
|
-
* `rows` must be in [8, 16].
|
|
262
|
-
* Returns the bucket index (0..=rows) = popcount of first `rows` bits of random[0].
|
|
263
|
-
*/
|
|
264
|
-
export function compute_roll_plinko(random: BigUint64Array, rows: number): number;
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Full Poseidon2 hash of an 8-element server seed.
|
|
268
|
-
*
|
|
269
|
-
* Returns all 4 hash elements. Note: the circuit stores only the
|
|
270
|
-
* **first 3 elements** as the leaf commitment (see `seed_hash_truncated`).
|
|
271
|
-
* This full variant is useful for client-side verification where all
|
|
272
|
-
* 4 elements may be needed.
|
|
273
|
-
*
|
|
274
|
-
* `server_seed` must be exactly 8 elements.
|
|
275
|
-
*/
|
|
276
|
-
export function compute_server_seed_hash(server_seed: BigUint64Array): BigUint64Array;
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Compute user seed with bet-parameter binding:
|
|
280
|
-
* `Poseidon2(game_id, bet, pred_hash[4], secret[4])` → 4 field elements.
|
|
281
|
-
*
|
|
282
|
-
* Matches the circuit constraint in `slot/fairness.rs`.
|
|
283
|
-
* Prevents the operator from swapping bet parameters after the user commits.
|
|
284
|
-
*
|
|
285
|
-
* `bet` is the full bet amount in atomic units (u64).
|
|
286
|
-
* `pred_hash` must be 4 elements (output of `compute_prediction_hash`).
|
|
287
|
-
* `secret` must be 4 elements (output of `generate_user_secret`).
|
|
288
|
-
*/
|
|
289
|
-
export function compute_user_seed_binding(game_id: number, bet: bigint, pred_hash: BigUint64Array, secret: BigUint64Array): BigUint64Array;
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Crash RTP percent (99). Canonical source for backend/frontend.
|
|
293
|
-
*/
|
|
294
|
-
export function crash_rtp_percent(): number;
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
|
|
298
|
-
*
|
|
299
|
-
* **Algorithm**: split 32 bytes into 4 × 8 bytes, interpret each chunk as
|
|
300
|
-
* little-endian u64, reduce mod p, then hash:
|
|
301
|
-
* `session_key = Poseidon2(reduced_chunks)`
|
|
302
|
-
*
|
|
303
|
-
* The reduction via `from_noncanonical_u64` is necessary because raw
|
|
304
|
-
* signature bytes can produce values >= p.
|
|
305
|
-
*
|
|
306
|
-
* ```js
|
|
307
|
-
* const sig = ethers.getBytes(metaMaskSignature).slice(0, 32);
|
|
308
|
-
* const sk = derive_session_key(new Uint8Array(sig));
|
|
309
|
-
* // sk.length === 4
|
|
310
|
-
* ```
|
|
311
|
-
*/
|
|
312
|
-
export function derive_session_key(sig_bytes: Uint8Array): BigUint64Array;
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Dice RTP percent (99). Canonical source for backend/frontend.
|
|
316
|
-
*/
|
|
317
|
-
export function dice_rtp_percent(): number;
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Encode 1-indexed Keno selected numbers into a bitmask pair `[lo, hi]`.
|
|
321
|
-
*
|
|
322
|
-
* `selected_1indexed`: player-chosen numbers as they come from the frontend (1..40).
|
|
323
|
-
* Returns `Uint32Array[2]`: `[lo, hi]` where `lo` covers numbers 0..29 and `hi` covers 30..39
|
|
324
|
-
* (0-indexed bit positions).
|
|
325
|
-
*/
|
|
326
|
-
export function encode_keno_selected(selected_1indexed: Uint8Array): Uint32Array;
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Generate a cryptographically random user secret — 4 Goldilocks field elements.
|
|
330
|
-
*
|
|
331
|
-
* Each element is reduced mod p for canonical representation (safe for circuit use).
|
|
332
|
-
* Uses `getrandom` (`crypto.getRandomValues` in browser, OS entropy in Node.js).
|
|
333
|
-
*
|
|
334
|
-
* ```js
|
|
335
|
-
* const secret = generate_user_secret();
|
|
336
|
-
* // secret.length === 4, each < GOLDILOCKS_P
|
|
337
|
-
* ```
|
|
338
|
-
*/
|
|
339
|
-
export function generate_user_secret(): BigUint64Array;
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Generate a random user seed — 10 alphanumeric characters.
|
|
343
|
-
*
|
|
344
|
-
* Uses `getrandom` (backed by `crypto.getRandomValues` in the browser
|
|
345
|
-
* and OS entropy on Node.js) for cryptographically secure randomness.
|
|
346
|
-
*
|
|
347
|
-
* ```js
|
|
348
|
-
* const seed = generate_user_seed();
|
|
349
|
-
* // e.g. "k7Qm2xW9aB"
|
|
350
|
-
* ```
|
|
351
|
-
*/
|
|
352
|
-
export function generate_user_seed(): string;
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Convert any Goldilocks field elements to a hex string.
|
|
356
|
-
*
|
|
357
|
-
* Each u64 is encoded as 8 little-endian bytes → 16 hex chars.
|
|
358
|
-
* For 4 elements: 64 hex chars (32 bytes).
|
|
359
|
-
*
|
|
360
|
-
* ```js
|
|
361
|
-
* const hex = goldilocks_fields_to_hex(BigUint64Array.from([1n, 2n, 3n, 4n]));
|
|
362
|
-
* ```
|
|
363
|
-
*/
|
|
364
|
-
export function goldilocks_fields_to_hex(fields: BigUint64Array): string;
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Returns the Goldilocks prime: p = 2^64 - 2^32 + 1.
|
|
368
|
-
*/
|
|
369
|
-
export function goldilocks_modulus(): bigint;
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Reduce an arbitrary u64 to its canonical representative mod p.
|
|
373
|
-
*
|
|
374
|
-
* Values already < p are returned unchanged. Values >= p are reduced.
|
|
375
|
-
* This uses `from_noncanonical_u64` internally (no panic on large values).
|
|
376
|
-
*/
|
|
377
|
-
export function goldilocks_reduce(value: bigint): bigint;
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Hash a raw 7-element balance leaf → 4-element Merkle node.
|
|
381
|
-
*
|
|
382
|
-
* Raw layout: `[balance_lo, balance_hi, seed_hash_0, seed_hash_1, seed_hash_2, credit_lo, credit_hi]`
|
|
383
|
-
*
|
|
384
|
-
* Identical to `hash_balance_leaf` in `prover/circuit/src/helpers/leaf_ops.rs`.
|
|
385
|
-
*
|
|
386
|
-
* **Input** : `BigUint64Array` of exactly 7 elements (each < `GOLDILOCKS_P`).
|
|
387
|
-
* **Output**: `BigUint64Array` of length 4 (one `HashOut`).
|
|
388
|
-
*
|
|
389
|
-
* ```js
|
|
390
|
-
* const raw = BigUint64Array.from([balLo, balHi, seed0, seed1, seed2, credLo, credHi]);
|
|
391
|
-
* const balanceHash = hash_balance_leaf(raw); // length 4
|
|
392
|
-
* ```
|
|
393
|
-
*/
|
|
394
|
-
export function hash_balance_leaf(raw: BigUint64Array): BigUint64Array;
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* RTP × 100 for ALL valid Keno configs.
|
|
398
|
-
* Returns JS object: `{ "0_1": 9450, "0_2": 9712, ..., "2_10": 9580 }`
|
|
399
|
-
* Keys: `"{risk}_{pick_count}"`.
|
|
400
|
-
*/
|
|
401
|
-
export function keno_all_rtp_x100(): any;
|
|
402
|
-
|
|
403
|
-
export function keno_draw_count(): number;
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Whether a (risk, pick_count) pair is a valid Keno config.
|
|
407
|
-
*/
|
|
408
|
-
export function keno_is_valid_config(risk: number, pick_count: number): boolean;
|
|
409
|
-
|
|
410
|
-
export function keno_max_picks(): number;
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* Returns the multiplier table (×10000) for the given Keno config.
|
|
414
|
-
* `risk`: 0=low, 1=medium, 2=high. `pick_count`: 1..10.
|
|
415
|
-
* Length = pick_count + 1. Returns empty vec for invalid combos.
|
|
416
|
-
*/
|
|
417
|
-
export function keno_multiplier_table(risk: number, pick_count: number): BigUint64Array;
|
|
418
|
-
|
|
419
|
-
export function keno_numbers_range(): number;
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* RTP × 100 for a Keno config (e.g. 9800 = 98.00%). Returns 0 for invalid combos.
|
|
423
|
-
*/
|
|
424
|
-
export function keno_rtp_x100(risk: number, pick_count: number): bigint;
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Limbo RTP percent (98). Canonical source for backend/frontend.
|
|
428
|
-
*/
|
|
429
|
-
export function limbo_rtp_percent(): number;
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* Build a main Merkle tree leaf from balance_hash, pk_hash, and address_hash.
|
|
433
|
-
*
|
|
434
|
-
* `main_leaf = Poseidon2(balance_hash[4] || pk_hash[0..2] || address_hash[0..2])`
|
|
435
|
-
*
|
|
436
|
-
* Uses truncated (128-bit) pk/address hashes to keep the preimage at 8 elements
|
|
437
|
-
* (single Poseidon2 permutation round). Identical to `make_main_leaf` in
|
|
438
|
-
* `prover/circuit/src/helpers/leaf_ops.rs`.
|
|
439
|
-
*
|
|
440
|
-
* All three inputs must be exactly 4 elements.
|
|
441
|
-
* **Output**: `BigUint64Array` of length 4 (the Merkle leaf hash).
|
|
442
|
-
*
|
|
443
|
-
* ```js
|
|
444
|
-
* const leaf = make_main_leaf(balanceHash, pkHash, addressHash);
|
|
445
|
-
* ```
|
|
446
|
-
*/
|
|
447
|
-
export function make_main_leaf(balance_hash: BigUint64Array, pk_hash: BigUint64Array, address_hash: BigUint64Array): BigUint64Array;
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* RTP × 100 for ALL valid Plinko configs.
|
|
451
|
-
* Returns JS object: `{ "0_8_normal": 9799, "1_12_extreme": 9881, ... }`
|
|
452
|
-
*/
|
|
453
|
-
export function plinko_all_rtp_x100(): any;
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* Whether a (sector, rows, is_extreme) triple is a valid Plinko config.
|
|
457
|
-
*/
|
|
458
|
-
export function plinko_is_valid_config(sector: number, rows: number, is_extreme: boolean): boolean;
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Whether rows is within the valid Plinko range [8, 16].
|
|
462
|
-
*/
|
|
463
|
-
export function plinko_is_valid_rows(rows: number): boolean;
|
|
464
|
-
|
|
465
|
-
export function plinko_max_rows(): number;
|
|
466
|
-
|
|
467
|
-
export function plinko_min_rows(): number;
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* Returns the multiplier table (×10000) for the given Plinko config.
|
|
471
|
-
* Length = rows + 1. Returns empty vec for invalid combos.
|
|
472
|
-
*/
|
|
473
|
-
export function plinko_multiplier_table(sector: number, rows: number, is_extreme: boolean): BigUint64Array;
|
|
474
|
-
|
|
475
|
-
export function plinko_num_sectors(): number;
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* RTP × 100 for a Plinko config (e.g. 9799 = 97.99%). Returns 0 for invalid combos.
|
|
479
|
-
*/
|
|
480
|
-
export function plinko_rtp_x100(sector: number, rows: number, is_extreme: boolean): bigint;
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Poseidon2 hash of an arbitrary number of Goldilocks field elements.
|
|
484
|
-
*
|
|
485
|
-
* Mirrors `builder.hash_n_to_hash_no_pad::<Poseidon2Hash>(...)` inside
|
|
486
|
-
* the circuit and `Poseidon2Hash::hash_no_pad` in `src/block_builder`.
|
|
487
|
-
*
|
|
488
|
-
* **Input** : `BigUint64Array` — each element must be < `GOLDILOCKS_P`.
|
|
489
|
-
* **Output**: `BigUint64Array` of length 4 (one `HashOut`).
|
|
490
|
-
*
|
|
491
|
-
* ```js
|
|
492
|
-
* const h = poseidon2_hash(BigUint64Array.from([1n, 2n, 3n]));
|
|
493
|
-
* // h.length === 4
|
|
494
|
-
* ```
|
|
495
|
-
*/
|
|
496
|
-
export function poseidon2_hash(input: BigUint64Array): BigUint64Array;
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* Merkle-tree hash: Poseidon2(left[4] ‖ right[4]).
|
|
500
|
-
*
|
|
501
|
-
* Identical to `poseidon_hash(left, right)` in `src/merkletree/hash.rs`.
|
|
502
|
-
* Input ordering is critical — `left` concatenated before `right`.
|
|
503
|
-
*
|
|
504
|
-
* Both arrays **must** have exactly 4 elements (one `HashOut` each).
|
|
505
|
-
*/
|
|
506
|
-
export function poseidon2_two_to_one(left: BigUint64Array, right: BigUint64Array): BigUint64Array;
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* Truncated seed hash — first 3 elements of `Poseidon2(server_seed)`.
|
|
510
|
-
*
|
|
511
|
-
* 192 bits of commitment → ~96-bit collision resistance, which closes the
|
|
512
|
-
* multi-preimage grinding vector that an earlier 128-bit truncation left open.
|
|
513
|
-
* This is the exact format stored in the Merkle-tree leaf and verified
|
|
514
|
-
* by the circuit. Matches `seed_hash_truncated` in
|
|
515
|
-
* `src/block_builder/builder.rs` and `src/circuit/slot/fairness.rs`.
|
|
516
|
-
*
|
|
517
|
-
* Returns `BigUint64Array` of length 3: `[h[0], h[1], h[2]]`.
|
|
518
|
-
*/
|
|
519
|
-
export function seed_hash_truncated(server_seed: BigUint64Array): BigUint64Array;
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Compute the public key for a session: `pk_hash = Poseidon2(session_key[4], expiry)`.
|
|
523
|
-
*
|
|
524
|
-
* The public key hash is stored in the user-asset Merkle leaf and verified
|
|
525
|
-
* inside the circuit (the prover must know the preimage `session_key` + `expiry`).
|
|
526
|
-
*
|
|
527
|
-
* `session_key` must be exactly 4 elements (output of `derive_session_key`).
|
|
528
|
-
* `session_expiry` is the Unix timestamp after which the session is invalid.
|
|
529
|
-
*/
|
|
530
|
-
export function session_public_key(session_key: BigUint64Array, session_expiry: bigint): BigUint64Array;
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* Convert a user seed string to 4 Goldilocks field elements.
|
|
534
|
-
*
|
|
535
|
-
* `SHA-256(str)` → split into 4 × 8 LE bytes → reduce each mod p.
|
|
536
|
-
*
|
|
537
|
-
* This matches the backend's `stringToUserSeed` and produces the exact
|
|
538
|
-
* field elements used in the provably-fair random computation:
|
|
539
|
-
* `random = Poseidon2(server_seed ‖ user_seed)`
|
|
540
|
-
*
|
|
541
|
-
* ```js
|
|
542
|
-
* const fields = string_to_user_seed("my-seed-123");
|
|
543
|
-
* // fields.length === 4, each < GOLDILOCKS_P
|
|
544
|
-
* ```
|
|
545
|
-
*/
|
|
546
|
-
export function string_to_user_seed(input: string): BigUint64Array;
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* Convert a user seed string directly to a hex representation.
|
|
550
|
-
*
|
|
551
|
-
* Equivalent to `goldiLocksFieldsToHex(stringToUserSeed(str))`.
|
|
552
|
-
* Returns a 64-character lowercase hex string (32 bytes).
|
|
553
|
-
*
|
|
554
|
-
* ```js
|
|
555
|
-
* const hex = string_to_user_seed_hex("my-seed-123");
|
|
556
|
-
* // hex === "a1b2c3..." (64 chars)
|
|
557
|
-
* ```
|
|
558
|
-
*/
|
|
559
|
-
export function string_to_user_seed_hex(input: string): string;
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* Re-check every per-slot circuit constraint on a candidate witness, returning
|
|
563
|
-
* the post-tx effects on success or a typed rejection reason on failure.
|
|
564
|
-
*
|
|
565
|
-
* Input: a JS object matching `tx_validator::SlotInput` (serde-compatible).
|
|
566
|
-
* Output on success: `{ ok: true, effects: SlotEffects }`.
|
|
567
|
-
* Output on failure: `{ ok: false, reason: string }`.
|
|
568
|
-
*/
|
|
569
|
-
export function validate_slot(input: any): any;
|
|
570
|
-
|
|
571
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
572
|
-
|
|
573
|
-
export interface InitOutput {
|
|
574
|
-
readonly memory: WebAssembly.Memory;
|
|
575
|
-
readonly amount_split: (a: number, b: bigint) => void;
|
|
576
|
-
readonly aviato_rtp_percent: () => number;
|
|
577
|
-
readonly blackjack_deal_shoe: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
578
|
-
readonly blackjack_pack_actions: (a: number, b: number, c: number) => void;
|
|
579
|
-
readonly coinflip_multiplier_x10000: () => number;
|
|
580
|
-
readonly compute_address_hash: (a: number, b: number, c: number) => void;
|
|
581
|
-
readonly compute_aviato_point: (a: number, b: number) => number;
|
|
582
|
-
readonly compute_crash_point: (a: number, b: number) => number;
|
|
583
|
-
readonly compute_drawn_keno: (a: number, b: number, c: number) => void;
|
|
584
|
-
readonly compute_multi_dice: (a: number) => bigint;
|
|
585
|
-
readonly compute_payout_aviato: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
586
|
-
readonly compute_payout_blackjack: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => void;
|
|
587
|
-
readonly compute_payout_coinflip: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
588
|
-
readonly compute_payout_crash: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
589
|
-
readonly compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
590
|
-
readonly compute_payout_keno: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
591
|
-
readonly compute_payout_limbo: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
592
|
-
readonly compute_payout_plinko: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
593
|
-
readonly compute_prediction_hash: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
594
|
-
readonly compute_prediction_hash_keno: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
595
|
-
readonly compute_roll_coinflip: (a: number, b: number) => number;
|
|
596
|
-
readonly compute_roll_dice: (a: number, b: number) => number;
|
|
597
|
-
readonly compute_roll_limbo: (a: number, b: number) => number;
|
|
598
|
-
readonly compute_roll_plinko: (a: number, b: number, c: number) => number;
|
|
599
|
-
readonly compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
600
|
-
readonly compute_user_seed_binding: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number) => void;
|
|
601
|
-
readonly derive_session_key: (a: number, b: number, c: number) => void;
|
|
602
|
-
readonly encode_keno_selected: (a: number, b: number, c: number) => void;
|
|
603
|
-
readonly generate_user_secret: (a: number) => void;
|
|
604
|
-
readonly generate_user_seed: (a: number) => void;
|
|
605
|
-
readonly goldilocks_fields_to_hex: (a: number, b: number, c: number) => void;
|
|
606
|
-
readonly goldilocks_reduce: (a: bigint) => bigint;
|
|
607
|
-
readonly hash_balance_leaf: (a: number, b: number, c: number) => void;
|
|
608
|
-
readonly keno_all_rtp_x100: () => number;
|
|
609
|
-
readonly keno_draw_count: () => number;
|
|
610
|
-
readonly keno_is_valid_config: (a: number, b: number) => number;
|
|
611
|
-
readonly keno_multiplier_table: (a: number, b: number, c: number) => void;
|
|
612
|
-
readonly keno_numbers_range: () => number;
|
|
613
|
-
readonly keno_rtp_x100: (a: number, b: number) => bigint;
|
|
614
|
-
readonly limbo_rtp_percent: () => number;
|
|
615
|
-
readonly make_main_leaf: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
616
|
-
readonly plinko_all_rtp_x100: () => number;
|
|
617
|
-
readonly plinko_is_valid_config: (a: number, b: number, c: number) => number;
|
|
618
|
-
readonly plinko_is_valid_rows: (a: number) => number;
|
|
619
|
-
readonly plinko_max_rows: () => number;
|
|
620
|
-
readonly plinko_min_rows: () => number;
|
|
621
|
-
readonly plinko_multiplier_table: (a: number, b: number, c: number, d: number) => void;
|
|
622
|
-
readonly plinko_num_sectors: () => number;
|
|
623
|
-
readonly plinko_rtp_x100: (a: number, b: number, c: number) => bigint;
|
|
624
|
-
readonly poseidon2_hash: (a: number, b: number, c: number) => void;
|
|
625
|
-
readonly poseidon2_two_to_one: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
626
|
-
readonly seed_hash_truncated: (a: number, b: number, c: number) => void;
|
|
627
|
-
readonly session_public_key: (a: number, b: number, c: number, d: bigint) => void;
|
|
628
|
-
readonly string_to_user_seed: (a: number, b: number, c: number) => void;
|
|
629
|
-
readonly string_to_user_seed_hex: (a: number, b: number, c: number) => void;
|
|
630
|
-
readonly validate_slot: (a: number, b: number) => void;
|
|
631
|
-
readonly coinflip_rtp_percent: () => number;
|
|
632
|
-
readonly crash_rtp_percent: () => number;
|
|
633
|
-
readonly dice_rtp_percent: () => number;
|
|
634
|
-
readonly keno_max_picks: () => number;
|
|
635
|
-
readonly goldilocks_modulus: () => bigint;
|
|
636
|
-
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
637
|
-
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
638
|
-
readonly __wbindgen_export3: (a: number) => void;
|
|
639
|
-
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
640
|
-
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
647
|
-
* a precompiled `WebAssembly.Module`.
|
|
648
|
-
*
|
|
649
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
650
|
-
*
|
|
651
|
-
* @returns {InitOutput}
|
|
652
|
-
*/
|
|
653
|
-
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
657
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
658
|
-
*
|
|
659
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
660
|
-
*
|
|
661
|
-
* @returns {Promise<InitOutput>}
|
|
662
|
-
*/
|
|
663
|
-
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|