@provablehq/wasm 0.11.3 → 0.11.5
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/mainnet/aleo_wasm.d.ts +70 -11
- package/dist/mainnet/aleo_wasm.wasm +0 -0
- package/dist/mainnet/index.cjs +148 -60
- package/dist/mainnet/index.cjs.map +1 -1
- package/dist/mainnet/index.js +148 -61
- package/dist/mainnet/index.js.map +1 -1
- package/dist/mainnet/worker.js +148 -60
- package/dist/mainnet/worker.js.map +1 -1
- package/dist/testnet/aleo_wasm.d.ts +73 -14
- package/dist/testnet/aleo_wasm.wasm +0 -0
- package/dist/testnet/index.cjs +156 -68
- package/dist/testnet/index.cjs.map +1 -1
- package/dist/testnet/index.js +156 -69
- package/dist/testnet/index.js.map +1 -1
- package/dist/testnet/worker.js +156 -68
- package/dist/testnet/worker.js.map +1 -1
- package/package.json +1 -1
package/dist/mainnet/index.js
CHANGED
|
@@ -286,16 +286,6 @@ function runRayonThread(receiver) {
|
|
|
286
286
|
wasm.runRayonThread(receiver);
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
/**
|
|
290
|
-
* @param {URL} url
|
|
291
|
-
* @param {number} num_threads
|
|
292
|
-
* @returns {Promise<void>}
|
|
293
|
-
*/
|
|
294
|
-
function initThreadPool$1(url, num_threads) {
|
|
295
|
-
const ret = wasm.initThreadPool(addHeapObject(url), num_threads);
|
|
296
|
-
return takeObject(ret);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
289
|
/**
|
|
300
290
|
* Set the WASM log level from JS. Called automatically by the SDK's
|
|
301
291
|
* `setLogLevel(level)` to keep TS and WASM logging in sync.
|
|
@@ -307,6 +297,16 @@ function setWasmLogLevel(level) {
|
|
|
307
297
|
wasm.setWasmLogLevel(level);
|
|
308
298
|
}
|
|
309
299
|
|
|
300
|
+
/**
|
|
301
|
+
* @param {URL} url
|
|
302
|
+
* @param {number} num_threads
|
|
303
|
+
* @returns {Promise<void>}
|
|
304
|
+
*/
|
|
305
|
+
function initThreadPool$1(url, num_threads) {
|
|
306
|
+
const ret = wasm.initThreadPool(addHeapObject(url), num_threads);
|
|
307
|
+
return takeObject(ret);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
310
|
let stack_pointer = 128;
|
|
311
311
|
|
|
312
312
|
function addBorrowedObject(obj) {
|
|
@@ -347,6 +347,38 @@ function snarkVerify(verifying_key, inputs, proof) {
|
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
/**
|
|
351
|
+
* Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
|
|
352
|
+
*
|
|
353
|
+
* This function verifies a batch proof produced by Aleo programs that may not be deployed on chain.
|
|
354
|
+
* Each verifying key is paired with one or more sets of public inputs (instances).
|
|
355
|
+
*
|
|
356
|
+
* @param {Array<string>} verifying_keys Array of verifying key strings, one per circuit
|
|
357
|
+
* @param {Array<Array<Array<string>>>} inputs 3D array of field element strings [circuit_idx][instance_idx][field_idx]
|
|
358
|
+
* @param {Proof} proof The batch proof to verify
|
|
359
|
+
* @returns {boolean} True if the batch proof is valid, false otherwise
|
|
360
|
+
* @param {Array<any>} verifying_keys
|
|
361
|
+
* @param {Array<any>} inputs
|
|
362
|
+
* @param {Proof} proof
|
|
363
|
+
* @returns {boolean}
|
|
364
|
+
*/
|
|
365
|
+
function snarkVerifyBatch(verifying_keys, inputs, proof) {
|
|
366
|
+
try {
|
|
367
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
368
|
+
_assertClass(proof, Proof);
|
|
369
|
+
wasm.snarkVerifyBatch(retptr, addHeapObject(verifying_keys), addHeapObject(inputs), proof.__wbg_ptr);
|
|
370
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
371
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
372
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
373
|
+
if (r2) {
|
|
374
|
+
throw takeObject(r1);
|
|
375
|
+
}
|
|
376
|
+
return r0 !== 0;
|
|
377
|
+
} finally {
|
|
378
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
350
382
|
/**
|
|
351
383
|
* Verify an execution. Executions with multiple transitions must have the program source code and
|
|
352
384
|
* verifying keys of imported functions supplied from outside to correctly verify. Also, this does
|
|
@@ -396,32 +428,39 @@ function verifyFunctionExecution(execution, verifying_key, program, function_id,
|
|
|
396
428
|
}
|
|
397
429
|
|
|
398
430
|
/**
|
|
399
|
-
*
|
|
431
|
+
* Returns the maximum number of imports allowed in a program by the
|
|
432
|
+
* snarkVM network implementation this SDK was built against.
|
|
400
433
|
*
|
|
401
|
-
*
|
|
402
|
-
* Each verifying key is paired with one or more sets of public inputs (instances).
|
|
434
|
+
* @returns {number} The maximum number of program imports.
|
|
403
435
|
*
|
|
404
|
-
* @
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
* @
|
|
409
|
-
* @param {Array<any>} inputs
|
|
410
|
-
* @param {Proof} proof
|
|
411
|
-
* @returns {boolean}
|
|
436
|
+
* @example
|
|
437
|
+
* import { getMaxProgramImports } from '@provablehq/sdk';
|
|
438
|
+
*
|
|
439
|
+
* const maxImports = getMaxProgramImports();
|
|
440
|
+
* @returns {number}
|
|
412
441
|
*/
|
|
413
|
-
function
|
|
442
|
+
function getMaxProgramImports() {
|
|
443
|
+
const ret = wasm.getMaxProgramImports();
|
|
444
|
+
return ret >>> 0;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* @param {string} string
|
|
449
|
+
* @returns {Field}
|
|
450
|
+
*/
|
|
451
|
+
function stringToField(string) {
|
|
414
452
|
try {
|
|
415
453
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
416
|
-
|
|
417
|
-
|
|
454
|
+
const ptr0 = passStringToWasm0(string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
455
|
+
const len0 = WASM_VECTOR_LEN;
|
|
456
|
+
wasm.stringToField(retptr, ptr0, len0);
|
|
418
457
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
419
458
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
420
459
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
421
460
|
if (r2) {
|
|
422
461
|
throw takeObject(r1);
|
|
423
462
|
}
|
|
424
|
-
return r0
|
|
463
|
+
return Field.__wrap(r0);
|
|
425
464
|
} finally {
|
|
426
465
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
427
466
|
}
|
|
@@ -436,7 +475,7 @@ function snarkVerifyBatch(verifying_keys, inputs, proof) {
|
|
|
436
475
|
* import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
|
|
437
476
|
*
|
|
438
477
|
* Set the consensus version heights.
|
|
439
|
-
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14");
|
|
478
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
|
|
440
479
|
* @param {string | null} [heights]
|
|
441
480
|
* @returns {Array<any>}
|
|
442
481
|
*/
|
|
@@ -447,28 +486,6 @@ function getOrInitConsensusVersionTestHeights(heights) {
|
|
|
447
486
|
return takeObject(ret);
|
|
448
487
|
}
|
|
449
488
|
|
|
450
|
-
/**
|
|
451
|
-
* @param {string} string
|
|
452
|
-
* @returns {Field}
|
|
453
|
-
*/
|
|
454
|
-
function stringToField(string) {
|
|
455
|
-
try {
|
|
456
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
457
|
-
const ptr0 = passStringToWasm0(string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
458
|
-
const len0 = WASM_VECTOR_LEN;
|
|
459
|
-
wasm.stringToField(retptr, ptr0, len0);
|
|
460
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
461
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
462
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
463
|
-
if (r2) {
|
|
464
|
-
throw takeObject(r1);
|
|
465
|
-
}
|
|
466
|
-
return Field.__wrap(r0);
|
|
467
|
-
} finally {
|
|
468
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
489
|
function passArrayJsValueToWasm0(array, malloc) {
|
|
473
490
|
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
474
491
|
const mem = getDataViewMemory0();
|
|
@@ -488,16 +505,16 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
488
505
|
}
|
|
489
506
|
return result;
|
|
490
507
|
}
|
|
491
|
-
function
|
|
492
|
-
wasm.
|
|
508
|
+
function __wasm_bindgen_func_elem_7393(arg0, arg1) {
|
|
509
|
+
wasm.__wasm_bindgen_func_elem_7393(arg0, arg1);
|
|
493
510
|
}
|
|
494
511
|
|
|
495
|
-
function
|
|
496
|
-
wasm.
|
|
512
|
+
function __wasm_bindgen_func_elem_8766(arg0, arg1, arg2) {
|
|
513
|
+
wasm.__wasm_bindgen_func_elem_8766(arg0, arg1, addHeapObject(arg2));
|
|
497
514
|
}
|
|
498
515
|
|
|
499
|
-
function
|
|
500
|
-
wasm.
|
|
516
|
+
function __wasm_bindgen_func_elem_7666(arg0, arg1, arg2, arg3) {
|
|
517
|
+
wasm.__wasm_bindgen_func_elem_7666(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
501
518
|
}
|
|
502
519
|
|
|
503
520
|
const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
|
|
@@ -10014,6 +10031,35 @@ class Program {
|
|
|
10014
10031
|
const ret = wasm.program_getFunctions(this.__wbg_ptr);
|
|
10015
10032
|
return takeObject(ret);
|
|
10016
10033
|
}
|
|
10034
|
+
/**
|
|
10035
|
+
* Get the program's name (without the `.aleo` suffix) encoded as a field element.
|
|
10036
|
+
*
|
|
10037
|
+
* This is the same value as casting the program name identifier to a field on-chain
|
|
10038
|
+
* (e.g. `my_program.aleo` -> `Identifier("my_program") as field`), which is used as
|
|
10039
|
+
* the program id in dynamic dispatch calls such as `IARC20@(token_id)`.
|
|
10040
|
+
*
|
|
10041
|
+
* @example
|
|
10042
|
+
* const program = aleo_wasm.Program.getCreditsProgram();
|
|
10043
|
+
* const field = program.nameToField(); // Field encoding of "credits"
|
|
10044
|
+
*
|
|
10045
|
+
* @returns {Field} The program name as a field element
|
|
10046
|
+
* @returns {Field}
|
|
10047
|
+
*/
|
|
10048
|
+
nameToField() {
|
|
10049
|
+
try {
|
|
10050
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
10051
|
+
wasm.program_nameToField(retptr, this.__wbg_ptr);
|
|
10052
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
10053
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
10054
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
10055
|
+
if (r2) {
|
|
10056
|
+
throw takeObject(r1);
|
|
10057
|
+
}
|
|
10058
|
+
return Field.__wrap(r0);
|
|
10059
|
+
} finally {
|
|
10060
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
10061
|
+
}
|
|
10062
|
+
}
|
|
10017
10063
|
/**
|
|
10018
10064
|
* Get the external call graph reachable from a specific entry function.
|
|
10019
10065
|
*
|
|
@@ -10269,6 +10315,47 @@ class Program {
|
|
|
10269
10315
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
10270
10316
|
}
|
|
10271
10317
|
}
|
|
10318
|
+
/**
|
|
10319
|
+
* Determine if the program implements the ARC-20 fungible token interface (IARC20).
|
|
10320
|
+
*
|
|
10321
|
+
* This checks that the program defines a `Token` record with an `amount: u128` entry
|
|
10322
|
+
* (additional entries are permitted, per the interface's open record definition) and
|
|
10323
|
+
* that every function and view function required by ARC-20 is present with the exact
|
|
10324
|
+
* input and output signature defined by the standard.
|
|
10325
|
+
*
|
|
10326
|
+
* @see https://github.com/ProvableHQ/ARCs/blob/master/arc-0020/README.md
|
|
10327
|
+
*
|
|
10328
|
+
* @returns {boolean} True if the program implements the ARC-20 token interface
|
|
10329
|
+
* @returns {boolean}
|
|
10330
|
+
*/
|
|
10331
|
+
isArc20() {
|
|
10332
|
+
const ret = wasm.program_isArc20(this.__wbg_ptr);
|
|
10333
|
+
return ret !== 0;
|
|
10334
|
+
}
|
|
10335
|
+
/**
|
|
10336
|
+
* Determine if the program implements the ARC-22 compliant token interface (IARC22).
|
|
10337
|
+
*
|
|
10338
|
+
* This checks that the program defines `Token` and `ComplianceRecord` records with the
|
|
10339
|
+
* entries required by the standard (additional entries are permitted, per the
|
|
10340
|
+
* interface's open record definitions), and that every function and view function
|
|
10341
|
+
* required by ARC-22 is present with the exact input and output signature defined by
|
|
10342
|
+
* the standard. The `MerkleProof` struct used by the private transfer functions may be
|
|
10343
|
+
* declared locally (in which case its shape must match the standard exactly) or
|
|
10344
|
+
* imported from another program such as a freeze list registry.
|
|
10345
|
+
*
|
|
10346
|
+
* Note: this checks the token interface (IARC22) only. The freeze list registry
|
|
10347
|
+
* interface (IARC22Freezelist) is typically implemented by a separate program and is
|
|
10348
|
+
* not required for a token program to be considered ARC-22 compliant.
|
|
10349
|
+
*
|
|
10350
|
+
* @see https://github.com/ProvableHQ/ARCs/blob/master/arc-0022/README.md
|
|
10351
|
+
*
|
|
10352
|
+
* @returns {boolean} True if the program implements the ARC-22 token interface
|
|
10353
|
+
* @returns {boolean}
|
|
10354
|
+
*/
|
|
10355
|
+
isArc22() {
|
|
10356
|
+
const ret = wasm.program_isArc22(this.__wbg_ptr);
|
|
10357
|
+
return ret !== 0;
|
|
10358
|
+
}
|
|
10272
10359
|
/**
|
|
10273
10360
|
* Determine equality with another program
|
|
10274
10361
|
*
|
|
@@ -19232,7 +19319,7 @@ function __wbg_get_imports(memory) {
|
|
|
19232
19319
|
const ret = getObject(arg0).length;
|
|
19233
19320
|
return ret;
|
|
19234
19321
|
};
|
|
19235
|
-
imports.wbg.
|
|
19322
|
+
imports.wbg.__wbg_log_a530da429f854235 = function(arg0, arg1) {
|
|
19236
19323
|
console.log(getStringFromWasm0(arg0, arg1));
|
|
19237
19324
|
};
|
|
19238
19325
|
imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
|
|
@@ -19250,7 +19337,7 @@ function __wbg_get_imports(memory) {
|
|
|
19250
19337
|
const a = state0.a;
|
|
19251
19338
|
state0.a = 0;
|
|
19252
19339
|
try {
|
|
19253
|
-
return
|
|
19340
|
+
return __wasm_bindgen_func_elem_7666(a, state0.b, arg0, arg1);
|
|
19254
19341
|
} finally {
|
|
19255
19342
|
state0.a = a;
|
|
19256
19343
|
}
|
|
@@ -19422,7 +19509,7 @@ function __wbg_get_imports(memory) {
|
|
|
19422
19509
|
const ret = Signature.__wrap(arg0);
|
|
19423
19510
|
return addHeapObject(ret);
|
|
19424
19511
|
};
|
|
19425
|
-
imports.wbg.
|
|
19512
|
+
imports.wbg.__wbg_spawnWorker_ad641c7b32ebd520 = function(arg0, arg1, arg2, arg3) {
|
|
19426
19513
|
const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
|
|
19427
19514
|
return addHeapObject(ret);
|
|
19428
19515
|
};
|
|
@@ -19521,12 +19608,12 @@ function __wbg_get_imports(memory) {
|
|
|
19521
19608
|
};
|
|
19522
19609
|
imports.wbg.__wbindgen_cast_4a64cbb5b17898c9 = function(arg0, arg1) {
|
|
19523
19610
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [Externref], shim_idx: 359, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
19524
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
19611
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7392, __wasm_bindgen_func_elem_8766);
|
|
19525
19612
|
return addHeapObject(ret);
|
|
19526
19613
|
};
|
|
19527
19614
|
imports.wbg.__wbindgen_cast_65bbaf572cb463ed = function(arg0, arg1) {
|
|
19528
19615
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 359, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
19529
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
19616
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7392, __wasm_bindgen_func_elem_8766);
|
|
19530
19617
|
return addHeapObject(ret);
|
|
19531
19618
|
};
|
|
19532
19619
|
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
@@ -19536,7 +19623,7 @@ function __wbg_get_imports(memory) {
|
|
|
19536
19623
|
};
|
|
19537
19624
|
imports.wbg.__wbindgen_cast_aca65e91b5ef2a91 = function(arg0, arg1) {
|
|
19538
19625
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [], shim_idx: 467, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
19539
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
19626
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7392, __wasm_bindgen_func_elem_7393);
|
|
19540
19627
|
return addHeapObject(ret);
|
|
19541
19628
|
};
|
|
19542
19629
|
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
@@ -19647,5 +19734,5 @@ async function initThreadPool(threads) {
|
|
|
19647
19734
|
await initThreadPool$1(new URL("worker.js", import.meta.url), threads);
|
|
19648
19735
|
}
|
|
19649
19736
|
|
|
19650
|
-
export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, CallbackQuery, Ciphertext, ComputeKey, DynamicRecord, EncryptionToolkit, Execution, ExecutionRequest, ExecutionResponse, Field, GraphKey, Group, I128, I16, I32, I64, I8, KeyPair, Metadata, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramImports, ProgramManager, Proof, ProvingKey, ProvingRequest, QueryOption, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, Value, VerifyingKey, ViewKey, getOrInitConsensusVersionTestHeights, initSync, initThreadPool, runRayonThread, setWasmLogLevel, snarkVerify, snarkVerifyBatch, stringToField, verifyFunctionExecution };
|
|
19737
|
+
export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, CallbackQuery, Ciphertext, ComputeKey, DynamicRecord, EncryptionToolkit, Execution, ExecutionRequest, ExecutionResponse, Field, GraphKey, Group, I128, I16, I32, I64, I8, KeyPair, Metadata, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramImports, ProgramManager, Proof, ProvingKey, ProvingRequest, QueryOption, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, Value, VerifyingKey, ViewKey, getMaxProgramImports, getOrInitConsensusVersionTestHeights, initSync, initThreadPool, runRayonThread, setWasmLogLevel, snarkVerify, snarkVerifyBatch, stringToField, verifyFunctionExecution };
|
|
19651
19738
|
//# sourceMappingURL=index.js.map
|