@provablehq/wasm 0.6.13 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/{crates → mainnet}/aleo_wasm.d.ts +40 -34
- package/dist/mainnet/aleo_wasm.js +4578 -0
- package/dist/mainnet/aleo_wasm.js.map +1 -0
- package/dist/mainnet/aleo_wasm.wasm +0 -0
- package/dist/{index.d.ts → mainnet/index.d.ts} +1 -1
- package/dist/{index.js → mainnet/index.js} +68 -60
- package/dist/mainnet/index.js.map +1 -0
- package/dist/{worker.js → mainnet/worker.js} +67 -59
- package/dist/mainnet/worker.js.map +1 -0
- package/dist/testnet/aleo_wasm.d.ts +1692 -0
- package/dist/testnet/aleo_wasm.js +4578 -0
- package/dist/testnet/aleo_wasm.js.map +1 -0
- package/dist/testnet/aleo_wasm.wasm +0 -0
- package/dist/testnet/aleo_wasm_init.d.ts +17 -0
- package/dist/testnet/index.d.ts +27 -0
- package/dist/testnet/index.js +4615 -0
- package/dist/testnet/index.js.map +1 -0
- package/dist/testnet/worker.d.ts +1 -0
- package/dist/testnet/worker.js +4611 -0
- package/dist/testnet/worker.js.map +1 -0
- package/package.json +12 -10
- package/dist/assets/aleo_wasm.wasm +0 -0
- package/dist/index.js.map +0 -1
- package/dist/worker.js.map +0 -1
- /package/dist/{crates → mainnet}/aleo_wasm_init.d.ts +0 -0
- /package/dist/{worker.d.ts → mainnet/worker.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[](https://crates.io/crates/aleo-wasm)
|
|
2
|
-
[](https://
|
|
2
|
+
[](https://provable.com)
|
|
3
3
|
[](./LICENSE.md)
|
|
4
4
|
|
|
5
5
|
[![github]](https://github.com/ProvableHQ/sdk) [![crates-io]](https://crates.io/crates/aleo-wasm) [![docs-rs]](https://docs.rs/aleo-wasm/latest/aleo-wasm/)
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
Aleo JavaScript and WebAssembly bindings for building zero-knowledge web applications.
|
|
14
14
|
|
|
15
|
-
`Rust` compiles easily to `WebAssembly`, but creating the glue code necessary to use compiled WebAssembly binaries
|
|
16
|
-
from other languages such as JavaScript is a challenging task. `wasm-bindgen` is a tool that simplifies this process by
|
|
17
|
-
auto-generating JavaScript bindings to Rust code that has been compiled into WebAssembly.
|
|
15
|
+
`Rust` compiles easily to `WebAssembly`, but creating the glue code necessary to use compiled WebAssembly binaries
|
|
16
|
+
from other languages such as JavaScript is a challenging task. `wasm-bindgen` is a tool that simplifies this process by
|
|
17
|
+
auto-generating JavaScript bindings to Rust code that has been compiled into WebAssembly.
|
|
18
18
|
|
|
19
19
|
This crate uses `wasm-bindgen` to create JavaScript bindings to Aleo source code so that it can be used to create zero-knowledge proofs directly within web browsers and `Node.js`.
|
|
20
20
|
|
|
@@ -23,7 +23,7 @@ Functionality exposed by this crate includes:
|
|
|
23
23
|
* Aleo primitives such as `Records`, `Programs`, and `Transactions` and their associated helper methods
|
|
24
24
|
* A `ProgramManager` object that contains methods for authoring, deploying, and interacting with Aleo programs
|
|
25
25
|
|
|
26
|
-
More information on these concepts can be found at the [Aleo Developer Hub](https://
|
|
26
|
+
More information on these concepts can be found at the [Aleo Developer Hub](https://docs.leo-lang.org/concepts).
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
29
29
|
|
|
@@ -56,7 +56,7 @@ wasm-pack test --[firefox/chrome/safari]
|
|
|
56
56
|
|
|
57
57
|
## Building Web Apps
|
|
58
58
|
|
|
59
|
-
Further documentation and tutorials as to how to use the modules built from this crate to build web apps will be built
|
|
59
|
+
Further documentation and tutorials as to how to use the modules built from this crate to build web apps will be built
|
|
60
60
|
in the future. However, in the meantime, the [provable.tools](https://provable.tools) website is a good
|
|
61
|
-
example of how to use these modules to build a web app. Its source code can be found in the
|
|
61
|
+
example of how to use these modules to build a web app. Its source code can be found in the
|
|
62
62
|
[Aleo SDK](https://github.com/ProvableHQ/sdk) repo in the `website` folder.
|
|
@@ -181,14 +181,14 @@ export class KeyPair {
|
|
|
181
181
|
/**
|
|
182
182
|
* Get the proving key. This method will remove the proving key from the key pair
|
|
183
183
|
*
|
|
184
|
-
* @returns {ProvingKey
|
|
184
|
+
* @returns {ProvingKey}
|
|
185
185
|
* @returns {ProvingKey}
|
|
186
186
|
*/
|
|
187
187
|
provingKey(): ProvingKey;
|
|
188
188
|
/**
|
|
189
189
|
* Get the verifying key. This method will remove the verifying key from the key pair
|
|
190
190
|
*
|
|
191
|
-
* @returns {VerifyingKey
|
|
191
|
+
* @returns {VerifyingKey}
|
|
192
192
|
* @returns {VerifyingKey}
|
|
193
193
|
*/
|
|
194
194
|
verifyingKey(): VerifyingKey;
|
|
@@ -285,9 +285,15 @@ export class OfflineQuery {
|
|
|
285
285
|
free(): void;
|
|
286
286
|
/**
|
|
287
287
|
* Creates a new offline query object. The state root is required to be passed in as a string
|
|
288
|
+
* @param {number} block_height
|
|
288
289
|
* @param {string} state_root
|
|
289
290
|
*/
|
|
290
|
-
constructor(state_root: string);
|
|
291
|
+
constructor(block_height: number, state_root: string);
|
|
292
|
+
/**
|
|
293
|
+
* Add a new block height to the offline query object.
|
|
294
|
+
* @param {number} block_height
|
|
295
|
+
*/
|
|
296
|
+
addBlockHeight(block_height: number): void;
|
|
291
297
|
/**
|
|
292
298
|
* Add a new state path to the offline query object.
|
|
293
299
|
*
|
|
@@ -374,7 +380,7 @@ export class PrivateKey {
|
|
|
374
380
|
* and will be needed to decrypt the private key later, so it should be stored securely
|
|
375
381
|
*
|
|
376
382
|
* @param {string} secret Secret used to encrypt the private key
|
|
377
|
-
* @returns {PrivateKeyCiphertext
|
|
383
|
+
* @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
|
|
378
384
|
* @param {string} secret
|
|
379
385
|
* @returns {PrivateKeyCiphertext}
|
|
380
386
|
*/
|
|
@@ -384,7 +390,7 @@ export class PrivateKey {
|
|
|
384
390
|
* decrypt the private key later, so it should be stored securely
|
|
385
391
|
*
|
|
386
392
|
* @param {string} secret Secret used to encrypt the private key
|
|
387
|
-
* @returns {PrivateKeyCiphertext
|
|
393
|
+
* @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
|
|
388
394
|
* @param {string} secret
|
|
389
395
|
* @returns {PrivateKeyCiphertext}
|
|
390
396
|
*/
|
|
@@ -394,7 +400,7 @@ export class PrivateKey {
|
|
|
394
400
|
*
|
|
395
401
|
* @param {PrivateKeyCiphertext} ciphertext Ciphertext representation of the private key
|
|
396
402
|
* @param {string} secret Secret originally used to encrypt the private key
|
|
397
|
-
* @returns {PrivateKey
|
|
403
|
+
* @returns {PrivateKey} Private key
|
|
398
404
|
* @param {PrivateKeyCiphertext} ciphertext
|
|
399
405
|
* @param {string} secret
|
|
400
406
|
* @returns {PrivateKey}
|
|
@@ -412,7 +418,7 @@ export class PrivateKeyCiphertext {
|
|
|
412
418
|
*
|
|
413
419
|
* @param {PrivateKey} private_key Private key to encrypt
|
|
414
420
|
* @param {string} secret Secret to encrypt the private key with
|
|
415
|
-
* @returns {PrivateKeyCiphertext
|
|
421
|
+
* @returns {PrivateKeyCiphertext} Private key ciphertext
|
|
416
422
|
* @param {PrivateKey} private_key
|
|
417
423
|
* @param {string} secret
|
|
418
424
|
* @returns {PrivateKeyCiphertext}
|
|
@@ -423,7 +429,7 @@ export class PrivateKeyCiphertext {
|
|
|
423
429
|
* encrypt the private key
|
|
424
430
|
*
|
|
425
431
|
* @param {string} secret Secret used to encrypt the private key
|
|
426
|
-
* @returns {PrivateKey
|
|
432
|
+
* @returns {PrivateKey} Private key
|
|
427
433
|
* @param {string} secret
|
|
428
434
|
* @returns {PrivateKey}
|
|
429
435
|
*/
|
|
@@ -439,7 +445,7 @@ export class PrivateKeyCiphertext {
|
|
|
439
445
|
* Creates a PrivateKeyCiphertext from a string
|
|
440
446
|
*
|
|
441
447
|
* @param {string} ciphertext Ciphertext string
|
|
442
|
-
* @returns {PrivateKeyCiphertext
|
|
448
|
+
* @returns {PrivateKeyCiphertext} Private key ciphertext
|
|
443
449
|
* @param {string} ciphertext
|
|
444
450
|
* @returns {PrivateKeyCiphertext}
|
|
445
451
|
*/
|
|
@@ -454,7 +460,7 @@ export class Program {
|
|
|
454
460
|
* Create a program from a program string
|
|
455
461
|
*
|
|
456
462
|
* @param {string} program Aleo program source code
|
|
457
|
-
* @returns {Program
|
|
463
|
+
* @returns {Program} Program object
|
|
458
464
|
* @param {string} program
|
|
459
465
|
* @returns {Program}
|
|
460
466
|
*/
|
|
@@ -503,7 +509,7 @@ export class Program {
|
|
|
503
509
|
* to generate a web form to capture user inputs for an execution of a function.
|
|
504
510
|
*
|
|
505
511
|
* @param {string} function_name Name of the function to get inputs for
|
|
506
|
-
* @returns {Array
|
|
512
|
+
* @returns {Array} Array of function inputs
|
|
507
513
|
*
|
|
508
514
|
* @example
|
|
509
515
|
* const expected_inputs = [
|
|
@@ -542,7 +548,7 @@ export class Program {
|
|
|
542
548
|
/**
|
|
543
549
|
* Get a the list of a program's mappings and the names/types of their keys and values.
|
|
544
550
|
*
|
|
545
|
-
* @returns {Array
|
|
551
|
+
* @returns {Array} - An array of objects representing the mappings in the program
|
|
546
552
|
* @example
|
|
547
553
|
* const expected_mappings = [
|
|
548
554
|
* {
|
|
@@ -564,7 +570,7 @@ export class Program {
|
|
|
564
570
|
* Get a javascript object representation of a program record and its types
|
|
565
571
|
*
|
|
566
572
|
* @param {string} record_name Name of the record to get members for
|
|
567
|
-
* @returns {Object
|
|
573
|
+
* @returns {Object} Object containing the record name, type, and members
|
|
568
574
|
*
|
|
569
575
|
* @example
|
|
570
576
|
*
|
|
@@ -596,7 +602,7 @@ export class Program {
|
|
|
596
602
|
* Get a javascript object representation of a program struct and its types
|
|
597
603
|
*
|
|
598
604
|
* @param {string} struct_name Name of the struct to get members for
|
|
599
|
-
* @returns {Array
|
|
605
|
+
* @returns {Array} Array containing the struct members
|
|
600
606
|
*
|
|
601
607
|
* @example
|
|
602
608
|
*
|
|
@@ -721,7 +727,7 @@ export class ProgramManager {
|
|
|
721
727
|
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
722
728
|
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
723
729
|
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
724
|
-
* @returns {Transaction
|
|
730
|
+
* @returns {Transaction}
|
|
725
731
|
* @param {PrivateKey} private_key
|
|
726
732
|
* @param {string} program
|
|
727
733
|
* @param {number} fee_credits
|
|
@@ -743,7 +749,7 @@ export class ProgramManager {
|
|
|
743
749
|
* @param imports (optional) Provide a list of imports to use for the deployment fee estimation
|
|
744
750
|
* in the form of a javascript object where the keys are a string of the program name and the values
|
|
745
751
|
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
746
|
-
* @returns {u64
|
|
752
|
+
* @returns {u64}
|
|
747
753
|
* @param {string} program
|
|
748
754
|
* @param {object | undefined} [imports]
|
|
749
755
|
* @returns {Promise<bigint>}
|
|
@@ -757,7 +763,7 @@ export class ProgramManager {
|
|
|
757
763
|
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
758
764
|
*
|
|
759
765
|
* @param name The name of the program to be deployed
|
|
760
|
-
* @returns {u64
|
|
766
|
+
* @returns {u64}
|
|
761
767
|
* @param {string} name
|
|
762
768
|
* @returns {bigint}
|
|
763
769
|
*/
|
|
@@ -816,7 +822,7 @@ export class ProgramManager {
|
|
|
816
822
|
* @param verifying_key (optional) Provide a verifying key to use for the function execution
|
|
817
823
|
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
818
824
|
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
819
|
-
* @returns {Transaction
|
|
825
|
+
* @returns {Transaction}
|
|
820
826
|
* @param {PrivateKey} private_key
|
|
821
827
|
* @param {string} program
|
|
822
828
|
* @param {string} _function
|
|
@@ -850,7 +856,7 @@ export class ProgramManager {
|
|
|
850
856
|
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
851
857
|
* @param proving_key (optional) Provide a verifying key to use for the fee estimation
|
|
852
858
|
* @param verifying_key (optional) Provide a verifying key to use for the fee estimation
|
|
853
|
-
* @returns {u64
|
|
859
|
+
* @returns {u64} Fee in microcredits
|
|
854
860
|
* @param {PrivateKey} private_key
|
|
855
861
|
* @param {string} program
|
|
856
862
|
* @param {string} _function
|
|
@@ -872,7 +878,7 @@ export class ProgramManager {
|
|
|
872
878
|
*
|
|
873
879
|
* @param program The program containing the function to estimate the finalize fee for
|
|
874
880
|
* @param function The function to estimate the finalize fee for
|
|
875
|
-
* @returns {u64
|
|
881
|
+
* @returns {u64} Fee in microcredits
|
|
876
882
|
* @param {string} program
|
|
877
883
|
* @param {string} _function
|
|
878
884
|
* @returns {bigint}
|
|
@@ -892,7 +898,7 @@ export class ProgramManager {
|
|
|
892
898
|
* @param join_verifying_key (optional) Provide a verifying key to use for the join function
|
|
893
899
|
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
894
900
|
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
895
|
-
* @returns {Transaction
|
|
901
|
+
* @returns {Transaction} Transaction object
|
|
896
902
|
* @param {PrivateKey} private_key
|
|
897
903
|
* @param {RecordPlaintext} record_1
|
|
898
904
|
* @param {RecordPlaintext} record_2
|
|
@@ -917,7 +923,7 @@ export class ProgramManager {
|
|
|
917
923
|
* @param url The url of the Aleo network node to send the transaction to
|
|
918
924
|
* @param split_proving_key (optional) Provide a proving key to use for the split function
|
|
919
925
|
* @param split_verifying_key (optional) Provide a verifying key to use for the split function
|
|
920
|
-
* @returns {Transaction
|
|
926
|
+
* @returns {Transaction} Transaction object
|
|
921
927
|
* @param {PrivateKey} private_key
|
|
922
928
|
* @param {number} split_amount
|
|
923
929
|
* @param {RecordPlaintext} amount_record
|
|
@@ -943,7 +949,7 @@ export class ProgramManager {
|
|
|
943
949
|
* function
|
|
944
950
|
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
945
951
|
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
946
|
-
* @returns {Transaction
|
|
952
|
+
* @returns {Transaction}
|
|
947
953
|
* @param {PrivateKey} private_key
|
|
948
954
|
* @param {number} amount_credits
|
|
949
955
|
* @param {string} recipient
|
|
@@ -1164,7 +1170,7 @@ export class ProvingKey {
|
|
|
1164
1170
|
* Construct a new proving key from a byte array
|
|
1165
1171
|
*
|
|
1166
1172
|
* @param {Uint8Array} bytes Byte array representation of a proving key
|
|
1167
|
-
* @returns {ProvingKey
|
|
1173
|
+
* @returns {ProvingKey}
|
|
1168
1174
|
* @param {Uint8Array} bytes
|
|
1169
1175
|
* @returns {ProvingKey}
|
|
1170
1176
|
*/
|
|
@@ -1172,7 +1178,7 @@ export class ProvingKey {
|
|
|
1172
1178
|
/**
|
|
1173
1179
|
* Create a proving key from string
|
|
1174
1180
|
*
|
|
1175
|
-
* @param {string
|
|
1181
|
+
* @param {string} String representation of the proving key
|
|
1176
1182
|
* @param {string} string
|
|
1177
1183
|
* @returns {ProvingKey}
|
|
1178
1184
|
*/
|
|
@@ -1180,7 +1186,7 @@ export class ProvingKey {
|
|
|
1180
1186
|
/**
|
|
1181
1187
|
* Return the byte representation of a proving key
|
|
1182
1188
|
*
|
|
1183
|
-
* @returns {Uint8Array
|
|
1189
|
+
* @returns {Uint8Array} Byte array representation of a proving key
|
|
1184
1190
|
* @returns {Uint8Array}
|
|
1185
1191
|
*/
|
|
1186
1192
|
toBytes(): Uint8Array;
|
|
@@ -1201,7 +1207,7 @@ export class RecordCiphertext {
|
|
|
1201
1207
|
* Create a record ciphertext from a string
|
|
1202
1208
|
*
|
|
1203
1209
|
* @param {string} record String representation of a record ciphertext
|
|
1204
|
-
* @returns {RecordCiphertext
|
|
1210
|
+
* @returns {RecordCiphertext} Record ciphertext
|
|
1205
1211
|
* @param {string} record
|
|
1206
1212
|
* @returns {RecordCiphertext}
|
|
1207
1213
|
*/
|
|
@@ -1218,7 +1224,7 @@ export class RecordCiphertext {
|
|
|
1218
1224
|
* decrypt if the record was encrypted by the account corresponding to the view key
|
|
1219
1225
|
*
|
|
1220
1226
|
* @param {ViewKey} view_key View key used to decrypt the ciphertext
|
|
1221
|
-
* @returns {RecordPlaintext
|
|
1227
|
+
* @returns {RecordPlaintext} Record plaintext object
|
|
1222
1228
|
* @param {ViewKey} view_key
|
|
1223
1229
|
* @returns {RecordPlaintext}
|
|
1224
1230
|
*/
|
|
@@ -1248,7 +1254,7 @@ export class RecordPlaintext {
|
|
|
1248
1254
|
* Return a record plaintext from a string.
|
|
1249
1255
|
*
|
|
1250
1256
|
* @param {string} record String representation of a plaintext representation of an Aleo record
|
|
1251
|
-
* @returns {RecordPlaintext
|
|
1257
|
+
* @returns {RecordPlaintext} Record plaintext
|
|
1252
1258
|
* @param {string} record
|
|
1253
1259
|
* @returns {RecordPlaintext}
|
|
1254
1260
|
*/
|
|
@@ -1280,7 +1286,7 @@ export class RecordPlaintext {
|
|
|
1280
1286
|
* @param {PrivateKey} private_key Private key of the account that owns the record
|
|
1281
1287
|
* @param {string} program_id Program ID of the program that the record is associated with
|
|
1282
1288
|
* @param {string} record_name Name of the record
|
|
1283
|
-
* @returns {string
|
|
1289
|
+
* @returns {string} Serial number of the record
|
|
1284
1290
|
* @param {PrivateKey} private_key
|
|
1285
1291
|
* @param {string} program_id
|
|
1286
1292
|
* @param {string} record_name
|
|
@@ -1344,7 +1350,7 @@ export class Transaction {
|
|
|
1344
1350
|
* Create a transaction from a string
|
|
1345
1351
|
*
|
|
1346
1352
|
* @param {string} transaction String representation of a transaction
|
|
1347
|
-
* @returns {Transaction
|
|
1353
|
+
* @returns {Transaction}
|
|
1348
1354
|
* @param {string} transaction
|
|
1349
1355
|
* @returns {Transaction}
|
|
1350
1356
|
*/
|
|
@@ -1609,7 +1615,7 @@ export class VerifyingKey {
|
|
|
1609
1615
|
* Construct a new verifying key from a byte array
|
|
1610
1616
|
*
|
|
1611
1617
|
* @param {Uint8Array} bytes Byte representation of a verifying key
|
|
1612
|
-
* @returns {VerifyingKey
|
|
1618
|
+
* @returns {VerifyingKey}
|
|
1613
1619
|
* @param {Uint8Array} bytes
|
|
1614
1620
|
* @returns {VerifyingKey}
|
|
1615
1621
|
*/
|
|
@@ -1618,7 +1624,7 @@ export class VerifyingKey {
|
|
|
1618
1624
|
* Create a verifying key from string
|
|
1619
1625
|
*
|
|
1620
1626
|
* @param {String} string String representation of a verifying key
|
|
1621
|
-
* @returns {VerifyingKey
|
|
1627
|
+
* @returns {VerifyingKey}
|
|
1622
1628
|
* @param {string} string
|
|
1623
1629
|
* @returns {VerifyingKey}
|
|
1624
1630
|
*/
|
|
@@ -1626,7 +1632,7 @@ export class VerifyingKey {
|
|
|
1626
1632
|
/**
|
|
1627
1633
|
* Create a byte array from a verifying key
|
|
1628
1634
|
*
|
|
1629
|
-
* @returns {Uint8Array
|
|
1635
|
+
* @returns {Uint8Array} Byte representation of a verifying key
|
|
1630
1636
|
* @returns {Uint8Array}
|
|
1631
1637
|
*/
|
|
1632
1638
|
toBytes(): Uint8Array;
|