@rolly-dev/wasm-signer 0.1.2 → 0.3.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/dist/node/rolly_wasm_signer.d.ts +41 -0
- package/dist/node/rolly_wasm_signer.js +148 -0
- package/dist/node/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/node/rolly_wasm_signer_bg.wasm.d.ts +4 -0
- package/dist/web/rolly_wasm_signer.d.ts +45 -0
- package/dist/web/rolly_wasm_signer.js +145 -0
- package/dist/web/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/web/rolly_wasm_signer_bg.wasm.d.ts +4 -0
- package/js/browser.d.mts +3 -0
- package/js/browser.mjs +3 -0
- package/js/index.d.ts +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
|
@@ -59,6 +59,18 @@ export function create_bet_auth(session_key: BigUint64Array, bet_amount: bigint,
|
|
|
59
59
|
*/
|
|
60
60
|
export function derive_session_key(sig_bytes: Uint8Array): BigUint64Array;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Convert any Goldilocks field elements to a hex string.
|
|
64
|
+
*
|
|
65
|
+
* Each u64 is encoded as 8 little-endian bytes → 16 hex chars.
|
|
66
|
+
* For 4 elements: 64 hex chars (32 bytes).
|
|
67
|
+
*
|
|
68
|
+
* ```js
|
|
69
|
+
* const hex = goldilocks_fields_to_hex(BigUint64Array.from([1n, 2n, 3n, 4n]));
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export function goldilocks_fields_to_hex(fields: BigUint64Array): string;
|
|
73
|
+
|
|
62
74
|
/**
|
|
63
75
|
* Returns the Goldilocks prime: p = 2^64 - 2^32 + 1.
|
|
64
76
|
*/
|
|
@@ -118,3 +130,32 @@ export function seed_hash_truncated(server_seed: BigUint64Array): BigUint64Array
|
|
|
118
130
|
* `session_key` must be exactly 4 elements (output of `derive_session_key`).
|
|
119
131
|
*/
|
|
120
132
|
export function session_public_key(session_key: BigUint64Array): BigUint64Array;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Convert a user seed string to 4 Goldilocks field elements.
|
|
136
|
+
*
|
|
137
|
+
* `SHA-256(str)` → split into 4 × 8 LE bytes → reduce each mod p.
|
|
138
|
+
*
|
|
139
|
+
* This matches the backend's `stringToUserSeed` and produces the exact
|
|
140
|
+
* field elements used in the provably-fair random computation:
|
|
141
|
+
* `random = Poseidon2(server_seed ‖ user_seed)`
|
|
142
|
+
*
|
|
143
|
+
* ```js
|
|
144
|
+
* const fields = string_to_user_seed("my-seed-123");
|
|
145
|
+
* // fields.length === 4, each < GOLDILOCKS_P
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export function string_to_user_seed(input: string): BigUint64Array;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Convert a user seed string directly to a hex representation.
|
|
152
|
+
*
|
|
153
|
+
* Equivalent to `goldiLocksFieldsToHex(stringToUserSeed(str))`.
|
|
154
|
+
* Returns a 64-character lowercase hex string (32 bytes).
|
|
155
|
+
*
|
|
156
|
+
* ```js
|
|
157
|
+
* const hex = string_to_user_seed_hex("my-seed-123");
|
|
158
|
+
* // hex === "a1b2c3..." (64 chars)
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export function string_to_user_seed_hex(input: string): string;
|
|
@@ -111,6 +111,38 @@ function derive_session_key(sig_bytes) {
|
|
|
111
111
|
}
|
|
112
112
|
exports.derive_session_key = derive_session_key;
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Convert any Goldilocks field elements to a hex string.
|
|
116
|
+
*
|
|
117
|
+
* Each u64 is encoded as 8 little-endian bytes → 16 hex chars.
|
|
118
|
+
* For 4 elements: 64 hex chars (32 bytes).
|
|
119
|
+
*
|
|
120
|
+
* ```js
|
|
121
|
+
* const hex = goldilocks_fields_to_hex(BigUint64Array.from([1n, 2n, 3n, 4n]));
|
|
122
|
+
* ```
|
|
123
|
+
* @param {BigUint64Array} fields
|
|
124
|
+
* @returns {string}
|
|
125
|
+
*/
|
|
126
|
+
function goldilocks_fields_to_hex(fields) {
|
|
127
|
+
let deferred2_0;
|
|
128
|
+
let deferred2_1;
|
|
129
|
+
try {
|
|
130
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
131
|
+
const ptr0 = passArray64ToWasm0(fields, wasm.__wbindgen_export);
|
|
132
|
+
const len0 = WASM_VECTOR_LEN;
|
|
133
|
+
wasm.goldilocks_fields_to_hex(retptr, ptr0, len0);
|
|
134
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
135
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
136
|
+
deferred2_0 = r0;
|
|
137
|
+
deferred2_1 = r1;
|
|
138
|
+
return getStringFromWasm0(r0, r1);
|
|
139
|
+
} finally {
|
|
140
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
141
|
+
wasm.__wbindgen_export2(deferred2_0, deferred2_1, 1);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.goldilocks_fields_to_hex = goldilocks_fields_to_hex;
|
|
145
|
+
|
|
114
146
|
/**
|
|
115
147
|
* Returns the Goldilocks prime: p = 2^64 - 2^32 + 1.
|
|
116
148
|
* @returns {bigint}
|
|
@@ -253,6 +285,72 @@ function session_public_key(session_key) {
|
|
|
253
285
|
}
|
|
254
286
|
exports.session_public_key = session_public_key;
|
|
255
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Convert a user seed string to 4 Goldilocks field elements.
|
|
290
|
+
*
|
|
291
|
+
* `SHA-256(str)` → split into 4 × 8 LE bytes → reduce each mod p.
|
|
292
|
+
*
|
|
293
|
+
* This matches the backend's `stringToUserSeed` and produces the exact
|
|
294
|
+
* field elements used in the provably-fair random computation:
|
|
295
|
+
* `random = Poseidon2(server_seed ‖ user_seed)`
|
|
296
|
+
*
|
|
297
|
+
* ```js
|
|
298
|
+
* const fields = string_to_user_seed("my-seed-123");
|
|
299
|
+
* // fields.length === 4, each < GOLDILOCKS_P
|
|
300
|
+
* ```
|
|
301
|
+
* @param {string} input
|
|
302
|
+
* @returns {BigUint64Array}
|
|
303
|
+
*/
|
|
304
|
+
function string_to_user_seed(input) {
|
|
305
|
+
try {
|
|
306
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
307
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export3);
|
|
308
|
+
const len0 = WASM_VECTOR_LEN;
|
|
309
|
+
wasm.string_to_user_seed(retptr, ptr0, len0);
|
|
310
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
311
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
312
|
+
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
313
|
+
wasm.__wbindgen_export2(r0, r1 * 8, 8);
|
|
314
|
+
return v2;
|
|
315
|
+
} finally {
|
|
316
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
exports.string_to_user_seed = string_to_user_seed;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Convert a user seed string directly to a hex representation.
|
|
323
|
+
*
|
|
324
|
+
* Equivalent to `goldiLocksFieldsToHex(stringToUserSeed(str))`.
|
|
325
|
+
* Returns a 64-character lowercase hex string (32 bytes).
|
|
326
|
+
*
|
|
327
|
+
* ```js
|
|
328
|
+
* const hex = string_to_user_seed_hex("my-seed-123");
|
|
329
|
+
* // hex === "a1b2c3..." (64 chars)
|
|
330
|
+
* ```
|
|
331
|
+
* @param {string} input
|
|
332
|
+
* @returns {string}
|
|
333
|
+
*/
|
|
334
|
+
function string_to_user_seed_hex(input) {
|
|
335
|
+
let deferred2_0;
|
|
336
|
+
let deferred2_1;
|
|
337
|
+
try {
|
|
338
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
339
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export3);
|
|
340
|
+
const len0 = WASM_VECTOR_LEN;
|
|
341
|
+
wasm.string_to_user_seed_hex(retptr, ptr0, len0);
|
|
342
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
343
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
344
|
+
deferred2_0 = r0;
|
|
345
|
+
deferred2_1 = r1;
|
|
346
|
+
return getStringFromWasm0(r0, r1);
|
|
347
|
+
} finally {
|
|
348
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
349
|
+
wasm.__wbindgen_export2(deferred2_0, deferred2_1, 1);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
exports.string_to_user_seed_hex = string_to_user_seed_hex;
|
|
353
|
+
|
|
256
354
|
function __wbg_get_imports() {
|
|
257
355
|
const import0 = {
|
|
258
356
|
__proto__: null,
|
|
@@ -314,12 +412,62 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
314
412
|
return ptr;
|
|
315
413
|
}
|
|
316
414
|
|
|
415
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
416
|
+
if (realloc === undefined) {
|
|
417
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
418
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
419
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
420
|
+
WASM_VECTOR_LEN = buf.length;
|
|
421
|
+
return ptr;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
let len = arg.length;
|
|
425
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
426
|
+
|
|
427
|
+
const mem = getUint8ArrayMemory0();
|
|
428
|
+
|
|
429
|
+
let offset = 0;
|
|
430
|
+
|
|
431
|
+
for (; offset < len; offset++) {
|
|
432
|
+
const code = arg.charCodeAt(offset);
|
|
433
|
+
if (code > 0x7F) break;
|
|
434
|
+
mem[ptr + offset] = code;
|
|
435
|
+
}
|
|
436
|
+
if (offset !== len) {
|
|
437
|
+
if (offset !== 0) {
|
|
438
|
+
arg = arg.slice(offset);
|
|
439
|
+
}
|
|
440
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
441
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
442
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
443
|
+
|
|
444
|
+
offset += ret.written;
|
|
445
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
WASM_VECTOR_LEN = offset;
|
|
449
|
+
return ptr;
|
|
450
|
+
}
|
|
451
|
+
|
|
317
452
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
318
453
|
cachedTextDecoder.decode();
|
|
319
454
|
function decodeText(ptr, len) {
|
|
320
455
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
321
456
|
}
|
|
322
457
|
|
|
458
|
+
const cachedTextEncoder = new TextEncoder();
|
|
459
|
+
|
|
460
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
461
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
462
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
463
|
+
view.set(buf);
|
|
464
|
+
return {
|
|
465
|
+
read: arg.length,
|
|
466
|
+
written: buf.length
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
|
|
323
471
|
let WASM_VECTOR_LEN = 0;
|
|
324
472
|
|
|
325
473
|
const wasmPath = `${__dirname}/rolly_wasm_signer_bg.wasm`;
|
|
Binary file
|
|
@@ -4,12 +4,16 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
5
5
|
export const create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
|
6
6
|
export const derive_session_key: (a: number, b: number, c: number) => void;
|
|
7
|
+
export const goldilocks_fields_to_hex: (a: number, b: number, c: number) => void;
|
|
7
8
|
export const goldilocks_reduce: (a: bigint) => bigint;
|
|
8
9
|
export const poseidon2_hash: (a: number, b: number, c: number) => void;
|
|
9
10
|
export const poseidon2_two_to_one: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
10
11
|
export const seed_hash_truncated: (a: number, b: number, c: number) => void;
|
|
11
12
|
export const session_public_key: (a: number, b: number, c: number) => void;
|
|
13
|
+
export const string_to_user_seed: (a: number, b: number, c: number) => void;
|
|
14
|
+
export const string_to_user_seed_hex: (a: number, b: number, c: number) => void;
|
|
12
15
|
export const goldilocks_modulus: () => bigint;
|
|
13
16
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
14
17
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
15
18
|
export const __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
19
|
+
export const __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
|
@@ -59,6 +59,18 @@ export function create_bet_auth(session_key: BigUint64Array, bet_amount: bigint,
|
|
|
59
59
|
*/
|
|
60
60
|
export function derive_session_key(sig_bytes: Uint8Array): BigUint64Array;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Convert any Goldilocks field elements to a hex string.
|
|
64
|
+
*
|
|
65
|
+
* Each u64 is encoded as 8 little-endian bytes → 16 hex chars.
|
|
66
|
+
* For 4 elements: 64 hex chars (32 bytes).
|
|
67
|
+
*
|
|
68
|
+
* ```js
|
|
69
|
+
* const hex = goldilocks_fields_to_hex(BigUint64Array.from([1n, 2n, 3n, 4n]));
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export function goldilocks_fields_to_hex(fields: BigUint64Array): string;
|
|
73
|
+
|
|
62
74
|
/**
|
|
63
75
|
* Returns the Goldilocks prime: p = 2^64 - 2^32 + 1.
|
|
64
76
|
*/
|
|
@@ -119,6 +131,35 @@ export function seed_hash_truncated(server_seed: BigUint64Array): BigUint64Array
|
|
|
119
131
|
*/
|
|
120
132
|
export function session_public_key(session_key: BigUint64Array): BigUint64Array;
|
|
121
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Convert a user seed string to 4 Goldilocks field elements.
|
|
136
|
+
*
|
|
137
|
+
* `SHA-256(str)` → split into 4 × 8 LE bytes → reduce each mod p.
|
|
138
|
+
*
|
|
139
|
+
* This matches the backend's `stringToUserSeed` and produces the exact
|
|
140
|
+
* field elements used in the provably-fair random computation:
|
|
141
|
+
* `random = Poseidon2(server_seed ‖ user_seed)`
|
|
142
|
+
*
|
|
143
|
+
* ```js
|
|
144
|
+
* const fields = string_to_user_seed("my-seed-123");
|
|
145
|
+
* // fields.length === 4, each < GOLDILOCKS_P
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export function string_to_user_seed(input: string): BigUint64Array;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Convert a user seed string directly to a hex representation.
|
|
152
|
+
*
|
|
153
|
+
* Equivalent to `goldiLocksFieldsToHex(stringToUserSeed(str))`.
|
|
154
|
+
* Returns a 64-character lowercase hex string (32 bytes).
|
|
155
|
+
*
|
|
156
|
+
* ```js
|
|
157
|
+
* const hex = string_to_user_seed_hex("my-seed-123");
|
|
158
|
+
* // hex === "a1b2c3..." (64 chars)
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export function string_to_user_seed_hex(input: string): string;
|
|
162
|
+
|
|
122
163
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
123
164
|
|
|
124
165
|
export interface InitOutput {
|
|
@@ -126,15 +167,19 @@ export interface InitOutput {
|
|
|
126
167
|
readonly compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
127
168
|
readonly create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
|
128
169
|
readonly derive_session_key: (a: number, b: number, c: number) => void;
|
|
170
|
+
readonly goldilocks_fields_to_hex: (a: number, b: number, c: number) => void;
|
|
129
171
|
readonly goldilocks_reduce: (a: bigint) => bigint;
|
|
130
172
|
readonly poseidon2_hash: (a: number, b: number, c: number) => void;
|
|
131
173
|
readonly poseidon2_two_to_one: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
132
174
|
readonly seed_hash_truncated: (a: number, b: number, c: number) => void;
|
|
133
175
|
readonly session_public_key: (a: number, b: number, c: number) => void;
|
|
176
|
+
readonly string_to_user_seed: (a: number, b: number, c: number) => void;
|
|
177
|
+
readonly string_to_user_seed_hex: (a: number, b: number, c: number) => void;
|
|
134
178
|
readonly goldilocks_modulus: () => bigint;
|
|
135
179
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
136
180
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
137
181
|
readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
182
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
|
138
183
|
}
|
|
139
184
|
|
|
140
185
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
@@ -108,6 +108,37 @@ export function derive_session_key(sig_bytes) {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Convert any Goldilocks field elements to a hex string.
|
|
113
|
+
*
|
|
114
|
+
* Each u64 is encoded as 8 little-endian bytes → 16 hex chars.
|
|
115
|
+
* For 4 elements: 64 hex chars (32 bytes).
|
|
116
|
+
*
|
|
117
|
+
* ```js
|
|
118
|
+
* const hex = goldilocks_fields_to_hex(BigUint64Array.from([1n, 2n, 3n, 4n]));
|
|
119
|
+
* ```
|
|
120
|
+
* @param {BigUint64Array} fields
|
|
121
|
+
* @returns {string}
|
|
122
|
+
*/
|
|
123
|
+
export function goldilocks_fields_to_hex(fields) {
|
|
124
|
+
let deferred2_0;
|
|
125
|
+
let deferred2_1;
|
|
126
|
+
try {
|
|
127
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
128
|
+
const ptr0 = passArray64ToWasm0(fields, wasm.__wbindgen_export);
|
|
129
|
+
const len0 = WASM_VECTOR_LEN;
|
|
130
|
+
wasm.goldilocks_fields_to_hex(retptr, ptr0, len0);
|
|
131
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
132
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
133
|
+
deferred2_0 = r0;
|
|
134
|
+
deferred2_1 = r1;
|
|
135
|
+
return getStringFromWasm0(r0, r1);
|
|
136
|
+
} finally {
|
|
137
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
138
|
+
wasm.__wbindgen_export2(deferred2_0, deferred2_1, 1);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
111
142
|
/**
|
|
112
143
|
* Returns the Goldilocks prime: p = 2^64 - 2^32 + 1.
|
|
113
144
|
* @returns {bigint}
|
|
@@ -244,6 +275,70 @@ export function session_public_key(session_key) {
|
|
|
244
275
|
}
|
|
245
276
|
}
|
|
246
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Convert a user seed string to 4 Goldilocks field elements.
|
|
280
|
+
*
|
|
281
|
+
* `SHA-256(str)` → split into 4 × 8 LE bytes → reduce each mod p.
|
|
282
|
+
*
|
|
283
|
+
* This matches the backend's `stringToUserSeed` and produces the exact
|
|
284
|
+
* field elements used in the provably-fair random computation:
|
|
285
|
+
* `random = Poseidon2(server_seed ‖ user_seed)`
|
|
286
|
+
*
|
|
287
|
+
* ```js
|
|
288
|
+
* const fields = string_to_user_seed("my-seed-123");
|
|
289
|
+
* // fields.length === 4, each < GOLDILOCKS_P
|
|
290
|
+
* ```
|
|
291
|
+
* @param {string} input
|
|
292
|
+
* @returns {BigUint64Array}
|
|
293
|
+
*/
|
|
294
|
+
export function string_to_user_seed(input) {
|
|
295
|
+
try {
|
|
296
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
297
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export3);
|
|
298
|
+
const len0 = WASM_VECTOR_LEN;
|
|
299
|
+
wasm.string_to_user_seed(retptr, ptr0, len0);
|
|
300
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
301
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
302
|
+
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
303
|
+
wasm.__wbindgen_export2(r0, r1 * 8, 8);
|
|
304
|
+
return v2;
|
|
305
|
+
} finally {
|
|
306
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Convert a user seed string directly to a hex representation.
|
|
312
|
+
*
|
|
313
|
+
* Equivalent to `goldiLocksFieldsToHex(stringToUserSeed(str))`.
|
|
314
|
+
* Returns a 64-character lowercase hex string (32 bytes).
|
|
315
|
+
*
|
|
316
|
+
* ```js
|
|
317
|
+
* const hex = string_to_user_seed_hex("my-seed-123");
|
|
318
|
+
* // hex === "a1b2c3..." (64 chars)
|
|
319
|
+
* ```
|
|
320
|
+
* @param {string} input
|
|
321
|
+
* @returns {string}
|
|
322
|
+
*/
|
|
323
|
+
export function string_to_user_seed_hex(input) {
|
|
324
|
+
let deferred2_0;
|
|
325
|
+
let deferred2_1;
|
|
326
|
+
try {
|
|
327
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
328
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export3);
|
|
329
|
+
const len0 = WASM_VECTOR_LEN;
|
|
330
|
+
wasm.string_to_user_seed_hex(retptr, ptr0, len0);
|
|
331
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
332
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
333
|
+
deferred2_0 = r0;
|
|
334
|
+
deferred2_1 = r1;
|
|
335
|
+
return getStringFromWasm0(r0, r1);
|
|
336
|
+
} finally {
|
|
337
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
338
|
+
wasm.__wbindgen_export2(deferred2_0, deferred2_1, 1);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
247
342
|
function __wbg_get_imports() {
|
|
248
343
|
const import0 = {
|
|
249
344
|
__proto__: null,
|
|
@@ -305,6 +400,43 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
305
400
|
return ptr;
|
|
306
401
|
}
|
|
307
402
|
|
|
403
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
404
|
+
if (realloc === undefined) {
|
|
405
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
406
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
407
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
408
|
+
WASM_VECTOR_LEN = buf.length;
|
|
409
|
+
return ptr;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
let len = arg.length;
|
|
413
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
414
|
+
|
|
415
|
+
const mem = getUint8ArrayMemory0();
|
|
416
|
+
|
|
417
|
+
let offset = 0;
|
|
418
|
+
|
|
419
|
+
for (; offset < len; offset++) {
|
|
420
|
+
const code = arg.charCodeAt(offset);
|
|
421
|
+
if (code > 0x7F) break;
|
|
422
|
+
mem[ptr + offset] = code;
|
|
423
|
+
}
|
|
424
|
+
if (offset !== len) {
|
|
425
|
+
if (offset !== 0) {
|
|
426
|
+
arg = arg.slice(offset);
|
|
427
|
+
}
|
|
428
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
429
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
430
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
431
|
+
|
|
432
|
+
offset += ret.written;
|
|
433
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
WASM_VECTOR_LEN = offset;
|
|
437
|
+
return ptr;
|
|
438
|
+
}
|
|
439
|
+
|
|
308
440
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
309
441
|
cachedTextDecoder.decode();
|
|
310
442
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
@@ -319,6 +451,19 @@ function decodeText(ptr, len) {
|
|
|
319
451
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
320
452
|
}
|
|
321
453
|
|
|
454
|
+
const cachedTextEncoder = new TextEncoder();
|
|
455
|
+
|
|
456
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
457
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
458
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
459
|
+
view.set(buf);
|
|
460
|
+
return {
|
|
461
|
+
read: arg.length,
|
|
462
|
+
written: buf.length
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
|
|
322
467
|
let WASM_VECTOR_LEN = 0;
|
|
323
468
|
|
|
324
469
|
let wasmModule, wasm;
|
|
Binary file
|
|
@@ -4,12 +4,16 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
5
5
|
export const create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
|
6
6
|
export const derive_session_key: (a: number, b: number, c: number) => void;
|
|
7
|
+
export const goldilocks_fields_to_hex: (a: number, b: number, c: number) => void;
|
|
7
8
|
export const goldilocks_reduce: (a: bigint) => bigint;
|
|
8
9
|
export const poseidon2_hash: (a: number, b: number, c: number) => void;
|
|
9
10
|
export const poseidon2_two_to_one: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
10
11
|
export const seed_hash_truncated: (a: number, b: number, c: number) => void;
|
|
11
12
|
export const session_public_key: (a: number, b: number, c: number) => void;
|
|
13
|
+
export const string_to_user_seed: (a: number, b: number, c: number) => void;
|
|
14
|
+
export const string_to_user_seed_hex: (a: number, b: number, c: number) => void;
|
|
12
15
|
export const goldilocks_modulus: () => bigint;
|
|
13
16
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
14
17
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
15
18
|
export const __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
19
|
+
export const __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
package/js/browser.d.mts
CHANGED
package/js/browser.mjs
CHANGED
package/js/index.d.ts
CHANGED
package/js/node.cjs
CHANGED
|
@@ -10,6 +10,9 @@ module.exports = {
|
|
|
10
10
|
create_bet_auth: wasm.create_bet_auth,
|
|
11
11
|
compute_server_seed_hash: wasm.compute_server_seed_hash,
|
|
12
12
|
seed_hash_truncated: wasm.seed_hash_truncated,
|
|
13
|
+
string_to_user_seed: wasm.string_to_user_seed,
|
|
14
|
+
string_to_user_seed_hex: wasm.string_to_user_seed_hex,
|
|
15
|
+
goldilocks_fields_to_hex: wasm.goldilocks_fields_to_hex,
|
|
13
16
|
goldilocks_modulus: wasm.goldilocks_modulus,
|
|
14
17
|
goldilocks_reduce: wasm.goldilocks_reduce,
|
|
15
18
|
};
|
package/js/node.mjs
CHANGED
package/js/react.d.mts
CHANGED
|
@@ -8,6 +8,9 @@ export interface RollyWasmResult {
|
|
|
8
8
|
create_bet_auth: ((session_key: BigUint64Array, bet_amount: bigint, nonce: bigint) => BigUint64Array) | null;
|
|
9
9
|
compute_server_seed_hash: ((server_seed: BigUint64Array) => BigUint64Array) | null;
|
|
10
10
|
seed_hash_truncated: ((server_seed: BigUint64Array) => BigUint64Array) | null;
|
|
11
|
+
string_to_user_seed: ((input: string) => BigUint64Array) | null;
|
|
12
|
+
string_to_user_seed_hex: ((input: string) => string) | null;
|
|
13
|
+
goldilocks_fields_to_hex: ((fields: BigUint64Array) => string) | null;
|
|
11
14
|
goldilocks_modulus: (() => bigint) | null;
|
|
12
15
|
goldilocks_reduce: ((value: bigint) => bigint) | null;
|
|
13
16
|
}
|
package/js/react.mjs
CHANGED
|
@@ -7,6 +7,9 @@ import init, {
|
|
|
7
7
|
create_bet_auth,
|
|
8
8
|
compute_server_seed_hash,
|
|
9
9
|
seed_hash_truncated,
|
|
10
|
+
string_to_user_seed,
|
|
11
|
+
string_to_user_seed_hex,
|
|
12
|
+
goldilocks_fields_to_hex,
|
|
10
13
|
goldilocks_modulus,
|
|
11
14
|
goldilocks_reduce,
|
|
12
15
|
} from '../dist/web/rolly_wasm_signer.js';
|
|
@@ -51,6 +54,9 @@ export function useRollyWasm() {
|
|
|
51
54
|
create_bet_auth: ready ? create_bet_auth : null,
|
|
52
55
|
compute_server_seed_hash: ready ? compute_server_seed_hash : null,
|
|
53
56
|
seed_hash_truncated: ready ? seed_hash_truncated : null,
|
|
57
|
+
string_to_user_seed: ready ? string_to_user_seed : null,
|
|
58
|
+
string_to_user_seed_hex: ready ? string_to_user_seed_hex : null,
|
|
59
|
+
goldilocks_fields_to_hex: ready ? goldilocks_fields_to_hex : null,
|
|
54
60
|
goldilocks_modulus: ready ? goldilocks_modulus : null,
|
|
55
61
|
goldilocks_reduce: ready ? goldilocks_reduce : null,
|
|
56
62
|
};
|