@rolly-dev/wasm-signer 1.2.1 → 1.5.1
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/dist/node/rolly_wasm_signer.d.ts +22 -0
- package/dist/node/rolly_wasm_signer.js +52 -0
- package/dist/node/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/node/rolly_wasm_signer_bg.wasm.d.ts +2 -0
- package/dist/node-inline/rolly_wasm_signer.d.ts +22 -0
- package/dist/node-inline/rolly_wasm_signer.js +53 -1
- package/dist/node-inline/rolly_wasm_signer.mjs +52 -2
- package/dist/node-inline/rolly_wasm_signer_bg.wasm.d.ts +2 -0
- package/dist/web/rolly_wasm_signer.d.ts +24 -0
- package/dist/web/rolly_wasm_signer.js +50 -0
- package/dist/web/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/web/rolly_wasm_signer_bg.wasm.d.ts +2 -0
- package/js/browser.mjs +14 -12
- package/js/index.d.ts +14 -12
- package/js/node-inline.cjs +21 -19
- package/js/node-inline.mjs +14 -12
- package/js/node.cjs +21 -19
- package/js/node.mjs +14 -12
- package/js/react.mjs +35 -37
- package/package.json +1 -1
|
@@ -92,6 +92,39 @@ export function compute_payout_dice(random, bet_atomic, game_mode, prediction_lo
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Full plinko payout computation — pure integer arithmetic, zero floats.
|
|
97
|
+
*
|
|
98
|
+
* `random`: 4 Goldilocks field elements (Poseidon2 output).
|
|
99
|
+
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
100
|
+
* `sector`: risk profile (0=low, 1=medium, 2=high).
|
|
101
|
+
* `rows`: number of pin rows (8..16).
|
|
102
|
+
* `is_extreme`: whether extreme mode is active.
|
|
103
|
+
*
|
|
104
|
+
* Returns `BigUint64Array[4]`: `[win_amount, bucket_index, is_win (0|1), multiplier×10000]`.
|
|
105
|
+
* @param {BigUint64Array} random
|
|
106
|
+
* @param {bigint} bet_atomic
|
|
107
|
+
* @param {number} sector
|
|
108
|
+
* @param {number} rows
|
|
109
|
+
* @param {boolean} is_extreme
|
|
110
|
+
* @returns {BigUint64Array}
|
|
111
|
+
*/
|
|
112
|
+
export function compute_payout_plinko(random, bet_atomic, sector, rows, is_extreme) {
|
|
113
|
+
try {
|
|
114
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
115
|
+
const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
|
|
116
|
+
const len0 = WASM_VECTOR_LEN;
|
|
117
|
+
wasm.compute_payout_plinko(retptr, ptr0, len0, bet_atomic, sector, rows, is_extreme);
|
|
118
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
119
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
120
|
+
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
121
|
+
wasm.__wbindgen_export2(r0, r1 * 8, 8);
|
|
122
|
+
return v2;
|
|
123
|
+
} finally {
|
|
124
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
95
128
|
/**
|
|
96
129
|
* Extract dice roll number [0, 1000) from Poseidon2 random output.
|
|
97
130
|
*
|
|
@@ -106,6 +139,23 @@ export function compute_roll_dice(random) {
|
|
|
106
139
|
return ret >>> 0;
|
|
107
140
|
}
|
|
108
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Extract plinko bucket index from Poseidon2 random output.
|
|
144
|
+
*
|
|
145
|
+
* `random` must be exactly 4 elements.
|
|
146
|
+
* `rows` must be in [8, 16].
|
|
147
|
+
* Returns the bucket index (0..=rows) = popcount of first `rows` bits of random[0].
|
|
148
|
+
* @param {BigUint64Array} random
|
|
149
|
+
* @param {number} rows
|
|
150
|
+
* @returns {number}
|
|
151
|
+
*/
|
|
152
|
+
export function compute_roll_plinko(random, rows) {
|
|
153
|
+
const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
|
|
154
|
+
const len0 = WASM_VECTOR_LEN;
|
|
155
|
+
const ret = wasm.compute_roll_plinko(ptr0, len0, rows);
|
|
156
|
+
return ret >>> 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
109
159
|
/**
|
|
110
160
|
* Full Poseidon2 hash of an 8-element server seed.
|
|
111
161
|
*
|
|
Binary file
|
|
@@ -5,7 +5,9 @@ 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
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_payout_plinko: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
8
9
|
export const compute_roll_dice: (a: number, b: number) => number;
|
|
10
|
+
export const compute_roll_plinko: (a: number, b: number, c: number) => number;
|
|
9
11
|
export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
10
12
|
export const derive_session_key: (a: number, b: number, c: number) => void;
|
|
11
13
|
export const generate_user_seed: (a: number) => void;
|
package/js/browser.mjs
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
export { default as init } from '../dist/web/rolly_wasm_signer.js';
|
|
2
2
|
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
amount_split,
|
|
5
|
+
compute_address_hash,
|
|
6
|
+
compute_multi_dice,
|
|
7
|
+
compute_payout_dice,
|
|
8
|
+
compute_payout_plinko,
|
|
9
|
+
compute_roll_dice,
|
|
10
|
+
compute_roll_plinko,
|
|
8
11
|
compute_server_seed_hash,
|
|
9
|
-
|
|
10
|
-
string_to_user_seed,
|
|
11
|
-
string_to_user_seed_hex,
|
|
12
|
+
derive_session_key,
|
|
12
13
|
generate_user_seed,
|
|
13
14
|
goldilocks_fields_to_hex,
|
|
14
15
|
goldilocks_modulus,
|
|
15
16
|
goldilocks_reduce,
|
|
16
|
-
amount_split,
|
|
17
|
-
compute_address_hash,
|
|
18
17
|
hash_balance_leaf,
|
|
19
18
|
make_main_leaf,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
poseidon2_hash,
|
|
20
|
+
poseidon2_two_to_one,
|
|
21
|
+
seed_hash_truncated,
|
|
22
|
+
session_public_key,
|
|
23
|
+
string_to_user_seed,
|
|
24
|
+
string_to_user_seed_hex,
|
|
23
25
|
} from '../dist/web/rolly_wasm_signer.js';
|
package/js/index.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
amount_split,
|
|
3
|
+
compute_address_hash,
|
|
4
|
+
compute_multi_dice,
|
|
5
|
+
compute_payout_dice,
|
|
6
|
+
compute_payout_plinko,
|
|
7
|
+
compute_roll_dice,
|
|
8
|
+
compute_roll_plinko,
|
|
6
9
|
compute_server_seed_hash,
|
|
7
|
-
|
|
8
|
-
string_to_user_seed,
|
|
9
|
-
string_to_user_seed_hex,
|
|
10
|
+
derive_session_key,
|
|
10
11
|
generate_user_seed,
|
|
11
12
|
goldilocks_fields_to_hex,
|
|
12
13
|
goldilocks_modulus,
|
|
13
14
|
goldilocks_reduce,
|
|
14
|
-
amount_split,
|
|
15
|
-
compute_address_hash,
|
|
16
15
|
hash_balance_leaf,
|
|
17
16
|
make_main_leaf,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
poseidon2_hash,
|
|
18
|
+
poseidon2_two_to_one,
|
|
19
|
+
seed_hash_truncated,
|
|
20
|
+
session_public_key,
|
|
21
|
+
string_to_user_seed,
|
|
22
|
+
string_to_user_seed_hex,
|
|
21
23
|
} from '../dist/node-inline/rolly_wasm_signer.js';
|
package/js/node-inline.cjs
CHANGED
|
@@ -3,23 +3,25 @@
|
|
|
3
3
|
const wasm = require('../dist/node-inline/rolly_wasm_signer.js');
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
amount_split: wasm.amount_split,
|
|
7
|
+
compute_address_hash: wasm.compute_address_hash,
|
|
8
|
+
compute_multi_dice: wasm.compute_multi_dice,
|
|
9
|
+
compute_payout_dice: wasm.compute_payout_dice,
|
|
10
|
+
compute_payout_plinko: wasm.compute_payout_plinko,
|
|
11
|
+
compute_roll_dice: wasm.compute_roll_dice,
|
|
12
|
+
compute_roll_plinko: wasm.compute_roll_plinko,
|
|
13
|
+
compute_server_seed_hash: wasm.compute_server_seed_hash,
|
|
14
|
+
derive_session_key: wasm.derive_session_key,
|
|
15
|
+
generate_user_seed: wasm.generate_user_seed,
|
|
16
|
+
goldilocks_fields_to_hex: wasm.goldilocks_fields_to_hex,
|
|
17
|
+
goldilocks_modulus: wasm.goldilocks_modulus,
|
|
18
|
+
goldilocks_reduce: wasm.goldilocks_reduce,
|
|
19
|
+
hash_balance_leaf: wasm.hash_balance_leaf,
|
|
20
|
+
make_main_leaf: wasm.make_main_leaf,
|
|
21
|
+
poseidon2_hash: wasm.poseidon2_hash,
|
|
22
|
+
poseidon2_two_to_one: wasm.poseidon2_two_to_one,
|
|
23
|
+
seed_hash_truncated: wasm.seed_hash_truncated,
|
|
24
|
+
session_public_key: wasm.session_public_key,
|
|
25
|
+
string_to_user_seed: wasm.string_to_user_seed,
|
|
26
|
+
string_to_user_seed_hex: wasm.string_to_user_seed_hex,
|
|
25
27
|
};
|
package/js/node-inline.mjs
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
amount_split,
|
|
3
|
+
compute_address_hash,
|
|
4
|
+
compute_multi_dice,
|
|
5
|
+
compute_payout_dice,
|
|
6
|
+
compute_payout_plinko,
|
|
7
|
+
compute_roll_dice,
|
|
8
|
+
compute_roll_plinko,
|
|
6
9
|
compute_server_seed_hash,
|
|
7
|
-
|
|
8
|
-
string_to_user_seed,
|
|
9
|
-
string_to_user_seed_hex,
|
|
10
|
+
derive_session_key,
|
|
10
11
|
generate_user_seed,
|
|
11
12
|
goldilocks_fields_to_hex,
|
|
12
13
|
goldilocks_modulus,
|
|
13
14
|
goldilocks_reduce,
|
|
14
|
-
amount_split,
|
|
15
|
-
compute_address_hash,
|
|
16
15
|
hash_balance_leaf,
|
|
17
16
|
make_main_leaf,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
poseidon2_hash,
|
|
18
|
+
poseidon2_two_to_one,
|
|
19
|
+
seed_hash_truncated,
|
|
20
|
+
session_public_key,
|
|
21
|
+
string_to_user_seed,
|
|
22
|
+
string_to_user_seed_hex,
|
|
21
23
|
} from '../dist/node-inline/rolly_wasm_signer.mjs';
|
package/js/node.cjs
CHANGED
|
@@ -3,23 +3,25 @@
|
|
|
3
3
|
const wasm = require('../dist/node/rolly_wasm_signer.js');
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
amount_split: wasm.amount_split,
|
|
7
|
+
compute_address_hash: wasm.compute_address_hash,
|
|
8
|
+
compute_multi_dice: wasm.compute_multi_dice,
|
|
9
|
+
compute_payout_dice: wasm.compute_payout_dice,
|
|
10
|
+
compute_payout_plinko: wasm.compute_payout_plinko,
|
|
11
|
+
compute_roll_dice: wasm.compute_roll_dice,
|
|
12
|
+
compute_roll_plinko: wasm.compute_roll_plinko,
|
|
13
|
+
compute_server_seed_hash: wasm.compute_server_seed_hash,
|
|
14
|
+
derive_session_key: wasm.derive_session_key,
|
|
15
|
+
generate_user_seed: wasm.generate_user_seed,
|
|
16
|
+
goldilocks_fields_to_hex: wasm.goldilocks_fields_to_hex,
|
|
17
|
+
goldilocks_modulus: wasm.goldilocks_modulus,
|
|
18
|
+
goldilocks_reduce: wasm.goldilocks_reduce,
|
|
19
|
+
hash_balance_leaf: wasm.hash_balance_leaf,
|
|
20
|
+
make_main_leaf: wasm.make_main_leaf,
|
|
21
|
+
poseidon2_hash: wasm.poseidon2_hash,
|
|
22
|
+
poseidon2_two_to_one: wasm.poseidon2_two_to_one,
|
|
23
|
+
seed_hash_truncated: wasm.seed_hash_truncated,
|
|
24
|
+
session_public_key: wasm.session_public_key,
|
|
25
|
+
string_to_user_seed: wasm.string_to_user_seed,
|
|
26
|
+
string_to_user_seed_hex: wasm.string_to_user_seed_hex,
|
|
25
27
|
};
|
package/js/node.mjs
CHANGED
|
@@ -4,23 +4,25 @@ const require = createRequire(import.meta.url);
|
|
|
4
4
|
const wasm = require('../dist/node/rolly_wasm_signer.js');
|
|
5
5
|
|
|
6
6
|
export const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
amount_split,
|
|
8
|
+
compute_address_hash,
|
|
9
|
+
compute_multi_dice,
|
|
10
|
+
compute_payout_dice,
|
|
11
|
+
compute_payout_plinko,
|
|
12
|
+
compute_roll_dice,
|
|
13
|
+
compute_roll_plinko,
|
|
11
14
|
compute_server_seed_hash,
|
|
12
|
-
|
|
13
|
-
string_to_user_seed,
|
|
14
|
-
string_to_user_seed_hex,
|
|
15
|
+
derive_session_key,
|
|
15
16
|
generate_user_seed,
|
|
16
17
|
goldilocks_fields_to_hex,
|
|
17
18
|
goldilocks_modulus,
|
|
18
19
|
goldilocks_reduce,
|
|
19
|
-
amount_split,
|
|
20
|
-
compute_address_hash,
|
|
21
20
|
hash_balance_leaf,
|
|
22
21
|
make_main_leaf,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
poseidon2_hash,
|
|
23
|
+
poseidon2_two_to_one,
|
|
24
|
+
seed_hash_truncated,
|
|
25
|
+
session_public_key,
|
|
26
|
+
string_to_user_seed,
|
|
27
|
+
string_to_user_seed_hex,
|
|
26
28
|
} = wasm;
|
package/js/react.mjs
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
import init, {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
amount_split,
|
|
4
|
+
compute_address_hash,
|
|
5
|
+
compute_multi_dice,
|
|
6
|
+
compute_payout_dice,
|
|
7
|
+
compute_payout_plinko,
|
|
8
|
+
compute_roll_dice,
|
|
9
|
+
compute_roll_plinko,
|
|
7
10
|
compute_server_seed_hash,
|
|
8
|
-
|
|
9
|
-
string_to_user_seed,
|
|
10
|
-
string_to_user_seed_hex,
|
|
11
|
+
derive_session_key,
|
|
11
12
|
generate_user_seed,
|
|
12
13
|
goldilocks_fields_to_hex,
|
|
13
14
|
goldilocks_modulus,
|
|
14
15
|
goldilocks_reduce,
|
|
15
|
-
amount_split,
|
|
16
|
-
compute_address_hash,
|
|
17
16
|
hash_balance_leaf,
|
|
18
17
|
make_main_leaf,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
poseidon2_hash,
|
|
19
|
+
poseidon2_two_to_one,
|
|
20
|
+
seed_hash_truncated,
|
|
21
|
+
session_public_key,
|
|
22
|
+
string_to_user_seed,
|
|
23
|
+
string_to_user_seed_hex,
|
|
22
24
|
} from '../dist/web/rolly_wasm_signer.js';
|
|
23
25
|
|
|
24
26
|
let _ready = false;
|
|
@@ -32,25 +34,27 @@ function guard(fn) {
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
const fns = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
37
|
+
amount_split: guard(amount_split),
|
|
38
|
+
compute_address_hash: guard(compute_address_hash),
|
|
39
|
+
compute_multi_dice: guard(compute_multi_dice),
|
|
40
|
+
compute_payout_dice: guard(compute_payout_dice),
|
|
41
|
+
compute_payout_plinko: guard(compute_payout_plinko),
|
|
42
|
+
compute_roll_dice: guard(compute_roll_dice),
|
|
43
|
+
compute_roll_plinko: guard(compute_roll_plinko),
|
|
44
|
+
compute_server_seed_hash: guard(compute_server_seed_hash),
|
|
45
|
+
derive_session_key: guard(derive_session_key),
|
|
46
|
+
generate_user_seed: guard(generate_user_seed),
|
|
47
|
+
goldilocks_fields_to_hex: guard(goldilocks_fields_to_hex),
|
|
48
|
+
goldilocks_modulus: guard(goldilocks_modulus),
|
|
49
|
+
goldilocks_reduce: guard(goldilocks_reduce),
|
|
50
|
+
hash_balance_leaf: guard(hash_balance_leaf),
|
|
51
|
+
make_main_leaf: guard(make_main_leaf),
|
|
52
|
+
poseidon2_hash: guard(poseidon2_hash),
|
|
53
|
+
poseidon2_two_to_one: guard(poseidon2_two_to_one),
|
|
54
|
+
seed_hash_truncated: guard(seed_hash_truncated),
|
|
55
|
+
session_public_key: guard(session_public_key),
|
|
56
|
+
string_to_user_seed: guard(string_to_user_seed),
|
|
57
|
+
string_to_user_seed_hex: guard(string_to_user_seed_hex),
|
|
54
58
|
};
|
|
55
59
|
|
|
56
60
|
/**
|
|
@@ -58,12 +62,6 @@ const fns = {
|
|
|
58
62
|
* returns `{ ready, error, ...wasmFunctions }`.
|
|
59
63
|
*
|
|
60
64
|
* Functions are always available but will throw if called before `ready === true`.
|
|
61
|
-
*
|
|
62
|
-
* ```jsx
|
|
63
|
-
* const { ready, poseidon2_hash } = useRollyWasm();
|
|
64
|
-
* if (!ready) return <Spinner />;
|
|
65
|
-
* const h = poseidon2_hash(BigUint64Array.from([1n, 2n]));
|
|
66
|
-
* ```
|
|
67
65
|
*/
|
|
68
66
|
export function useRollyWasm() {
|
|
69
67
|
const [ready, setReady] = useState(_ready);
|