@rolly-dev/wasm-signer 1.28.1 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/rolly_wasm_signer.d.ts +89 -12
- package/dist/node/rolly_wasm_signer.js +185 -14
- package/dist/node/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/node/rolly_wasm_signer_bg.wasm.d.ts +6 -0
- package/dist/node-inline/rolly_wasm_signer.d.ts +89 -12
- package/dist/node-inline/rolly_wasm_signer.js +186 -15
- package/dist/node-inline/rolly_wasm_signer.mjs +181 -16
- package/dist/node-inline/rolly_wasm_signer_bg.wasm.d.ts +6 -0
- package/dist/web/rolly_wasm_signer.d.ts +95 -12
- package/dist/web/rolly_wasm_signer.js +179 -14
- package/dist/web/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/web/rolly_wasm_signer_bg.wasm.d.ts +6 -0
- package/js/browser.mjs +6 -0
- package/js/index.d.ts +6 -0
- package/js/node-inline.cjs +6 -0
- package/js/node-inline.mjs +6 -0
- package/js/node.cjs +6 -0
- package/js/node.mjs +6 -0
- package/js/react.mjs +12 -0
- package/package.json +1 -1
|
@@ -13,10 +13,45 @@
|
|
|
13
13
|
export function amount_split(amount: bigint): Uint32Array;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Backward-compatible alias for `crash_rtp_percent`.
|
|
17
17
|
*/
|
|
18
18
|
export function aviato_rtp_percent(): number;
|
|
19
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
|
+
|
|
20
55
|
/**
|
|
21
56
|
* CoinFlip multiplier × 10000 (19800 = 1.98×). Canonical source for backend/frontend.
|
|
22
57
|
*/
|
|
@@ -34,12 +69,17 @@ export function coinflip_rtp_percent(): number;
|
|
|
34
69
|
export function compute_address_hash(address_hex: string): BigUint64Array;
|
|
35
70
|
|
|
36
71
|
/**
|
|
37
|
-
*
|
|
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.
|
|
38
78
|
*
|
|
39
79
|
* `random` must be exactly 4 elements (first 4 fields of server_seed).
|
|
40
|
-
* Returns the clamped
|
|
80
|
+
* Returns the clamped crash multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
|
|
41
81
|
*/
|
|
42
|
-
export function
|
|
82
|
+
export function compute_crash_point(random: BigUint64Array): number;
|
|
43
83
|
|
|
44
84
|
/**
|
|
45
85
|
* Extract the 10 drawn numbers from Poseidon2 random output using
|
|
@@ -59,17 +99,36 @@ export function compute_drawn_keno(random: BigUint64Array): Uint8Array;
|
|
|
59
99
|
export function compute_multi_dice(win_numbers: number): bigint;
|
|
60
100
|
|
|
61
101
|
/**
|
|
62
|
-
*
|
|
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.
|
|
63
108
|
*
|
|
64
|
-
*
|
|
65
|
-
* `
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
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`].
|
|
69
122
|
*
|
|
70
|
-
* Returns
|
|
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
|
+
* ```
|
|
71
130
|
*/
|
|
72
|
-
export function
|
|
131
|
+
export function compute_payout_blackjack(server_seed: BigUint64Array, user_secret_random: BigUint64Array, prediction_lo: number, prediction_hi: number, base_bet: bigint): any;
|
|
73
132
|
|
|
74
133
|
/**
|
|
75
134
|
* Full coinflip payout computation — pure integer arithmetic, zero floats.
|
|
@@ -82,6 +141,19 @@ export function compute_payout_aviato(random: BigUint64Array, bet_atomic: bigint
|
|
|
82
141
|
*/
|
|
83
142
|
export function compute_payout_coinflip(random: BigUint64Array, bet_atomic: bigint, prediction: number): BigUint64Array;
|
|
84
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Full crash payout computation — pure integer arithmetic, zero floats.
|
|
146
|
+
*
|
|
147
|
+
* `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
|
|
148
|
+
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
149
|
+
* `cashout_x100`: multiplier at which the user cashed out (×100).
|
|
150
|
+
* - 0 = user did NOT cash out (loss).
|
|
151
|
+
* - 100..=1_000_000 = user stopped at this multiplier.
|
|
152
|
+
*
|
|
153
|
+
* Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
|
|
154
|
+
*/
|
|
155
|
+
export function compute_payout_crash(random: BigUint64Array, bet_atomic: bigint, cashout_x100: number): BigUint64Array;
|
|
156
|
+
|
|
85
157
|
/**
|
|
86
158
|
* Full dice payout computation — pure integer arithmetic, zero floats.
|
|
87
159
|
*
|
|
@@ -211,6 +283,11 @@ export function compute_server_seed_hash(server_seed: BigUint64Array): BigUint64
|
|
|
211
283
|
*/
|
|
212
284
|
export function compute_user_seed_binding(game_id: number, bet: bigint, pred_hash: BigUint64Array, secret: BigUint64Array): BigUint64Array;
|
|
213
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Crash RTP percent (99). Canonical source for backend/frontend.
|
|
288
|
+
*/
|
|
289
|
+
export function crash_rtp_percent(): number;
|
|
290
|
+
|
|
214
291
|
/**
|
|
215
292
|
* Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
|
|
216
293
|
*
|
|
@@ -27,7 +27,7 @@ function amount_split(amount) {
|
|
|
27
27
|
exports.amount_split = amount_split;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Backward-compatible alias for `crash_rtp_percent`.
|
|
31
31
|
* @returns {number}
|
|
32
32
|
*/
|
|
33
33
|
function aviato_rtp_percent() {
|
|
@@ -36,6 +36,78 @@ function aviato_rtp_percent() {
|
|
|
36
36
|
}
|
|
37
37
|
exports.aviato_rtp_percent = aviato_rtp_percent;
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Reconstruct the 30 dealt Blackjack rank codes from the fairness seeds.
|
|
41
|
+
*
|
|
42
|
+
* This is the SINGLE client/backend-side mirror of the native shoe unfold in
|
|
43
|
+
* `tx_validator::blackjack::unfold_shoe` and the in-circuit shuffle: it computes
|
|
44
|
+
* `mix = Poseidon2(server_seed ‖ user_secret_random)` and the per-step swap
|
|
45
|
+
* randomness `low32(Poseidon2(mix ‖ k))`, then defers the deterministic
|
|
46
|
+
* 30-swap partial Fisher–Yates over the fixed 416-card layout to the pure
|
|
47
|
+
* `rolly_game_core::blackjack::deal_shoe`. Mixing the player-chosen
|
|
48
|
+
* `user_secret_random` into the seed makes the shuffle a mutual commit–reveal,
|
|
49
|
+
* so neither the operator nor the player can pre-grind a shoe.
|
|
50
|
+
*
|
|
51
|
+
* `server_seed` must be 8 elements (the full fairness preimage); `user_secret_random`
|
|
52
|
+
* must be 4 elements (`string_to_user_seed(user_seed_source)`).
|
|
53
|
+
*
|
|
54
|
+
* **Output**: `Uint8Array` of length 30 — rank codes `0..=12` (Ace=0, 2..9=1..8,
|
|
55
|
+
* 10/J/Q/K=9..12). Suits are cosmetic and restored off-engine.
|
|
56
|
+
*
|
|
57
|
+
* ```js
|
|
58
|
+
* const shoe = blackjack_deal_shoe(serverSeed8, userSecret4); // length 30
|
|
59
|
+
* ```
|
|
60
|
+
* @param {BigUint64Array} server_seed
|
|
61
|
+
* @param {BigUint64Array} user_secret_random
|
|
62
|
+
* @returns {Uint8Array}
|
|
63
|
+
*/
|
|
64
|
+
function blackjack_deal_shoe(server_seed, user_secret_random) {
|
|
65
|
+
try {
|
|
66
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
67
|
+
const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export);
|
|
68
|
+
const len0 = WASM_VECTOR_LEN;
|
|
69
|
+
const ptr1 = passArray64ToWasm0(user_secret_random, wasm.__wbindgen_export);
|
|
70
|
+
const len1 = WASM_VECTOR_LEN;
|
|
71
|
+
wasm.blackjack_deal_shoe(retptr, ptr0, len0, ptr1, len1);
|
|
72
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
73
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
74
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
75
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
76
|
+
return v3;
|
|
77
|
+
} finally {
|
|
78
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.blackjack_deal_shoe = blackjack_deal_shoe;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Pack a Blackjack action sequence into the two base-8 halves the rollup records
|
|
85
|
+
* as `prediction_lo` / `prediction_hi` (`actions[0..10]` → lo, `actions[10..20]`
|
|
86
|
+
* → hi). Single-sources `rolly_game_core::blackjack::pack_actions` so the
|
|
87
|
+
* backend feeds the WitnessEngine exactly what the circuit re-derives.
|
|
88
|
+
*
|
|
89
|
+
* `actions` are the `ACTION_*` codes (1..=6). **Output**: `Uint32Array` of
|
|
90
|
+
* length 2 = `[prediction_lo, prediction_hi]`.
|
|
91
|
+
* @param {Uint8Array} actions
|
|
92
|
+
* @returns {Uint32Array}
|
|
93
|
+
*/
|
|
94
|
+
function blackjack_pack_actions(actions) {
|
|
95
|
+
try {
|
|
96
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
97
|
+
const ptr0 = passArray8ToWasm0(actions, wasm.__wbindgen_export);
|
|
98
|
+
const len0 = WASM_VECTOR_LEN;
|
|
99
|
+
wasm.blackjack_pack_actions(retptr, ptr0, len0);
|
|
100
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
101
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
102
|
+
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
103
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
104
|
+
return v2;
|
|
105
|
+
} finally {
|
|
106
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.blackjack_pack_actions = blackjack_pack_actions;
|
|
110
|
+
|
|
39
111
|
/**
|
|
40
112
|
* CoinFlip multiplier × 10000 (19800 = 1.98×). Canonical source for backend/frontend.
|
|
41
113
|
* @returns {number}
|
|
@@ -80,10 +152,7 @@ function compute_address_hash(address_hex) {
|
|
|
80
152
|
exports.compute_address_hash = compute_address_hash;
|
|
81
153
|
|
|
82
154
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* `random` must be exactly 4 elements (first 4 fields of server_seed).
|
|
86
|
-
* Returns the clamped aviato multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
|
|
155
|
+
* Backward-compatible alias for `compute_crash_point`.
|
|
87
156
|
* @param {BigUint64Array} random
|
|
88
157
|
* @returns {number}
|
|
89
158
|
*/
|
|
@@ -95,6 +164,22 @@ function compute_aviato_point(random) {
|
|
|
95
164
|
}
|
|
96
165
|
exports.compute_aviato_point = compute_aviato_point;
|
|
97
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Extract crash point (×100) from raw server seed fields.
|
|
169
|
+
*
|
|
170
|
+
* `random` must be exactly 4 elements (first 4 fields of server_seed).
|
|
171
|
+
* Returns the clamped crash multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
|
|
172
|
+
* @param {BigUint64Array} random
|
|
173
|
+
* @returns {number}
|
|
174
|
+
*/
|
|
175
|
+
function compute_crash_point(random) {
|
|
176
|
+
const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
|
|
177
|
+
const len0 = WASM_VECTOR_LEN;
|
|
178
|
+
const ret = wasm.compute_crash_point(ptr0, len0);
|
|
179
|
+
return ret >>> 0;
|
|
180
|
+
}
|
|
181
|
+
exports.compute_crash_point = compute_crash_point;
|
|
182
|
+
|
|
98
183
|
/**
|
|
99
184
|
* Extract the 10 drawn numbers from Poseidon2 random output using
|
|
100
185
|
* the combinatorial number system: `combo_index = random[0] % C(40,10)`.
|
|
@@ -136,15 +221,7 @@ function compute_multi_dice(win_numbers) {
|
|
|
136
221
|
exports.compute_multi_dice = compute_multi_dice;
|
|
137
222
|
|
|
138
223
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
|
|
142
|
-
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
143
|
-
* `cashout_x100`: multiplier at which the user cashed out (×100).
|
|
144
|
-
* - 0 = user did NOT cash out (loss).
|
|
145
|
-
* - 100..=1_000_000 = user stopped at this multiplier.
|
|
146
|
-
*
|
|
147
|
-
* Returns `BigUint64Array[4]`: `[win_amount, aviato_x100, is_win (0|1), multiplier×10000]`.
|
|
224
|
+
* Backward-compatible alias for `compute_payout_crash`.
|
|
148
225
|
* @param {BigUint64Array} random
|
|
149
226
|
* @param {bigint} bet_atomic
|
|
150
227
|
* @param {number} cashout_x100
|
|
@@ -167,6 +244,58 @@ function compute_payout_aviato(random, bet_atomic, cashout_x100) {
|
|
|
167
244
|
}
|
|
168
245
|
exports.compute_payout_aviato = compute_payout_aviato;
|
|
169
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Client-side provably-fair verification of a full Blackjack round.
|
|
249
|
+
*
|
|
250
|
+
* Reconstructs the fair shoe from `(server_seed ‖ user_secret_random)` (see
|
|
251
|
+
* [`blackjack_deal_shoe`]), decodes the base-8 `prediction_lo` / `prediction_hi`
|
|
252
|
+
* action halves, and replays the exact same state machine the circuit and the
|
|
253
|
+
* tx-validator run (`rolly_game_core::blackjack::replay_full`). This lets a
|
|
254
|
+
* player independently confirm the settled `win`/`bet` off-chain; it is NOT on
|
|
255
|
+
* the tx/settlement path.
|
|
256
|
+
*
|
|
257
|
+
* `server_seed` must be 8 elements (the revealed fairness preimage);
|
|
258
|
+
* `user_secret_random` must be 4 elements (`string_to_user_seed(...)`).
|
|
259
|
+
* `base_bet` is the base stake in atomic units. The returned `total_staked`
|
|
260
|
+
* grows with double/split/insurance exactly as the engine books them.
|
|
261
|
+
*
|
|
262
|
+
* **Output**: a JS object matching [`BlackjackVerifyResult`].
|
|
263
|
+
*
|
|
264
|
+
* Returns an error if the decoded action list contains an invalid code
|
|
265
|
+
* (outside `1..=6`), mirroring the tx-validator's typed rejection.
|
|
266
|
+
*
|
|
267
|
+
* ```js
|
|
268
|
+
* const res = compute_payout_blackjack(serverSeed8, userSecret4, lo, hi, betAtomic);
|
|
269
|
+
* // res.win_amount, res.total_staked, res.shoe (length 30), ...
|
|
270
|
+
* ```
|
|
271
|
+
* @param {BigUint64Array} server_seed
|
|
272
|
+
* @param {BigUint64Array} user_secret_random
|
|
273
|
+
* @param {number} prediction_lo
|
|
274
|
+
* @param {number} prediction_hi
|
|
275
|
+
* @param {bigint} base_bet
|
|
276
|
+
* @returns {any}
|
|
277
|
+
*/
|
|
278
|
+
function compute_payout_blackjack(server_seed, user_secret_random, prediction_lo, prediction_hi, base_bet) {
|
|
279
|
+
try {
|
|
280
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
281
|
+
const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export);
|
|
282
|
+
const len0 = WASM_VECTOR_LEN;
|
|
283
|
+
const ptr1 = passArray64ToWasm0(user_secret_random, wasm.__wbindgen_export);
|
|
284
|
+
const len1 = WASM_VECTOR_LEN;
|
|
285
|
+
wasm.compute_payout_blackjack(retptr, ptr0, len0, ptr1, len1, prediction_lo, prediction_hi, base_bet);
|
|
286
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
287
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
288
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
289
|
+
if (r2) {
|
|
290
|
+
throw takeObject(r1);
|
|
291
|
+
}
|
|
292
|
+
return takeObject(r0);
|
|
293
|
+
} finally {
|
|
294
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
exports.compute_payout_blackjack = compute_payout_blackjack;
|
|
298
|
+
|
|
170
299
|
/**
|
|
171
300
|
* Full coinflip payout computation — pure integer arithmetic, zero floats.
|
|
172
301
|
*
|
|
@@ -197,6 +326,38 @@ function compute_payout_coinflip(random, bet_atomic, prediction) {
|
|
|
197
326
|
}
|
|
198
327
|
exports.compute_payout_coinflip = compute_payout_coinflip;
|
|
199
328
|
|
|
329
|
+
/**
|
|
330
|
+
* Full crash payout computation — pure integer arithmetic, zero floats.
|
|
331
|
+
*
|
|
332
|
+
* `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
|
|
333
|
+
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
334
|
+
* `cashout_x100`: multiplier at which the user cashed out (×100).
|
|
335
|
+
* - 0 = user did NOT cash out (loss).
|
|
336
|
+
* - 100..=1_000_000 = user stopped at this multiplier.
|
|
337
|
+
*
|
|
338
|
+
* Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
|
|
339
|
+
* @param {BigUint64Array} random
|
|
340
|
+
* @param {bigint} bet_atomic
|
|
341
|
+
* @param {number} cashout_x100
|
|
342
|
+
* @returns {BigUint64Array}
|
|
343
|
+
*/
|
|
344
|
+
function compute_payout_crash(random, bet_atomic, cashout_x100) {
|
|
345
|
+
try {
|
|
346
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
347
|
+
const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
|
|
348
|
+
const len0 = WASM_VECTOR_LEN;
|
|
349
|
+
wasm.compute_payout_crash(retptr, ptr0, len0, bet_atomic, cashout_x100);
|
|
350
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
351
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
352
|
+
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
353
|
+
wasm.__wbindgen_export4(r0, r1 * 8, 8);
|
|
354
|
+
return v2;
|
|
355
|
+
} finally {
|
|
356
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
exports.compute_payout_crash = compute_payout_crash;
|
|
360
|
+
|
|
200
361
|
/**
|
|
201
362
|
* Full dice payout computation — pure integer arithmetic, zero floats.
|
|
202
363
|
*
|
|
@@ -519,6 +680,16 @@ function compute_user_seed_binding(game_id, bet, pred_hash, secret) {
|
|
|
519
680
|
}
|
|
520
681
|
exports.compute_user_seed_binding = compute_user_seed_binding;
|
|
521
682
|
|
|
683
|
+
/**
|
|
684
|
+
* Crash RTP percent (99). Canonical source for backend/frontend.
|
|
685
|
+
* @returns {number}
|
|
686
|
+
*/
|
|
687
|
+
function crash_rtp_percent() {
|
|
688
|
+
const ret = wasm.aviato_rtp_percent();
|
|
689
|
+
return ret >>> 0;
|
|
690
|
+
}
|
|
691
|
+
exports.crash_rtp_percent = crash_rtp_percent;
|
|
692
|
+
|
|
522
693
|
/**
|
|
523
694
|
* Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
|
|
524
695
|
*
|
|
Binary file
|
|
@@ -3,13 +3,18 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const amount_split: (a: number, b: bigint) => void;
|
|
5
5
|
export const aviato_rtp_percent: () => number;
|
|
6
|
+
export const blackjack_deal_shoe: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
7
|
+
export const blackjack_pack_actions: (a: number, b: number, c: number) => void;
|
|
6
8
|
export const coinflip_multiplier_x10000: () => number;
|
|
7
9
|
export const compute_address_hash: (a: number, b: number, c: number) => void;
|
|
8
10
|
export const compute_aviato_point: (a: number, b: number) => number;
|
|
11
|
+
export const compute_crash_point: (a: number, b: number) => number;
|
|
9
12
|
export const compute_drawn_keno: (a: number, b: number, c: number) => void;
|
|
10
13
|
export const compute_multi_dice: (a: number) => bigint;
|
|
11
14
|
export const compute_payout_aviato: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
15
|
+
export const compute_payout_blackjack: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => void;
|
|
12
16
|
export const compute_payout_coinflip: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
17
|
+
export const compute_payout_crash: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
13
18
|
export const compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
14
19
|
export const compute_payout_keno: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
15
20
|
export const compute_payout_limbo: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
@@ -53,6 +58,7 @@ export const string_to_user_seed: (a: number, b: number, c: number) => void;
|
|
|
53
58
|
export const string_to_user_seed_hex: (a: number, b: number, c: number) => void;
|
|
54
59
|
export const validate_slot: (a: number, b: number) => void;
|
|
55
60
|
export const coinflip_rtp_percent: () => number;
|
|
61
|
+
export const crash_rtp_percent: () => number;
|
|
56
62
|
export const dice_rtp_percent: () => number;
|
|
57
63
|
export const keno_max_picks: () => number;
|
|
58
64
|
export const goldilocks_modulus: () => bigint;
|
|
@@ -13,10 +13,45 @@
|
|
|
13
13
|
export function amount_split(amount: bigint): Uint32Array;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Backward-compatible alias for `crash_rtp_percent`.
|
|
17
17
|
*/
|
|
18
18
|
export function aviato_rtp_percent(): number;
|
|
19
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
|
+
|
|
20
55
|
/**
|
|
21
56
|
* CoinFlip multiplier × 10000 (19800 = 1.98×). Canonical source for backend/frontend.
|
|
22
57
|
*/
|
|
@@ -34,12 +69,17 @@ export function coinflip_rtp_percent(): number;
|
|
|
34
69
|
export function compute_address_hash(address_hex: string): BigUint64Array;
|
|
35
70
|
|
|
36
71
|
/**
|
|
37
|
-
*
|
|
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.
|
|
38
78
|
*
|
|
39
79
|
* `random` must be exactly 4 elements (first 4 fields of server_seed).
|
|
40
|
-
* Returns the clamped
|
|
80
|
+
* Returns the clamped crash multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
|
|
41
81
|
*/
|
|
42
|
-
export function
|
|
82
|
+
export function compute_crash_point(random: BigUint64Array): number;
|
|
43
83
|
|
|
44
84
|
/**
|
|
45
85
|
* Extract the 10 drawn numbers from Poseidon2 random output using
|
|
@@ -59,17 +99,36 @@ export function compute_drawn_keno(random: BigUint64Array): Uint8Array;
|
|
|
59
99
|
export function compute_multi_dice(win_numbers: number): bigint;
|
|
60
100
|
|
|
61
101
|
/**
|
|
62
|
-
*
|
|
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.
|
|
63
108
|
*
|
|
64
|
-
*
|
|
65
|
-
* `
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
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`].
|
|
69
122
|
*
|
|
70
|
-
* Returns
|
|
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
|
+
* ```
|
|
71
130
|
*/
|
|
72
|
-
export function
|
|
131
|
+
export function compute_payout_blackjack(server_seed: BigUint64Array, user_secret_random: BigUint64Array, prediction_lo: number, prediction_hi: number, base_bet: bigint): any;
|
|
73
132
|
|
|
74
133
|
/**
|
|
75
134
|
* Full coinflip payout computation — pure integer arithmetic, zero floats.
|
|
@@ -82,6 +141,19 @@ export function compute_payout_aviato(random: BigUint64Array, bet_atomic: bigint
|
|
|
82
141
|
*/
|
|
83
142
|
export function compute_payout_coinflip(random: BigUint64Array, bet_atomic: bigint, prediction: number): BigUint64Array;
|
|
84
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Full crash payout computation — pure integer arithmetic, zero floats.
|
|
146
|
+
*
|
|
147
|
+
* `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
|
|
148
|
+
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
149
|
+
* `cashout_x100`: multiplier at which the user cashed out (×100).
|
|
150
|
+
* - 0 = user did NOT cash out (loss).
|
|
151
|
+
* - 100..=1_000_000 = user stopped at this multiplier.
|
|
152
|
+
*
|
|
153
|
+
* Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
|
|
154
|
+
*/
|
|
155
|
+
export function compute_payout_crash(random: BigUint64Array, bet_atomic: bigint, cashout_x100: number): BigUint64Array;
|
|
156
|
+
|
|
85
157
|
/**
|
|
86
158
|
* Full dice payout computation — pure integer arithmetic, zero floats.
|
|
87
159
|
*
|
|
@@ -211,6 +283,11 @@ export function compute_server_seed_hash(server_seed: BigUint64Array): BigUint64
|
|
|
211
283
|
*/
|
|
212
284
|
export function compute_user_seed_binding(game_id: number, bet: bigint, pred_hash: BigUint64Array, secret: BigUint64Array): BigUint64Array;
|
|
213
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Crash RTP percent (99). Canonical source for backend/frontend.
|
|
288
|
+
*/
|
|
289
|
+
export function crash_rtp_percent(): number;
|
|
290
|
+
|
|
214
291
|
/**
|
|
215
292
|
* Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
|
|
216
293
|
*
|