@rolly-dev/wasm-signer 1.25.0 → 1.27.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.
@@ -137,7 +137,7 @@ export function compute_payout_plinko(random: BigUint64Array, bet_atomic: bigint
137
137
  * and the in-circuit `build_prediction_hash`.
138
138
  *
139
139
  * Semantics of p0–p2 depend on the game:
140
- * Limbo: `(99, prediction_x100, 0)` — RTP hardcoded at 99
140
+ * Limbo: `(98, prediction_x100, 0)` — RTP hardcoded at 98
141
141
  * Dice: `(mode, pred_lo, pred_hi)`
142
142
  * Plinko: `(sector, rows, is_extreme)`
143
143
  * CoinFlip: `(prediction, 0, 0)`
@@ -342,7 +342,7 @@ export function keno_numbers_range(): number;
342
342
  export function keno_rtp_x100(risk: number, pick_count: number): bigint;
343
343
 
344
344
  /**
345
- * Limbo RTP percent (99). Canonical source for backend/frontend.
345
+ * Limbo RTP percent (98). Canonical source for backend/frontend.
346
346
  */
347
347
  export function limbo_rtp_percent(): number;
348
348
 
@@ -335,7 +335,7 @@ exports.compute_payout_plinko = compute_payout_plinko;
335
335
  * and the in-circuit `build_prediction_hash`.
336
336
  *
337
337
  * Semantics of p0–p2 depend on the game:
338
- * Limbo: `(99, prediction_x100, 0)` — RTP hardcoded at 99
338
+ * Limbo: `(98, prediction_x100, 0)` — RTP hardcoded at 98
339
339
  * Dice: `(mode, pred_lo, pred_hi)`
340
340
  * Plinko: `(sector, rows, is_extreme)`
341
341
  * CoinFlip: `(prediction, 0, 0)`
@@ -824,7 +824,7 @@ function keno_rtp_x100(risk, pick_count) {
824
824
  exports.keno_rtp_x100 = keno_rtp_x100;
825
825
 
826
826
  /**
827
- * Limbo RTP percent (99). Canonical source for backend/frontend.
827
+ * Limbo RTP percent (98). Canonical source for backend/frontend.
828
828
  * @returns {number}
829
829
  */
830
830
  function limbo_rtp_percent() {
Binary file
@@ -137,7 +137,7 @@ export function compute_payout_plinko(random: BigUint64Array, bet_atomic: bigint
137
137
  * and the in-circuit `build_prediction_hash`.
138
138
  *
139
139
  * Semantics of p0–p2 depend on the game:
140
- * Limbo: `(99, prediction_x100, 0)` — RTP hardcoded at 99
140
+ * Limbo: `(98, prediction_x100, 0)` — RTP hardcoded at 98
141
141
  * Dice: `(mode, pred_lo, pred_hi)`
142
142
  * Plinko: `(sector, rows, is_extreme)`
143
143
  * CoinFlip: `(prediction, 0, 0)`
@@ -342,7 +342,7 @@ export function keno_numbers_range(): number;
342
342
  export function keno_rtp_x100(risk: number, pick_count: number): bigint;
343
343
 
344
344
  /**
345
- * Limbo RTP percent (99). Canonical source for backend/frontend.
345
+ * Limbo RTP percent (98). Canonical source for backend/frontend.
346
346
  */
347
347
  export function limbo_rtp_percent(): number;
348
348
 
@@ -321,7 +321,7 @@ export function compute_payout_plinko(random, bet_atomic, sector, rows, is_extre
321
321
  * and the in-circuit `build_prediction_hash`.
322
322
  *
323
323
  * Semantics of p0–p2 depend on the game:
324
- * Limbo: `(99, prediction_x100, 0)` — RTP hardcoded at 99
324
+ * Limbo: `(98, prediction_x100, 0)` — RTP hardcoded at 98
325
325
  * Dice: `(mode, pred_lo, pred_hi)`
326
326
  * Plinko: `(sector, rows, is_extreme)`
327
327
  * CoinFlip: `(prediction, 0, 0)`
@@ -786,7 +786,7 @@ export function keno_rtp_x100(risk, pick_count) {
786
786
  }
787
787
 
788
788
  /**
789
- * Limbo RTP percent (99). Canonical source for backend/frontend.
789
+ * Limbo RTP percent (98). Canonical source for backend/frontend.
790
790
  * @returns {number}
791
791
  */
792
792
  export function limbo_rtp_percent() {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolly-dev/wasm-signer",
3
- "version": "1.25.0",
3
+ "version": "1.27.0",
4
4
  "description": "Poseidon2 hashing & bet signing for Rolly ZK-Rollup (WASM, Goldilocks field)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,148 +0,0 @@
1
- # @rolly-dev/wasm-signer
2
-
3
- Client-side Poseidon2 hashing and bet authentication for the Rolly ZK-Rollup casino.
4
-
5
- Built with Rust → WebAssembly (via `wasm-pack`), using the same Poseidon2 hasher
6
- and Goldilocks field as the plonky2 proving circuit.
7
-
8
- ## Build
9
-
10
- ```bash
11
- # requires: cargo, wasm-pack
12
- npm run build
13
- # → dist/node/ (Node.js, CJS, sync init)
14
- # → dist/web/ (Browser, ESM, async init)
15
- ```
16
-
17
- ## Usage
18
-
19
- ### Node.js (CommonJS)
20
-
21
- ```javascript
22
- const {
23
- poseidon2_hash,
24
- derive_session_key,
25
- session_public_key,
26
- } = require('@rolly-dev/wasm-signer');
27
-
28
- const hash = poseidon2_hash(BigUint64Array.from([1n, 2n, 3n]));
29
- // → BigUint64Array(4)
30
- ```
31
-
32
- ### Node.js (ESM)
33
-
34
- ```javascript
35
- import {
36
- poseidon2_hash,
37
- derive_session_key,
38
- session_public_key,
39
- } from '@rolly-dev/wasm-signer';
40
-
41
- const sessionKey = derive_session_key(metamaskSignatureBytes);
42
- const pkHash = session_public_key(sessionKey, BigInt(expiryTimestamp));
43
- ```
44
-
45
- ### React
46
-
47
- ```jsx
48
- import { useRollyWasm } from '@rolly-dev/wasm-signer/react';
49
-
50
- function SessionInfo({ sessionKey, expiry }) {
51
- const { ready, session_public_key } = useRollyWasm();
52
-
53
- if (!ready) return <span>Loading...</span>;
54
-
55
- const pkHash = session_public_key(sessionKey, BigInt(expiry));
56
- // register pkHash on-chain via key_register tx...
57
-
58
- return <div>Session active until {new Date(Number(expiry) * 1000).toLocaleString()}</div>;
59
- }
60
- ```
61
-
62
- ### Browser (vanilla ESM)
63
-
64
- ```html
65
- <script type="module">
66
- import { init, poseidon2_hash } from '@rolly-dev/wasm-signer';
67
-
68
- await init(); // loads .wasm, must be called once
69
- const h = poseidon2_hash(BigUint64Array.from([1n, 2n]));
70
- </script>
71
- ```
72
-
73
- ### Manual init (advanced)
74
-
75
- ```javascript
76
- import init, { poseidon2_hash } from '@rolly-dev/wasm-signer/init';
77
-
78
- // custom wasm URL or ArrayBuffer
79
- await init('/assets/rolly_wasm_signer_bg.wasm');
80
- poseidon2_hash(BigUint64Array.from([1n]));
81
- ```
82
-
83
- ## API
84
-
85
- | Function | Input | Output | Description |
86
- |----------------------------|--------------------------------|-------------------|------------------------------------------------|
87
- | `poseidon2_hash` | `BigUint64Array` | `BigUint64Array(4)` | Hash N field elements |
88
- | `poseidon2_two_to_one` | `BigUint64Array(4)` × 2 | `BigUint64Array(4)` | Merkle hash: H(left‖right) |
89
- | `derive_session_key` | `Uint8Array(32)` | `BigUint64Array(4)` | MetaMask sig → session key |
90
- | `session_public_key` | `(BigUint64Array(4), bigint)` | `BigUint64Array(4)` | pk_hash = Poseidon2(session_key, expiry) |
91
- | `compute_server_seed_hash` | `BigUint64Array(8)` | `BigUint64Array(4)` | Full hash of server seed |
92
- | `seed_hash_truncated` | `BigUint64Array(8)` | `BigUint64Array(3)` | First 3 elements (circuit leaf format, 192-bit commitment) |
93
- | `goldilocks_modulus` | — | `bigint` | Returns p = 2^64 - 2^32 + 1 |
94
- | `goldilocks_reduce` | `bigint` | `bigint` | Reduce mod p |
95
-
96
- ## Bundler notes
97
-
98
- **Vite** — add to `optimizeDeps.exclude`:
99
- ```js
100
- optimizeDeps: { exclude: ['@rolly-dev/wasm-signer'] }
101
- ```
102
-
103
- **Webpack 5** — enable WASM experiments:
104
- ```js
105
- module.exports = { experiments: { asyncWebAssembly: true } };
106
- ```
107
-
108
- **Next.js** — conditional exports auto-resolve: Node.js entry on server, browser entry on client.
109
-
110
- ## Dice — range constraints
111
-
112
- Roll number: `[0, 999]` (TOTAL_RANGE = 1000).
113
- win_numbers (wn): `[1, 950]` (MIN_RANGE..=MAX_RANGE).
114
-
115
- ### prediction_range constraints per mode
116
-
117
- | Mode | wn formula | prediction\[0\] | prediction\[1\] | wn range |
118
- |-------|-------------------------------------------------|-----------------|-----------------|------------|
119
- | Under | `prediction[0]` | `[1, 950]` | unused (0) | `[1, 950]` |
120
- | Over | `999 − prediction[0]` | `[49, 998]` | unused (0) | `[1, 950]` |
121
- | In | `prediction[1] − prediction[0] + 1` | `[0, 999]` | `[0, 999]` | `[1, 950]` |
122
- | Out | `1000 − (prediction[1] − prediction[0] + 1)` | `[0, 999]` | `[0, 999]` | `[1, 950]` |
123
-
124
- **Under** — `prediction[0]` ∈ `[1, 950]` (= wn directly). Win: `roll < prediction[0]`.
125
-
126
- **Over** — `prediction[0]` ∈ `[49, 998]` (lower: `999 − 950 = 49`, upper: `999 − 1 = 998`). Win: `roll > prediction[0]`.
127
-
128
- **In** — `prediction[0] <= prediction[1]`, span ∈ `[1, 950]`. Win: `prediction[0] <= roll <= prediction[1]`.
129
-
130
- **Out** — `prediction[0] <= prediction[1]`, inner span ∈ `[50, 999]` (wn = `1000 − inner` ∈ `[1, 950]`). Win: `roll < prediction[0] || roll > prediction[1]`.
131
-
132
- ### Multiplier
133
-
134
- `multiplier = floor(9_900_000 / wn)` (scaled ×10000).
135
-
136
- | wn | multiplier | display |
137
- |-----|-----------|-----------|
138
- | 1 | 9_900_000 | 990.0000x |
139
- | 500 | 19_800 | 1.9800x |
140
- | 950 | 10_421 | 1.0421x |
141
-
142
- ### RTP
143
-
144
- Theoretical: **98.998%** (floor-division costs ~0.002%). House edge: **~1.002%**. Max win cap: 10,000 USDT (business rule, not formula).
145
-
146
- ## License
147
-
148
- MIT
@@ -1 +0,0 @@
1
- {"type":"commonjs"}