@rolly-dev/wasm-signer 1.31.0 → 1.31.2
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/README.md +10 -55
- package/dist/node/README.md +10 -55
- package/dist/node/rolly_wasm_signer.d.ts +10 -2
- package/dist/node/rolly_wasm_signer.js +10 -2
- package/dist/node/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/node-inline/README.md +10 -55
- package/dist/node-inline/rolly_wasm_signer.d.ts +10 -2
- package/dist/node-inline/rolly_wasm_signer.js +11 -3
- package/dist/node-inline/rolly_wasm_signer.mjs +11 -3
- package/package.json +6 -25
- package/dist/web/README.md +0 -148
- package/dist/web/rolly_wasm_signer.d.ts +0 -659
- package/dist/web/rolly_wasm_signer.js +0 -1909
- package/dist/web/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/web/rolly_wasm_signer_bg.wasm.d.ts +0 -69
- package/js/browser.d.mts +0 -38
- package/js/browser.mjs +0 -65
- package/js/react.d.mts +0 -56
- package/js/react.mjs +0 -162
package/README.md
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
# @rolly-dev/wasm-signer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Server-side Poseidon2 hashing and bet authentication for the Rolly ZK-Rollup casino.
|
|
4
4
|
|
|
5
5
|
Built with Rust → WebAssembly (via `wasm-pack`), using the same Poseidon2 hasher
|
|
6
6
|
and Goldilocks field as the plonky2 proving circuit.
|
|
7
7
|
|
|
8
|
+
Node.js only — the backend and orchestrator run this package; the block explorer
|
|
9
|
+
still consumes the published `1.31.x` browser build for payout verification. The
|
|
10
|
+
web dApp uses the pure-TS `@rolly-dev/auth-sign` package for hashing / signing
|
|
11
|
+
instead (WASM does not load reliably under strict CSP / on some devices), and
|
|
12
|
+
`auth-sign` carries no payout math — `games-core` via this crate is the only
|
|
13
|
+
JS-facing source of it.
|
|
14
|
+
|
|
8
15
|
## Build
|
|
9
16
|
|
|
10
17
|
```bash
|
|
11
18
|
# requires: cargo, wasm-pack
|
|
12
19
|
npm run build
|
|
13
|
-
# → dist/node/
|
|
14
|
-
# → dist/
|
|
20
|
+
# → dist/node/ (Node.js, CJS, sync init, loads .wasm from disk)
|
|
21
|
+
# → dist/node-inline/ (Node.js, self-contained, WASM embedded as base64)
|
|
15
22
|
```
|
|
16
23
|
|
|
17
24
|
## Usage
|
|
@@ -42,44 +49,6 @@ const sessionKey = derive_session_key(metamaskSignatureBytes);
|
|
|
42
49
|
const pkHash = session_public_key(sessionKey, BigInt(expiryTimestamp));
|
|
43
50
|
```
|
|
44
51
|
|
|
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
52
|
## API
|
|
84
53
|
|
|
85
54
|
| Function | Input | Output | Description |
|
|
@@ -93,20 +62,6 @@ poseidon2_hash(BigUint64Array.from([1n]));
|
|
|
93
62
|
| `goldilocks_modulus` | — | `bigint` | Returns p = 2^64 - 2^32 + 1 |
|
|
94
63
|
| `goldilocks_reduce` | `bigint` | `bigint` | Reduce mod p |
|
|
95
64
|
|
|
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
65
|
## Dice — range constraints
|
|
111
66
|
|
|
112
67
|
Roll number: `[0, 999]` (TOTAL_RANGE = 1000).
|
package/dist/node/README.md
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
# @rolly-dev/wasm-signer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Server-side Poseidon2 hashing and bet authentication for the Rolly ZK-Rollup casino.
|
|
4
4
|
|
|
5
5
|
Built with Rust → WebAssembly (via `wasm-pack`), using the same Poseidon2 hasher
|
|
6
6
|
and Goldilocks field as the plonky2 proving circuit.
|
|
7
7
|
|
|
8
|
+
Node.js only — the backend and orchestrator run this package; the block explorer
|
|
9
|
+
still consumes the published `1.31.x` browser build for payout verification. The
|
|
10
|
+
web dApp uses the pure-TS `@rolly-dev/auth-sign` package for hashing / signing
|
|
11
|
+
instead (WASM does not load reliably under strict CSP / on some devices), and
|
|
12
|
+
`auth-sign` carries no payout math — `games-core` via this crate is the only
|
|
13
|
+
JS-facing source of it.
|
|
14
|
+
|
|
8
15
|
## Build
|
|
9
16
|
|
|
10
17
|
```bash
|
|
11
18
|
# requires: cargo, wasm-pack
|
|
12
19
|
npm run build
|
|
13
|
-
# → dist/node/
|
|
14
|
-
# → dist/
|
|
20
|
+
# → dist/node/ (Node.js, CJS, sync init, loads .wasm from disk)
|
|
21
|
+
# → dist/node-inline/ (Node.js, self-contained, WASM embedded as base64)
|
|
15
22
|
```
|
|
16
23
|
|
|
17
24
|
## Usage
|
|
@@ -42,44 +49,6 @@ const sessionKey = derive_session_key(metamaskSignatureBytes);
|
|
|
42
49
|
const pkHash = session_public_key(sessionKey, BigInt(expiryTimestamp));
|
|
43
50
|
```
|
|
44
51
|
|
|
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
52
|
## API
|
|
84
53
|
|
|
85
54
|
| Function | Input | Output | Description |
|
|
@@ -93,20 +62,6 @@ poseidon2_hash(BigUint64Array.from([1n]));
|
|
|
93
62
|
| `goldilocks_modulus` | — | `bigint` | Returns p = 2^64 - 2^32 + 1 |
|
|
94
63
|
| `goldilocks_reduce` | `bigint` | `bigint` | Reduce mod p |
|
|
95
64
|
|
|
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
65
|
## Dice — range constraints
|
|
111
66
|
|
|
112
67
|
Roll number: `[0, 999]` (TOTAL_RANGE = 1000).
|
|
@@ -33,7 +33,9 @@ export function aviato_rtp_percent(): number;
|
|
|
33
33
|
* must be 4 elements (`string_to_user_seed(user_seed_source)`).
|
|
34
34
|
*
|
|
35
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
|
|
36
|
+
* 10/J/Q/K=9..12). Suits are cosmetic (not consensus); the true suits of the
|
|
37
|
+
* same drawn cards are exposed by [`compute_payout_blackjack`] (`shoe_suits`
|
|
38
|
+
* and the per-hand `*_suits`).
|
|
37
39
|
*
|
|
38
40
|
* ```js
|
|
39
41
|
* const shoe = blackjack_deal_shoe(serverSeed8, userSecret4); // length 30
|
|
@@ -126,7 +128,13 @@ export function compute_payout_aviato(random: BigUint64Array, bet_atomic: bigint
|
|
|
126
128
|
* ```js
|
|
127
129
|
* const res = compute_payout_blackjack(serverSeed8, userSecret4, lo, hi, betAtomic);
|
|
128
130
|
* // res.win_amount, res.total_staked, res.shoe (length 30),
|
|
129
|
-
* // res.
|
|
131
|
+
* // res.shoe_suits (length 30, cosmetic suit codes 0..3 of the same cards),
|
|
132
|
+
* // res.first_cards / res.second_cards / res.dealer_cards (rank codes),
|
|
133
|
+
* // res.first_suits / res.second_suits / res.dealer_suits (parallel suits),
|
|
134
|
+
* // res.first_kind / res.second_kind (per-hand type: 0=bet,1=hit,2=stand,
|
|
135
|
+
* // 3=double,4=split,5=insurance; a closed hand reports 2),
|
|
136
|
+
* // res.first_amount / res.second_amount (per-hand staked, atomic),
|
|
137
|
+
* // res.first_win / res.second_win (per-hand win, atomic, pre-cap), ...
|
|
130
138
|
* ```
|
|
131
139
|
*/
|
|
132
140
|
export function compute_payout_blackjack(server_seed: BigUint64Array, user_secret_random: BigUint64Array, prediction_lo: number, prediction_hi: number, base_bet: bigint): any;
|
|
@@ -52,7 +52,9 @@ exports.aviato_rtp_percent = aviato_rtp_percent;
|
|
|
52
52
|
* must be 4 elements (`string_to_user_seed(user_seed_source)`).
|
|
53
53
|
*
|
|
54
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
|
|
55
|
+
* 10/J/Q/K=9..12). Suits are cosmetic (not consensus); the true suits of the
|
|
56
|
+
* same drawn cards are exposed by [`compute_payout_blackjack`] (`shoe_suits`
|
|
57
|
+
* and the per-hand `*_suits`).
|
|
56
58
|
*
|
|
57
59
|
* ```js
|
|
58
60
|
* const shoe = blackjack_deal_shoe(serverSeed8, userSecret4); // length 30
|
|
@@ -267,7 +269,13 @@ exports.compute_payout_aviato = compute_payout_aviato;
|
|
|
267
269
|
* ```js
|
|
268
270
|
* const res = compute_payout_blackjack(serverSeed8, userSecret4, lo, hi, betAtomic);
|
|
269
271
|
* // res.win_amount, res.total_staked, res.shoe (length 30),
|
|
270
|
-
* // res.
|
|
272
|
+
* // res.shoe_suits (length 30, cosmetic suit codes 0..3 of the same cards),
|
|
273
|
+
* // res.first_cards / res.second_cards / res.dealer_cards (rank codes),
|
|
274
|
+
* // res.first_suits / res.second_suits / res.dealer_suits (parallel suits),
|
|
275
|
+
* // res.first_kind / res.second_kind (per-hand type: 0=bet,1=hit,2=stand,
|
|
276
|
+
* // 3=double,4=split,5=insurance; a closed hand reports 2),
|
|
277
|
+
* // res.first_amount / res.second_amount (per-hand staked, atomic),
|
|
278
|
+
* // res.first_win / res.second_win (per-hand win, atomic, pre-cap), ...
|
|
271
279
|
* ```
|
|
272
280
|
* @param {BigUint64Array} server_seed
|
|
273
281
|
* @param {BigUint64Array} user_secret_random
|
|
Binary file
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
# @rolly-dev/wasm-signer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Server-side Poseidon2 hashing and bet authentication for the Rolly ZK-Rollup casino.
|
|
4
4
|
|
|
5
5
|
Built with Rust → WebAssembly (via `wasm-pack`), using the same Poseidon2 hasher
|
|
6
6
|
and Goldilocks field as the plonky2 proving circuit.
|
|
7
7
|
|
|
8
|
+
Node.js only — the backend and orchestrator run this package; the block explorer
|
|
9
|
+
still consumes the published `1.31.x` browser build for payout verification. The
|
|
10
|
+
web dApp uses the pure-TS `@rolly-dev/auth-sign` package for hashing / signing
|
|
11
|
+
instead (WASM does not load reliably under strict CSP / on some devices), and
|
|
12
|
+
`auth-sign` carries no payout math — `games-core` via this crate is the only
|
|
13
|
+
JS-facing source of it.
|
|
14
|
+
|
|
8
15
|
## Build
|
|
9
16
|
|
|
10
17
|
```bash
|
|
11
18
|
# requires: cargo, wasm-pack
|
|
12
19
|
npm run build
|
|
13
|
-
# → dist/node/
|
|
14
|
-
# → dist/
|
|
20
|
+
# → dist/node/ (Node.js, CJS, sync init, loads .wasm from disk)
|
|
21
|
+
# → dist/node-inline/ (Node.js, self-contained, WASM embedded as base64)
|
|
15
22
|
```
|
|
16
23
|
|
|
17
24
|
## Usage
|
|
@@ -42,44 +49,6 @@ const sessionKey = derive_session_key(metamaskSignatureBytes);
|
|
|
42
49
|
const pkHash = session_public_key(sessionKey, BigInt(expiryTimestamp));
|
|
43
50
|
```
|
|
44
51
|
|
|
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
52
|
## API
|
|
84
53
|
|
|
85
54
|
| Function | Input | Output | Description |
|
|
@@ -93,20 +62,6 @@ poseidon2_hash(BigUint64Array.from([1n]));
|
|
|
93
62
|
| `goldilocks_modulus` | — | `bigint` | Returns p = 2^64 - 2^32 + 1 |
|
|
94
63
|
| `goldilocks_reduce` | `bigint` | `bigint` | Reduce mod p |
|
|
95
64
|
|
|
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
65
|
## Dice — range constraints
|
|
111
66
|
|
|
112
67
|
Roll number: `[0, 999]` (TOTAL_RANGE = 1000).
|
|
@@ -33,7 +33,9 @@ export function aviato_rtp_percent(): number;
|
|
|
33
33
|
* must be 4 elements (`string_to_user_seed(user_seed_source)`).
|
|
34
34
|
*
|
|
35
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
|
|
36
|
+
* 10/J/Q/K=9..12). Suits are cosmetic (not consensus); the true suits of the
|
|
37
|
+
* same drawn cards are exposed by [`compute_payout_blackjack`] (`shoe_suits`
|
|
38
|
+
* and the per-hand `*_suits`).
|
|
37
39
|
*
|
|
38
40
|
* ```js
|
|
39
41
|
* const shoe = blackjack_deal_shoe(serverSeed8, userSecret4); // length 30
|
|
@@ -126,7 +128,13 @@ export function compute_payout_aviato(random: BigUint64Array, bet_atomic: bigint
|
|
|
126
128
|
* ```js
|
|
127
129
|
* const res = compute_payout_blackjack(serverSeed8, userSecret4, lo, hi, betAtomic);
|
|
128
130
|
* // res.win_amount, res.total_staked, res.shoe (length 30),
|
|
129
|
-
* // res.
|
|
131
|
+
* // res.shoe_suits (length 30, cosmetic suit codes 0..3 of the same cards),
|
|
132
|
+
* // res.first_cards / res.second_cards / res.dealer_cards (rank codes),
|
|
133
|
+
* // res.first_suits / res.second_suits / res.dealer_suits (parallel suits),
|
|
134
|
+
* // res.first_kind / res.second_kind (per-hand type: 0=bet,1=hit,2=stand,
|
|
135
|
+
* // 3=double,4=split,5=insurance; a closed hand reports 2),
|
|
136
|
+
* // res.first_amount / res.second_amount (per-hand staked, atomic),
|
|
137
|
+
* // res.first_win / res.second_win (per-hand win, atomic, pre-cap), ...
|
|
130
138
|
* ```
|
|
131
139
|
*/
|
|
132
140
|
export function compute_payout_blackjack(server_seed: BigUint64Array, user_secret_random: BigUint64Array, prediction_lo: number, prediction_hi: number, base_bet: bigint): any;
|