@rolly-dev/wasm-signer 1.20.0 → 1.21.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.
@@ -28,6 +28,14 @@ export function coinflip_rtp_percent(): number;
28
28
  */
29
29
  export function compute_address_hash(address_hex: string): BigUint64Array;
30
30
 
31
+ /**
32
+ * Extract crash point (×100) from Poseidon2 random output.
33
+ *
34
+ * `random` must be exactly 4 elements.
35
+ * Returns the clamped crash multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
36
+ */
37
+ export function compute_crash_point(random: BigUint64Array): number;
38
+
31
39
  /**
32
40
  * Extract the 10 drawn numbers from Poseidon2 random output using
33
41
  * the combinatorial number system: `combo_index = random[0] % C(40,10)`.
@@ -56,6 +64,19 @@ export function compute_multi_dice(win_numbers: number): bigint;
56
64
  */
57
65
  export function compute_payout_coinflip(random: BigUint64Array, bet_atomic: bigint, prediction: number): BigUint64Array;
58
66
 
67
+ /**
68
+ * Full crash payout computation — pure integer arithmetic, zero floats.
69
+ *
70
+ * `random`: 4 Goldilocks field elements (Poseidon2 output of server_seed).
71
+ * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
72
+ * `cashout_x100`: multiplier at which the user cashed out (×100).
73
+ * - 0 = user did NOT cash out (loss).
74
+ * - 100..=1_000_000 = user stopped at this multiplier.
75
+ *
76
+ * Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
77
+ */
78
+ export function compute_payout_crash(random: BigUint64Array, bet_atomic: bigint, cashout_x100: number): BigUint64Array;
79
+
59
80
  /**
60
81
  * Full dice payout computation — pure integer arithmetic, zero floats.
61
82
  *
@@ -185,6 +206,11 @@ export function compute_server_seed_hash(server_seed: BigUint64Array): BigUint64
185
206
  */
186
207
  export function compute_user_seed_binding(game_id: number, bet: bigint, pred_hash: BigUint64Array, secret: BigUint64Array): BigUint64Array;
187
208
 
209
+ /**
210
+ * Crash RTP percent (99). Canonical source for backend/frontend.
211
+ */
212
+ export function crash_rtp_percent(): number;
213
+
188
214
  /**
189
215
  * Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
190
216
  *
@@ -69,6 +69,22 @@ function compute_address_hash(address_hex) {
69
69
  }
70
70
  exports.compute_address_hash = compute_address_hash;
71
71
 
72
+ /**
73
+ * Extract crash point (×100) from Poseidon2 random output.
74
+ *
75
+ * `random` must be exactly 4 elements.
76
+ * Returns the clamped crash multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
77
+ * @param {BigUint64Array} random
78
+ * @returns {number}
79
+ */
80
+ function compute_crash_point(random) {
81
+ const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
82
+ const len0 = WASM_VECTOR_LEN;
83
+ const ret = wasm.compute_crash_point(ptr0, len0);
84
+ return ret >>> 0;
85
+ }
86
+ exports.compute_crash_point = compute_crash_point;
87
+
72
88
  /**
73
89
  * Extract the 10 drawn numbers from Poseidon2 random output using
74
90
  * the combinatorial number system: `combo_index = random[0] % C(40,10)`.
@@ -139,6 +155,38 @@ function compute_payout_coinflip(random, bet_atomic, prediction) {
139
155
  }
140
156
  exports.compute_payout_coinflip = compute_payout_coinflip;
141
157
 
158
+ /**
159
+ * Full crash payout computation — pure integer arithmetic, zero floats.
160
+ *
161
+ * `random`: 4 Goldilocks field elements (Poseidon2 output of server_seed).
162
+ * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
163
+ * `cashout_x100`: multiplier at which the user cashed out (×100).
164
+ * - 0 = user did NOT cash out (loss).
165
+ * - 100..=1_000_000 = user stopped at this multiplier.
166
+ *
167
+ * Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
168
+ * @param {BigUint64Array} random
169
+ * @param {bigint} bet_atomic
170
+ * @param {number} cashout_x100
171
+ * @returns {BigUint64Array}
172
+ */
173
+ function compute_payout_crash(random, bet_atomic, cashout_x100) {
174
+ try {
175
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
176
+ const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
177
+ const len0 = WASM_VECTOR_LEN;
178
+ wasm.compute_payout_crash(retptr, ptr0, len0, bet_atomic, cashout_x100);
179
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
180
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
181
+ var v2 = getArrayU64FromWasm0(r0, r1).slice();
182
+ wasm.__wbindgen_export2(r0, r1 * 8, 8);
183
+ return v2;
184
+ } finally {
185
+ wasm.__wbindgen_add_to_stack_pointer(16);
186
+ }
187
+ }
188
+ exports.compute_payout_crash = compute_payout_crash;
189
+
142
190
  /**
143
191
  * Full dice payout computation — pure integer arithmetic, zero floats.
144
192
  *
@@ -461,6 +509,16 @@ function compute_user_seed_binding(game_id, bet, pred_hash, secret) {
461
509
  }
462
510
  exports.compute_user_seed_binding = compute_user_seed_binding;
463
511
 
512
+ /**
513
+ * Crash RTP percent (99). Canonical source for backend/frontend.
514
+ * @returns {number}
515
+ */
516
+ function crash_rtp_percent() {
517
+ const ret = wasm.coinflip_rtp_percent();
518
+ return ret >>> 0;
519
+ }
520
+ exports.crash_rtp_percent = crash_rtp_percent;
521
+
464
522
  /**
465
523
  * Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
466
524
  *
Binary file
@@ -5,9 +5,11 @@ export const amount_split: (a: number, b: bigint) => void;
5
5
  export const coinflip_multiplier_x10000: () => number;
6
6
  export const coinflip_rtp_percent: () => number;
7
7
  export const compute_address_hash: (a: number, b: number, c: number) => void;
8
+ export const compute_crash_point: (a: number, b: number) => number;
8
9
  export const compute_drawn_keno: (a: number, b: number, c: number) => void;
9
10
  export const compute_multi_dice: (a: number) => bigint;
10
11
  export const compute_payout_coinflip: (a: number, b: number, c: number, d: bigint, e: number) => void;
12
+ export const compute_payout_crash: (a: number, b: number, c: number, d: bigint, e: number) => void;
11
13
  export const compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
12
14
  export const compute_payout_keno: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
13
15
  export const compute_payout_limbo: (a: number, b: number, c: number, d: bigint, e: number) => void;
@@ -48,6 +50,7 @@ export const seed_hash_truncated: (a: number, b: number, c: number) => void;
48
50
  export const session_public_key: (a: number, b: number, c: number, d: bigint) => void;
49
51
  export const string_to_user_seed: (a: number, b: number, c: number) => void;
50
52
  export const string_to_user_seed_hex: (a: number, b: number, c: number) => void;
53
+ export const crash_rtp_percent: () => number;
51
54
  export const dice_rtp_percent: () => number;
52
55
  export const keno_max_picks: () => number;
53
56
  export const limbo_rtp_percent: () => number;
@@ -28,6 +28,14 @@ export function coinflip_rtp_percent(): number;
28
28
  */
29
29
  export function compute_address_hash(address_hex: string): BigUint64Array;
30
30
 
31
+ /**
32
+ * Extract crash point (×100) from Poseidon2 random output.
33
+ *
34
+ * `random` must be exactly 4 elements.
35
+ * Returns the clamped crash multiplier ×100 (100..=1_000_000, i.e. 1.00x..10000.00x).
36
+ */
37
+ export function compute_crash_point(random: BigUint64Array): number;
38
+
31
39
  /**
32
40
  * Extract the 10 drawn numbers from Poseidon2 random output using
33
41
  * the combinatorial number system: `combo_index = random[0] % C(40,10)`.
@@ -56,6 +64,19 @@ export function compute_multi_dice(win_numbers: number): bigint;
56
64
  */
57
65
  export function compute_payout_coinflip(random: BigUint64Array, bet_atomic: bigint, prediction: number): BigUint64Array;
58
66
 
67
+ /**
68
+ * Full crash payout computation — pure integer arithmetic, zero floats.
69
+ *
70
+ * `random`: 4 Goldilocks field elements (Poseidon2 output of server_seed).
71
+ * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
72
+ * `cashout_x100`: multiplier at which the user cashed out (×100).
73
+ * - 0 = user did NOT cash out (loss).
74
+ * - 100..=1_000_000 = user stopped at this multiplier.
75
+ *
76
+ * Returns `BigUint64Array[4]`: `[win_amount, crash_x100, is_win (0|1), multiplier×10000]`.
77
+ */
78
+ export function compute_payout_crash(random: BigUint64Array, bet_atomic: bigint, cashout_x100: number): BigUint64Array;
79
+
59
80
  /**
60
81
  * Full dice payout computation — pure integer arithmetic, zero floats.
61
82
  *
@@ -185,6 +206,11 @@ export function compute_server_seed_hash(server_seed: BigUint64Array): BigUint64
185
206
  */
186
207
  export function compute_user_seed_binding(game_id: number, bet: bigint, pred_hash: BigUint64Array, secret: BigUint64Array): BigUint64Array;
187
208
 
209
+ /**
210
+ * Crash RTP percent (99). Canonical source for backend/frontend.
211
+ */
212
+ export function crash_rtp_percent(): number;
213
+
188
214
  /**
189
215
  * Derive a session key from 32 bytes of entropy (e.g. MetaMask signature).
190
216
  *