@tari-project/ootle-wasm 0.53.5 → 0.55.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 +14 -10
- package/ootle_wasm.d.ts +12 -7
- package/ootle_wasm_bg.js +44 -30
- package/ootle_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,12 +35,15 @@ const publicKey = publicKeyFromSecretKey(secretKey);
|
|
|
35
35
|
// publicKey: Uint8Array (32 bytes)
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
### `hashUnsignedTransaction(unsignedTxJson, sealSignerPublicKey)`
|
|
38
|
+
### `hashUnsignedTransaction(unsignedTxJson, sealSignerPublicKey, authorizerPublicKeys)`
|
|
39
39
|
|
|
40
40
|
Hash a transaction for an authorization signature. Returns the 64-byte `Uint8Array` an external signer signs (see [External signers](#external-signers-hsm-mpc)). The hash excludes attached signatures, so it is the same before and after `attachTransactionSignature`.
|
|
41
41
|
|
|
42
42
|
- `unsignedTxJson` — JSON-serialised `UnsignedTransactionV1` or `UnsealedTransactionV1`
|
|
43
43
|
- `sealSignerPublicKey` — raw public key bytes of the account owner (seal signer)
|
|
44
|
+
- `authorizerPublicKeys` — the 32-byte public keys of every authorizer, concatenated in any order
|
|
45
|
+
|
|
46
|
+
Every authorizer signs over the same set of authorizer keys, so decide the set before anyone signs. The sealed transaction verifies only with an authorization from each key in the set and no other.
|
|
44
47
|
|
|
45
48
|
```typescript
|
|
46
49
|
import { hashUnsignedTransaction } from "@tari-project/ootle-wasm";
|
|
@@ -48,12 +51,13 @@ import { hashUnsignedTransaction } from "@tari-project/ootle-wasm";
|
|
|
48
51
|
const hash = hashUnsignedTransaction(
|
|
49
52
|
JSON.stringify(unsignedTransaction),
|
|
50
53
|
sealSignerPublicKey,
|
|
54
|
+
authorizerPublicKeys,
|
|
51
55
|
);
|
|
52
56
|
```
|
|
53
57
|
|
|
54
|
-
### `addTransactionSigner(txJson, signerSecretKey, sealSignerPublicKey)`
|
|
58
|
+
### `addTransactionSigner(txJson, signerSecretKey, sealSignerPublicKey, authorizerPublicKeys)`
|
|
55
59
|
|
|
56
|
-
Hash the transaction and
|
|
60
|
+
Hash the transaction and add an authorization signature by `signerSecretKey`, committing to the seal signer `sealSignerPublicKey` and the authorizer set `authorizerPublicKeys`, which must include the signer's own key. Accepts unsigned or unsealed transaction JSON and returns the unsealed transaction JSON.
|
|
57
61
|
|
|
58
62
|
### `sealTransaction(txJson, sealSignerSecretKey)`
|
|
59
63
|
|
|
@@ -63,8 +67,8 @@ Hash the transaction and seal it with `sealSignerSecretKey`. Accepts unsigned or
|
|
|
63
67
|
import { addTransactionSigner, sealTransaction } from "@tari-project/ootle-wasm";
|
|
64
68
|
|
|
65
69
|
let txJson = JSON.stringify(unsignedTransaction);
|
|
66
|
-
// Optional: authorizations from other keys
|
|
67
|
-
txJson = addTransactionSigner(txJson, authorizerSecretKey, sealSignerPublicKey);
|
|
70
|
+
// Optional: authorizations from other keys, each over the set of all of them
|
|
71
|
+
txJson = addTransactionSigner(txJson, authorizerSecretKey, sealSignerPublicKey, authorizerPublicKeys);
|
|
68
72
|
const transactionJson = sealTransaction(txJson, sealSignerSecretKey);
|
|
69
73
|
```
|
|
70
74
|
|
|
@@ -95,9 +99,9 @@ Hash a transaction for sealing. Returns the 64-byte seal message for the seal si
|
|
|
95
99
|
|
|
96
100
|
Seal a transaction with the seal signer's signature over the `hashUnsealedTransaction` hash. Returns the sealed `Transaction` JSON. Throws if the seal signature, or any authorization signature already attached, does not verify.
|
|
97
101
|
|
|
98
|
-
### `attachTransactionSignature(txJson, signerPublicKey, signature, sealSignerPublicKey)`
|
|
102
|
+
### `attachTransactionSignature(txJson, signerPublicKey, signature, sealSignerPublicKey, authorizerPublicKeys)`
|
|
99
103
|
|
|
100
|
-
|
|
104
|
+
Add an authorization signature from an additional authorizer key. The signature is over the `hashUnsignedTransaction` hash for `sealSignerPublicKey` and `authorizerPublicKeys`, which must include `signerPublicKey`. Returns the unsealed transaction JSON. Throws if the signature does not verify.
|
|
101
105
|
|
|
102
106
|
```typescript
|
|
103
107
|
import {
|
|
@@ -110,10 +114,10 @@ import {
|
|
|
110
114
|
|
|
111
115
|
let txJson = JSON.stringify(unsignedTransaction);
|
|
112
116
|
|
|
113
|
-
// Optional: authorizations from other keys (repeat per authorizer)
|
|
114
|
-
const authHash = hashUnsignedTransaction(txJson, sealSignerPublicKey);
|
|
117
|
+
// Optional: authorizations from other keys (repeat per authorizer, each over the same set)
|
|
118
|
+
const authHash = hashUnsignedTransaction(txJson, sealSignerPublicKey, authorizerPublicKeys);
|
|
115
119
|
const authSig = await externalSigner.sign(authorizerKeyId, authHash);
|
|
116
|
-
txJson = attachTransactionSignature(txJson, authorizerPublicKey, authSig, sealSignerPublicKey);
|
|
120
|
+
txJson = attachTransactionSignature(txJson, authorizerPublicKey, authSig, sealSignerPublicKey, authorizerPublicKeys);
|
|
117
121
|
|
|
118
122
|
// Seal last
|
|
119
123
|
const sealHash = hashUnsealedTransaction(txJson);
|
package/ootle_wasm.d.ts
CHANGED
|
@@ -136,9 +136,11 @@ export class StealthOutputsResult {
|
|
|
136
136
|
* Add a signer to a transaction (unsigned or unsealed JSON).
|
|
137
137
|
*
|
|
138
138
|
* Accepts either an `UnsignedTransactionV1` or `UnsealedTransactionV1` JSON string.
|
|
139
|
-
*
|
|
139
|
+
* `authorizer_public_keys` is the 32-byte public key of every authorizer, concatenated in any order and
|
|
140
|
+
* including this signer's: every authorizer signs over the same set, so it is fixed before anyone signs.
|
|
141
|
+
* Returns the `UnsealedTransactionV1` (with the new signature added) as a JSON string.
|
|
140
142
|
*/
|
|
141
|
-
export function addTransactionSigner(tx_json: string, signer_secret_key: Uint8Array, seal_signer_public_key: Uint8Array): string;
|
|
143
|
+
export function addTransactionSigner(tx_json: string, signer_secret_key: Uint8Array, seal_signer_public_key: Uint8Array, authorizer_public_keys: Uint8Array): string;
|
|
142
144
|
|
|
143
145
|
/**
|
|
144
146
|
* Aggregate the commitment masks of stealth inputs into a single 32-byte Ristretto scalar.
|
|
@@ -167,11 +169,11 @@ export function attachSealSignature(tx_json: string, seal_signer_public_key: Uin
|
|
|
167
169
|
* unsealed JSON).
|
|
168
170
|
*
|
|
169
171
|
* `signature` is the 64-byte sr25519 signature (scheme in the NPM README) over the hash from
|
|
170
|
-
* `hashUnsignedTransaction` for `seal_signer_public_key`, made by the key
|
|
171
|
-
* `signer_public_key
|
|
172
|
-
* Returns the `UnsealedTransactionV1` (with the new signature
|
|
172
|
+
* `hashUnsignedTransaction` for `seal_signer_public_key` and `authorizer_public_keys`, made by the key
|
|
173
|
+
* for `signer_public_key`, which must be one of the authorizers. It is verified before it is added.
|
|
174
|
+
* Returns the `UnsealedTransactionV1` (with the new signature added) as a JSON string.
|
|
173
175
|
*/
|
|
174
|
-
export function attachTransactionSignature(tx_json: string, signer_public_key: Uint8Array, signature: Uint8Array, seal_signer_public_key: Uint8Array): string;
|
|
176
|
+
export function attachTransactionSignature(tx_json: string, signer_public_key: Uint8Array, signature: Uint8Array, seal_signer_public_key: Uint8Array, authorizer_public_keys: Uint8Array): string;
|
|
175
177
|
|
|
176
178
|
/**
|
|
177
179
|
* BOR-encode a Transaction (JSON string) → base64 string (TransactionEnvelope format).
|
|
@@ -386,8 +388,11 @@ export function hashUnsealedTransaction(tx_json: string): Uint8Array;
|
|
|
386
388
|
* The message excludes attached signatures, so it is the same before and after `attachTransactionSignature`.
|
|
387
389
|
*
|
|
388
390
|
* `seal_signer_public_key` is the raw bytes of the seal signer's public key (account owner).
|
|
391
|
+
* `authorizer_public_keys` is the 32-byte public key of every authorizer, concatenated in any order.
|
|
392
|
+
* Every authorizer signs over the same set, and a transaction verifies only with an authorization from
|
|
393
|
+
* each of them attached.
|
|
389
394
|
*/
|
|
390
|
-
export function hashUnsignedTransaction(unsigned_tx_json: string, seal_signer_public_key: Uint8Array): Uint8Array;
|
|
395
|
+
export function hashUnsignedTransaction(unsigned_tx_json: string, seal_signer_public_key: Uint8Array, authorizer_public_keys: Uint8Array): Uint8Array;
|
|
391
396
|
|
|
392
397
|
/**
|
|
393
398
|
* Called automatically when the WASM module is instantiated. Do not call directly.
|
package/ootle_wasm_bg.js
CHANGED
|
@@ -487,15 +487,18 @@ if (Symbol.dispose) StealthOutputsResult.prototype[Symbol.dispose] = StealthOutp
|
|
|
487
487
|
* Add a signer to a transaction (unsigned or unsealed JSON).
|
|
488
488
|
*
|
|
489
489
|
* Accepts either an `UnsignedTransactionV1` or `UnsealedTransactionV1` JSON string.
|
|
490
|
-
*
|
|
490
|
+
* `authorizer_public_keys` is the 32-byte public key of every authorizer, concatenated in any order and
|
|
491
|
+
* including this signer's: every authorizer signs over the same set, so it is fixed before anyone signs.
|
|
492
|
+
* Returns the `UnsealedTransactionV1` (with the new signature added) as a JSON string.
|
|
491
493
|
* @param {string} tx_json
|
|
492
494
|
* @param {Uint8Array} signer_secret_key
|
|
493
495
|
* @param {Uint8Array} seal_signer_public_key
|
|
496
|
+
* @param {Uint8Array} authorizer_public_keys
|
|
494
497
|
* @returns {string}
|
|
495
498
|
*/
|
|
496
|
-
export function addTransactionSigner(tx_json, signer_secret_key, seal_signer_public_key) {
|
|
497
|
-
let
|
|
498
|
-
let
|
|
499
|
+
export function addTransactionSigner(tx_json, signer_secret_key, seal_signer_public_key, authorizer_public_keys) {
|
|
500
|
+
let deferred6_0;
|
|
501
|
+
let deferred6_1;
|
|
499
502
|
try {
|
|
500
503
|
const ptr0 = passStringToWasm0(tx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
501
504
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -503,18 +506,20 @@ export function addTransactionSigner(tx_json, signer_secret_key, seal_signer_pub
|
|
|
503
506
|
const len1 = WASM_VECTOR_LEN;
|
|
504
507
|
const ptr2 = passArray8ToWasm0(seal_signer_public_key, wasm.__wbindgen_malloc);
|
|
505
508
|
const len2 = WASM_VECTOR_LEN;
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
+
const ptr3 = passArray8ToWasm0(authorizer_public_keys, wasm.__wbindgen_malloc);
|
|
510
|
+
const len3 = WASM_VECTOR_LEN;
|
|
511
|
+
const ret = wasm.addTransactionSigner(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
512
|
+
var ptr5 = ret[0];
|
|
513
|
+
var len5 = ret[1];
|
|
509
514
|
if (ret[3]) {
|
|
510
|
-
|
|
515
|
+
ptr5 = 0; len5 = 0;
|
|
511
516
|
throw takeFromExternrefTable0(ret[2]);
|
|
512
517
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
return getStringFromWasm0(
|
|
518
|
+
deferred6_0 = ptr5;
|
|
519
|
+
deferred6_1 = len5;
|
|
520
|
+
return getStringFromWasm0(ptr5, len5);
|
|
516
521
|
} finally {
|
|
517
|
-
wasm.__wbindgen_free(
|
|
522
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
518
523
|
}
|
|
519
524
|
}
|
|
520
525
|
|
|
@@ -584,18 +589,19 @@ export function attachSealSignature(tx_json, seal_signer_public_key, signature)
|
|
|
584
589
|
* unsealed JSON).
|
|
585
590
|
*
|
|
586
591
|
* `signature` is the 64-byte sr25519 signature (scheme in the NPM README) over the hash from
|
|
587
|
-
* `hashUnsignedTransaction` for `seal_signer_public_key`, made by the key
|
|
588
|
-
* `signer_public_key
|
|
589
|
-
* Returns the `UnsealedTransactionV1` (with the new signature
|
|
592
|
+
* `hashUnsignedTransaction` for `seal_signer_public_key` and `authorizer_public_keys`, made by the key
|
|
593
|
+
* for `signer_public_key`, which must be one of the authorizers. It is verified before it is added.
|
|
594
|
+
* Returns the `UnsealedTransactionV1` (with the new signature added) as a JSON string.
|
|
590
595
|
* @param {string} tx_json
|
|
591
596
|
* @param {Uint8Array} signer_public_key
|
|
592
597
|
* @param {Uint8Array} signature
|
|
593
598
|
* @param {Uint8Array} seal_signer_public_key
|
|
599
|
+
* @param {Uint8Array} authorizer_public_keys
|
|
594
600
|
* @returns {string}
|
|
595
601
|
*/
|
|
596
|
-
export function attachTransactionSignature(tx_json, signer_public_key, signature, seal_signer_public_key) {
|
|
597
|
-
let
|
|
598
|
-
let
|
|
602
|
+
export function attachTransactionSignature(tx_json, signer_public_key, signature, seal_signer_public_key, authorizer_public_keys) {
|
|
603
|
+
let deferred7_0;
|
|
604
|
+
let deferred7_1;
|
|
599
605
|
try {
|
|
600
606
|
const ptr0 = passStringToWasm0(tx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
601
607
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -605,18 +611,20 @@ export function attachTransactionSignature(tx_json, signer_public_key, signature
|
|
|
605
611
|
const len2 = WASM_VECTOR_LEN;
|
|
606
612
|
const ptr3 = passArray8ToWasm0(seal_signer_public_key, wasm.__wbindgen_malloc);
|
|
607
613
|
const len3 = WASM_VECTOR_LEN;
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
|
|
614
|
+
const ptr4 = passArray8ToWasm0(authorizer_public_keys, wasm.__wbindgen_malloc);
|
|
615
|
+
const len4 = WASM_VECTOR_LEN;
|
|
616
|
+
const ret = wasm.attachTransactionSignature(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
617
|
+
var ptr6 = ret[0];
|
|
618
|
+
var len6 = ret[1];
|
|
611
619
|
if (ret[3]) {
|
|
612
|
-
|
|
620
|
+
ptr6 = 0; len6 = 0;
|
|
613
621
|
throw takeFromExternrefTable0(ret[2]);
|
|
614
622
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
return getStringFromWasm0(
|
|
623
|
+
deferred7_0 = ptr6;
|
|
624
|
+
deferred7_1 = len6;
|
|
625
|
+
return getStringFromWasm0(ptr6, len6);
|
|
618
626
|
} finally {
|
|
619
|
-
wasm.__wbindgen_free(
|
|
627
|
+
wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
|
|
620
628
|
}
|
|
621
629
|
}
|
|
622
630
|
|
|
@@ -1153,22 +1161,28 @@ export function hashUnsealedTransaction(tx_json) {
|
|
|
1153
1161
|
* The message excludes attached signatures, so it is the same before and after `attachTransactionSignature`.
|
|
1154
1162
|
*
|
|
1155
1163
|
* `seal_signer_public_key` is the raw bytes of the seal signer's public key (account owner).
|
|
1164
|
+
* `authorizer_public_keys` is the 32-byte public key of every authorizer, concatenated in any order.
|
|
1165
|
+
* Every authorizer signs over the same set, and a transaction verifies only with an authorization from
|
|
1166
|
+
* each of them attached.
|
|
1156
1167
|
* @param {string} unsigned_tx_json
|
|
1157
1168
|
* @param {Uint8Array} seal_signer_public_key
|
|
1169
|
+
* @param {Uint8Array} authorizer_public_keys
|
|
1158
1170
|
* @returns {Uint8Array}
|
|
1159
1171
|
*/
|
|
1160
|
-
export function hashUnsignedTransaction(unsigned_tx_json, seal_signer_public_key) {
|
|
1172
|
+
export function hashUnsignedTransaction(unsigned_tx_json, seal_signer_public_key, authorizer_public_keys) {
|
|
1161
1173
|
const ptr0 = passStringToWasm0(unsigned_tx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1162
1174
|
const len0 = WASM_VECTOR_LEN;
|
|
1163
1175
|
const ptr1 = passArray8ToWasm0(seal_signer_public_key, wasm.__wbindgen_malloc);
|
|
1164
1176
|
const len1 = WASM_VECTOR_LEN;
|
|
1165
|
-
const
|
|
1177
|
+
const ptr2 = passArray8ToWasm0(authorizer_public_keys, wasm.__wbindgen_malloc);
|
|
1178
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1179
|
+
const ret = wasm.hashUnsignedTransaction(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1166
1180
|
if (ret[3]) {
|
|
1167
1181
|
throw takeFromExternrefTable0(ret[2]);
|
|
1168
1182
|
}
|
|
1169
|
-
var
|
|
1183
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1170
1184
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1171
|
-
return
|
|
1185
|
+
return v4;
|
|
1172
1186
|
}
|
|
1173
1187
|
|
|
1174
1188
|
/**
|
package/ootle_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"The Tari Development Community"
|
|
6
6
|
],
|
|
7
7
|
"description": "WASM bindings for Tari Ootle client-side crypto — thin wasm-bindgen shell over ootle-wasm-core",
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.55.0",
|
|
9
9
|
"license": "BSD-3-Clause",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|