@provablehq/wasm 0.11.3 → 0.11.4
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 +61 -14
- package/dist/mainnet/aleo_wasm.wasm +0 -0
- package/dist/mainnet/index.cjs +129 -59
- package/dist/mainnet/index.cjs.map +1 -1
- package/dist/mainnet/index.js +129 -59
- package/dist/mainnet/index.js.map +1 -1
- package/dist/mainnet/worker.js +129 -59
- package/dist/mainnet/worker.js.map +1 -1
- package/dist/testnet/aleo_wasm.d.ts +60 -13
- package/dist/testnet/aleo_wasm.wasm +0 -0
- package/dist/testnet/index.cjs +104 -34
- package/dist/testnet/index.cjs.map +1 -1
- package/dist/testnet/index.js +104 -34
- package/dist/testnet/index.js.map +1 -1
- package/dist/testnet/worker.js +104 -34
- package/dist/testnet/worker.js.map +1 -1
- package/package.json +1 -1
package/dist/mainnet/worker.js
CHANGED
|
@@ -314,39 +314,6 @@ function addBorrowedObject(obj) {
|
|
|
314
314
|
heap[--stack_pointer] = obj;
|
|
315
315
|
return stack_pointer;
|
|
316
316
|
}
|
|
317
|
-
/**
|
|
318
|
-
* Verify a SNARK proof against a verifying key and public inputs.
|
|
319
|
-
*
|
|
320
|
-
* This function verifies a proof produced by an Aleo program that may not be deployed on chain.
|
|
321
|
-
* It directly invokes the Varuna proof verification from snarkVM.
|
|
322
|
-
*
|
|
323
|
-
* @param {VerifyingKey} verifying_key The verifying key for the circuit
|
|
324
|
-
* @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
|
|
325
|
-
* @param {Proof} proof The proof to verify
|
|
326
|
-
* @returns {boolean} True if the proof is valid, false otherwise
|
|
327
|
-
* @param {VerifyingKey} verifying_key
|
|
328
|
-
* @param {Array<any>} inputs
|
|
329
|
-
* @param {Proof} proof
|
|
330
|
-
* @returns {boolean}
|
|
331
|
-
*/
|
|
332
|
-
function snarkVerify(verifying_key, inputs, proof) {
|
|
333
|
-
try {
|
|
334
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
335
|
-
_assertClass(verifying_key, VerifyingKey);
|
|
336
|
-
_assertClass(proof, Proof);
|
|
337
|
-
wasm.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
|
|
338
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
339
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
340
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
341
|
-
if (r2) {
|
|
342
|
-
throw takeObject(r1);
|
|
343
|
-
}
|
|
344
|
-
return r0 !== 0;
|
|
345
|
-
} finally {
|
|
346
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
317
|
/**
|
|
351
318
|
* Verify an execution. Executions with multiple transitions must have the program source code and
|
|
352
319
|
* verifying keys of imported functions supplied from outside to correctly verify. Also, this does
|
|
@@ -428,23 +395,36 @@ function snarkVerifyBatch(verifying_keys, inputs, proof) {
|
|
|
428
395
|
}
|
|
429
396
|
|
|
430
397
|
/**
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
* @param {string | undefined} heights The block heights at which each consensus version applies. This input should be a simple csv list of block heights and there should be one number for each consensus version. If left undefined, the default test heights will be applied.
|
|
398
|
+
* Verify a SNARK proof against a verifying key and public inputs.
|
|
434
399
|
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
400
|
+
* This function verifies a proof produced by an Aleo program that may not be deployed on chain.
|
|
401
|
+
* It directly invokes the Varuna proof verification from snarkVM.
|
|
437
402
|
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
* @param {
|
|
441
|
-
* @returns {
|
|
403
|
+
* @param {VerifyingKey} verifying_key The verifying key for the circuit
|
|
404
|
+
* @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
|
|
405
|
+
* @param {Proof} proof The proof to verify
|
|
406
|
+
* @returns {boolean} True if the proof is valid, false otherwise
|
|
407
|
+
* @param {VerifyingKey} verifying_key
|
|
408
|
+
* @param {Array<any>} inputs
|
|
409
|
+
* @param {Proof} proof
|
|
410
|
+
* @returns {boolean}
|
|
442
411
|
*/
|
|
443
|
-
function
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
412
|
+
function snarkVerify(verifying_key, inputs, proof) {
|
|
413
|
+
try {
|
|
414
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
415
|
+
_assertClass(verifying_key, VerifyingKey);
|
|
416
|
+
_assertClass(proof, Proof);
|
|
417
|
+
wasm.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
|
|
418
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
419
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
420
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
421
|
+
if (r2) {
|
|
422
|
+
throw takeObject(r1);
|
|
423
|
+
}
|
|
424
|
+
return r0 !== 0;
|
|
425
|
+
} finally {
|
|
426
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
427
|
+
}
|
|
448
428
|
}
|
|
449
429
|
|
|
450
430
|
/**
|
|
@@ -469,6 +449,26 @@ function stringToField(string) {
|
|
|
469
449
|
}
|
|
470
450
|
}
|
|
471
451
|
|
|
452
|
+
/**
|
|
453
|
+
* Set test consensus version heights for testing.
|
|
454
|
+
*
|
|
455
|
+
* @param {string | undefined} heights The block heights at which each consensus version applies. This input should be a simple csv list of block heights and there should be one number for each consensus version. If left undefined, the default test heights will be applied.
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
|
|
459
|
+
*
|
|
460
|
+
* Set the consensus version heights.
|
|
461
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
|
|
462
|
+
* @param {string | null} [heights]
|
|
463
|
+
* @returns {Array<any>}
|
|
464
|
+
*/
|
|
465
|
+
function getOrInitConsensusVersionTestHeights(heights) {
|
|
466
|
+
var ptr0 = isLikeNone(heights) ? 0 : passStringToWasm0(heights, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
467
|
+
var len0 = WASM_VECTOR_LEN;
|
|
468
|
+
const ret = wasm.getOrInitConsensusVersionTestHeights(ptr0, len0);
|
|
469
|
+
return takeObject(ret);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
472
|
function passArrayJsValueToWasm0(array, malloc) {
|
|
473
473
|
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
474
474
|
const mem = getDataViewMemory0();
|
|
@@ -488,16 +488,16 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
488
488
|
}
|
|
489
489
|
return result;
|
|
490
490
|
}
|
|
491
|
-
function
|
|
492
|
-
wasm.
|
|
491
|
+
function __wasm_bindgen_func_elem_8765(arg0, arg1, arg2) {
|
|
492
|
+
wasm.__wasm_bindgen_func_elem_8765(arg0, arg1, addHeapObject(arg2));
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
function
|
|
496
|
-
wasm.
|
|
495
|
+
function __wasm_bindgen_func_elem_7397(arg0, arg1) {
|
|
496
|
+
wasm.__wasm_bindgen_func_elem_7397(arg0, arg1);
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
function
|
|
500
|
-
wasm.
|
|
499
|
+
function __wasm_bindgen_func_elem_7669(arg0, arg1, arg2, arg3) {
|
|
500
|
+
wasm.__wasm_bindgen_func_elem_7669(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
501
501
|
}
|
|
502
502
|
|
|
503
503
|
const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
|
|
@@ -10014,6 +10014,35 @@ class Program {
|
|
|
10014
10014
|
const ret = wasm.program_getFunctions(this.__wbg_ptr);
|
|
10015
10015
|
return takeObject(ret);
|
|
10016
10016
|
}
|
|
10017
|
+
/**
|
|
10018
|
+
* Get the program's name (without the `.aleo` suffix) encoded as a field element.
|
|
10019
|
+
*
|
|
10020
|
+
* This is the same value as casting the program name identifier to a field on-chain
|
|
10021
|
+
* (e.g. `my_program.aleo` -> `Identifier("my_program") as field`), which is used as
|
|
10022
|
+
* the program id in dynamic dispatch calls such as `IARC20@(token_id)`.
|
|
10023
|
+
*
|
|
10024
|
+
* @example
|
|
10025
|
+
* const program = aleo_wasm.Program.getCreditsProgram();
|
|
10026
|
+
* const field = program.nameToField(); // Field encoding of "credits"
|
|
10027
|
+
*
|
|
10028
|
+
* @returns {Field} The program name as a field element
|
|
10029
|
+
* @returns {Field}
|
|
10030
|
+
*/
|
|
10031
|
+
nameToField() {
|
|
10032
|
+
try {
|
|
10033
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
10034
|
+
wasm.program_nameToField(retptr, this.__wbg_ptr);
|
|
10035
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
10036
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
10037
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
10038
|
+
if (r2) {
|
|
10039
|
+
throw takeObject(r1);
|
|
10040
|
+
}
|
|
10041
|
+
return Field.__wrap(r0);
|
|
10042
|
+
} finally {
|
|
10043
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
10044
|
+
}
|
|
10045
|
+
}
|
|
10017
10046
|
/**
|
|
10018
10047
|
* Get the external call graph reachable from a specific entry function.
|
|
10019
10048
|
*
|
|
@@ -10269,6 +10298,47 @@ class Program {
|
|
|
10269
10298
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
10270
10299
|
}
|
|
10271
10300
|
}
|
|
10301
|
+
/**
|
|
10302
|
+
* Determine if the program implements the ARC-20 fungible token interface (IARC20).
|
|
10303
|
+
*
|
|
10304
|
+
* This checks that the program defines a `Token` record with an `amount: u128` entry
|
|
10305
|
+
* (additional entries are permitted, per the interface's open record definition) and
|
|
10306
|
+
* that every function and view function required by ARC-20 is present with the exact
|
|
10307
|
+
* input and output signature defined by the standard.
|
|
10308
|
+
*
|
|
10309
|
+
* @see https://github.com/ProvableHQ/ARCs/blob/master/arc-0020/README.md
|
|
10310
|
+
*
|
|
10311
|
+
* @returns {boolean} True if the program implements the ARC-20 token interface
|
|
10312
|
+
* @returns {boolean}
|
|
10313
|
+
*/
|
|
10314
|
+
isArc20() {
|
|
10315
|
+
const ret = wasm.program_isArc20(this.__wbg_ptr);
|
|
10316
|
+
return ret !== 0;
|
|
10317
|
+
}
|
|
10318
|
+
/**
|
|
10319
|
+
* Determine if the program implements the ARC-22 compliant token interface (IARC22).
|
|
10320
|
+
*
|
|
10321
|
+
* This checks that the program defines `Token` and `ComplianceRecord` records with the
|
|
10322
|
+
* entries required by the standard (additional entries are permitted, per the
|
|
10323
|
+
* interface's open record definitions), and that every function and view function
|
|
10324
|
+
* required by ARC-22 is present with the exact input and output signature defined by
|
|
10325
|
+
* the standard. The `MerkleProof` struct used by the private transfer functions may be
|
|
10326
|
+
* declared locally (in which case its shape must match the standard exactly) or
|
|
10327
|
+
* imported from another program such as a freeze list registry.
|
|
10328
|
+
*
|
|
10329
|
+
* Note: this checks the token interface (IARC22) only. The freeze list registry
|
|
10330
|
+
* interface (IARC22Freezelist) is typically implemented by a separate program and is
|
|
10331
|
+
* not required for a token program to be considered ARC-22 compliant.
|
|
10332
|
+
*
|
|
10333
|
+
* @see https://github.com/ProvableHQ/ARCs/blob/master/arc-0022/README.md
|
|
10334
|
+
*
|
|
10335
|
+
* @returns {boolean} True if the program implements the ARC-22 token interface
|
|
10336
|
+
* @returns {boolean}
|
|
10337
|
+
*/
|
|
10338
|
+
isArc22() {
|
|
10339
|
+
const ret = wasm.program_isArc22(this.__wbg_ptr);
|
|
10340
|
+
return ret !== 0;
|
|
10341
|
+
}
|
|
10272
10342
|
/**
|
|
10273
10343
|
* Determine equality with another program
|
|
10274
10344
|
*
|
|
@@ -19232,7 +19302,7 @@ function __wbg_get_imports(memory) {
|
|
|
19232
19302
|
const ret = getObject(arg0).length;
|
|
19233
19303
|
return ret;
|
|
19234
19304
|
};
|
|
19235
|
-
imports.wbg.
|
|
19305
|
+
imports.wbg.__wbg_log_4507b73801c06872 = function(arg0, arg1) {
|
|
19236
19306
|
console.log(getStringFromWasm0(arg0, arg1));
|
|
19237
19307
|
};
|
|
19238
19308
|
imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
|
|
@@ -19250,7 +19320,7 @@ function __wbg_get_imports(memory) {
|
|
|
19250
19320
|
const a = state0.a;
|
|
19251
19321
|
state0.a = 0;
|
|
19252
19322
|
try {
|
|
19253
|
-
return
|
|
19323
|
+
return __wasm_bindgen_func_elem_7669(a, state0.b, arg0, arg1);
|
|
19254
19324
|
} finally {
|
|
19255
19325
|
state0.a = a;
|
|
19256
19326
|
}
|
|
@@ -19422,7 +19492,7 @@ function __wbg_get_imports(memory) {
|
|
|
19422
19492
|
const ret = Signature.__wrap(arg0);
|
|
19423
19493
|
return addHeapObject(ret);
|
|
19424
19494
|
};
|
|
19425
|
-
imports.wbg.
|
|
19495
|
+
imports.wbg.__wbg_spawnWorker_6197e35077a8baba = function(arg0, arg1, arg2, arg3) {
|
|
19426
19496
|
const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
|
|
19427
19497
|
return addHeapObject(ret);
|
|
19428
19498
|
};
|
|
@@ -19521,12 +19591,12 @@ function __wbg_get_imports(memory) {
|
|
|
19521
19591
|
};
|
|
19522
19592
|
imports.wbg.__wbindgen_cast_4a64cbb5b17898c9 = function(arg0, arg1) {
|
|
19523
19593
|
// 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.
|
|
19594
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7396, __wasm_bindgen_func_elem_8765);
|
|
19525
19595
|
return addHeapObject(ret);
|
|
19526
19596
|
};
|
|
19527
19597
|
imports.wbg.__wbindgen_cast_65bbaf572cb463ed = function(arg0, arg1) {
|
|
19528
19598
|
// 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.
|
|
19599
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7396, __wasm_bindgen_func_elem_8765);
|
|
19530
19600
|
return addHeapObject(ret);
|
|
19531
19601
|
};
|
|
19532
19602
|
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
@@ -19536,7 +19606,7 @@ function __wbg_get_imports(memory) {
|
|
|
19536
19606
|
};
|
|
19537
19607
|
imports.wbg.__wbindgen_cast_aca65e91b5ef2a91 = function(arg0, arg1) {
|
|
19538
19608
|
// 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.
|
|
19609
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7396, __wasm_bindgen_func_elem_7397);
|
|
19540
19610
|
return addHeapObject(ret);
|
|
19541
19611
|
};
|
|
19542
19612
|
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|