@rolly-dev/wasm-signer 1.7.0 → 1.11.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.
@@ -4,10 +4,14 @@ export const memory: WebAssembly.Memory;
4
4
  export const amount_split: (a: number, b: bigint) => void;
5
5
  export const compute_address_hash: (a: number, b: number, c: number) => void;
6
6
  export const compute_multi_dice: (a: number) => bigint;
7
+ export const compute_payout_coinflip: (a: number, b: number, c: number, d: bigint, e: number) => void;
7
8
  export const compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
9
+ export const compute_payout_limbo: (a: number, b: number, c: number, d: bigint, e: number, f: number) => void;
8
10
  export const compute_payout_plinko: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
9
11
  export const compute_prediction_hash: (a: number, b: number, c: number, d: number, e: number) => void;
12
+ export const compute_roll_coinflip: (a: number, b: number) => number;
10
13
  export const compute_roll_dice: (a: number, b: number) => number;
14
+ export const compute_roll_limbo: (a: number, b: number, c: number) => number;
11
15
  export const compute_roll_plinko: (a: number, b: number, c: number) => number;
12
16
  export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
13
17
  export const compute_user_seed_binding: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number) => void;
@@ -26,6 +26,17 @@ export function compute_address_hash(address_hex: string): BigUint64Array;
26
26
  */
27
27
  export function compute_multi_dice(win_numbers: number): bigint;
28
28
 
29
+ /**
30
+ * Full coinflip payout computation — pure integer arithmetic, zero floats.
31
+ *
32
+ * `random`: 4 Goldilocks field elements (Poseidon2 output).
33
+ * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
34
+ * `prediction`: 0 or 1.
35
+ *
36
+ * Returns `BigUint64Array[4]`: `[win_amount, roll (0|1), is_win (0|1), multiplier×10000]`.
37
+ */
38
+ export function compute_payout_coinflip(random: BigUint64Array, bet_atomic: bigint, prediction: number): BigUint64Array;
39
+
29
40
  /**
30
41
  * Full dice payout computation — pure integer arithmetic, zero floats.
31
42
  *
@@ -38,6 +49,18 @@ export function compute_multi_dice(win_numbers: number): bigint;
38
49
  */
39
50
  export function compute_payout_dice(random: BigUint64Array, bet_atomic: bigint, game_mode: number, prediction_lo: number, prediction_hi: number): BigUint64Array;
40
51
 
52
+ /**
53
+ * Full limbo payout computation — pure integer arithmetic, zero floats.
54
+ *
55
+ * `random`: 4 Goldilocks field elements (Poseidon2 output).
56
+ * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
57
+ * `prediction_x100`: target multiplier × 100 (101..999999, i.e. 1.01x–9999.99x).
58
+ * `rtp_numer`: RTP numerator for this bet (90–99). Stored per-bet, included in prediction_hash.
59
+ *
60
+ * Returns `BigUint64Array[4]`: `[win_amount, multiplier_x100, is_win (0|1), payout_multiplier×10000]`.
61
+ */
62
+ export function compute_payout_limbo(random: BigUint64Array, bet_atomic: bigint, prediction_x100: number, rtp_numer: number): BigUint64Array;
63
+
41
64
  /**
42
65
  * Full plinko payout computation — pure integer arithmetic, zero floats.
43
66
  *
@@ -58,11 +81,20 @@ export function compute_payout_plinko(random: BigUint64Array, bet_atomic: bigint
58
81
  * and the in-circuit `build_prediction_hash`.
59
82
  *
60
83
  * Semantics of p0–p2 depend on the game:
61
- * Dice: `(mode, pred_lo, pred_hi)`
62
- * Plinko: `(sector, rows, is_extreme)`
84
+ * Limbo: `(rtp_numer, prediction_x100, 0)`
85
+ * Dice: `(mode, pred_lo, pred_hi)`
86
+ * Plinko: `(sector, rows, is_extreme)`
87
+ * CoinFlip: `(prediction, 0, 0)`
63
88
  */
64
89
  export function compute_prediction_hash(game_id: number, p0: number, p1: number, p2: number): BigUint64Array;
65
90
 
91
+ /**
92
+ * Extract coinflip roll (0 or 1) from Poseidon2 random output.
93
+ *
94
+ * `random` must be exactly 4 elements. Returns `random[0] % 2`.
95
+ */
96
+ export function compute_roll_coinflip(random: BigUint64Array): number;
97
+
66
98
  /**
67
99
  * Extract dice roll number [0, 1000) from Poseidon2 random output.
68
100
  *
@@ -70,6 +102,15 @@ export function compute_prediction_hash(game_id: number, p0: number, p1: number,
70
102
  */
71
103
  export function compute_roll_dice(random: BigUint64Array): number;
72
104
 
105
+ /**
106
+ * Extract limbo result multiplier × 100 from Poseidon2 random output.
107
+ *
108
+ * `random` must be exactly 4 elements.
109
+ * `rtp_numer` must be in [90, 99].
110
+ * Returns the clamped multiplier × 100 (101..999999).
111
+ */
112
+ export function compute_roll_limbo(random: BigUint64Array, rtp_numer: number): number;
113
+
73
114
  /**
74
115
  * Extract plinko bucket index from Poseidon2 random output.
75
116
  *
@@ -294,10 +335,14 @@ export interface InitOutput {
294
335
  readonly amount_split: (a: number, b: bigint) => void;
295
336
  readonly compute_address_hash: (a: number, b: number, c: number) => void;
296
337
  readonly compute_multi_dice: (a: number) => bigint;
338
+ readonly compute_payout_coinflip: (a: number, b: number, c: number, d: bigint, e: number) => void;
297
339
  readonly compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
340
+ readonly compute_payout_limbo: (a: number, b: number, c: number, d: bigint, e: number, f: number) => void;
298
341
  readonly compute_payout_plinko: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
299
342
  readonly compute_prediction_hash: (a: number, b: number, c: number, d: number, e: number) => void;
343
+ readonly compute_roll_coinflip: (a: number, b: number) => number;
300
344
  readonly compute_roll_dice: (a: number, b: number) => number;
345
+ readonly compute_roll_limbo: (a: number, b: number, c: number) => number;
301
346
  readonly compute_roll_plinko: (a: number, b: number, c: number) => number;
302
347
  readonly compute_server_seed_hash: (a: number, b: number, c: number) => void;
303
348
  readonly compute_user_seed_binding: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number) => void;
@@ -60,6 +60,35 @@ export function compute_multi_dice(win_numbers) {
60
60
  return BigInt.asUintN(64, ret);
61
61
  }
62
62
 
63
+ /**
64
+ * Full coinflip payout computation — pure integer arithmetic, zero floats.
65
+ *
66
+ * `random`: 4 Goldilocks field elements (Poseidon2 output).
67
+ * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
68
+ * `prediction`: 0 or 1.
69
+ *
70
+ * Returns `BigUint64Array[4]`: `[win_amount, roll (0|1), is_win (0|1), multiplier×10000]`.
71
+ * @param {BigUint64Array} random
72
+ * @param {bigint} bet_atomic
73
+ * @param {number} prediction
74
+ * @returns {BigUint64Array}
75
+ */
76
+ export function compute_payout_coinflip(random, bet_atomic, prediction) {
77
+ try {
78
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
79
+ const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
80
+ const len0 = WASM_VECTOR_LEN;
81
+ wasm.compute_payout_coinflip(retptr, ptr0, len0, bet_atomic, prediction);
82
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
83
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
84
+ var v2 = getArrayU64FromWasm0(r0, r1).slice();
85
+ wasm.__wbindgen_export2(r0, r1 * 8, 8);
86
+ return v2;
87
+ } finally {
88
+ wasm.__wbindgen_add_to_stack_pointer(16);
89
+ }
90
+ }
91
+
63
92
  /**
64
93
  * Full dice payout computation — pure integer arithmetic, zero floats.
65
94
  *
@@ -92,6 +121,37 @@ export function compute_payout_dice(random, bet_atomic, game_mode, prediction_lo
92
121
  }
93
122
  }
94
123
 
124
+ /**
125
+ * Full limbo payout computation — pure integer arithmetic, zero floats.
126
+ *
127
+ * `random`: 4 Goldilocks field elements (Poseidon2 output).
128
+ * `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
129
+ * `prediction_x100`: target multiplier × 100 (101..999999, i.e. 1.01x–9999.99x).
130
+ * `rtp_numer`: RTP numerator for this bet (90–99). Stored per-bet, included in prediction_hash.
131
+ *
132
+ * Returns `BigUint64Array[4]`: `[win_amount, multiplier_x100, is_win (0|1), payout_multiplier×10000]`.
133
+ * @param {BigUint64Array} random
134
+ * @param {bigint} bet_atomic
135
+ * @param {number} prediction_x100
136
+ * @param {number} rtp_numer
137
+ * @returns {BigUint64Array}
138
+ */
139
+ export function compute_payout_limbo(random, bet_atomic, prediction_x100, rtp_numer) {
140
+ try {
141
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
142
+ const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
143
+ const len0 = WASM_VECTOR_LEN;
144
+ wasm.compute_payout_limbo(retptr, ptr0, len0, bet_atomic, prediction_x100, rtp_numer);
145
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
146
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
147
+ var v2 = getArrayU64FromWasm0(r0, r1).slice();
148
+ wasm.__wbindgen_export2(r0, r1 * 8, 8);
149
+ return v2;
150
+ } finally {
151
+ wasm.__wbindgen_add_to_stack_pointer(16);
152
+ }
153
+ }
154
+
95
155
  /**
96
156
  * Full plinko payout computation — pure integer arithmetic, zero floats.
97
157
  *
@@ -132,8 +192,10 @@ export function compute_payout_plinko(random, bet_atomic, sector, rows, is_extre
132
192
  * and the in-circuit `build_prediction_hash`.
133
193
  *
134
194
  * Semantics of p0–p2 depend on the game:
135
- * Dice: `(mode, pred_lo, pred_hi)`
136
- * Plinko: `(sector, rows, is_extreme)`
195
+ * Limbo: `(rtp_numer, prediction_x100, 0)`
196
+ * Dice: `(mode, pred_lo, pred_hi)`
197
+ * Plinko: `(sector, rows, is_extreme)`
198
+ * CoinFlip: `(prediction, 0, 0)`
137
199
  * @param {number} game_id
138
200
  * @param {number} p0
139
201
  * @param {number} p1
@@ -154,6 +216,20 @@ export function compute_prediction_hash(game_id, p0, p1, p2) {
154
216
  }
155
217
  }
156
218
 
219
+ /**
220
+ * Extract coinflip roll (0 or 1) from Poseidon2 random output.
221
+ *
222
+ * `random` must be exactly 4 elements. Returns `random[0] % 2`.
223
+ * @param {BigUint64Array} random
224
+ * @returns {number}
225
+ */
226
+ export function compute_roll_coinflip(random) {
227
+ const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
228
+ const len0 = WASM_VECTOR_LEN;
229
+ const ret = wasm.compute_roll_coinflip(ptr0, len0);
230
+ return ret >>> 0;
231
+ }
232
+
157
233
  /**
158
234
  * Extract dice roll number [0, 1000) from Poseidon2 random output.
159
235
  *
@@ -168,6 +244,23 @@ export function compute_roll_dice(random) {
168
244
  return ret >>> 0;
169
245
  }
170
246
 
247
+ /**
248
+ * Extract limbo result multiplier × 100 from Poseidon2 random output.
249
+ *
250
+ * `random` must be exactly 4 elements.
251
+ * `rtp_numer` must be in [90, 99].
252
+ * Returns the clamped multiplier × 100 (101..999999).
253
+ * @param {BigUint64Array} random
254
+ * @param {number} rtp_numer
255
+ * @returns {number}
256
+ */
257
+ export function compute_roll_limbo(random, rtp_numer) {
258
+ const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
259
+ const len0 = WASM_VECTOR_LEN;
260
+ const ret = wasm.compute_roll_limbo(ptr0, len0, rtp_numer);
261
+ return ret >>> 0;
262
+ }
263
+
171
264
  /**
172
265
  * Extract plinko bucket index from Poseidon2 random output.
173
266
  *
Binary file
@@ -4,10 +4,14 @@ export const memory: WebAssembly.Memory;
4
4
  export const amount_split: (a: number, b: bigint) => void;
5
5
  export const compute_address_hash: (a: number, b: number, c: number) => void;
6
6
  export const compute_multi_dice: (a: number) => bigint;
7
+ export const compute_payout_coinflip: (a: number, b: number, c: number, d: bigint, e: number) => void;
7
8
  export const compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
9
+ export const compute_payout_limbo: (a: number, b: number, c: number, d: bigint, e: number, f: number) => void;
8
10
  export const compute_payout_plinko: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
9
11
  export const compute_prediction_hash: (a: number, b: number, c: number, d: number, e: number) => void;
12
+ export const compute_roll_coinflip: (a: number, b: number) => number;
10
13
  export const compute_roll_dice: (a: number, b: number) => number;
14
+ export const compute_roll_limbo: (a: number, b: number, c: number) => number;
11
15
  export const compute_roll_plinko: (a: number, b: number, c: number) => number;
12
16
  export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
13
17
  export const compute_user_seed_binding: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number) => void;
package/js/browser.mjs CHANGED
@@ -4,10 +4,14 @@ export {
4
4
  amount_split,
5
5
  compute_address_hash,
6
6
  compute_multi_dice,
7
+ compute_payout_coinflip,
7
8
  compute_payout_dice,
9
+ compute_payout_limbo,
8
10
  compute_payout_plinko,
9
11
  compute_prediction_hash,
12
+ compute_roll_coinflip,
10
13
  compute_roll_dice,
14
+ compute_roll_limbo,
11
15
  compute_roll_plinko,
12
16
  compute_server_seed_hash,
13
17
  compute_user_seed_binding,
package/js/index.d.ts CHANGED
@@ -2,10 +2,14 @@ export {
2
2
  amount_split,
3
3
  compute_address_hash,
4
4
  compute_multi_dice,
5
+ compute_payout_coinflip,
5
6
  compute_payout_dice,
7
+ compute_payout_limbo,
6
8
  compute_payout_plinko,
7
9
  compute_prediction_hash,
10
+ compute_roll_coinflip,
8
11
  compute_roll_dice,
12
+ compute_roll_limbo,
9
13
  compute_roll_plinko,
10
14
  compute_server_seed_hash,
11
15
  compute_user_seed_binding,
@@ -6,10 +6,14 @@ module.exports = {
6
6
  amount_split: wasm.amount_split,
7
7
  compute_address_hash: wasm.compute_address_hash,
8
8
  compute_multi_dice: wasm.compute_multi_dice,
9
+ compute_payout_coinflip: wasm.compute_payout_coinflip,
9
10
  compute_payout_dice: wasm.compute_payout_dice,
11
+ compute_payout_limbo: wasm.compute_payout_limbo,
10
12
  compute_payout_plinko: wasm.compute_payout_plinko,
11
13
  compute_prediction_hash: wasm.compute_prediction_hash,
14
+ compute_roll_coinflip: wasm.compute_roll_coinflip,
12
15
  compute_roll_dice: wasm.compute_roll_dice,
16
+ compute_roll_limbo: wasm.compute_roll_limbo,
13
17
  compute_roll_plinko: wasm.compute_roll_plinko,
14
18
  compute_server_seed_hash: wasm.compute_server_seed_hash,
15
19
  compute_user_seed_binding: wasm.compute_user_seed_binding,
@@ -2,10 +2,14 @@ export {
2
2
  amount_split,
3
3
  compute_address_hash,
4
4
  compute_multi_dice,
5
+ compute_payout_coinflip,
5
6
  compute_payout_dice,
7
+ compute_payout_limbo,
6
8
  compute_payout_plinko,
7
9
  compute_prediction_hash,
10
+ compute_roll_coinflip,
8
11
  compute_roll_dice,
12
+ compute_roll_limbo,
9
13
  compute_roll_plinko,
10
14
  compute_server_seed_hash,
11
15
  compute_user_seed_binding,
package/js/node.cjs CHANGED
@@ -6,10 +6,14 @@ module.exports = {
6
6
  amount_split: wasm.amount_split,
7
7
  compute_address_hash: wasm.compute_address_hash,
8
8
  compute_multi_dice: wasm.compute_multi_dice,
9
+ compute_payout_coinflip: wasm.compute_payout_coinflip,
9
10
  compute_payout_dice: wasm.compute_payout_dice,
11
+ compute_payout_limbo: wasm.compute_payout_limbo,
10
12
  compute_payout_plinko: wasm.compute_payout_plinko,
11
13
  compute_prediction_hash: wasm.compute_prediction_hash,
14
+ compute_roll_coinflip: wasm.compute_roll_coinflip,
12
15
  compute_roll_dice: wasm.compute_roll_dice,
16
+ compute_roll_limbo: wasm.compute_roll_limbo,
13
17
  compute_roll_plinko: wasm.compute_roll_plinko,
14
18
  compute_server_seed_hash: wasm.compute_server_seed_hash,
15
19
  compute_user_seed_binding: wasm.compute_user_seed_binding,
package/js/node.mjs CHANGED
@@ -7,10 +7,14 @@ export const {
7
7
  amount_split,
8
8
  compute_address_hash,
9
9
  compute_multi_dice,
10
+ compute_payout_coinflip,
10
11
  compute_payout_dice,
12
+ compute_payout_limbo,
11
13
  compute_payout_plinko,
12
14
  compute_prediction_hash,
15
+ compute_roll_coinflip,
13
16
  compute_roll_dice,
17
+ compute_roll_limbo,
14
18
  compute_roll_plinko,
15
19
  compute_server_seed_hash,
16
20
  compute_user_seed_binding,
package/js/react.mjs CHANGED
@@ -3,10 +3,14 @@ import init, {
3
3
  amount_split,
4
4
  compute_address_hash,
5
5
  compute_multi_dice,
6
+ compute_payout_coinflip,
6
7
  compute_payout_dice,
8
+ compute_payout_limbo,
7
9
  compute_payout_plinko,
8
10
  compute_prediction_hash,
11
+ compute_roll_coinflip,
9
12
  compute_roll_dice,
13
+ compute_roll_limbo,
10
14
  compute_roll_plinko,
11
15
  compute_server_seed_hash,
12
16
  compute_user_seed_binding,
@@ -40,10 +44,14 @@ const fns = {
40
44
  amount_split: guard(amount_split),
41
45
  compute_address_hash: guard(compute_address_hash),
42
46
  compute_multi_dice: guard(compute_multi_dice),
47
+ compute_payout_coinflip: guard(compute_payout_coinflip),
43
48
  compute_payout_dice: guard(compute_payout_dice),
49
+ compute_payout_limbo: guard(compute_payout_limbo),
44
50
  compute_payout_plinko: guard(compute_payout_plinko),
45
51
  compute_prediction_hash: guard(compute_prediction_hash),
52
+ compute_roll_coinflip: guard(compute_roll_coinflip),
46
53
  compute_roll_dice: guard(compute_roll_dice),
54
+ compute_roll_limbo: guard(compute_roll_limbo),
47
55
  compute_roll_plinko: guard(compute_roll_plinko),
48
56
  compute_server_seed_hash: guard(compute_server_seed_hash),
49
57
  compute_user_seed_binding: guard(compute_user_seed_binding),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolly-dev/wasm-signer",
3
- "version": "1.7.0",
3
+ "version": "1.11.0",
4
4
  "description": "Poseidon2 hashing & bet signing for Rolly ZK-Rollup (WASM, Goldilocks field)",
5
5
  "type": "module",
6
6
  "exports": {