@rolly-dev/wasm-signer 1.0.0 → 1.1.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/README.md +36 -0
- package/dist/node/README.md +36 -0
- package/dist/node/rolly_wasm_signer.d.ts +27 -0
- package/dist/node/rolly_wasm_signer.js +62 -0
- package/dist/node/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/node/rolly_wasm_signer_bg.wasm.d.ts +3 -0
- package/dist/node-inline/README.md +36 -0
- package/dist/node-inline/rolly_wasm_signer.d.ts +27 -0
- package/dist/node-inline/rolly_wasm_signer.js +63 -1
- package/dist/node-inline/rolly_wasm_signer.mjs +61 -2
- package/dist/node-inline/rolly_wasm_signer_bg.wasm.d.ts +3 -0
- package/dist/web/README.md +36 -0
- package/dist/web/rolly_wasm_signer.d.ts +30 -0
- package/dist/web/rolly_wasm_signer.js +59 -0
- package/dist/web/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/web/rolly_wasm_signer_bg.wasm.d.ts +3 -0
- package/js/browser.d.mts +3 -0
- package/js/browser.mjs +3 -0
- package/js/index.d.ts +3 -0
- package/js/node-inline.cjs +3 -0
- package/js/node-inline.mjs +3 -0
- package/js/node.cjs +3 -0
- package/js/node.mjs +3 -0
- package/js/react.d.mts +3 -0
- package/js/react.mjs +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,6 +107,42 @@ module.exports = { experiments: { asyncWebAssembly: true } };
|
|
|
107
107
|
|
|
108
108
|
**Next.js** — conditional exports auto-resolve: Node.js entry on server, browser entry on client.
|
|
109
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
|
+
|
|
110
146
|
## License
|
|
111
147
|
|
|
112
148
|
MIT
|
package/dist/node/README.md
CHANGED
|
@@ -107,6 +107,42 @@ module.exports = { experiments: { asyncWebAssembly: true } };
|
|
|
107
107
|
|
|
108
108
|
**Next.js** — conditional exports auto-resolve: Node.js entry on server, browser entry on client.
|
|
109
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
|
+
|
|
110
146
|
## License
|
|
111
147
|
|
|
112
148
|
MIT
|
|
@@ -18,6 +18,33 @@ export function amount_split(amount: bigint): Uint32Array;
|
|
|
18
18
|
*/
|
|
19
19
|
export function compute_address_hash(address_hex: string): BigUint64Array;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Compute dice multiplier × 10000 from win_numbers count.
|
|
23
|
+
*
|
|
24
|
+
* Formula: `9_900_000 / win_numbers` (integer division = floor).
|
|
25
|
+
* `win_numbers` must be in [1, 950].
|
|
26
|
+
*/
|
|
27
|
+
export function compute_multi_dice(win_numbers: number): bigint;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Full dice 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
|
+
* `game_mode`: 0=Under, 1=Over, 2=In, 3=Out.
|
|
35
|
+
* `prediction_lo` / `prediction_hi`: prediction range bounds (0..999).
|
|
36
|
+
*
|
|
37
|
+
* Returns `BigUint64Array[4]`: `[win_amount, roll_number, is_win (0|1), multiplier×10000]`.
|
|
38
|
+
*/
|
|
39
|
+
export function compute_payout_dice(random: BigUint64Array, bet_atomic: bigint, game_mode: number, prediction_lo: number, prediction_hi: number): BigUint64Array;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Extract dice roll number [0, 1000) from Poseidon2 random output.
|
|
43
|
+
*
|
|
44
|
+
* `random` must be exactly 4 elements. Returns `random[0] % 1000`.
|
|
45
|
+
*/
|
|
46
|
+
export function compute_roll_dice(random: BigUint64Array): number;
|
|
47
|
+
|
|
21
48
|
/**
|
|
22
49
|
* Full Poseidon2 hash of an 8-element server seed.
|
|
23
50
|
*
|
|
@@ -49,6 +49,68 @@ function compute_address_hash(address_hex) {
|
|
|
49
49
|
}
|
|
50
50
|
exports.compute_address_hash = compute_address_hash;
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Compute dice multiplier × 10000 from win_numbers count.
|
|
54
|
+
*
|
|
55
|
+
* Formula: `9_900_000 / win_numbers` (integer division = floor).
|
|
56
|
+
* `win_numbers` must be in [1, 950].
|
|
57
|
+
* @param {number} win_numbers
|
|
58
|
+
* @returns {bigint}
|
|
59
|
+
*/
|
|
60
|
+
function compute_multi_dice(win_numbers) {
|
|
61
|
+
const ret = wasm.compute_multi_dice(win_numbers);
|
|
62
|
+
return BigInt.asUintN(64, ret);
|
|
63
|
+
}
|
|
64
|
+
exports.compute_multi_dice = compute_multi_dice;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Full dice payout computation — pure integer arithmetic, zero floats.
|
|
68
|
+
*
|
|
69
|
+
* `random`: 4 Goldilocks field elements (Poseidon2 output).
|
|
70
|
+
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
71
|
+
* `game_mode`: 0=Under, 1=Over, 2=In, 3=Out.
|
|
72
|
+
* `prediction_lo` / `prediction_hi`: prediction range bounds (0..999).
|
|
73
|
+
*
|
|
74
|
+
* Returns `BigUint64Array[4]`: `[win_amount, roll_number, is_win (0|1), multiplier×10000]`.
|
|
75
|
+
* @param {BigUint64Array} random
|
|
76
|
+
* @param {bigint} bet_atomic
|
|
77
|
+
* @param {number} game_mode
|
|
78
|
+
* @param {number} prediction_lo
|
|
79
|
+
* @param {number} prediction_hi
|
|
80
|
+
* @returns {BigUint64Array}
|
|
81
|
+
*/
|
|
82
|
+
function compute_payout_dice(random, bet_atomic, game_mode, prediction_lo, prediction_hi) {
|
|
83
|
+
try {
|
|
84
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
85
|
+
const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
|
|
86
|
+
const len0 = WASM_VECTOR_LEN;
|
|
87
|
+
wasm.compute_payout_dice(retptr, ptr0, len0, bet_atomic, game_mode, prediction_lo, prediction_hi);
|
|
88
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
89
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
90
|
+
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
91
|
+
wasm.__wbindgen_export2(r0, r1 * 8, 8);
|
|
92
|
+
return v2;
|
|
93
|
+
} finally {
|
|
94
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.compute_payout_dice = compute_payout_dice;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Extract dice roll number [0, 1000) from Poseidon2 random output.
|
|
101
|
+
*
|
|
102
|
+
* `random` must be exactly 4 elements. Returns `random[0] % 1000`.
|
|
103
|
+
* @param {BigUint64Array} random
|
|
104
|
+
* @returns {number}
|
|
105
|
+
*/
|
|
106
|
+
function compute_roll_dice(random) {
|
|
107
|
+
const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
|
|
108
|
+
const len0 = WASM_VECTOR_LEN;
|
|
109
|
+
const ret = wasm.compute_roll_dice(ptr0, len0);
|
|
110
|
+
return ret >>> 0;
|
|
111
|
+
}
|
|
112
|
+
exports.compute_roll_dice = compute_roll_dice;
|
|
113
|
+
|
|
52
114
|
/**
|
|
53
115
|
* Full Poseidon2 hash of an 8-element server seed.
|
|
54
116
|
*
|
|
Binary file
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
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
|
+
export const compute_multi_dice: (a: number) => bigint;
|
|
7
|
+
export const compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
8
|
+
export const compute_roll_dice: (a: number, b: number) => number;
|
|
6
9
|
export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
7
10
|
export const derive_session_key: (a: number, b: number, c: number) => void;
|
|
8
11
|
export const generate_user_seed: (a: number) => void;
|
|
@@ -107,6 +107,42 @@ module.exports = { experiments: { asyncWebAssembly: true } };
|
|
|
107
107
|
|
|
108
108
|
**Next.js** — conditional exports auto-resolve: Node.js entry on server, browser entry on client.
|
|
109
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
|
+
|
|
110
146
|
## License
|
|
111
147
|
|
|
112
148
|
MIT
|
|
@@ -18,6 +18,33 @@ export function amount_split(amount: bigint): Uint32Array;
|
|
|
18
18
|
*/
|
|
19
19
|
export function compute_address_hash(address_hex: string): BigUint64Array;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Compute dice multiplier × 10000 from win_numbers count.
|
|
23
|
+
*
|
|
24
|
+
* Formula: `9_900_000 / win_numbers` (integer division = floor).
|
|
25
|
+
* `win_numbers` must be in [1, 950].
|
|
26
|
+
*/
|
|
27
|
+
export function compute_multi_dice(win_numbers: number): bigint;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Full dice 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
|
+
* `game_mode`: 0=Under, 1=Over, 2=In, 3=Out.
|
|
35
|
+
* `prediction_lo` / `prediction_hi`: prediction range bounds (0..999).
|
|
36
|
+
*
|
|
37
|
+
* Returns `BigUint64Array[4]`: `[win_amount, roll_number, is_win (0|1), multiplier×10000]`.
|
|
38
|
+
*/
|
|
39
|
+
export function compute_payout_dice(random: BigUint64Array, bet_atomic: bigint, game_mode: number, prediction_lo: number, prediction_hi: number): BigUint64Array;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Extract dice roll number [0, 1000) from Poseidon2 random output.
|
|
43
|
+
*
|
|
44
|
+
* `random` must be exactly 4 elements. Returns `random[0] % 1000`.
|
|
45
|
+
*/
|
|
46
|
+
export function compute_roll_dice(random: BigUint64Array): number;
|
|
47
|
+
|
|
21
48
|
/**
|
|
22
49
|
* Full Poseidon2 hash of an 8-element server seed.
|
|
23
50
|
*
|