@rolly-dev/wasm-signer 0.7.0 → 0.9.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.
@@ -39,7 +39,7 @@ export function compute_server_seed_hash(server_seed: BigUint64Array): BigUint64
39
39
  * const hash = compute_tx_msg_hash(5, userId, 0, amountLo, amountHi);
40
40
  * ```
41
41
  */
42
- export function compute_tx_msg_hash(tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number): BigUint64Array;
42
+ export function compute_tx_msg_hash(tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number, session_expiry: bigint): BigUint64Array;
43
43
 
44
44
  /**
45
45
  * Create a `bet_auth` MAC that proves the user authorized this specific bet.
@@ -236,7 +236,7 @@ export function schnorr_sign_cpk(old_sk_hex: string, user_id: number, new_pk_has
236
236
  * // sig.pubkey (80 hex), sig.sig_s (80 hex), sig.sig_e (80 hex)
237
237
  * ```
238
238
  */
239
- export function schnorr_sign_tx(sk_hex: string, tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number): any;
239
+ export function schnorr_sign_tx(sk_hex: string, tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number, session_expiry: bigint): any;
240
240
 
241
241
  /**
242
242
  * Verify a Schnorr signature (s, e) for a transaction.
@@ -249,7 +249,7 @@ export function schnorr_sign_tx(sk_hex: string, tx_type: number, user_id: number
249
249
  * const ok = schnorr_verify_tx(pubkeyHex, sigSHex, sigEHex, 5, userId, 0, amountLo, amountHi);
250
250
  * ```
251
251
  */
252
- export function schnorr_verify_tx(pk_hex: string, sig_s_hex: string, sig_e_hex: string, tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number): boolean;
252
+ export function schnorr_verify_tx(pk_hex: string, sig_s_hex: string, sig_e_hex: string, tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number, session_expiry: bigint): boolean;
253
253
 
254
254
  /**
255
255
  * Truncated seed hash — first 2 elements of `Poseidon2(server_seed)`.
@@ -91,12 +91,13 @@ exports.compute_server_seed_hash = compute_server_seed_hash;
91
91
  * @param {number} currency_id
92
92
  * @param {number} amount_lo
93
93
  * @param {number} amount_hi
94
+ * @param {bigint} session_expiry
94
95
  * @returns {BigUint64Array}
95
96
  */
96
- function compute_tx_msg_hash(tx_type, user_id, currency_id, amount_lo, amount_hi) {
97
+ function compute_tx_msg_hash(tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry) {
97
98
  try {
98
99
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
99
- wasm.compute_tx_msg_hash(retptr, tx_type, user_id, currency_id, amount_lo, amount_hi);
100
+ wasm.compute_tx_msg_hash(retptr, tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry);
100
101
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
101
102
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
102
103
  var v1 = getArrayU64FromWasm0(r0, r1).slice();
@@ -535,12 +536,13 @@ exports.schnorr_sign_cpk = schnorr_sign_cpk;
535
536
  * @param {number} currency_id
536
537
  * @param {number} amount_lo
537
538
  * @param {number} amount_hi
539
+ * @param {bigint} session_expiry
538
540
  * @returns {any}
539
541
  */
540
- function schnorr_sign_tx(sk_hex, tx_type, user_id, currency_id, amount_lo, amount_hi) {
542
+ function schnorr_sign_tx(sk_hex, tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry) {
541
543
  const ptr0 = passStringToWasm0(sk_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
542
544
  const len0 = WASM_VECTOR_LEN;
543
- const ret = wasm.schnorr_sign_tx(ptr0, len0, tx_type, user_id, currency_id, amount_lo, amount_hi);
545
+ const ret = wasm.schnorr_sign_tx(ptr0, len0, tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry);
544
546
  return takeObject(ret);
545
547
  }
546
548
  exports.schnorr_sign_tx = schnorr_sign_tx;
@@ -563,16 +565,17 @@ exports.schnorr_sign_tx = schnorr_sign_tx;
563
565
  * @param {number} currency_id
564
566
  * @param {number} amount_lo
565
567
  * @param {number} amount_hi
568
+ * @param {bigint} session_expiry
566
569
  * @returns {boolean}
567
570
  */
568
- function schnorr_verify_tx(pk_hex, sig_s_hex, sig_e_hex, tx_type, user_id, currency_id, amount_lo, amount_hi) {
571
+ function schnorr_verify_tx(pk_hex, sig_s_hex, sig_e_hex, tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry) {
569
572
  const ptr0 = passStringToWasm0(pk_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
570
573
  const len0 = WASM_VECTOR_LEN;
571
574
  const ptr1 = passStringToWasm0(sig_s_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
572
575
  const len1 = WASM_VECTOR_LEN;
573
576
  const ptr2 = passStringToWasm0(sig_e_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
574
577
  const len2 = WASM_VECTOR_LEN;
575
- const ret = wasm.schnorr_verify_tx(ptr0, len0, ptr1, len1, ptr2, len2, tx_type, user_id, currency_id, amount_lo, amount_hi);
578
+ const ret = wasm.schnorr_verify_tx(ptr0, len0, ptr1, len1, ptr2, len2, tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry);
576
579
  return ret !== 0;
577
580
  }
578
581
  exports.schnorr_verify_tx = schnorr_verify_tx;
Binary file
@@ -4,7 +4,7 @@ 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
6
  export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
7
- export const compute_tx_msg_hash: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
7
+ export const compute_tx_msg_hash: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
8
8
  export const create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
9
9
  export const derive_session_key: (a: number, b: number, c: number) => void;
10
10
  export const generate_user_seed: (a: number) => void;
@@ -18,8 +18,8 @@ export const schnorr_pk_hash: (a: number, b: number, c: number) => void;
18
18
  export const schnorr_pk_hash_hex: (a: number, b: number, c: number) => void;
19
19
  export const schnorr_pubkey: (a: number, b: number, c: number) => void;
20
20
  export const schnorr_sign_cpk: (a: number, b: number, c: number, d: number, e: number) => number;
21
- export const schnorr_sign_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
22
- export const schnorr_verify_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
21
+ export const schnorr_sign_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => number;
22
+ export const schnorr_verify_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: bigint) => number;
23
23
  export const seed_hash_truncated: (a: number, b: number, c: number) => void;
24
24
  export const session_public_key: (a: number, b: number, c: number) => void;
25
25
  export const string_to_user_seed: (a: number, b: number, c: number) => void;
@@ -39,7 +39,7 @@ export function compute_server_seed_hash(server_seed: BigUint64Array): BigUint64
39
39
  * const hash = compute_tx_msg_hash(5, userId, 0, amountLo, amountHi);
40
40
  * ```
41
41
  */
42
- export function compute_tx_msg_hash(tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number): BigUint64Array;
42
+ export function compute_tx_msg_hash(tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number, session_expiry: bigint): BigUint64Array;
43
43
 
44
44
  /**
45
45
  * Create a `bet_auth` MAC that proves the user authorized this specific bet.
@@ -236,7 +236,7 @@ export function schnorr_sign_cpk(old_sk_hex: string, user_id: number, new_pk_has
236
236
  * // sig.pubkey (80 hex), sig.sig_s (80 hex), sig.sig_e (80 hex)
237
237
  * ```
238
238
  */
239
- export function schnorr_sign_tx(sk_hex: string, tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number): any;
239
+ export function schnorr_sign_tx(sk_hex: string, tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number, session_expiry: bigint): any;
240
240
 
241
241
  /**
242
242
  * Verify a Schnorr signature (s, e) for a transaction.
@@ -249,7 +249,7 @@ export function schnorr_sign_tx(sk_hex: string, tx_type: number, user_id: number
249
249
  * const ok = schnorr_verify_tx(pubkeyHex, sigSHex, sigEHex, 5, userId, 0, amountLo, amountHi);
250
250
  * ```
251
251
  */
252
- export function schnorr_verify_tx(pk_hex: string, sig_s_hex: string, sig_e_hex: string, tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number): boolean;
252
+ export function schnorr_verify_tx(pk_hex: string, sig_s_hex: string, sig_e_hex: string, tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number, session_expiry: bigint): boolean;
253
253
 
254
254
  /**
255
255
  * Truncated seed hash — first 2 elements of `Poseidon2(server_seed)`.
@@ -308,7 +308,7 @@ export interface InitOutput {
308
308
  readonly amount_split: (a: number, b: bigint) => void;
309
309
  readonly compute_address_hash: (a: number, b: number, c: number) => void;
310
310
  readonly compute_server_seed_hash: (a: number, b: number, c: number) => void;
311
- readonly compute_tx_msg_hash: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
311
+ readonly compute_tx_msg_hash: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
312
312
  readonly create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
313
313
  readonly derive_session_key: (a: number, b: number, c: number) => void;
314
314
  readonly generate_user_seed: (a: number) => void;
@@ -322,8 +322,8 @@ export interface InitOutput {
322
322
  readonly schnorr_pk_hash_hex: (a: number, b: number, c: number) => void;
323
323
  readonly schnorr_pubkey: (a: number, b: number, c: number) => void;
324
324
  readonly schnorr_sign_cpk: (a: number, b: number, c: number, d: number, e: number) => number;
325
- readonly schnorr_sign_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
326
- readonly schnorr_verify_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
325
+ readonly schnorr_sign_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => number;
326
+ readonly schnorr_verify_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: bigint) => number;
327
327
  readonly seed_hash_truncated: (a: number, b: number, c: number) => void;
328
328
  readonly session_public_key: (a: number, b: number, c: number) => void;
329
329
  readonly string_to_user_seed: (a: number, b: number, c: number) => void;
@@ -88,12 +88,13 @@ export function compute_server_seed_hash(server_seed) {
88
88
  * @param {number} currency_id
89
89
  * @param {number} amount_lo
90
90
  * @param {number} amount_hi
91
+ * @param {bigint} session_expiry
91
92
  * @returns {BigUint64Array}
92
93
  */
93
- export function compute_tx_msg_hash(tx_type, user_id, currency_id, amount_lo, amount_hi) {
94
+ export function compute_tx_msg_hash(tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry) {
94
95
  try {
95
96
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
96
- wasm.compute_tx_msg_hash(retptr, tx_type, user_id, currency_id, amount_lo, amount_hi);
97
+ wasm.compute_tx_msg_hash(retptr, tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry);
97
98
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
98
99
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
99
100
  var v1 = getArrayU64FromWasm0(r0, r1).slice();
@@ -517,12 +518,13 @@ export function schnorr_sign_cpk(old_sk_hex, user_id, new_pk_hash) {
517
518
  * @param {number} currency_id
518
519
  * @param {number} amount_lo
519
520
  * @param {number} amount_hi
521
+ * @param {bigint} session_expiry
520
522
  * @returns {any}
521
523
  */
522
- export function schnorr_sign_tx(sk_hex, tx_type, user_id, currency_id, amount_lo, amount_hi) {
524
+ export function schnorr_sign_tx(sk_hex, tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry) {
523
525
  const ptr0 = passStringToWasm0(sk_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
524
526
  const len0 = WASM_VECTOR_LEN;
525
- const ret = wasm.schnorr_sign_tx(ptr0, len0, tx_type, user_id, currency_id, amount_lo, amount_hi);
527
+ const ret = wasm.schnorr_sign_tx(ptr0, len0, tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry);
526
528
  return takeObject(ret);
527
529
  }
528
530
 
@@ -544,16 +546,17 @@ export function schnorr_sign_tx(sk_hex, tx_type, user_id, currency_id, amount_lo
544
546
  * @param {number} currency_id
545
547
  * @param {number} amount_lo
546
548
  * @param {number} amount_hi
549
+ * @param {bigint} session_expiry
547
550
  * @returns {boolean}
548
551
  */
549
- export function schnorr_verify_tx(pk_hex, sig_s_hex, sig_e_hex, tx_type, user_id, currency_id, amount_lo, amount_hi) {
552
+ export function schnorr_verify_tx(pk_hex, sig_s_hex, sig_e_hex, tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry) {
550
553
  const ptr0 = passStringToWasm0(pk_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
551
554
  const len0 = WASM_VECTOR_LEN;
552
555
  const ptr1 = passStringToWasm0(sig_s_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
553
556
  const len1 = WASM_VECTOR_LEN;
554
557
  const ptr2 = passStringToWasm0(sig_e_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
555
558
  const len2 = WASM_VECTOR_LEN;
556
- const ret = wasm.schnorr_verify_tx(ptr0, len0, ptr1, len1, ptr2, len2, tx_type, user_id, currency_id, amount_lo, amount_hi);
559
+ const ret = wasm.schnorr_verify_tx(ptr0, len0, ptr1, len1, ptr2, len2, tx_type, user_id, currency_id, amount_lo, amount_hi, session_expiry);
557
560
  return ret !== 0;
558
561
  }
559
562
 
Binary file
@@ -4,7 +4,7 @@ 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
6
  export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
7
- export const compute_tx_msg_hash: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
7
+ export const compute_tx_msg_hash: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
8
8
  export const create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
9
9
  export const derive_session_key: (a: number, b: number, c: number) => void;
10
10
  export const generate_user_seed: (a: number) => void;
@@ -18,8 +18,8 @@ export const schnorr_pk_hash: (a: number, b: number, c: number) => void;
18
18
  export const schnorr_pk_hash_hex: (a: number, b: number, c: number) => void;
19
19
  export const schnorr_pubkey: (a: number, b: number, c: number) => void;
20
20
  export const schnorr_sign_cpk: (a: number, b: number, c: number, d: number, e: number) => number;
21
- export const schnorr_sign_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
22
- export const schnorr_verify_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
21
+ export const schnorr_sign_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => number;
22
+ export const schnorr_verify_tx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: bigint) => number;
23
23
  export const seed_hash_truncated: (a: number, b: number, c: number) => void;
24
24
  export const session_public_key: (a: number, b: number, c: number) => void;
25
25
  export const string_to_user_seed: (a: number, b: number, c: number) => void;
package/js/browser.d.mts CHANGED
@@ -12,6 +12,17 @@ export {
12
12
  goldilocks_fields_to_hex,
13
13
  goldilocks_modulus,
14
14
  goldilocks_reduce,
15
+ schnorr_keygen,
16
+ schnorr_pubkey,
17
+ schnorr_sign_tx,
18
+ schnorr_verify_tx,
19
+ schnorr_pk_hash,
20
+ schnorr_pk_hash_hex,
21
+ schnorr_pk_encode,
22
+ schnorr_sign_cpk,
23
+ compute_tx_msg_hash,
24
+ amount_split,
25
+ compute_address_hash,
15
26
  } from '../dist/web/rolly_wasm_signer.js';
16
27
 
17
28
  export { default as init } from '../dist/web/rolly_wasm_signer.js';
package/js/react.d.mts CHANGED
@@ -14,6 +14,17 @@ export interface RollyWasmResult {
14
14
  goldilocks_fields_to_hex: (fields: BigUint64Array) => string;
15
15
  goldilocks_modulus: () => bigint;
16
16
  goldilocks_reduce: (value: bigint) => bigint;
17
+ schnorr_keygen: (entropy: Uint8Array) => string;
18
+ schnorr_pubkey: (sk_hex: string) => string;
19
+ schnorr_sign_tx: (sk_hex: string, tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number, session_expiry: bigint) => any;
20
+ schnorr_verify_tx: (pk_hex: string, sig_s_hex: string, sig_e_hex: string, tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number, session_expiry: bigint) => boolean;
21
+ schnorr_pk_hash: (pk_hex: string) => BigUint64Array;
22
+ schnorr_pk_hash_hex: (pk_hex: string) => string;
23
+ schnorr_pk_encode: (pk_hex: string) => BigUint64Array;
24
+ schnorr_sign_cpk: (old_sk_hex: string, user_id: number, new_pk_hash: BigUint64Array) => any;
25
+ compute_tx_msg_hash: (tx_type: number, user_id: number, currency_id: number, amount_lo: number, amount_hi: number, session_expiry: bigint) => BigUint64Array;
26
+ amount_split: (amount: bigint) => Uint32Array;
27
+ compute_address_hash: (address_hex: string) => BigUint64Array;
17
28
  }
18
29
 
19
30
  export function useRollyWasm(): RollyWasmResult;
package/js/react.mjs CHANGED
@@ -13,6 +13,17 @@ import init, {
13
13
  goldilocks_fields_to_hex,
14
14
  goldilocks_modulus,
15
15
  goldilocks_reduce,
16
+ schnorr_keygen,
17
+ schnorr_pubkey,
18
+ schnorr_sign_tx,
19
+ schnorr_verify_tx,
20
+ schnorr_pk_hash,
21
+ schnorr_pk_hash_hex,
22
+ schnorr_pk_encode,
23
+ schnorr_sign_cpk,
24
+ compute_tx_msg_hash,
25
+ amount_split,
26
+ compute_address_hash,
16
27
  } from '../dist/web/rolly_wasm_signer.js';
17
28
 
18
29
  let _ready = false;
@@ -39,6 +50,17 @@ const fns = {
39
50
  goldilocks_fields_to_hex: guard(goldilocks_fields_to_hex),
40
51
  goldilocks_modulus: guard(goldilocks_modulus),
41
52
  goldilocks_reduce: guard(goldilocks_reduce),
53
+ schnorr_keygen: guard(schnorr_keygen),
54
+ schnorr_pubkey: guard(schnorr_pubkey),
55
+ schnorr_sign_tx: guard(schnorr_sign_tx),
56
+ schnorr_verify_tx: guard(schnorr_verify_tx),
57
+ schnorr_pk_hash: guard(schnorr_pk_hash),
58
+ schnorr_pk_hash_hex: guard(schnorr_pk_hash_hex),
59
+ schnorr_pk_encode: guard(schnorr_pk_encode),
60
+ schnorr_sign_cpk: guard(schnorr_sign_cpk),
61
+ compute_tx_msg_hash: guard(compute_tx_msg_hash),
62
+ amount_split: guard(amount_split),
63
+ compute_address_hash: guard(compute_address_hash),
42
64
  };
43
65
 
44
66
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolly-dev/wasm-signer",
3
- "version": "0.7.0",
3
+ "version": "0.9.1",
4
4
  "description": "Poseidon2 hashing & bet signing for Rolly ZK-Rollup (WASM, Goldilocks field)",
5
5
  "type": "module",
6
6
  "exports": {