@rolly-dev/wasm-signer 0.6.1 → 0.7.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 +16 -10
- package/dist/node/rolly_wasm_signer.js +36 -13
- package/dist/node/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/node/rolly_wasm_signer_bg.wasm.d.ts +1 -0
- package/dist/web/rolly_wasm_signer.d.ts +17 -10
- package/dist/web/rolly_wasm_signer.js +35 -13
- package/dist/web/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/web/rolly_wasm_signer_bg.wasm.d.ts +1 -0
- package/js/browser.mjs +11 -0
- package/js/index.d.ts +11 -0
- package/js/node.cjs +11 -0
- package/js/node.mjs +11 -0
- package/package.json +1 -1
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export function amount_split(amount: bigint): Uint32Array;
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Compute address_hash = Poseidon2(addr_byte_0, ..., addr_byte_19).
|
|
17
|
+
* Takes a hex address string (with or without 0x prefix), returns [u64; 4].
|
|
18
|
+
*/
|
|
19
|
+
export function compute_address_hash(address_hex: string): BigUint64Array;
|
|
20
|
+
|
|
15
21
|
/**
|
|
16
22
|
* Full Poseidon2 hash of an 8-element server seed.
|
|
17
23
|
*
|
|
@@ -204,13 +210,13 @@ export function schnorr_pk_hash_hex(pk_hex: string): string;
|
|
|
204
210
|
export function schnorr_pubkey(sk_hex: string): string;
|
|
205
211
|
|
|
206
212
|
/**
|
|
207
|
-
* Sign a ChangePubKey (tx_type=9) transaction.
|
|
213
|
+
* Sign a ChangePubKey (tx_type=9) transaction in (s, e) format.
|
|
208
214
|
*
|
|
209
215
|
* msg_hash = Poseidon2(9, user_id, new_pk_hash[0..4])
|
|
210
216
|
*
|
|
211
217
|
* The old key signs this message to authorize key rotation.
|
|
212
218
|
*
|
|
213
|
-
* Returns a JS object: `{ pubkey: "hex",
|
|
219
|
+
* Returns a JS object: `{ pubkey: "hex", sig_s: "hex", sig_e: "hex" }`
|
|
214
220
|
*
|
|
215
221
|
* ```js
|
|
216
222
|
* const sig = schnorr_sign_cpk(oldSkHex, userId, newPkHashArray);
|
|
@@ -219,31 +225,31 @@ export function schnorr_pubkey(sk_hex: string): string;
|
|
|
219
225
|
export function schnorr_sign_cpk(old_sk_hex: string, user_id: number, new_pk_hash: BigUint64Array): any;
|
|
220
226
|
|
|
221
227
|
/**
|
|
222
|
-
* Sign a transaction with Schnorr (ECgFp5).
|
|
228
|
+
* Sign a transaction with Schnorr (ECgFp5) in (s, e) format.
|
|
223
229
|
*
|
|
224
230
|
* msg_hash = Poseidon2(tx_type, user_id, currency_id, amount_lo, amount_hi)
|
|
225
231
|
*
|
|
226
|
-
* Returns a JS object: `{ pubkey: "hex",
|
|
232
|
+
* Returns a JS object: `{ pubkey: "hex", sig_s: "hex", sig_e: "hex" }`
|
|
227
233
|
*
|
|
228
234
|
* ```js
|
|
229
|
-
* const sig = schnorr_sign_tx(skHex, 5, userId, 0,
|
|
230
|
-
* // sig.pubkey
|
|
235
|
+
* const sig = schnorr_sign_tx(skHex, 5, userId, 0, amountLo, amountHi);
|
|
236
|
+
* // sig.pubkey (80 hex), sig.sig_s (80 hex), sig.sig_e (80 hex)
|
|
231
237
|
* ```
|
|
232
238
|
*/
|
|
233
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;
|
|
234
240
|
|
|
235
241
|
/**
|
|
236
|
-
* Verify a Schnorr signature for a transaction
|
|
242
|
+
* Verify a Schnorr signature (s, e) for a transaction.
|
|
237
243
|
*
|
|
238
|
-
*
|
|
244
|
+
* Algorithm: R_v = s·G + e·pk, e_v = H(R_v‖pk‖msg), check e == e_v.
|
|
239
245
|
*
|
|
240
246
|
* Returns `true` if signature is valid, `false` otherwise.
|
|
241
247
|
*
|
|
242
248
|
* ```js
|
|
243
|
-
* const ok = schnorr_verify_tx(pubkeyHex,
|
|
249
|
+
* const ok = schnorr_verify_tx(pubkeyHex, sigSHex, sigEHex, 5, userId, 0, amountLo, amountHi);
|
|
244
250
|
* ```
|
|
245
251
|
*/
|
|
246
|
-
export function schnorr_verify_tx(pk_hex: string,
|
|
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;
|
|
247
253
|
|
|
248
254
|
/**
|
|
249
255
|
* Truncated seed hash — first 2 elements of `Poseidon2(server_seed)`.
|
|
@@ -26,6 +26,29 @@ function amount_split(amount) {
|
|
|
26
26
|
}
|
|
27
27
|
exports.amount_split = amount_split;
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Compute address_hash = Poseidon2(addr_byte_0, ..., addr_byte_19).
|
|
31
|
+
* Takes a hex address string (with or without 0x prefix), returns [u64; 4].
|
|
32
|
+
* @param {string} address_hex
|
|
33
|
+
* @returns {BigUint64Array}
|
|
34
|
+
*/
|
|
35
|
+
function compute_address_hash(address_hex) {
|
|
36
|
+
try {
|
|
37
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
38
|
+
const ptr0 = passStringToWasm0(address_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
39
|
+
const len0 = WASM_VECTOR_LEN;
|
|
40
|
+
wasm.compute_address_hash(retptr, ptr0, len0);
|
|
41
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
42
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
43
|
+
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
44
|
+
wasm.__wbindgen_export4(r0, r1 * 8, 8);
|
|
45
|
+
return v2;
|
|
46
|
+
} finally {
|
|
47
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.compute_address_hash = compute_address_hash;
|
|
51
|
+
|
|
29
52
|
/**
|
|
30
53
|
* Full Poseidon2 hash of an 8-element server seed.
|
|
31
54
|
*
|
|
@@ -469,13 +492,13 @@ function schnorr_pubkey(sk_hex) {
|
|
|
469
492
|
exports.schnorr_pubkey = schnorr_pubkey;
|
|
470
493
|
|
|
471
494
|
/**
|
|
472
|
-
* Sign a ChangePubKey (tx_type=9) transaction.
|
|
495
|
+
* Sign a ChangePubKey (tx_type=9) transaction in (s, e) format.
|
|
473
496
|
*
|
|
474
497
|
* msg_hash = Poseidon2(9, user_id, new_pk_hash[0..4])
|
|
475
498
|
*
|
|
476
499
|
* The old key signs this message to authorize key rotation.
|
|
477
500
|
*
|
|
478
|
-
* Returns a JS object: `{ pubkey: "hex",
|
|
501
|
+
* Returns a JS object: `{ pubkey: "hex", sig_s: "hex", sig_e: "hex" }`
|
|
479
502
|
*
|
|
480
503
|
* ```js
|
|
481
504
|
* const sig = schnorr_sign_cpk(oldSkHex, userId, newPkHashArray);
|
|
@@ -496,15 +519,15 @@ function schnorr_sign_cpk(old_sk_hex, user_id, new_pk_hash) {
|
|
|
496
519
|
exports.schnorr_sign_cpk = schnorr_sign_cpk;
|
|
497
520
|
|
|
498
521
|
/**
|
|
499
|
-
* Sign a transaction with Schnorr (ECgFp5).
|
|
522
|
+
* Sign a transaction with Schnorr (ECgFp5) in (s, e) format.
|
|
500
523
|
*
|
|
501
524
|
* msg_hash = Poseidon2(tx_type, user_id, currency_id, amount_lo, amount_hi)
|
|
502
525
|
*
|
|
503
|
-
* Returns a JS object: `{ pubkey: "hex",
|
|
526
|
+
* Returns a JS object: `{ pubkey: "hex", sig_s: "hex", sig_e: "hex" }`
|
|
504
527
|
*
|
|
505
528
|
* ```js
|
|
506
|
-
* const sig = schnorr_sign_tx(skHex, 5, userId, 0,
|
|
507
|
-
* // sig.pubkey
|
|
529
|
+
* const sig = schnorr_sign_tx(skHex, 5, userId, 0, amountLo, amountHi);
|
|
530
|
+
* // sig.pubkey (80 hex), sig.sig_s (80 hex), sig.sig_e (80 hex)
|
|
508
531
|
* ```
|
|
509
532
|
* @param {string} sk_hex
|
|
510
533
|
* @param {number} tx_type
|
|
@@ -523,18 +546,18 @@ function schnorr_sign_tx(sk_hex, tx_type, user_id, currency_id, amount_lo, amoun
|
|
|
523
546
|
exports.schnorr_sign_tx = schnorr_sign_tx;
|
|
524
547
|
|
|
525
548
|
/**
|
|
526
|
-
* Verify a Schnorr signature for a transaction
|
|
549
|
+
* Verify a Schnorr signature (s, e) for a transaction.
|
|
527
550
|
*
|
|
528
|
-
*
|
|
551
|
+
* Algorithm: R_v = s·G + e·pk, e_v = H(R_v‖pk‖msg), check e == e_v.
|
|
529
552
|
*
|
|
530
553
|
* Returns `true` if signature is valid, `false` otherwise.
|
|
531
554
|
*
|
|
532
555
|
* ```js
|
|
533
|
-
* const ok = schnorr_verify_tx(pubkeyHex,
|
|
556
|
+
* const ok = schnorr_verify_tx(pubkeyHex, sigSHex, sigEHex, 5, userId, 0, amountLo, amountHi);
|
|
534
557
|
* ```
|
|
535
558
|
* @param {string} pk_hex
|
|
536
|
-
* @param {string} sig_r_hex
|
|
537
559
|
* @param {string} sig_s_hex
|
|
560
|
+
* @param {string} sig_e_hex
|
|
538
561
|
* @param {number} tx_type
|
|
539
562
|
* @param {number} user_id
|
|
540
563
|
* @param {number} currency_id
|
|
@@ -542,12 +565,12 @@ exports.schnorr_sign_tx = schnorr_sign_tx;
|
|
|
542
565
|
* @param {number} amount_hi
|
|
543
566
|
* @returns {boolean}
|
|
544
567
|
*/
|
|
545
|
-
function schnorr_verify_tx(pk_hex,
|
|
568
|
+
function schnorr_verify_tx(pk_hex, sig_s_hex, sig_e_hex, tx_type, user_id, currency_id, amount_lo, amount_hi) {
|
|
546
569
|
const ptr0 = passStringToWasm0(pk_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
547
570
|
const len0 = WASM_VECTOR_LEN;
|
|
548
|
-
const ptr1 = passStringToWasm0(
|
|
571
|
+
const ptr1 = passStringToWasm0(sig_s_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
549
572
|
const len1 = WASM_VECTOR_LEN;
|
|
550
|
-
const ptr2 = passStringToWasm0(
|
|
573
|
+
const ptr2 = passStringToWasm0(sig_e_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
551
574
|
const len2 = WASM_VECTOR_LEN;
|
|
552
575
|
const ret = wasm.schnorr_verify_tx(ptr0, len0, ptr1, len1, ptr2, len2, tx_type, user_id, currency_id, amount_lo, amount_hi);
|
|
553
576
|
return ret !== 0;
|
|
Binary file
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const amount_split: (a: number, b: bigint) => void;
|
|
5
|
+
export const compute_address_hash: (a: number, b: number, c: number) => void;
|
|
5
6
|
export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
6
7
|
export const compute_tx_msg_hash: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
7
8
|
export const create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export function amount_split(amount: bigint): Uint32Array;
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Compute address_hash = Poseidon2(addr_byte_0, ..., addr_byte_19).
|
|
17
|
+
* Takes a hex address string (with or without 0x prefix), returns [u64; 4].
|
|
18
|
+
*/
|
|
19
|
+
export function compute_address_hash(address_hex: string): BigUint64Array;
|
|
20
|
+
|
|
15
21
|
/**
|
|
16
22
|
* Full Poseidon2 hash of an 8-element server seed.
|
|
17
23
|
*
|
|
@@ -204,13 +210,13 @@ export function schnorr_pk_hash_hex(pk_hex: string): string;
|
|
|
204
210
|
export function schnorr_pubkey(sk_hex: string): string;
|
|
205
211
|
|
|
206
212
|
/**
|
|
207
|
-
* Sign a ChangePubKey (tx_type=9) transaction.
|
|
213
|
+
* Sign a ChangePubKey (tx_type=9) transaction in (s, e) format.
|
|
208
214
|
*
|
|
209
215
|
* msg_hash = Poseidon2(9, user_id, new_pk_hash[0..4])
|
|
210
216
|
*
|
|
211
217
|
* The old key signs this message to authorize key rotation.
|
|
212
218
|
*
|
|
213
|
-
* Returns a JS object: `{ pubkey: "hex",
|
|
219
|
+
* Returns a JS object: `{ pubkey: "hex", sig_s: "hex", sig_e: "hex" }`
|
|
214
220
|
*
|
|
215
221
|
* ```js
|
|
216
222
|
* const sig = schnorr_sign_cpk(oldSkHex, userId, newPkHashArray);
|
|
@@ -219,31 +225,31 @@ export function schnorr_pubkey(sk_hex: string): string;
|
|
|
219
225
|
export function schnorr_sign_cpk(old_sk_hex: string, user_id: number, new_pk_hash: BigUint64Array): any;
|
|
220
226
|
|
|
221
227
|
/**
|
|
222
|
-
* Sign a transaction with Schnorr (ECgFp5).
|
|
228
|
+
* Sign a transaction with Schnorr (ECgFp5) in (s, e) format.
|
|
223
229
|
*
|
|
224
230
|
* msg_hash = Poseidon2(tx_type, user_id, currency_id, amount_lo, amount_hi)
|
|
225
231
|
*
|
|
226
|
-
* Returns a JS object: `{ pubkey: "hex",
|
|
232
|
+
* Returns a JS object: `{ pubkey: "hex", sig_s: "hex", sig_e: "hex" }`
|
|
227
233
|
*
|
|
228
234
|
* ```js
|
|
229
|
-
* const sig = schnorr_sign_tx(skHex, 5, userId, 0,
|
|
230
|
-
* // sig.pubkey
|
|
235
|
+
* const sig = schnorr_sign_tx(skHex, 5, userId, 0, amountLo, amountHi);
|
|
236
|
+
* // sig.pubkey (80 hex), sig.sig_s (80 hex), sig.sig_e (80 hex)
|
|
231
237
|
* ```
|
|
232
238
|
*/
|
|
233
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;
|
|
234
240
|
|
|
235
241
|
/**
|
|
236
|
-
* Verify a Schnorr signature for a transaction
|
|
242
|
+
* Verify a Schnorr signature (s, e) for a transaction.
|
|
237
243
|
*
|
|
238
|
-
*
|
|
244
|
+
* Algorithm: R_v = s·G + e·pk, e_v = H(R_v‖pk‖msg), check e == e_v.
|
|
239
245
|
*
|
|
240
246
|
* Returns `true` if signature is valid, `false` otherwise.
|
|
241
247
|
*
|
|
242
248
|
* ```js
|
|
243
|
-
* const ok = schnorr_verify_tx(pubkeyHex,
|
|
249
|
+
* const ok = schnorr_verify_tx(pubkeyHex, sigSHex, sigEHex, 5, userId, 0, amountLo, amountHi);
|
|
244
250
|
* ```
|
|
245
251
|
*/
|
|
246
|
-
export function schnorr_verify_tx(pk_hex: string,
|
|
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;
|
|
247
253
|
|
|
248
254
|
/**
|
|
249
255
|
* Truncated seed hash — first 2 elements of `Poseidon2(server_seed)`.
|
|
@@ -300,6 +306,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
300
306
|
export interface InitOutput {
|
|
301
307
|
readonly memory: WebAssembly.Memory;
|
|
302
308
|
readonly amount_split: (a: number, b: bigint) => void;
|
|
309
|
+
readonly compute_address_hash: (a: number, b: number, c: number) => void;
|
|
303
310
|
readonly compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
304
311
|
readonly compute_tx_msg_hash: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
305
312
|
readonly create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
|
@@ -25,6 +25,28 @@ export function amount_split(amount) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Compute address_hash = Poseidon2(addr_byte_0, ..., addr_byte_19).
|
|
30
|
+
* Takes a hex address string (with or without 0x prefix), returns [u64; 4].
|
|
31
|
+
* @param {string} address_hex
|
|
32
|
+
* @returns {BigUint64Array}
|
|
33
|
+
*/
|
|
34
|
+
export function compute_address_hash(address_hex) {
|
|
35
|
+
try {
|
|
36
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
37
|
+
const ptr0 = passStringToWasm0(address_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
wasm.compute_address_hash(retptr, ptr0, len0);
|
|
40
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
41
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
42
|
+
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
43
|
+
wasm.__wbindgen_export4(r0, r1 * 8, 8);
|
|
44
|
+
return v2;
|
|
45
|
+
} finally {
|
|
46
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
28
50
|
/**
|
|
29
51
|
* Full Poseidon2 hash of an 8-element server seed.
|
|
30
52
|
*
|
|
@@ -453,13 +475,13 @@ export function schnorr_pubkey(sk_hex) {
|
|
|
453
475
|
}
|
|
454
476
|
|
|
455
477
|
/**
|
|
456
|
-
* Sign a ChangePubKey (tx_type=9) transaction.
|
|
478
|
+
* Sign a ChangePubKey (tx_type=9) transaction in (s, e) format.
|
|
457
479
|
*
|
|
458
480
|
* msg_hash = Poseidon2(9, user_id, new_pk_hash[0..4])
|
|
459
481
|
*
|
|
460
482
|
* The old key signs this message to authorize key rotation.
|
|
461
483
|
*
|
|
462
|
-
* Returns a JS object: `{ pubkey: "hex",
|
|
484
|
+
* Returns a JS object: `{ pubkey: "hex", sig_s: "hex", sig_e: "hex" }`
|
|
463
485
|
*
|
|
464
486
|
* ```js
|
|
465
487
|
* const sig = schnorr_sign_cpk(oldSkHex, userId, newPkHashArray);
|
|
@@ -479,15 +501,15 @@ export function schnorr_sign_cpk(old_sk_hex, user_id, new_pk_hash) {
|
|
|
479
501
|
}
|
|
480
502
|
|
|
481
503
|
/**
|
|
482
|
-
* Sign a transaction with Schnorr (ECgFp5).
|
|
504
|
+
* Sign a transaction with Schnorr (ECgFp5) in (s, e) format.
|
|
483
505
|
*
|
|
484
506
|
* msg_hash = Poseidon2(tx_type, user_id, currency_id, amount_lo, amount_hi)
|
|
485
507
|
*
|
|
486
|
-
* Returns a JS object: `{ pubkey: "hex",
|
|
508
|
+
* Returns a JS object: `{ pubkey: "hex", sig_s: "hex", sig_e: "hex" }`
|
|
487
509
|
*
|
|
488
510
|
* ```js
|
|
489
|
-
* const sig = schnorr_sign_tx(skHex, 5, userId, 0,
|
|
490
|
-
* // sig.pubkey
|
|
511
|
+
* const sig = schnorr_sign_tx(skHex, 5, userId, 0, amountLo, amountHi);
|
|
512
|
+
* // sig.pubkey (80 hex), sig.sig_s (80 hex), sig.sig_e (80 hex)
|
|
491
513
|
* ```
|
|
492
514
|
* @param {string} sk_hex
|
|
493
515
|
* @param {number} tx_type
|
|
@@ -505,18 +527,18 @@ export function schnorr_sign_tx(sk_hex, tx_type, user_id, currency_id, amount_lo
|
|
|
505
527
|
}
|
|
506
528
|
|
|
507
529
|
/**
|
|
508
|
-
* Verify a Schnorr signature for a transaction
|
|
530
|
+
* Verify a Schnorr signature (s, e) for a transaction.
|
|
509
531
|
*
|
|
510
|
-
*
|
|
532
|
+
* Algorithm: R_v = s·G + e·pk, e_v = H(R_v‖pk‖msg), check e == e_v.
|
|
511
533
|
*
|
|
512
534
|
* Returns `true` if signature is valid, `false` otherwise.
|
|
513
535
|
*
|
|
514
536
|
* ```js
|
|
515
|
-
* const ok = schnorr_verify_tx(pubkeyHex,
|
|
537
|
+
* const ok = schnorr_verify_tx(pubkeyHex, sigSHex, sigEHex, 5, userId, 0, amountLo, amountHi);
|
|
516
538
|
* ```
|
|
517
539
|
* @param {string} pk_hex
|
|
518
|
-
* @param {string} sig_r_hex
|
|
519
540
|
* @param {string} sig_s_hex
|
|
541
|
+
* @param {string} sig_e_hex
|
|
520
542
|
* @param {number} tx_type
|
|
521
543
|
* @param {number} user_id
|
|
522
544
|
* @param {number} currency_id
|
|
@@ -524,12 +546,12 @@ export function schnorr_sign_tx(sk_hex, tx_type, user_id, currency_id, amount_lo
|
|
|
524
546
|
* @param {number} amount_hi
|
|
525
547
|
* @returns {boolean}
|
|
526
548
|
*/
|
|
527
|
-
export function schnorr_verify_tx(pk_hex,
|
|
549
|
+
export function schnorr_verify_tx(pk_hex, sig_s_hex, sig_e_hex, tx_type, user_id, currency_id, amount_lo, amount_hi) {
|
|
528
550
|
const ptr0 = passStringToWasm0(pk_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
529
551
|
const len0 = WASM_VECTOR_LEN;
|
|
530
|
-
const ptr1 = passStringToWasm0(
|
|
552
|
+
const ptr1 = passStringToWasm0(sig_s_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
531
553
|
const len1 = WASM_VECTOR_LEN;
|
|
532
|
-
const ptr2 = passStringToWasm0(
|
|
554
|
+
const ptr2 = passStringToWasm0(sig_e_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
533
555
|
const len2 = WASM_VECTOR_LEN;
|
|
534
556
|
const ret = wasm.schnorr_verify_tx(ptr0, len0, ptr1, len1, ptr2, len2, tx_type, user_id, currency_id, amount_lo, amount_hi);
|
|
535
557
|
return ret !== 0;
|
|
Binary file
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const amount_split: (a: number, b: bigint) => void;
|
|
5
|
+
export const compute_address_hash: (a: number, b: number, c: number) => void;
|
|
5
6
|
export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
6
7
|
export const compute_tx_msg_hash: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
7
8
|
export const create_bet_auth: (a: number, b: number, c: number, d: bigint, e: bigint) => void;
|
package/js/browser.mjs
CHANGED
|
@@ -14,4 +14,15 @@ export {
|
|
|
14
14
|
goldilocks_fields_to_hex,
|
|
15
15
|
goldilocks_modulus,
|
|
16
16
|
goldilocks_reduce,
|
|
17
|
+
schnorr_keygen,
|
|
18
|
+
schnorr_pubkey,
|
|
19
|
+
schnorr_sign_tx,
|
|
20
|
+
schnorr_verify_tx,
|
|
21
|
+
schnorr_pk_hash,
|
|
22
|
+
schnorr_pk_hash_hex,
|
|
23
|
+
schnorr_pk_encode,
|
|
24
|
+
schnorr_sign_cpk,
|
|
25
|
+
compute_tx_msg_hash,
|
|
26
|
+
amount_split,
|
|
27
|
+
compute_address_hash,
|
|
17
28
|
} from '../dist/web/rolly_wasm_signer.js';
|
package/js/index.d.ts
CHANGED
|
@@ -12,4 +12,15 @@ 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/node/rolly_wasm_signer.js';
|
package/js/node.cjs
CHANGED
|
@@ -16,4 +16,15 @@ module.exports = {
|
|
|
16
16
|
goldilocks_fields_to_hex: wasm.goldilocks_fields_to_hex,
|
|
17
17
|
goldilocks_modulus: wasm.goldilocks_modulus,
|
|
18
18
|
goldilocks_reduce: wasm.goldilocks_reduce,
|
|
19
|
+
schnorr_keygen: wasm.schnorr_keygen,
|
|
20
|
+
schnorr_pubkey: wasm.schnorr_pubkey,
|
|
21
|
+
schnorr_sign_tx: wasm.schnorr_sign_tx,
|
|
22
|
+
schnorr_verify_tx: wasm.schnorr_verify_tx,
|
|
23
|
+
schnorr_pk_hash: wasm.schnorr_pk_hash,
|
|
24
|
+
schnorr_pk_hash_hex: wasm.schnorr_pk_hash_hex,
|
|
25
|
+
schnorr_pk_encode: wasm.schnorr_pk_encode,
|
|
26
|
+
schnorr_sign_cpk: wasm.schnorr_sign_cpk,
|
|
27
|
+
compute_tx_msg_hash: wasm.compute_tx_msg_hash,
|
|
28
|
+
amount_split: wasm.amount_split,
|
|
29
|
+
compute_address_hash: wasm.compute_address_hash,
|
|
19
30
|
};
|
package/js/node.mjs
CHANGED
|
@@ -17,4 +17,15 @@ export const {
|
|
|
17
17
|
goldilocks_fields_to_hex,
|
|
18
18
|
goldilocks_modulus,
|
|
19
19
|
goldilocks_reduce,
|
|
20
|
+
schnorr_keygen,
|
|
21
|
+
schnorr_pubkey,
|
|
22
|
+
schnorr_sign_tx,
|
|
23
|
+
schnorr_verify_tx,
|
|
24
|
+
schnorr_pk_hash,
|
|
25
|
+
schnorr_pk_hash_hex,
|
|
26
|
+
schnorr_pk_encode,
|
|
27
|
+
schnorr_sign_cpk,
|
|
28
|
+
compute_tx_msg_hash,
|
|
29
|
+
amount_split,
|
|
30
|
+
compute_address_hash,
|
|
20
31
|
} = wasm;
|