@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
|
@@ -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
|
*
|
|
@@ -492,13 +569,18 @@ export interface InitOutput {
|
|
|
492
569
|
readonly memory: WebAssembly.Memory;
|
|
493
570
|
readonly amount_split: (a: number, b: bigint) => void;
|
|
494
571
|
readonly aviato_rtp_percent: () => number;
|
|
572
|
+
readonly blackjack_deal_shoe: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
573
|
+
readonly blackjack_pack_actions: (a: number, b: number, c: number) => void;
|
|
495
574
|
readonly coinflip_multiplier_x10000: () => number;
|
|
496
575
|
readonly compute_address_hash: (a: number, b: number, c: number) => void;
|
|
497
576
|
readonly compute_aviato_point: (a: number, b: number) => number;
|
|
577
|
+
readonly compute_crash_point: (a: number, b: number) => number;
|
|
498
578
|
readonly compute_drawn_keno: (a: number, b: number, c: number) => void;
|
|
499
579
|
readonly compute_multi_dice: (a: number) => bigint;
|
|
500
580
|
readonly compute_payout_aviato: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
581
|
+
readonly compute_payout_blackjack: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => void;
|
|
501
582
|
readonly compute_payout_coinflip: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
583
|
+
readonly compute_payout_crash: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
502
584
|
readonly compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
503
585
|
readonly compute_payout_keno: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
504
586
|
readonly compute_payout_limbo: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
@@ -542,6 +624,7 @@ export interface InitOutput {
|
|
|
542
624
|
readonly string_to_user_seed_hex: (a: number, b: number, c: number) => void;
|
|
543
625
|
readonly validate_slot: (a: number, b: number) => void;
|
|
544
626
|
readonly coinflip_rtp_percent: () => number;
|
|
627
|
+
readonly crash_rtp_percent: () => number;
|
|
545
628
|
readonly dice_rtp_percent: () => number;
|
|
546
629
|
readonly keno_max_picks: () => number;
|
|
547
630
|
readonly goldilocks_modulus: () => bigint;
|
|
@@ -26,7 +26,7 @@ export function amount_split(amount) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Backward-compatible alias for `crash_rtp_percent`.
|
|
30
30
|
* @returns {number}
|
|
31
31
|
*/
|
|
32
32
|
export function aviato_rtp_percent() {
|
|
@@ -34,6 +34,76 @@ export function aviato_rtp_percent() {
|
|
|
34
34
|
return ret >>> 0;
|
|
35
35
|
}
|
|
36
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
|
+
|
|
37
107
|
/**
|
|
38
108
|
* CoinFlip multiplier × 10000 (19800 = 1.98×). Canonical source for backend/frontend.
|
|
39
109
|
* @returns {number}
|
|
@@ -75,10 +145,7 @@ export function compute_address_hash(address_hex) {
|
|
|
75
145
|
}
|
|
76
146
|
|
|
77
147
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* `random` must be exactly 4 elements (first 4 fields of server_seed).
|
|
81
|
-
* Returns the clamped aviato multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
|
|
148
|
+
* Backward-compatible alias for `compute_crash_point`.
|
|
82
149
|
* @param {BigUint64Array} random
|
|
83
150
|
* @returns {number}
|
|
84
151
|
*/
|
|
@@ -89,6 +156,21 @@ export function compute_aviato_point(random) {
|
|
|
89
156
|
return ret >>> 0;
|
|
90
157
|
}
|
|
91
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
|
+
|
|
92
174
|
/**
|
|
93
175
|
* Extract the 10 drawn numbers from Poseidon2 random output using
|
|
94
176
|
* the combinatorial number system: `combo_index = random[0] % C(40,10)`.
|
|
@@ -128,15 +210,7 @@ export function compute_multi_dice(win_numbers) {
|
|
|
128
210
|
}
|
|
129
211
|
|
|
130
212
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
|
|
134
|
-
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
135
|
-
* `cashout_x100`: multiplier at which the user cashed out (×100).
|
|
136
|
-
* - 0 = user did NOT cash out (loss).
|
|
137
|
-
* - 100..=1_000_000 = user stopped at this multiplier.
|
|
138
|
-
*
|
|
139
|
-
* Returns `BigUint64Array[4]`: `[win_amount, aviato_x100, is_win (0|1), multiplier×10000]`.
|
|
213
|
+
* Backward-compatible alias for `compute_payout_crash`.
|
|
140
214
|
* @param {BigUint64Array} random
|
|
141
215
|
* @param {bigint} bet_atomic
|
|
142
216
|
* @param {number} cashout_x100
|
|
@@ -158,6 +232,57 @@ export function compute_payout_aviato(random, bet_atomic, cashout_x100) {
|
|
|
158
232
|
}
|
|
159
233
|
}
|
|
160
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
|
+
* ```
|
|
259
|
+
* @param {BigUint64Array} server_seed
|
|
260
|
+
* @param {BigUint64Array} user_secret_random
|
|
261
|
+
* @param {number} prediction_lo
|
|
262
|
+
* @param {number} prediction_hi
|
|
263
|
+
* @param {bigint} base_bet
|
|
264
|
+
* @returns {any}
|
|
265
|
+
*/
|
|
266
|
+
export function compute_payout_blackjack(server_seed, user_secret_random, prediction_lo, prediction_hi, base_bet) {
|
|
267
|
+
try {
|
|
268
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
269
|
+
const ptr0 = passArray64ToWasm0(server_seed, wasm.__wbindgen_export);
|
|
270
|
+
const len0 = WASM_VECTOR_LEN;
|
|
271
|
+
const ptr1 = passArray64ToWasm0(user_secret_random, wasm.__wbindgen_export);
|
|
272
|
+
const len1 = WASM_VECTOR_LEN;
|
|
273
|
+
wasm.compute_payout_blackjack(retptr, ptr0, len0, ptr1, len1, prediction_lo, prediction_hi, base_bet);
|
|
274
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
275
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
276
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
277
|
+
if (r2) {
|
|
278
|
+
throw takeObject(r1);
|
|
279
|
+
}
|
|
280
|
+
return takeObject(r0);
|
|
281
|
+
} finally {
|
|
282
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
161
286
|
/**
|
|
162
287
|
* Full coinflip payout computation — pure integer arithmetic, zero floats.
|
|
163
288
|
*
|
|
@@ -187,6 +312,37 @@ export function compute_payout_coinflip(random, bet_atomic, prediction) {
|
|
|
187
312
|
}
|
|
188
313
|
}
|
|
189
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Full crash payout computation — pure integer arithmetic, zero floats.
|
|
317
|
+
*
|
|
318
|
+
* `random`: 4 Goldilocks field elements (first 4 fields of raw server_seed).
|
|
319
|
+
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
320
|
+
* `cashout_x100`: multiplier at which the user cashed out (×100).
|
|
321
|
+
* - 0 = user did NOT cash out (loss).
|
|
322
|
+
* - 100..=1_000_000 = user stopped at this multiplier.
|
|
323
|
+
*
|
|
324
|
+
* Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
|
|
325
|
+
* @param {BigUint64Array} random
|
|
326
|
+
* @param {bigint} bet_atomic
|
|
327
|
+
* @param {number} cashout_x100
|
|
328
|
+
* @returns {BigUint64Array}
|
|
329
|
+
*/
|
|
330
|
+
export function compute_payout_crash(random, bet_atomic, cashout_x100) {
|
|
331
|
+
try {
|
|
332
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
333
|
+
const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export);
|
|
334
|
+
const len0 = WASM_VECTOR_LEN;
|
|
335
|
+
wasm.compute_payout_crash(retptr, ptr0, len0, bet_atomic, cashout_x100);
|
|
336
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
337
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
338
|
+
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
339
|
+
wasm.__wbindgen_export4(r0, r1 * 8, 8);
|
|
340
|
+
return v2;
|
|
341
|
+
} finally {
|
|
342
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
190
346
|
/**
|
|
191
347
|
* Full dice payout computation — pure integer arithmetic, zero floats.
|
|
192
348
|
*
|
|
@@ -497,6 +653,15 @@ export function compute_user_seed_binding(game_id, bet, pred_hash, secret) {
|
|
|
497
653
|
}
|
|
498
654
|
}
|
|
499
655
|
|
|
656
|
+
/**
|
|
657
|
+
* Crash RTP percent (99). Canonical source for backend/frontend.
|
|
658
|
+
* @returns {number}
|
|
659
|
+
*/
|
|
660
|
+
export function crash_rtp_percent() {
|
|
661
|
+
const ret = wasm.aviato_rtp_percent();
|
|
662
|
+
return ret >>> 0;
|
|
663
|
+
}
|
|
664
|
+
|
|
500
665
|
/**
|
|
501
666
|
* Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
|
|
502
667
|
*
|
|
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;
|
package/js/browser.mjs
CHANGED
|
@@ -3,14 +3,19 @@ export { default as init } from '../dist/web/rolly_wasm_signer.js';
|
|
|
3
3
|
export {
|
|
4
4
|
amount_split,
|
|
5
5
|
aviato_rtp_percent,
|
|
6
|
+
blackjack_deal_shoe,
|
|
7
|
+
blackjack_pack_actions,
|
|
6
8
|
coinflip_multiplier_x10000,
|
|
7
9
|
coinflip_rtp_percent,
|
|
8
10
|
compute_address_hash,
|
|
9
11
|
compute_aviato_point,
|
|
12
|
+
compute_crash_point,
|
|
10
13
|
compute_drawn_keno,
|
|
11
14
|
compute_multi_dice,
|
|
12
15
|
compute_payout_aviato,
|
|
16
|
+
compute_payout_blackjack,
|
|
13
17
|
compute_payout_coinflip,
|
|
18
|
+
compute_payout_crash,
|
|
14
19
|
compute_payout_dice,
|
|
15
20
|
compute_payout_keno,
|
|
16
21
|
compute_payout_limbo,
|
|
@@ -23,6 +28,7 @@ export {
|
|
|
23
28
|
compute_roll_plinko,
|
|
24
29
|
compute_server_seed_hash,
|
|
25
30
|
compute_user_seed_binding,
|
|
31
|
+
crash_rtp_percent,
|
|
26
32
|
derive_session_key,
|
|
27
33
|
dice_rtp_percent,
|
|
28
34
|
encode_keno_selected,
|
package/js/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
export {
|
|
2
2
|
amount_split,
|
|
3
3
|
aviato_rtp_percent,
|
|
4
|
+
blackjack_deal_shoe,
|
|
5
|
+
blackjack_pack_actions,
|
|
4
6
|
coinflip_multiplier_x10000,
|
|
5
7
|
coinflip_rtp_percent,
|
|
6
8
|
compute_address_hash,
|
|
7
9
|
compute_aviato_point,
|
|
10
|
+
compute_crash_point,
|
|
8
11
|
compute_drawn_keno,
|
|
9
12
|
compute_multi_dice,
|
|
10
13
|
compute_payout_aviato,
|
|
14
|
+
compute_payout_blackjack,
|
|
11
15
|
compute_payout_coinflip,
|
|
16
|
+
compute_payout_crash,
|
|
12
17
|
compute_payout_dice,
|
|
13
18
|
compute_payout_keno,
|
|
14
19
|
compute_payout_limbo,
|
|
@@ -21,6 +26,7 @@ export {
|
|
|
21
26
|
compute_roll_plinko,
|
|
22
27
|
compute_server_seed_hash,
|
|
23
28
|
compute_user_seed_binding,
|
|
29
|
+
crash_rtp_percent,
|
|
24
30
|
derive_session_key,
|
|
25
31
|
dice_rtp_percent,
|
|
26
32
|
encode_keno_selected,
|
package/js/node-inline.cjs
CHANGED
|
@@ -5,14 +5,19 @@ const wasm = require('../dist/node-inline/rolly_wasm_signer.js');
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
amount_split: wasm.amount_split,
|
|
7
7
|
aviato_rtp_percent: wasm.aviato_rtp_percent,
|
|
8
|
+
blackjack_deal_shoe: wasm.blackjack_deal_shoe,
|
|
9
|
+
blackjack_pack_actions: wasm.blackjack_pack_actions,
|
|
8
10
|
coinflip_multiplier_x10000: wasm.coinflip_multiplier_x10000,
|
|
9
11
|
coinflip_rtp_percent: wasm.coinflip_rtp_percent,
|
|
10
12
|
compute_address_hash: wasm.compute_address_hash,
|
|
11
13
|
compute_aviato_point: wasm.compute_aviato_point,
|
|
14
|
+
compute_crash_point: wasm.compute_crash_point,
|
|
12
15
|
compute_drawn_keno: wasm.compute_drawn_keno,
|
|
13
16
|
compute_multi_dice: wasm.compute_multi_dice,
|
|
14
17
|
compute_payout_aviato: wasm.compute_payout_aviato,
|
|
18
|
+
compute_payout_blackjack: wasm.compute_payout_blackjack,
|
|
15
19
|
compute_payout_coinflip: wasm.compute_payout_coinflip,
|
|
20
|
+
compute_payout_crash: wasm.compute_payout_crash,
|
|
16
21
|
compute_payout_dice: wasm.compute_payout_dice,
|
|
17
22
|
compute_payout_keno: wasm.compute_payout_keno,
|
|
18
23
|
compute_payout_limbo: wasm.compute_payout_limbo,
|
|
@@ -25,6 +30,7 @@ module.exports = {
|
|
|
25
30
|
compute_roll_plinko: wasm.compute_roll_plinko,
|
|
26
31
|
compute_server_seed_hash: wasm.compute_server_seed_hash,
|
|
27
32
|
compute_user_seed_binding: wasm.compute_user_seed_binding,
|
|
33
|
+
crash_rtp_percent: wasm.crash_rtp_percent,
|
|
28
34
|
derive_session_key: wasm.derive_session_key,
|
|
29
35
|
dice_rtp_percent: wasm.dice_rtp_percent,
|
|
30
36
|
encode_keno_selected: wasm.encode_keno_selected,
|
package/js/node-inline.mjs
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
export {
|
|
2
2
|
amount_split,
|
|
3
3
|
aviato_rtp_percent,
|
|
4
|
+
blackjack_deal_shoe,
|
|
5
|
+
blackjack_pack_actions,
|
|
4
6
|
coinflip_multiplier_x10000,
|
|
5
7
|
coinflip_rtp_percent,
|
|
6
8
|
compute_address_hash,
|
|
7
9
|
compute_aviato_point,
|
|
10
|
+
compute_crash_point,
|
|
8
11
|
compute_drawn_keno,
|
|
9
12
|
compute_multi_dice,
|
|
10
13
|
compute_payout_aviato,
|
|
14
|
+
compute_payout_blackjack,
|
|
11
15
|
compute_payout_coinflip,
|
|
16
|
+
compute_payout_crash,
|
|
12
17
|
compute_payout_dice,
|
|
13
18
|
compute_payout_keno,
|
|
14
19
|
compute_payout_limbo,
|
|
@@ -21,6 +26,7 @@ export {
|
|
|
21
26
|
compute_roll_plinko,
|
|
22
27
|
compute_server_seed_hash,
|
|
23
28
|
compute_user_seed_binding,
|
|
29
|
+
crash_rtp_percent,
|
|
24
30
|
derive_session_key,
|
|
25
31
|
dice_rtp_percent,
|
|
26
32
|
encode_keno_selected,
|
package/js/node.cjs
CHANGED
|
@@ -5,14 +5,19 @@ const wasm = require('../dist/node/rolly_wasm_signer.js');
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
amount_split: wasm.amount_split,
|
|
7
7
|
aviato_rtp_percent: wasm.aviato_rtp_percent,
|
|
8
|
+
blackjack_deal_shoe: wasm.blackjack_deal_shoe,
|
|
9
|
+
blackjack_pack_actions: wasm.blackjack_pack_actions,
|
|
8
10
|
coinflip_multiplier_x10000: wasm.coinflip_multiplier_x10000,
|
|
9
11
|
coinflip_rtp_percent: wasm.coinflip_rtp_percent,
|
|
10
12
|
compute_address_hash: wasm.compute_address_hash,
|
|
11
13
|
compute_aviato_point: wasm.compute_aviato_point,
|
|
14
|
+
compute_crash_point: wasm.compute_crash_point,
|
|
12
15
|
compute_drawn_keno: wasm.compute_drawn_keno,
|
|
13
16
|
compute_multi_dice: wasm.compute_multi_dice,
|
|
14
17
|
compute_payout_aviato: wasm.compute_payout_aviato,
|
|
18
|
+
compute_payout_blackjack: wasm.compute_payout_blackjack,
|
|
15
19
|
compute_payout_coinflip: wasm.compute_payout_coinflip,
|
|
20
|
+
compute_payout_crash: wasm.compute_payout_crash,
|
|
16
21
|
compute_payout_dice: wasm.compute_payout_dice,
|
|
17
22
|
compute_payout_keno: wasm.compute_payout_keno,
|
|
18
23
|
compute_payout_limbo: wasm.compute_payout_limbo,
|
|
@@ -25,6 +30,7 @@ module.exports = {
|
|
|
25
30
|
compute_roll_plinko: wasm.compute_roll_plinko,
|
|
26
31
|
compute_server_seed_hash: wasm.compute_server_seed_hash,
|
|
27
32
|
compute_user_seed_binding: wasm.compute_user_seed_binding,
|
|
33
|
+
crash_rtp_percent: wasm.crash_rtp_percent,
|
|
28
34
|
derive_session_key: wasm.derive_session_key,
|
|
29
35
|
dice_rtp_percent: wasm.dice_rtp_percent,
|
|
30
36
|
encode_keno_selected: wasm.encode_keno_selected,
|
package/js/node.mjs
CHANGED
|
@@ -6,14 +6,19 @@ const wasm = require('../dist/node/rolly_wasm_signer.js');
|
|
|
6
6
|
export const {
|
|
7
7
|
amount_split,
|
|
8
8
|
aviato_rtp_percent,
|
|
9
|
+
blackjack_deal_shoe,
|
|
10
|
+
blackjack_pack_actions,
|
|
9
11
|
coinflip_multiplier_x10000,
|
|
10
12
|
coinflip_rtp_percent,
|
|
11
13
|
compute_address_hash,
|
|
12
14
|
compute_aviato_point,
|
|
15
|
+
compute_crash_point,
|
|
13
16
|
compute_drawn_keno,
|
|
14
17
|
compute_multi_dice,
|
|
15
18
|
compute_payout_aviato,
|
|
19
|
+
compute_payout_blackjack,
|
|
16
20
|
compute_payout_coinflip,
|
|
21
|
+
compute_payout_crash,
|
|
17
22
|
compute_payout_dice,
|
|
18
23
|
compute_payout_keno,
|
|
19
24
|
compute_payout_limbo,
|
|
@@ -26,6 +31,7 @@ export const {
|
|
|
26
31
|
compute_roll_plinko,
|
|
27
32
|
compute_server_seed_hash,
|
|
28
33
|
compute_user_seed_binding,
|
|
34
|
+
crash_rtp_percent,
|
|
29
35
|
derive_session_key,
|
|
30
36
|
dice_rtp_percent,
|
|
31
37
|
encode_keno_selected,
|