@chironbuilder/ootle-sdk 0.1.20 → 0.1.22
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/wallet.d.ts.map +1 -1
- package/dist/wallet.js +29 -21
- package/package.json +10 -12
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/README.md +128 -0
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/ootle_wasm.d.ts +436 -0
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/ootle_wasm.js +9 -0
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/ootle_wasm_bg.js +1450 -0
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/ootle_wasm_bg.wasm +0 -0
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/package.json +30 -0
|
@@ -0,0 +1,1450 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decrypted contents of an inbound stealth UTXO.
|
|
3
|
+
*/
|
|
4
|
+
export class DecryptedOutputResult {
|
|
5
|
+
static __wrap(ptr) {
|
|
6
|
+
const obj = Object.create(DecryptedOutputResult.prototype);
|
|
7
|
+
obj.__wbg_ptr = ptr;
|
|
8
|
+
DecryptedOutputResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
9
|
+
return obj;
|
|
10
|
+
}
|
|
11
|
+
__destroy_into_raw() {
|
|
12
|
+
const ptr = this.__wbg_ptr;
|
|
13
|
+
this.__wbg_ptr = 0;
|
|
14
|
+
DecryptedOutputResultFinalization.unregister(this);
|
|
15
|
+
return ptr;
|
|
16
|
+
}
|
|
17
|
+
free() {
|
|
18
|
+
const ptr = this.__destroy_into_raw();
|
|
19
|
+
wasm.__wbg_decryptedoutputresult_free(ptr, 0);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The 32-byte commitment mask scalar.
|
|
23
|
+
* @returns {Uint8Array}
|
|
24
|
+
*/
|
|
25
|
+
get mask() {
|
|
26
|
+
const ret = wasm.__wbg_get_decryptedoutputresult_mask(this.__wbg_ptr);
|
|
27
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
28
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
29
|
+
return v1;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
|
|
33
|
+
* the payload carried no memo or `skipMemo` was set.
|
|
34
|
+
* @returns {string | undefined}
|
|
35
|
+
*/
|
|
36
|
+
get memo_json() {
|
|
37
|
+
const ret = wasm.__wbg_get_decryptedoutputresult_memo_json(this.__wbg_ptr);
|
|
38
|
+
let v1;
|
|
39
|
+
if (ret[0] !== 0) {
|
|
40
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
41
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
42
|
+
}
|
|
43
|
+
return v1;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The plaintext value (u64).
|
|
47
|
+
* @returns {bigint}
|
|
48
|
+
*/
|
|
49
|
+
get value() {
|
|
50
|
+
const ret = wasm.__wbg_get_decryptedoutputresult_value(this.__wbg_ptr);
|
|
51
|
+
return BigInt.asUintN(64, ret);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The 32-byte commitment mask scalar.
|
|
55
|
+
* @param {Uint8Array} arg0
|
|
56
|
+
*/
|
|
57
|
+
set mask(arg0) {
|
|
58
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
59
|
+
const len0 = WASM_VECTOR_LEN;
|
|
60
|
+
wasm.__wbg_set_decryptedoutputresult_mask(this.__wbg_ptr, ptr0, len0);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* JSON-encoded `Memo` (variants: `U256` / `Message` / `Bytes` / `PayRefAndBytes`), or `null` if
|
|
64
|
+
* the payload carried no memo or `skipMemo` was set.
|
|
65
|
+
* @param {string | null} [arg0]
|
|
66
|
+
*/
|
|
67
|
+
set memo_json(arg0) {
|
|
68
|
+
var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
69
|
+
var len0 = WASM_VECTOR_LEN;
|
|
70
|
+
wasm.__wbg_set_decryptedoutputresult_memo_json(this.__wbg_ptr, ptr0, len0);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The plaintext value (u64).
|
|
74
|
+
* @param {bigint} arg0
|
|
75
|
+
*/
|
|
76
|
+
set value(arg0) {
|
|
77
|
+
wasm.__wbg_set_decryptedoutputresult_value(this.__wbg_ptr, arg0);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (Symbol.dispose) DecryptedOutputResult.prototype[Symbol.dispose] = DecryptedOutputResult.prototype.free;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A generated keypair (raw bytes).
|
|
84
|
+
*/
|
|
85
|
+
export class KeypairResult {
|
|
86
|
+
static __wrap(ptr) {
|
|
87
|
+
const obj = Object.create(KeypairResult.prototype);
|
|
88
|
+
obj.__wbg_ptr = ptr;
|
|
89
|
+
KeypairResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
90
|
+
return obj;
|
|
91
|
+
}
|
|
92
|
+
__destroy_into_raw() {
|
|
93
|
+
const ptr = this.__wbg_ptr;
|
|
94
|
+
this.__wbg_ptr = 0;
|
|
95
|
+
KeypairResultFinalization.unregister(this);
|
|
96
|
+
return ptr;
|
|
97
|
+
}
|
|
98
|
+
free() {
|
|
99
|
+
const ptr = this.__destroy_into_raw();
|
|
100
|
+
wasm.__wbg_keypairresult_free(ptr, 0);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @returns {Uint8Array}
|
|
104
|
+
*/
|
|
105
|
+
get public_key() {
|
|
106
|
+
const ret = wasm.__wbg_get_keypairresult_public_key(this.__wbg_ptr);
|
|
107
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
108
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
109
|
+
return v1;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* @returns {Uint8Array}
|
|
113
|
+
*/
|
|
114
|
+
get secret_key() {
|
|
115
|
+
const ret = wasm.__wbg_get_keypairresult_secret_key(this.__wbg_ptr);
|
|
116
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
117
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
118
|
+
return v1;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @param {Uint8Array} arg0
|
|
122
|
+
*/
|
|
123
|
+
set public_key(arg0) {
|
|
124
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
125
|
+
const len0 = WASM_VECTOR_LEN;
|
|
126
|
+
wasm.__wbg_set_keypairresult_public_key(this.__wbg_ptr, ptr0, len0);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @param {Uint8Array} arg0
|
|
130
|
+
*/
|
|
131
|
+
set secret_key(arg0) {
|
|
132
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
133
|
+
const len0 = WASM_VECTOR_LEN;
|
|
134
|
+
wasm.__wbg_set_keypairresult_secret_key(this.__wbg_ptr, ptr0, len0);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (Symbol.dispose) KeypairResult.prototype[Symbol.dispose] = KeypairResult.prototype.free;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A pair of Ootle public keys derived from an OotleSecretKey.
|
|
141
|
+
*/
|
|
142
|
+
export class OotlePublicKey {
|
|
143
|
+
static __wrap(ptr) {
|
|
144
|
+
const obj = Object.create(OotlePublicKey.prototype);
|
|
145
|
+
obj.__wbg_ptr = ptr;
|
|
146
|
+
OotlePublicKeyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
147
|
+
return obj;
|
|
148
|
+
}
|
|
149
|
+
__destroy_into_raw() {
|
|
150
|
+
const ptr = this.__wbg_ptr;
|
|
151
|
+
this.__wbg_ptr = 0;
|
|
152
|
+
OotlePublicKeyFinalization.unregister(this);
|
|
153
|
+
return ptr;
|
|
154
|
+
}
|
|
155
|
+
free() {
|
|
156
|
+
const ptr = this.__destroy_into_raw();
|
|
157
|
+
wasm.__wbg_ootlepublickey_free(ptr, 0);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The owner (spending) public key bytes.
|
|
161
|
+
* @returns {Uint8Array}
|
|
162
|
+
*/
|
|
163
|
+
get owner_key() {
|
|
164
|
+
const ret = wasm.__wbg_get_ootlepublickey_owner_key(this.__wbg_ptr);
|
|
165
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
166
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
167
|
+
return v1;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The view-only public key bytes.
|
|
171
|
+
* @returns {Uint8Array}
|
|
172
|
+
*/
|
|
173
|
+
get view_key() {
|
|
174
|
+
const ret = wasm.__wbg_get_ootlepublickey_view_key(this.__wbg_ptr);
|
|
175
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
176
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
177
|
+
return v1;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The owner (spending) public key bytes.
|
|
181
|
+
* @param {Uint8Array} arg0
|
|
182
|
+
*/
|
|
183
|
+
set owner_key(arg0) {
|
|
184
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
185
|
+
const len0 = WASM_VECTOR_LEN;
|
|
186
|
+
wasm.__wbg_set_ootlepublickey_owner_key(this.__wbg_ptr, ptr0, len0);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The view-only public key bytes.
|
|
190
|
+
* @param {Uint8Array} arg0
|
|
191
|
+
*/
|
|
192
|
+
set view_key(arg0) {
|
|
193
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
194
|
+
const len0 = WASM_VECTOR_LEN;
|
|
195
|
+
wasm.__wbg_set_ootlepublickey_view_key(this.__wbg_ptr, ptr0, len0);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (Symbol.dispose) OotlePublicKey.prototype[Symbol.dispose] = OotlePublicKey.prototype.free;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* A pair of Ootle secret keys (owner + view).
|
|
202
|
+
*/
|
|
203
|
+
export class OotleSecretKey {
|
|
204
|
+
static __wrap(ptr) {
|
|
205
|
+
const obj = Object.create(OotleSecretKey.prototype);
|
|
206
|
+
obj.__wbg_ptr = ptr;
|
|
207
|
+
OotleSecretKeyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
208
|
+
return obj;
|
|
209
|
+
}
|
|
210
|
+
__destroy_into_raw() {
|
|
211
|
+
const ptr = this.__wbg_ptr;
|
|
212
|
+
this.__wbg_ptr = 0;
|
|
213
|
+
OotleSecretKeyFinalization.unregister(this);
|
|
214
|
+
return ptr;
|
|
215
|
+
}
|
|
216
|
+
free() {
|
|
217
|
+
const ptr = this.__destroy_into_raw();
|
|
218
|
+
wasm.__wbg_ootlesecretkey_free(ptr, 0);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* The owner (spending) secret key bytes.
|
|
222
|
+
* @returns {Uint8Array}
|
|
223
|
+
*/
|
|
224
|
+
get owner_key() {
|
|
225
|
+
const ret = wasm.__wbg_get_ootlesecretkey_owner_key(this.__wbg_ptr);
|
|
226
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
227
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
228
|
+
return v1;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The view-only secret key bytes.
|
|
232
|
+
* @returns {Uint8Array}
|
|
233
|
+
*/
|
|
234
|
+
get view_key() {
|
|
235
|
+
const ret = wasm.__wbg_get_ootlesecretkey_view_key(this.__wbg_ptr);
|
|
236
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
237
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
238
|
+
return v1;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The owner (spending) secret key bytes.
|
|
242
|
+
* @param {Uint8Array} arg0
|
|
243
|
+
*/
|
|
244
|
+
set owner_key(arg0) {
|
|
245
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
246
|
+
const len0 = WASM_VECTOR_LEN;
|
|
247
|
+
wasm.__wbg_set_ootlesecretkey_owner_key(this.__wbg_ptr, ptr0, len0);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The view-only secret key bytes.
|
|
251
|
+
* @param {Uint8Array} arg0
|
|
252
|
+
*/
|
|
253
|
+
set view_key(arg0) {
|
|
254
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
255
|
+
const len0 = WASM_VECTOR_LEN;
|
|
256
|
+
wasm.__wbg_set_ootlesecretkey_view_key(this.__wbg_ptr, ptr0, len0);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (Symbol.dispose) OotleSecretKey.prototype[Symbol.dispose] = OotleSecretKey.prototype.free;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Parsed components of an Ootle address.
|
|
263
|
+
*/
|
|
264
|
+
export class ParsedOotleAddress {
|
|
265
|
+
static __wrap(ptr) {
|
|
266
|
+
const obj = Object.create(ParsedOotleAddress.prototype);
|
|
267
|
+
obj.__wbg_ptr = ptr;
|
|
268
|
+
ParsedOotleAddressFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
269
|
+
return obj;
|
|
270
|
+
}
|
|
271
|
+
__destroy_into_raw() {
|
|
272
|
+
const ptr = this.__wbg_ptr;
|
|
273
|
+
this.__wbg_ptr = 0;
|
|
274
|
+
ParsedOotleAddressFinalization.unregister(this);
|
|
275
|
+
return ptr;
|
|
276
|
+
}
|
|
277
|
+
free() {
|
|
278
|
+
const ptr = this.__destroy_into_raw();
|
|
279
|
+
wasm.__wbg_parsedootleaddress_free(ptr, 0);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Optional pay reference / memo bytes.
|
|
283
|
+
* @returns {Uint8Array | undefined}
|
|
284
|
+
*/
|
|
285
|
+
get memo() {
|
|
286
|
+
const ret = wasm.__wbg_get_parsedootleaddress_memo(this.__wbg_ptr);
|
|
287
|
+
let v1;
|
|
288
|
+
if (ret[0] !== 0) {
|
|
289
|
+
v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
290
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
291
|
+
}
|
|
292
|
+
return v1;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* The network byte.
|
|
296
|
+
* @returns {number}
|
|
297
|
+
*/
|
|
298
|
+
get network() {
|
|
299
|
+
const ret = wasm.__wbg_get_parsedootleaddress_network(this.__wbg_ptr);
|
|
300
|
+
return ret;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The owner (spending) public key bytes.
|
|
304
|
+
* @returns {Uint8Array}
|
|
305
|
+
*/
|
|
306
|
+
get owner_key() {
|
|
307
|
+
const ret = wasm.__wbg_get_parsedootleaddress_owner_key(this.__wbg_ptr);
|
|
308
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
309
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
310
|
+
return v1;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The view-only public key bytes.
|
|
314
|
+
* @returns {Uint8Array}
|
|
315
|
+
*/
|
|
316
|
+
get view_key() {
|
|
317
|
+
const ret = wasm.__wbg_get_parsedootleaddress_view_key(this.__wbg_ptr);
|
|
318
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
319
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
320
|
+
return v1;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Optional pay reference / memo bytes.
|
|
324
|
+
* @param {Uint8Array | null} [arg0]
|
|
325
|
+
*/
|
|
326
|
+
set memo(arg0) {
|
|
327
|
+
var ptr0 = isLikeNone(arg0) ? 0 : passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
328
|
+
var len0 = WASM_VECTOR_LEN;
|
|
329
|
+
wasm.__wbg_set_parsedootleaddress_memo(this.__wbg_ptr, ptr0, len0);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* The network byte.
|
|
333
|
+
* @param {number} arg0
|
|
334
|
+
*/
|
|
335
|
+
set network(arg0) {
|
|
336
|
+
wasm.__wbg_set_parsedootleaddress_network(this.__wbg_ptr, arg0);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* The owner (spending) public key bytes.
|
|
340
|
+
* @param {Uint8Array} arg0
|
|
341
|
+
*/
|
|
342
|
+
set owner_key(arg0) {
|
|
343
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
344
|
+
const len0 = WASM_VECTOR_LEN;
|
|
345
|
+
wasm.__wbg_set_parsedootleaddress_owner_key(this.__wbg_ptr, ptr0, len0);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* The view-only public key bytes.
|
|
349
|
+
* @param {Uint8Array} arg0
|
|
350
|
+
*/
|
|
351
|
+
set view_key(arg0) {
|
|
352
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
353
|
+
const len0 = WASM_VECTOR_LEN;
|
|
354
|
+
wasm.__wbg_set_parsedootleaddress_view_key(this.__wbg_ptr, ptr0, len0);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (Symbol.dispose) ParsedOotleAddress.prototype[Symbol.dispose] = ParsedOotleAddress.prototype.free;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Result of a Schnorr signature operation (raw bytes). Also used for balance proof signatures, which
|
|
361
|
+
* share the `(public_nonce, signature)` shape.
|
|
362
|
+
*/
|
|
363
|
+
export class SchnorrSignatureResult {
|
|
364
|
+
static __wrap(ptr) {
|
|
365
|
+
const obj = Object.create(SchnorrSignatureResult.prototype);
|
|
366
|
+
obj.__wbg_ptr = ptr;
|
|
367
|
+
SchnorrSignatureResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
368
|
+
return obj;
|
|
369
|
+
}
|
|
370
|
+
__destroy_into_raw() {
|
|
371
|
+
const ptr = this.__wbg_ptr;
|
|
372
|
+
this.__wbg_ptr = 0;
|
|
373
|
+
SchnorrSignatureResultFinalization.unregister(this);
|
|
374
|
+
return ptr;
|
|
375
|
+
}
|
|
376
|
+
free() {
|
|
377
|
+
const ptr = this.__destroy_into_raw();
|
|
378
|
+
wasm.__wbg_schnorrsignatureresult_free(ptr, 0);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* @returns {Uint8Array}
|
|
382
|
+
*/
|
|
383
|
+
get public_nonce() {
|
|
384
|
+
const ret = wasm.__wbg_get_schnorrsignatureresult_public_nonce(this.__wbg_ptr);
|
|
385
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
386
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
387
|
+
return v1;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* @returns {Uint8Array}
|
|
391
|
+
*/
|
|
392
|
+
get signature() {
|
|
393
|
+
const ret = wasm.__wbg_get_schnorrsignatureresult_signature(this.__wbg_ptr);
|
|
394
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
395
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
396
|
+
return v1;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* @param {Uint8Array} arg0
|
|
400
|
+
*/
|
|
401
|
+
set public_nonce(arg0) {
|
|
402
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
403
|
+
const len0 = WASM_VECTOR_LEN;
|
|
404
|
+
wasm.__wbg_set_schnorrsignatureresult_public_nonce(this.__wbg_ptr, ptr0, len0);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* @param {Uint8Array} arg0
|
|
408
|
+
*/
|
|
409
|
+
set signature(arg0) {
|
|
410
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
411
|
+
const len0 = WASM_VECTOR_LEN;
|
|
412
|
+
wasm.__wbg_set_schnorrsignatureresult_signature(this.__wbg_ptr, ptr0, len0);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (Symbol.dispose) SchnorrSignatureResult.prototype[Symbol.dispose] = SchnorrSignatureResult.prototype.free;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Result of generating a stealth outputs statement.
|
|
419
|
+
*/
|
|
420
|
+
export class StealthOutputsResult {
|
|
421
|
+
static __wrap(ptr) {
|
|
422
|
+
const obj = Object.create(StealthOutputsResult.prototype);
|
|
423
|
+
obj.__wbg_ptr = ptr;
|
|
424
|
+
StealthOutputsResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
425
|
+
return obj;
|
|
426
|
+
}
|
|
427
|
+
__destroy_into_raw() {
|
|
428
|
+
const ptr = this.__wbg_ptr;
|
|
429
|
+
this.__wbg_ptr = 0;
|
|
430
|
+
StealthOutputsResultFinalization.unregister(this);
|
|
431
|
+
return ptr;
|
|
432
|
+
}
|
|
433
|
+
free() {
|
|
434
|
+
const ptr = this.__destroy_into_raw();
|
|
435
|
+
wasm.__wbg_stealthoutputsresult_free(ptr, 0);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Sum of all witness masks, suitable for use as the `aggregated_output_mask` argument to
|
|
439
|
+
* `generateStealthBalanceProofSignature`.
|
|
440
|
+
* @returns {Uint8Array}
|
|
441
|
+
*/
|
|
442
|
+
get aggregated_output_mask() {
|
|
443
|
+
const ret = wasm.__wbg_get_stealthoutputsresult_aggregated_output_mask(this.__wbg_ptr);
|
|
444
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
445
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
446
|
+
return v1;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* JSON-serialized `StealthOutputsStatement` (the wire-format payload).
|
|
450
|
+
* @returns {string}
|
|
451
|
+
*/
|
|
452
|
+
get statement_json() {
|
|
453
|
+
let deferred1_0;
|
|
454
|
+
let deferred1_1;
|
|
455
|
+
try {
|
|
456
|
+
const ret = wasm.__wbg_get_stealthoutputsresult_statement_json(this.__wbg_ptr);
|
|
457
|
+
deferred1_0 = ret[0];
|
|
458
|
+
deferred1_1 = ret[1];
|
|
459
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
460
|
+
} finally {
|
|
461
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Sum of all witness masks, suitable for use as the `aggregated_output_mask` argument to
|
|
466
|
+
* `generateStealthBalanceProofSignature`.
|
|
467
|
+
* @param {Uint8Array} arg0
|
|
468
|
+
*/
|
|
469
|
+
set aggregated_output_mask(arg0) {
|
|
470
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
471
|
+
const len0 = WASM_VECTOR_LEN;
|
|
472
|
+
wasm.__wbg_set_stealthoutputsresult_aggregated_output_mask(this.__wbg_ptr, ptr0, len0);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* JSON-serialized `StealthOutputsStatement` (the wire-format payload).
|
|
476
|
+
* @param {string} arg0
|
|
477
|
+
*/
|
|
478
|
+
set statement_json(arg0) {
|
|
479
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
480
|
+
const len0 = WASM_VECTOR_LEN;
|
|
481
|
+
wasm.__wbg_set_stealthoutputsresult_statement_json(this.__wbg_ptr, ptr0, len0);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
if (Symbol.dispose) StealthOutputsResult.prototype[Symbol.dispose] = StealthOutputsResult.prototype.free;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Add a signer to a transaction (unsigned or unsealed JSON).
|
|
488
|
+
*
|
|
489
|
+
* Accepts either an `UnsignedTransactionV1` or `UnsealedTransactionV1` JSON string.
|
|
490
|
+
* Returns the `UnsealedTransactionV1` (with the new signature appended) as a JSON string.
|
|
491
|
+
* @param {string} tx_json
|
|
492
|
+
* @param {Uint8Array} signer_secret_key
|
|
493
|
+
* @param {Uint8Array} seal_signer_public_key
|
|
494
|
+
* @returns {string}
|
|
495
|
+
*/
|
|
496
|
+
export function addTransactionSigner(tx_json, signer_secret_key, seal_signer_public_key) {
|
|
497
|
+
let deferred5_0;
|
|
498
|
+
let deferred5_1;
|
|
499
|
+
try {
|
|
500
|
+
const ptr0 = passStringToWasm0(tx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
501
|
+
const len0 = WASM_VECTOR_LEN;
|
|
502
|
+
const ptr1 = passArray8ToWasm0(signer_secret_key, wasm.__wbindgen_malloc);
|
|
503
|
+
const len1 = WASM_VECTOR_LEN;
|
|
504
|
+
const ptr2 = passArray8ToWasm0(seal_signer_public_key, wasm.__wbindgen_malloc);
|
|
505
|
+
const len2 = WASM_VECTOR_LEN;
|
|
506
|
+
const ret = wasm.addTransactionSigner(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
507
|
+
var ptr4 = ret[0];
|
|
508
|
+
var len4 = ret[1];
|
|
509
|
+
if (ret[3]) {
|
|
510
|
+
ptr4 = 0; len4 = 0;
|
|
511
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
512
|
+
}
|
|
513
|
+
deferred5_0 = ptr4;
|
|
514
|
+
deferred5_1 = len4;
|
|
515
|
+
return getStringFromWasm0(ptr4, len4);
|
|
516
|
+
} finally {
|
|
517
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Aggregate the commitment masks of stealth inputs into a single 32-byte Ristretto scalar.
|
|
523
|
+
*
|
|
524
|
+
* `masks_concat` is the concatenated bytes of all input masks (32 bytes per mask, so the input
|
|
525
|
+
* length must be a multiple of 32). Pass an empty array to obtain the zero scalar.
|
|
526
|
+
*
|
|
527
|
+
* Returns the sum as 32 bytes, suitable as the `aggregated_input_mask` argument to
|
|
528
|
+
* `generateStealthBalanceProofSignature`. The output side of the same balance proof is aggregated
|
|
529
|
+
* automatically by `generateStealthOutputsStatement` (returned as `aggregated_output_mask`).
|
|
530
|
+
* @param {Uint8Array} masks_concat
|
|
531
|
+
* @returns {Uint8Array}
|
|
532
|
+
*/
|
|
533
|
+
export function aggregateInputMasks(masks_concat) {
|
|
534
|
+
const ptr0 = passArray8ToWasm0(masks_concat, wasm.__wbindgen_malloc);
|
|
535
|
+
const len0 = WASM_VECTOR_LEN;
|
|
536
|
+
const ret = wasm.aggregateInputMasks(ptr0, len0);
|
|
537
|
+
if (ret[3]) {
|
|
538
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
539
|
+
}
|
|
540
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
541
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
542
|
+
return v2;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* BOR-encode a Transaction (JSON string) → base64 string (TransactionEnvelope format).
|
|
547
|
+
* @param {string} transaction_json
|
|
548
|
+
* @returns {string}
|
|
549
|
+
*/
|
|
550
|
+
export function borEncodeTransaction(transaction_json) {
|
|
551
|
+
let deferred3_0;
|
|
552
|
+
let deferred3_1;
|
|
553
|
+
try {
|
|
554
|
+
const ptr0 = passStringToWasm0(transaction_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
555
|
+
const len0 = WASM_VECTOR_LEN;
|
|
556
|
+
const ret = wasm.borEncodeTransaction(ptr0, len0);
|
|
557
|
+
var ptr2 = ret[0];
|
|
558
|
+
var len2 = ret[1];
|
|
559
|
+
if (ret[3]) {
|
|
560
|
+
ptr2 = 0; len2 = 0;
|
|
561
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
562
|
+
}
|
|
563
|
+
deferred3_0 = ptr2;
|
|
564
|
+
deferred3_1 = len2;
|
|
565
|
+
return getStringFromWasm0(ptr2, len2);
|
|
566
|
+
} finally {
|
|
567
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Build a script-path `SpendWitness` revealing `leaf` from the committed `conditions` set, optionally
|
|
573
|
+
* supplying a witness `data` blob the leaf's predicate interprets (e.g. a hashlock preimage). Returns a
|
|
574
|
+
* JSON object: `{ "witness": <SpendWitness>, "condition_root": <Hash32> }`.
|
|
575
|
+
*
|
|
576
|
+
* `conditions_json` is the JSON array of `SpendCondition` leaves exactly as passed to
|
|
577
|
+
* `createStealthOutputWitness`'s `PayTo::Conditions` when the output was created; `leaf_json` is the
|
|
578
|
+
* single leaf being revealed. The returned `condition_root` must match the `Script` root recorded in
|
|
579
|
+
* that output's `SpendAuthorization` -- record it against the spent input via
|
|
580
|
+
* `buildStealthInputsStatementFromInputs`.
|
|
581
|
+
*
|
|
582
|
+
* Pass an empty `data` array for a leaf whose predicate needs no spender-supplied data (e.g. a plain
|
|
583
|
+
* timelock refund).
|
|
584
|
+
* @param {string} conditions_json
|
|
585
|
+
* @param {string} leaf_json
|
|
586
|
+
* @param {Uint8Array} data
|
|
587
|
+
* @returns {string}
|
|
588
|
+
*/
|
|
589
|
+
export function buildScriptPathWitness(conditions_json, leaf_json, data) {
|
|
590
|
+
let deferred5_0;
|
|
591
|
+
let deferred5_1;
|
|
592
|
+
try {
|
|
593
|
+
const ptr0 = passStringToWasm0(conditions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
594
|
+
const len0 = WASM_VECTOR_LEN;
|
|
595
|
+
const ptr1 = passStringToWasm0(leaf_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
596
|
+
const len1 = WASM_VECTOR_LEN;
|
|
597
|
+
const ptr2 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
598
|
+
const len2 = WASM_VECTOR_LEN;
|
|
599
|
+
const ret = wasm.buildScriptPathWitness(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
600
|
+
var ptr4 = ret[0];
|
|
601
|
+
var len4 = ret[1];
|
|
602
|
+
if (ret[3]) {
|
|
603
|
+
ptr4 = 0; len4 = 0;
|
|
604
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
605
|
+
}
|
|
606
|
+
deferred5_0 = ptr4;
|
|
607
|
+
deferred5_1 = len4;
|
|
608
|
+
return getStringFromWasm0(ptr4, len4);
|
|
609
|
+
} finally {
|
|
610
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Build a `StealthInputsStatement` JSON from raw input commitments and a revealed amount.
|
|
616
|
+
*
|
|
617
|
+
* `input_commitments` is the concatenated bytes of all 32-byte commitments (so the length must be a
|
|
618
|
+
* multiple of 32). Pass an empty array for a revealed-only statement.
|
|
619
|
+
*
|
|
620
|
+
* This is a convenience helper so callers don't need to hand-craft the wire JSON; the result is used
|
|
621
|
+
* as the `inputs_statement_json` argument to `generateStealthBalanceProofSignature` and friends.
|
|
622
|
+
* @param {Uint8Array} input_commitments
|
|
623
|
+
* @param {bigint} revealed_amount_microtari
|
|
624
|
+
* @returns {string}
|
|
625
|
+
*/
|
|
626
|
+
export function buildStealthInputsStatement(input_commitments, revealed_amount_microtari) {
|
|
627
|
+
let deferred3_0;
|
|
628
|
+
let deferred3_1;
|
|
629
|
+
try {
|
|
630
|
+
const ptr0 = passArray8ToWasm0(input_commitments, wasm.__wbindgen_malloc);
|
|
631
|
+
const len0 = WASM_VECTOR_LEN;
|
|
632
|
+
const ret = wasm.buildStealthInputsStatement(ptr0, len0, revealed_amount_microtari);
|
|
633
|
+
var ptr2 = ret[0];
|
|
634
|
+
var len2 = ret[1];
|
|
635
|
+
if (ret[3]) {
|
|
636
|
+
ptr2 = 0; len2 = 0;
|
|
637
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
638
|
+
}
|
|
639
|
+
deferred3_0 = ptr2;
|
|
640
|
+
deferred3_1 = len2;
|
|
641
|
+
return getStringFromWasm0(ptr2, len2);
|
|
642
|
+
} finally {
|
|
643
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Build a `StealthInputsStatement` JSON from a JSON array of per-input `{commitment, witness}` pairs
|
|
649
|
+
* and a revealed amount.
|
|
650
|
+
*
|
|
651
|
+
* Unlike `buildStealthInputsStatement`, which only builds key-path inputs from raw commitment bytes,
|
|
652
|
+
* this accepts a caller-supplied `witness` per input -- the only way to spend an output committed with
|
|
653
|
+
* `PayTo::Conditions` (e.g. claiming or refunding an HTLC-style hashlock/timelock output). Build each
|
|
654
|
+
* script-path input's witness with `buildScriptPathWitness` first; a plain key-path input can still be
|
|
655
|
+
* included in the same call, either with `"witness":"KeyPath"` or by omitting `witness` entirely
|
|
656
|
+
* (defaults to key path).
|
|
657
|
+
*
|
|
658
|
+
* `inputs_json` shape: `[{ "commitment": <hex 32 bytes>, "witness"?: <SpendWitness> }, ...]`.
|
|
659
|
+
* @param {string} inputs_json
|
|
660
|
+
* @param {bigint} revealed_amount_microtari
|
|
661
|
+
* @returns {string}
|
|
662
|
+
*/
|
|
663
|
+
export function buildStealthInputsStatementFromInputs(inputs_json, revealed_amount_microtari) {
|
|
664
|
+
let deferred3_0;
|
|
665
|
+
let deferred3_1;
|
|
666
|
+
try {
|
|
667
|
+
const ptr0 = passStringToWasm0(inputs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
668
|
+
const len0 = WASM_VECTOR_LEN;
|
|
669
|
+
const ret = wasm.buildStealthInputsStatementFromInputs(ptr0, len0, revealed_amount_microtari);
|
|
670
|
+
var ptr2 = ret[0];
|
|
671
|
+
var len2 = ret[1];
|
|
672
|
+
if (ret[3]) {
|
|
673
|
+
ptr2 = 0; len2 = 0;
|
|
674
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
675
|
+
}
|
|
676
|
+
deferred3_0 = ptr2;
|
|
677
|
+
deferred3_1 = len2;
|
|
678
|
+
return getStringFromWasm0(ptr2, len2);
|
|
679
|
+
} finally {
|
|
680
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Build a complete `StealthTransferStatement` JSON from unblinded input/output witnesses.
|
|
686
|
+
*
|
|
687
|
+
* Unlike `generateStealthOutputsStatement` / `buildStealthInputsStatementFromInputs` +
|
|
688
|
+
* `generateStealthBalanceProofSignature`, which build and sign each half of a transfer
|
|
689
|
+
* separately, this wraps the single primitive that produces the *entire*, internally-consistent
|
|
690
|
+
* statement in one call, including a covenant balance-integrity proof for any script-path input
|
|
691
|
+
* whose revealed leaf gates on `Covenant::BalancePreserved` (see `ootle_wasm_core::stealth::
|
|
692
|
+
* transfer::build_stealth_transfer_statement` for when a claim is and isn't needed).
|
|
693
|
+
*
|
|
694
|
+
* `input_witnesses_json` is a JSON array of `{ "mask_and_value": { "value": <u64>, "mask": <hex
|
|
695
|
+
* 32 bytes> }, "witness"?: <SpendWitness>, "condition_root"?: <Hash32> }` -- each entry's
|
|
696
|
+
* `witness`/`condition_root` are the exact pair `buildScriptPathWitness` returns, for a
|
|
697
|
+
* script-path input; omit both for a plain key-path input. Mixing key-path and script-path
|
|
698
|
+
* inputs in one call is supported.
|
|
699
|
+
*
|
|
700
|
+
* `output_witnesses_json` is a JSON array of the same `{ "witness": {...}, "auth": ..., "tag":
|
|
701
|
+
* ... }` shape `createStealthOutputWitness` returns -- collect one entry per output (including
|
|
702
|
+
* change).
|
|
703
|
+
* @param {string} input_witnesses_json
|
|
704
|
+
* @param {bigint} revealed_input_amount_microtari
|
|
705
|
+
* @param {string} output_witnesses_json
|
|
706
|
+
* @param {bigint} revealed_output_amount_microtari
|
|
707
|
+
* @param {Uint8Array} revealed_receiver
|
|
708
|
+
* @returns {string}
|
|
709
|
+
*/
|
|
710
|
+
export function buildStealthTransferStatement(input_witnesses_json, revealed_input_amount_microtari, output_witnesses_json, revealed_output_amount_microtari, revealed_receiver) {
|
|
711
|
+
let deferred5_0;
|
|
712
|
+
let deferred5_1;
|
|
713
|
+
try {
|
|
714
|
+
const ptr0 = passStringToWasm0(input_witnesses_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
715
|
+
const len0 = WASM_VECTOR_LEN;
|
|
716
|
+
const ptr1 = passStringToWasm0(output_witnesses_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
717
|
+
const len1 = WASM_VECTOR_LEN;
|
|
718
|
+
const ptr2 = passArray8ToWasm0(revealed_receiver, wasm.__wbindgen_malloc);
|
|
719
|
+
const len2 = WASM_VECTOR_LEN;
|
|
720
|
+
const ret = wasm.buildStealthTransferStatement(ptr0, len0, revealed_input_amount_microtari, ptr1, len1, revealed_output_amount_microtari, ptr2, len2);
|
|
721
|
+
var ptr4 = ret[0];
|
|
722
|
+
var len4 = ret[1];
|
|
723
|
+
if (ret[3]) {
|
|
724
|
+
ptr4 = 0; len4 = 0;
|
|
725
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
726
|
+
}
|
|
727
|
+
deferred5_0 = ptr4;
|
|
728
|
+
deferred5_1 = len4;
|
|
729
|
+
return getStringFromWasm0(ptr4, len4);
|
|
730
|
+
} finally {
|
|
731
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Build a single stealth output witness entirely client-side (sender side), mirroring the wallet
|
|
737
|
+
* daemon's `create_output_witness`.
|
|
738
|
+
*
|
|
739
|
+
* A fresh commitment mask and ephemeral nonce are generated internally; the recipient recovers the
|
|
740
|
+
* value and mask by decrypting `encrypted_data`. Returns one witness as a JSON string with the shape:
|
|
741
|
+
* ```text
|
|
742
|
+
* {
|
|
743
|
+
* "witness": {
|
|
744
|
+
* "amount": <u64>,
|
|
745
|
+
* "mask": <hex 32 bytes>,
|
|
746
|
+
* "sender_public_nonce": <hex 32 bytes>,
|
|
747
|
+
* "minimum_value_promise": <u64>,
|
|
748
|
+
* "encrypted_data": <hex variable-length>,
|
|
749
|
+
* "resource_view_key": <hex 32 bytes | null>
|
|
750
|
+
* },
|
|
751
|
+
* "auth": <SpendAuthorization>,
|
|
752
|
+
* "tag": <u32>
|
|
753
|
+
* }
|
|
754
|
+
* ```
|
|
755
|
+
* Collect one witness per output (including change) into a JSON array and pass it to
|
|
756
|
+
* `generateStealthOutputsStatement`.
|
|
757
|
+
*
|
|
758
|
+
* - `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, ...).
|
|
759
|
+
* - `destination_account_public_key` / `destination_view_public_key` are the recipient's 32-byte keys.
|
|
760
|
+
* - `resource_address` is the `resource_<hex>` string of the resource being sent.
|
|
761
|
+
* - `resource_view_key` is the resource view-key holder's 32-byte public key, or `null` for resources without a
|
|
762
|
+
* viewable balance (when set, the output receives an ElGamal proof at statement time).
|
|
763
|
+
* - `memo_json` is an optional JSON-encoded `Memo` to embed in the encrypted payload.
|
|
764
|
+
* - `pay_to_json` is an optional JSON-encoded `PayTo`: `"StealthPublicKey"` (the default when `null`, producing a
|
|
765
|
+
* one-time stealth spend key) or `{"AccessRule": <AccessRule>}`.
|
|
766
|
+
* - `minimum_value_promise` is the range-proof lower bound and must be `<= amount` (use `0` normally).
|
|
767
|
+
* @param {number} network
|
|
768
|
+
* @param {Uint8Array} destination_account_public_key
|
|
769
|
+
* @param {Uint8Array} destination_view_public_key
|
|
770
|
+
* @param {bigint} amount
|
|
771
|
+
* @param {string} resource_address
|
|
772
|
+
* @param {Uint8Array | null | undefined} resource_view_key
|
|
773
|
+
* @param {string | null | undefined} memo_json
|
|
774
|
+
* @param {string | null | undefined} pay_to_json
|
|
775
|
+
* @param {bigint} minimum_value_promise
|
|
776
|
+
* @returns {string}
|
|
777
|
+
*/
|
|
778
|
+
export function createStealthOutputWitness(network, destination_account_public_key, destination_view_public_key, amount, resource_address, resource_view_key, memo_json, pay_to_json, minimum_value_promise) {
|
|
779
|
+
let deferred8_0;
|
|
780
|
+
let deferred8_1;
|
|
781
|
+
try {
|
|
782
|
+
const ptr0 = passArray8ToWasm0(destination_account_public_key, wasm.__wbindgen_malloc);
|
|
783
|
+
const len0 = WASM_VECTOR_LEN;
|
|
784
|
+
const ptr1 = passArray8ToWasm0(destination_view_public_key, wasm.__wbindgen_malloc);
|
|
785
|
+
const len1 = WASM_VECTOR_LEN;
|
|
786
|
+
const ptr2 = passStringToWasm0(resource_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
787
|
+
const len2 = WASM_VECTOR_LEN;
|
|
788
|
+
var ptr3 = isLikeNone(resource_view_key) ? 0 : passArray8ToWasm0(resource_view_key, wasm.__wbindgen_malloc);
|
|
789
|
+
var len3 = WASM_VECTOR_LEN;
|
|
790
|
+
var ptr4 = isLikeNone(memo_json) ? 0 : passStringToWasm0(memo_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
791
|
+
var len4 = WASM_VECTOR_LEN;
|
|
792
|
+
var ptr5 = isLikeNone(pay_to_json) ? 0 : passStringToWasm0(pay_to_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
793
|
+
var len5 = WASM_VECTOR_LEN;
|
|
794
|
+
const ret = wasm.createStealthOutputWitness(network, ptr0, len0, ptr1, len1, amount, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, minimum_value_promise);
|
|
795
|
+
var ptr7 = ret[0];
|
|
796
|
+
var len7 = ret[1];
|
|
797
|
+
if (ret[3]) {
|
|
798
|
+
ptr7 = 0; len7 = 0;
|
|
799
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
800
|
+
}
|
|
801
|
+
deferred8_0 = ptr7;
|
|
802
|
+
deferred8_1 = len7;
|
|
803
|
+
return getStringFromWasm0(ptr7, len7);
|
|
804
|
+
} finally {
|
|
805
|
+
wasm.__wbindgen_free(deferred8_0, deferred8_1, 1);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Brute-force decrypt an ElGamal viewable-balance proof to recover the bound value.
|
|
811
|
+
*
|
|
812
|
+
* Tries each value in `[min_value, max_value]` (inclusive). Returns `null` (via `Option`) if no
|
|
813
|
+
* candidate matches. Uses an on-the-fly value lookup — there is no precomputed table dependency, so
|
|
814
|
+
* callers should keep the range tight (large ranges produce proportional CPU cost).
|
|
815
|
+
*
|
|
816
|
+
* `commitment` is the Pedersen commitment the proof is bound to. Both the view public key and the
|
|
817
|
+
* view secret key are required: the public key is used to re-verify the ZK proof (rejecting tampered
|
|
818
|
+
* proofs before decrypting), the secret key performs the ElGamal decryption itself.
|
|
819
|
+
* @param {string} proof_json
|
|
820
|
+
* @param {Uint8Array} commitment
|
|
821
|
+
* @param {Uint8Array} view_public_key
|
|
822
|
+
* @param {Uint8Array} view_secret_key
|
|
823
|
+
* @param {bigint} min_value
|
|
824
|
+
* @param {bigint} max_value
|
|
825
|
+
* @returns {bigint | undefined}
|
|
826
|
+
*/
|
|
827
|
+
export function decryptElgamalViewableBalance(proof_json, commitment, view_public_key, view_secret_key, min_value, max_value) {
|
|
828
|
+
const ptr0 = passStringToWasm0(proof_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
829
|
+
const len0 = WASM_VECTOR_LEN;
|
|
830
|
+
const ptr1 = passArray8ToWasm0(commitment, wasm.__wbindgen_malloc);
|
|
831
|
+
const len1 = WASM_VECTOR_LEN;
|
|
832
|
+
const ptr2 = passArray8ToWasm0(view_public_key, wasm.__wbindgen_malloc);
|
|
833
|
+
const len2 = WASM_VECTOR_LEN;
|
|
834
|
+
const ptr3 = passArray8ToWasm0(view_secret_key, wasm.__wbindgen_malloc);
|
|
835
|
+
const len3 = WASM_VECTOR_LEN;
|
|
836
|
+
const ret = wasm.decryptElgamalViewableBalance(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, min_value, max_value);
|
|
837
|
+
if (ret[3]) {
|
|
838
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
839
|
+
}
|
|
840
|
+
return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Derive the AEAD encryption key for `encrypted_data` from a Diffie-Hellman shared secret: `H(DH(s, P))`.
|
|
845
|
+
* Sender derives it with `(sender_secret_nonce, recipient_view_pub)`; receiver derives the same key
|
|
846
|
+
* with `(recipient_view_secret, sender_public_nonce)`.
|
|
847
|
+
* @param {Uint8Array} private_key
|
|
848
|
+
* @param {Uint8Array} public_key
|
|
849
|
+
* @returns {Uint8Array}
|
|
850
|
+
*/
|
|
851
|
+
export function encryptedDataDhKdfAead(private_key, public_key) {
|
|
852
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
853
|
+
const len0 = WASM_VECTOR_LEN;
|
|
854
|
+
const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
855
|
+
const len1 = WASM_VECTOR_LEN;
|
|
856
|
+
const ret = wasm.encryptedDataDhKdfAead(ptr0, len0, ptr1, len1);
|
|
857
|
+
if (ret[3]) {
|
|
858
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
859
|
+
}
|
|
860
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
861
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
862
|
+
return v3;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* Generate an ElGamal viewable-balance proof: a zero-knowledge proof that `amount` is the value bound
|
|
867
|
+
* by `commitment`, encrypted to the resource view-key holder.
|
|
868
|
+
*
|
|
869
|
+
* Returns the JSON-encoded `ViewableBalanceProof` (8 × 32-byte fields).
|
|
870
|
+
* @param {Uint8Array} mask
|
|
871
|
+
* @param {bigint} amount
|
|
872
|
+
* @param {Uint8Array} commitment
|
|
873
|
+
* @param {Uint8Array} view_public_key
|
|
874
|
+
* @returns {string}
|
|
875
|
+
*/
|
|
876
|
+
export function generateElgamalViewableBalanceProof(mask, amount, commitment, view_public_key) {
|
|
877
|
+
let deferred5_0;
|
|
878
|
+
let deferred5_1;
|
|
879
|
+
try {
|
|
880
|
+
const ptr0 = passArray8ToWasm0(mask, wasm.__wbindgen_malloc);
|
|
881
|
+
const len0 = WASM_VECTOR_LEN;
|
|
882
|
+
const ptr1 = passArray8ToWasm0(commitment, wasm.__wbindgen_malloc);
|
|
883
|
+
const len1 = WASM_VECTOR_LEN;
|
|
884
|
+
const ptr2 = passArray8ToWasm0(view_public_key, wasm.__wbindgen_malloc);
|
|
885
|
+
const len2 = WASM_VECTOR_LEN;
|
|
886
|
+
const ret = wasm.generateElgamalViewableBalanceProof(ptr0, len0, amount, ptr1, len1, ptr2, len2);
|
|
887
|
+
var ptr4 = ret[0];
|
|
888
|
+
var len4 = ret[1];
|
|
889
|
+
if (ret[3]) {
|
|
890
|
+
ptr4 = 0; len4 = 0;
|
|
891
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
892
|
+
}
|
|
893
|
+
deferred5_0 = ptr4;
|
|
894
|
+
deferred5_1 = len4;
|
|
895
|
+
return getStringFromWasm0(ptr4, len4);
|
|
896
|
+
} finally {
|
|
897
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Generate an extended bulletproof aggregating range proofs for a set of output witnesses, proving
|
|
903
|
+
* each amount is in `[minimum_value_promise, 2^64)`. The number of witnesses is padded to the next
|
|
904
|
+
* power of two internally.
|
|
905
|
+
*
|
|
906
|
+
* `witnesses_json` is a JSON array of "flat" output witnesses (the `witness` field shape from
|
|
907
|
+
* [`generate_stealth_outputs_statement`] — without the surrounding `auth` / `tag`).
|
|
908
|
+
*
|
|
909
|
+
* Returns the raw range proof bytes (may be empty if the input array is empty).
|
|
910
|
+
* @param {string} witnesses_json
|
|
911
|
+
* @returns {Uint8Array}
|
|
912
|
+
*/
|
|
913
|
+
export function generateExtendedBulletProof(witnesses_json) {
|
|
914
|
+
const ptr0 = passStringToWasm0(witnesses_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
915
|
+
const len0 = WASM_VECTOR_LEN;
|
|
916
|
+
const ret = wasm.generateExtendedBulletProof(ptr0, len0);
|
|
917
|
+
if (ret[3]) {
|
|
918
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
919
|
+
}
|
|
920
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
921
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
922
|
+
return v2;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Generate a new random Ristretto keypair.
|
|
927
|
+
* Returns { secret_key: Uint8Array, public_key: Uint8Array }.
|
|
928
|
+
* @returns {KeypairResult}
|
|
929
|
+
*/
|
|
930
|
+
export function generateKeypair() {
|
|
931
|
+
const ret = wasm.generateKeypair();
|
|
932
|
+
return KeypairResult.__wrap(ret);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Generate an Ootle address (bech32m string) from public keys.
|
|
937
|
+
*
|
|
938
|
+
* `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, etc.).
|
|
939
|
+
* `memo` is an optional pay reference (max 64 bytes).
|
|
940
|
+
* @param {Uint8Array} owner_public_key
|
|
941
|
+
* @param {Uint8Array} view_public_key
|
|
942
|
+
* @param {number} network
|
|
943
|
+
* @param {Uint8Array | null} [memo]
|
|
944
|
+
* @returns {string}
|
|
945
|
+
*/
|
|
946
|
+
export function generateOotleAddress(owner_public_key, view_public_key, network, memo) {
|
|
947
|
+
let deferred5_0;
|
|
948
|
+
let deferred5_1;
|
|
949
|
+
try {
|
|
950
|
+
const ptr0 = passArray8ToWasm0(owner_public_key, wasm.__wbindgen_malloc);
|
|
951
|
+
const len0 = WASM_VECTOR_LEN;
|
|
952
|
+
const ptr1 = passArray8ToWasm0(view_public_key, wasm.__wbindgen_malloc);
|
|
953
|
+
const len1 = WASM_VECTOR_LEN;
|
|
954
|
+
var ptr2 = isLikeNone(memo) ? 0 : passArray8ToWasm0(memo, wasm.__wbindgen_malloc);
|
|
955
|
+
var len2 = WASM_VECTOR_LEN;
|
|
956
|
+
const ret = wasm.generateOotleAddress(ptr0, len0, ptr1, len1, network, ptr2, len2);
|
|
957
|
+
var ptr4 = ret[0];
|
|
958
|
+
var len4 = ret[1];
|
|
959
|
+
if (ret[3]) {
|
|
960
|
+
ptr4 = 0; len4 = 0;
|
|
961
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
962
|
+
}
|
|
963
|
+
deferred5_0 = ptr4;
|
|
964
|
+
deferred5_1 = len4;
|
|
965
|
+
return getStringFromWasm0(ptr4, len4);
|
|
966
|
+
} finally {
|
|
967
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Generate a new random pair of Ootle secret keys (owner + view).
|
|
973
|
+
* Returns { owner_key: Uint8Array, view_key: Uint8Array }.
|
|
974
|
+
* @returns {OotleSecretKey}
|
|
975
|
+
*/
|
|
976
|
+
export function generateOotleSecretKey() {
|
|
977
|
+
const ret = wasm.generateOotleSecretKey();
|
|
978
|
+
return OotleSecretKey.__wrap(ret);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Sign the balance proof for a stealth transfer.
|
|
983
|
+
*
|
|
984
|
+
* `aggregated_input_mask` and `aggregated_output_mask` are the 32-byte sums of all input / output
|
|
985
|
+
* commitment masks respectively. Returns a `(public_nonce, signature)` pair (each 32 bytes); the pair
|
|
986
|
+
* may be all-zeros for revealed-only transfers — callers normally omit the balance proof in that case.
|
|
987
|
+
* @param {Uint8Array} aggregated_input_mask
|
|
988
|
+
* @param {Uint8Array} aggregated_output_mask
|
|
989
|
+
* @param {string} inputs_statement_json
|
|
990
|
+
* @param {string} outputs_statement_json
|
|
991
|
+
* @param {string} covenant_claims_json
|
|
992
|
+
* @returns {SchnorrSignatureResult}
|
|
993
|
+
*/
|
|
994
|
+
export function generateStealthBalanceProofSignature(aggregated_input_mask, aggregated_output_mask, inputs_statement_json, outputs_statement_json, covenant_claims_json) {
|
|
995
|
+
const ptr0 = passArray8ToWasm0(aggregated_input_mask, wasm.__wbindgen_malloc);
|
|
996
|
+
const len0 = WASM_VECTOR_LEN;
|
|
997
|
+
const ptr1 = passArray8ToWasm0(aggregated_output_mask, wasm.__wbindgen_malloc);
|
|
998
|
+
const len1 = WASM_VECTOR_LEN;
|
|
999
|
+
const ptr2 = passStringToWasm0(inputs_statement_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1000
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1001
|
+
const ptr3 = passStringToWasm0(outputs_statement_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1002
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1003
|
+
const ptr4 = passStringToWasm0(covenant_claims_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1004
|
+
const len4 = WASM_VECTOR_LEN;
|
|
1005
|
+
const ret = wasm.generateStealthBalanceProofSignature(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
1006
|
+
if (ret[2]) {
|
|
1007
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1008
|
+
}
|
|
1009
|
+
return SchnorrSignatureResult.__wrap(ret[0]);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Generate the output side of a stealth transfer: per-output Pedersen commitments and encrypted data,
|
|
1014
|
+
* optional ElGamal viewable-balance proofs (for outputs with a `resource_view_key`), and an aggregated
|
|
1015
|
+
* bulletproof range proof.
|
|
1016
|
+
*
|
|
1017
|
+
* `witnesses_json` is a JSON array of stealth output witnesses. Each entry has the shape:
|
|
1018
|
+
* ```text
|
|
1019
|
+
* {
|
|
1020
|
+
* "witness": {
|
|
1021
|
+
* "amount": <u64>,
|
|
1022
|
+
* "mask": <hex 32 bytes>,
|
|
1023
|
+
* "sender_public_nonce": <hex 32 bytes>,
|
|
1024
|
+
* "minimum_value_promise": <u64>,
|
|
1025
|
+
* "encrypted_data": <hex variable-length>,
|
|
1026
|
+
* "resource_view_key": <hex 32 bytes | null>
|
|
1027
|
+
* },
|
|
1028
|
+
* "auth": <SpendAuthorization>,
|
|
1029
|
+
* "tag": <u32>
|
|
1030
|
+
* }
|
|
1031
|
+
* ```
|
|
1032
|
+
*
|
|
1033
|
+
* Returns the serialized statement plus the aggregated output mask, which the sender feeds to
|
|
1034
|
+
* `generateStealthBalanceProofSignature` together with the aggregated input mask.
|
|
1035
|
+
* @param {string} witnesses_json
|
|
1036
|
+
* @param {bigint} revealed_output_amount_microtari
|
|
1037
|
+
* @param {Uint8Array} revealed_receiver
|
|
1038
|
+
* @returns {StealthOutputsResult}
|
|
1039
|
+
*/
|
|
1040
|
+
export function generateStealthOutputsStatement(witnesses_json, revealed_output_amount_microtari, revealed_receiver) {
|
|
1041
|
+
const ptr0 = passStringToWasm0(witnesses_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1042
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1043
|
+
const ptr1 = passArray8ToWasm0(revealed_receiver, wasm.__wbindgen_malloc);
|
|
1044
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1045
|
+
const ret = wasm.generateStealthOutputsStatement(ptr0, len0, revealed_output_amount_microtari, ptr1, len1);
|
|
1046
|
+
if (ret[2]) {
|
|
1047
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1048
|
+
}
|
|
1049
|
+
return StealthOutputsResult.__wrap(ret[0]);
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Hash an UnsignedTransactionV1 (JSON string) for signing.
|
|
1054
|
+
* Returns the 64-byte signing message that must be Schnorr-signed.
|
|
1055
|
+
*
|
|
1056
|
+
* `seal_signer_public_key` is the raw bytes of the seal signer's public key (account owner).
|
|
1057
|
+
* @param {string} unsigned_tx_json
|
|
1058
|
+
* @param {Uint8Array} seal_signer_public_key
|
|
1059
|
+
* @returns {Uint8Array}
|
|
1060
|
+
*/
|
|
1061
|
+
export function hashUnsignedTransaction(unsigned_tx_json, seal_signer_public_key) {
|
|
1062
|
+
const ptr0 = passStringToWasm0(unsigned_tx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1063
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1064
|
+
const ptr1 = passArray8ToWasm0(seal_signer_public_key, wasm.__wbindgen_malloc);
|
|
1065
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1066
|
+
const ret = wasm.hashUnsignedTransaction(ptr0, len0, ptr1, len1);
|
|
1067
|
+
if (ret[3]) {
|
|
1068
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1069
|
+
}
|
|
1070
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1071
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1072
|
+
return v3;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* Called automatically when the WASM module is instantiated. Do not call directly.
|
|
1077
|
+
*/
|
|
1078
|
+
export function on_start() {
|
|
1079
|
+
wasm.on_start();
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Derive the Ootle public keys from a pair of secret keys.
|
|
1084
|
+
* Returns { owner_key: Uint8Array, view_key: Uint8Array }.
|
|
1085
|
+
* @param {Uint8Array} owner_key
|
|
1086
|
+
* @param {Uint8Array} view_key
|
|
1087
|
+
* @returns {OotlePublicKey}
|
|
1088
|
+
*/
|
|
1089
|
+
export function ootlePublicKeyFromSecretKey(owner_key, view_key) {
|
|
1090
|
+
const ptr0 = passArray8ToWasm0(owner_key, wasm.__wbindgen_malloc);
|
|
1091
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1092
|
+
const ptr1 = passArray8ToWasm0(view_key, wasm.__wbindgen_malloc);
|
|
1093
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1094
|
+
const ret = wasm.ootlePublicKeyFromSecretKey(ptr0, len0, ptr1, len1);
|
|
1095
|
+
if (ret[2]) {
|
|
1096
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1097
|
+
}
|
|
1098
|
+
return OotlePublicKey.__wrap(ret[0]);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* Parse a bech32m Ootle address string into its components.
|
|
1103
|
+
* Returns { owner_key: Uint8Array, view_key: Uint8Array, network: number, memo: Uint8Array | undefined }.
|
|
1104
|
+
* @param {string} address
|
|
1105
|
+
* @returns {ParsedOotleAddress}
|
|
1106
|
+
*/
|
|
1107
|
+
export function parseOotleAddress(address) {
|
|
1108
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1109
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1110
|
+
const ret = wasm.parseOotleAddress(ptr0, len0);
|
|
1111
|
+
if (ret[2]) {
|
|
1112
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1113
|
+
}
|
|
1114
|
+
return ParsedOotleAddress.__wrap(ret[0]);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Derive the public key from a secret key (both raw bytes).
|
|
1119
|
+
* @param {Uint8Array} secret_key
|
|
1120
|
+
* @returns {Uint8Array}
|
|
1121
|
+
*/
|
|
1122
|
+
export function publicKeyFromSecretKey(secret_key) {
|
|
1123
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
1124
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1125
|
+
const ret = wasm.publicKeyFromSecretKey(ptr0, len0);
|
|
1126
|
+
if (ret[3]) {
|
|
1127
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1128
|
+
}
|
|
1129
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1130
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1131
|
+
return v2;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Schnorr-sign a message with a secret key.
|
|
1136
|
+
* Returns { public_nonce: Uint8Array, signature: Uint8Array }.
|
|
1137
|
+
* @param {Uint8Array} secret_key
|
|
1138
|
+
* @param {Uint8Array} message
|
|
1139
|
+
* @returns {SchnorrSignatureResult}
|
|
1140
|
+
*/
|
|
1141
|
+
export function schnorrSign(secret_key, message) {
|
|
1142
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
1143
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1144
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
1145
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1146
|
+
const ret = wasm.schnorrSign(ptr0, len0, ptr1, len1);
|
|
1147
|
+
if (ret[2]) {
|
|
1148
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1149
|
+
}
|
|
1150
|
+
return SchnorrSignatureResult.__wrap(ret[0]);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* Seal a transaction (unsigned or unsealed JSON) with the seal signer's secret key.
|
|
1155
|
+
*
|
|
1156
|
+
* Accepts either an `UnsignedTransactionV1` or `UnsealedTransactionV1` JSON string.
|
|
1157
|
+
* Returns the sealed `Transaction` as a JSON string.
|
|
1158
|
+
* @param {string} tx_json
|
|
1159
|
+
* @param {Uint8Array} seal_signer_secret_key
|
|
1160
|
+
* @returns {string}
|
|
1161
|
+
*/
|
|
1162
|
+
export function sealTransaction(tx_json, seal_signer_secret_key) {
|
|
1163
|
+
let deferred4_0;
|
|
1164
|
+
let deferred4_1;
|
|
1165
|
+
try {
|
|
1166
|
+
const ptr0 = passStringToWasm0(tx_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1167
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1168
|
+
const ptr1 = passArray8ToWasm0(seal_signer_secret_key, wasm.__wbindgen_malloc);
|
|
1169
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1170
|
+
const ret = wasm.sealTransaction(ptr0, len0, ptr1, len1);
|
|
1171
|
+
var ptr3 = ret[0];
|
|
1172
|
+
var len3 = ret[1];
|
|
1173
|
+
if (ret[3]) {
|
|
1174
|
+
ptr3 = 0; len3 = 0;
|
|
1175
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1176
|
+
}
|
|
1177
|
+
deferred4_0 = ptr3;
|
|
1178
|
+
deferred4_1 = len3;
|
|
1179
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1180
|
+
} finally {
|
|
1181
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
/**
|
|
1186
|
+
* Derive the recipient's stealth spending scalar `c + k`, where `c = H(network || k.G * r)`. The
|
|
1187
|
+
* receiver runs this with their account secret key (`private_key`) and the sender-provided public
|
|
1188
|
+
* nonce to obtain the one-time secret that controls the stealth output.
|
|
1189
|
+
*
|
|
1190
|
+
* `network` is the network byte (0x00 = MainNet, 0x10 = LocalNet, 0x26 = Esmeralda, ...).
|
|
1191
|
+
* @param {number} network
|
|
1192
|
+
* @param {Uint8Array} private_key
|
|
1193
|
+
* @param {Uint8Array} public_nonce
|
|
1194
|
+
* @returns {Uint8Array}
|
|
1195
|
+
*/
|
|
1196
|
+
export function stealthDhSecret(network, private_key, public_nonce) {
|
|
1197
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
1198
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1199
|
+
const ptr1 = passArray8ToWasm0(public_nonce, wasm.__wbindgen_malloc);
|
|
1200
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1201
|
+
const ret = wasm.stealthDhSecret(network, ptr0, len0, ptr1, len1);
|
|
1202
|
+
if (ret[3]) {
|
|
1203
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1204
|
+
}
|
|
1205
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1206
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1207
|
+
return v3;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Decrypt and verify the AEAD payload of an inbound stealth UTXO.
|
|
1212
|
+
*
|
|
1213
|
+
* `output_commitment` is the 32-byte Pedersen commitment; `encrypted_data` is the variable-length
|
|
1214
|
+
* XChaCha20Poly1305-encrypted blob; `encryption_key` is the 32-byte AEAD key derived via
|
|
1215
|
+
* `encryptedDataDhKdfAead`. Setting `skip_memo` to `true` returns no memo even if the payload carries
|
|
1216
|
+
* one (useful when only the value / mask are needed).
|
|
1217
|
+
*
|
|
1218
|
+
* Throws on AEAD failure or on a commitment mismatch — either indicates the payload was not produced
|
|
1219
|
+
* for this view key.
|
|
1220
|
+
* @param {Uint8Array} output_commitment
|
|
1221
|
+
* @param {Uint8Array} encrypted_data
|
|
1222
|
+
* @param {Uint8Array} encryption_key
|
|
1223
|
+
* @param {boolean} skip_memo
|
|
1224
|
+
* @returns {DecryptedOutputResult}
|
|
1225
|
+
*/
|
|
1226
|
+
export function unblindOutput(output_commitment, encrypted_data, encryption_key, skip_memo) {
|
|
1227
|
+
const ptr0 = passArray8ToWasm0(output_commitment, wasm.__wbindgen_malloc);
|
|
1228
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1229
|
+
const ptr1 = passArray8ToWasm0(encrypted_data, wasm.__wbindgen_malloc);
|
|
1230
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1231
|
+
const ptr2 = passArray8ToWasm0(encryption_key, wasm.__wbindgen_malloc);
|
|
1232
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1233
|
+
const ret = wasm.unblindOutput(ptr0, len0, ptr1, len1, ptr2, len2, skip_memo);
|
|
1234
|
+
if (ret[2]) {
|
|
1235
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1236
|
+
}
|
|
1237
|
+
return DecryptedOutputResult.__wrap(ret[0]);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* Pre-flight check that a balance proof signature is cryptographically valid for the given input /
|
|
1242
|
+
* output statements. Returns `false` on a malformed proof or invalid signature; the engine performs
|
|
1243
|
+
* the authoritative check at submission.
|
|
1244
|
+
* @param {Uint8Array} public_nonce
|
|
1245
|
+
* @param {Uint8Array} signature
|
|
1246
|
+
* @param {string} inputs_statement_json
|
|
1247
|
+
* @param {string} outputs_statement_json
|
|
1248
|
+
* @param {string} covenant_claims_json
|
|
1249
|
+
* @returns {boolean}
|
|
1250
|
+
*/
|
|
1251
|
+
export function validateBalanceProofSignature(public_nonce, signature, inputs_statement_json, outputs_statement_json, covenant_claims_json) {
|
|
1252
|
+
const ptr0 = passArray8ToWasm0(public_nonce, wasm.__wbindgen_malloc);
|
|
1253
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1254
|
+
const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
1255
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1256
|
+
const ptr2 = passStringToWasm0(inputs_statement_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1257
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1258
|
+
const ptr3 = passStringToWasm0(outputs_statement_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1259
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1260
|
+
const ptr4 = passStringToWasm0(covenant_claims_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1261
|
+
const len4 = WASM_VECTOR_LEN;
|
|
1262
|
+
const ret = wasm.validateBalanceProofSignature(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
1263
|
+
if (ret[2]) {
|
|
1264
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1265
|
+
}
|
|
1266
|
+
return ret[0] !== 0;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/**
|
|
1270
|
+
* Run the same validation the engine performs on a complete `StealthTransferStatement` envelope:
|
|
1271
|
+
* structural sanity, commitment well-formedness, range and balance-proof verification.
|
|
1272
|
+
*
|
|
1273
|
+
* `view_key` is the 32-byte resource view public key, required for resources with a viewable balance
|
|
1274
|
+
* and rejected otherwise. Pass `null` for resources without a view key.
|
|
1275
|
+
*
|
|
1276
|
+
* Throws on a validation failure; returns successfully on a valid statement.
|
|
1277
|
+
* @param {string} transfer_json
|
|
1278
|
+
* @param {Uint8Array | null} [view_key]
|
|
1279
|
+
*/
|
|
1280
|
+
export function validateStealthTransfer(transfer_json, view_key) {
|
|
1281
|
+
const ptr0 = passStringToWasm0(transfer_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1282
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1283
|
+
var ptr1 = isLikeNone(view_key) ? 0 : passArray8ToWasm0(view_key, wasm.__wbindgen_malloc);
|
|
1284
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1285
|
+
const ret = wasm.validateStealthTransfer(ptr0, len0, ptr1, len1);
|
|
1286
|
+
if (ret[1]) {
|
|
1287
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
export function __wbg_Error_67e7344beaa85059(arg0, arg1) {
|
|
1291
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1292
|
+
return ret;
|
|
1293
|
+
}
|
|
1294
|
+
export function __wbg___wbindgen_throw_5d9e815e6fdf150f(arg0, arg1) {
|
|
1295
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1296
|
+
}
|
|
1297
|
+
export function __wbg_getRandomValues_47873ea553f6780e() { return handleError(function (arg0, arg1) {
|
|
1298
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
1299
|
+
}, arguments); }
|
|
1300
|
+
export function __wbindgen_init_externref_table() {
|
|
1301
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1302
|
+
const offset = table.grow(4);
|
|
1303
|
+
table.set(0, undefined);
|
|
1304
|
+
table.set(offset + 0, undefined);
|
|
1305
|
+
table.set(offset + 1, null);
|
|
1306
|
+
table.set(offset + 2, true);
|
|
1307
|
+
table.set(offset + 3, false);
|
|
1308
|
+
}
|
|
1309
|
+
const DecryptedOutputResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1310
|
+
? { register: () => {}, unregister: () => {} }
|
|
1311
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_decryptedoutputresult_free(ptr, 1));
|
|
1312
|
+
const KeypairResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1313
|
+
? { register: () => {}, unregister: () => {} }
|
|
1314
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_keypairresult_free(ptr, 1));
|
|
1315
|
+
const OotlePublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1316
|
+
? { register: () => {}, unregister: () => {} }
|
|
1317
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_ootlepublickey_free(ptr, 1));
|
|
1318
|
+
const OotleSecretKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1319
|
+
? { register: () => {}, unregister: () => {} }
|
|
1320
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_ootlesecretkey_free(ptr, 1));
|
|
1321
|
+
const ParsedOotleAddressFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1322
|
+
? { register: () => {}, unregister: () => {} }
|
|
1323
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_parsedootleaddress_free(ptr, 1));
|
|
1324
|
+
const SchnorrSignatureResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1325
|
+
? { register: () => {}, unregister: () => {} }
|
|
1326
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_schnorrsignatureresult_free(ptr, 1));
|
|
1327
|
+
const StealthOutputsResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1328
|
+
? { register: () => {}, unregister: () => {} }
|
|
1329
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_stealthoutputsresult_free(ptr, 1));
|
|
1330
|
+
|
|
1331
|
+
function addToExternrefTable0(obj) {
|
|
1332
|
+
const idx = wasm.__externref_table_alloc();
|
|
1333
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1334
|
+
return idx;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1338
|
+
ptr = ptr >>> 0;
|
|
1339
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
function getStringFromWasm0(ptr, len) {
|
|
1343
|
+
return decodeText(ptr >>> 0, len);
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1347
|
+
function getUint8ArrayMemory0() {
|
|
1348
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1349
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1350
|
+
}
|
|
1351
|
+
return cachedUint8ArrayMemory0;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
function handleError(f, args) {
|
|
1355
|
+
try {
|
|
1356
|
+
return f.apply(this, args);
|
|
1357
|
+
} catch (e) {
|
|
1358
|
+
const idx = addToExternrefTable0(e);
|
|
1359
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
function isLikeNone(x) {
|
|
1364
|
+
return x === undefined || x === null;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1368
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1369
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1370
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1371
|
+
return ptr;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1375
|
+
if (realloc === undefined) {
|
|
1376
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1377
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1378
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1379
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1380
|
+
return ptr;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
let len = arg.length;
|
|
1384
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1385
|
+
|
|
1386
|
+
const mem = getUint8ArrayMemory0();
|
|
1387
|
+
|
|
1388
|
+
let offset = 0;
|
|
1389
|
+
|
|
1390
|
+
for (; offset < len; offset++) {
|
|
1391
|
+
const code = arg.charCodeAt(offset);
|
|
1392
|
+
if (code > 0x7F) break;
|
|
1393
|
+
mem[ptr + offset] = code;
|
|
1394
|
+
}
|
|
1395
|
+
if (offset !== len) {
|
|
1396
|
+
if (offset !== 0) {
|
|
1397
|
+
arg = arg.slice(offset);
|
|
1398
|
+
}
|
|
1399
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1400
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1401
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1402
|
+
|
|
1403
|
+
offset += ret.written;
|
|
1404
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
WASM_VECTOR_LEN = offset;
|
|
1408
|
+
return ptr;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
function takeFromExternrefTable0(idx) {
|
|
1412
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1413
|
+
wasm.__externref_table_dealloc(idx);
|
|
1414
|
+
return value;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1418
|
+
cachedTextDecoder.decode();
|
|
1419
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1420
|
+
let numBytesDecoded = 0;
|
|
1421
|
+
function decodeText(ptr, len) {
|
|
1422
|
+
numBytesDecoded += len;
|
|
1423
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1424
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1425
|
+
cachedTextDecoder.decode();
|
|
1426
|
+
numBytesDecoded = len;
|
|
1427
|
+
}
|
|
1428
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1432
|
+
|
|
1433
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1434
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1435
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1436
|
+
view.set(buf);
|
|
1437
|
+
return {
|
|
1438
|
+
read: arg.length,
|
|
1439
|
+
written: buf.length
|
|
1440
|
+
};
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
let WASM_VECTOR_LEN = 0;
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
let wasm;
|
|
1448
|
+
export function __wbg_set_wasm(val) {
|
|
1449
|
+
wasm = val;
|
|
1450
|
+
}
|