diff --git a/.cargo/config b/.cargo/config
index 7c6d59471..f2d74754d 100644
--- a/.cargo/config
+++ b/.cargo/config
@@ -1,2 +1,5 @@
[target.'cfg(not(target_arch = "wasm32"))']
rustflags = ["-C", "target-cpu=native"]
+
+[target.wasm32-unknown-unknown]
+rustflags = ["-C", "link-arg=--max-memory=4294967296"]
\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
index dc4a1d54b..85994e4c9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -88,6 +88,9 @@ dependencies = [
"serde_json",
"snarkvm",
"snarkvm-console",
+ "snarkvm-synthesizer",
+ "snarkvm-utilities",
+ "snarkvm-wasm",
"ureq",
]
@@ -163,11 +166,20 @@ dependencies = [
"console_error_panic_hook",
"getrandom",
"hex",
+ "js-sys",
"rand",
+ "rand_chacha",
+ "rayon",
+ "serde",
+ "serde-wasm-bindgen",
"serde_json",
+ "snarkvm-console",
+ "snarkvm-synthesizer",
"snarkvm-wasm",
"wasm-bindgen",
+ "wasm-bindgen-rayon",
"wasm-bindgen-test",
+ "web-sys",
]
[[package]]
@@ -255,9 +267,9 @@ dependencies = [
[[package]]
name = "blake2s_simd"
-version = "1.0.1"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f"
+checksum = "db539cc2b5f6003621f1cd9ef92d7ded8ea5232c7de0f9faa2de251cd98730d4"
dependencies = [
"arrayref",
"arrayvec",
@@ -393,9 +405,9 @@ dependencies = [
[[package]]
name = "constant_time_eq"
-version = "0.2.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3ad85c1f65dc7b37604eb0e89748faf0b9653065f2a8ef69f96a687ec1e9279"
+checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]]
name = "core-foundation"
@@ -454,9 +466,9 @@ dependencies = [
[[package]]
name = "crossbeam-epoch"
-version = "0.9.13"
+version = "0.9.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a"
+checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695"
dependencies = [
"autocfg",
"cfg-if",
@@ -639,9 +651,9 @@ dependencies = [
[[package]]
name = "fastrand"
-version = "1.9.0"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
+checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
dependencies = [
"instant",
]
@@ -1131,9 +1143,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "memoffset"
-version = "0.7.1"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
+checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1"
dependencies = [
"autocfg",
]
@@ -1171,14 +1183,14 @@ dependencies = [
[[package]]
name = "mio"
-version = "0.8.6"
+version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
+checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
dependencies = [
"libc",
"log",
"wasi",
- "windows-sys 0.45.0",
+ "windows-sys 0.42.0",
]
[[package]]
@@ -1878,18 +1890,29 @@ checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a"
[[package]]
name = "serde"
-version = "1.0.159"
+version = "1.0.160"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065"
+checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c"
dependencies = [
"serde_derive",
]
+[[package]]
+name = "serde-wasm-bindgen"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3b4c031cd0d9014307d82b8abf653c0290fbdaeb4c02d00c63cf52f728628bf"
+dependencies = [
+ "js-sys",
+ "serde",
+ "wasm-bindgen",
+]
+
[[package]]
name = "serde_derive"
-version = "1.0.159"
+version = "1.0.160"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585"
+checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
dependencies = [
"proc-macro2 1.0.54",
"quote 1.0.26",
@@ -1898,9 +1921,9 @@ dependencies = [
[[package]]
name = "serde_json"
-version = "1.0.93"
+version = "1.0.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76"
+checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
dependencies = [
"indexmap",
"itoa",
@@ -1989,14 +2012,13 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "snarkvm"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c5ce5ec3f31d3884ebbe5742ebe4e202e6fde0ba354e018194e0048b97ec2a0"
+version = "0.10.2"
dependencies = [
"anyhow",
"clap",
"colored",
"indexmap",
+ "num-format",
"once_cell",
"parking_lot",
"rand",
@@ -2015,9 +2037,7 @@ dependencies = [
[[package]]
name = "snarkvm-algorithms"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac07aa0f93ba4fec19ad612bc5c545a581e7b9711f4fdb7c60308c65667195a9"
+version = "0.10.2"
dependencies = [
"aleo-std",
"anyhow",
@@ -2038,13 +2058,12 @@ dependencies = [
"snarkvm-r1cs",
"snarkvm-utilities",
"thiserror",
+ "web-sys",
]
[[package]]
name = "snarkvm-circuit"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d081367e4a256b5e41fd5ef7385b9d5c810cd11d4b443c286ebc58273ecf704f"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-account",
"snarkvm-circuit-algorithms",
@@ -2057,9 +2076,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-account"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2983871a63a9b4d866dd820f2eb879b52748b0021fdbcd5be0428d5af86672d1"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-algorithms",
"snarkvm-circuit-network",
@@ -2069,9 +2086,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-algorithms"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fa93fdb148cf64178c6de0d84aa3a1c469d1c4d38cc1990e60b7d3ab7bab5e7"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-types",
"snarkvm-console-algorithms",
@@ -2080,9 +2095,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-collections"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2974cdad52a9520c804912d0f7999c16eac9490ceb4deb718543bdae74d24575"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-algorithms",
"snarkvm-circuit-types",
@@ -2091,9 +2104,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-environment"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "45ae9958c57a53a68326f801e188aa9e2c242f8da639ac62a9d0110ace3cb211"
+version = "0.10.2"
dependencies = [
"indexmap",
"itertools",
@@ -2110,15 +2121,11 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-environment-witness"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05208a9b68281e5647e494953e1f28f46daabef7a8471db4584bcc2eef848933"
+version = "0.10.2"
[[package]]
name = "snarkvm-circuit-network"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fca98609055dadccab650a52924046cbe5023788cde13b4d33718bfc8fb97a7c"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-algorithms",
"snarkvm-circuit-collections",
@@ -2128,9 +2135,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-program"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20e333aa328cb25229a55c63eb643af9cabb6105404d744520db759970c4d176"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-account",
"snarkvm-circuit-collections",
@@ -2142,9 +2147,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03162c34cb55ed61fd0ebbd567ac5c3a679d93436f376ae1a6fd4c009155d440"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-address",
@@ -2158,9 +2161,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-address"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "48e622a535a68fd695f987efd5a01b14c119b964bf7ca20ac4fb1a2b180959c9"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@@ -2172,9 +2173,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-boolean"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b5bf5ad2d81dd9d9248274c0c9c289ada8055198a72f99c527d2d16ba32300cb"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-console-types-boolean",
@@ -2182,9 +2181,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-field"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ce314b46b2785be23853069e6098129d4104846750cf0c9c1d9f473a3cfff78"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@@ -2193,9 +2190,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-group"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8bbbd93fc54085d92f08c2c4c93487f123ed50a063978fe8279a5925e4411f0d"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@@ -2206,9 +2201,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-integers"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22af00a59fc943b1537519ad084eee2328795f1acb18d4257e4c81edca0c1d42"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@@ -2218,9 +2211,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-scalar"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e56d3e76252d21c82c39e82c698a32761f7edd5b67e790977c5de5ec0ddb926c"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@@ -2230,9 +2221,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-string"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ace13b3fb6299f461ccc7129d4733eec712e137aa77089f52b2c0b4890ceb09d"
+version = "0.10.2"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@@ -2243,9 +2232,7 @@ dependencies = [
[[package]]
name = "snarkvm-console"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "99d698128fe3e9ae4bfb1f71603a8e53bcc327a6dc6de5e2fdfc7c14261d0249"
+version = "0.10.2"
dependencies = [
"snarkvm-console-account",
"snarkvm-console-algorithms",
@@ -2257,9 +2244,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-account"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "634c8b94dbb3bd100f84b90301b5daefce190cc30cfed5f564f4b00e488c0a09"
+version = "0.10.2"
dependencies = [
"bs58",
"snarkvm-console-network",
@@ -2268,9 +2253,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-algorithms"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5188f23cdc492d4a303f39bcb43898c9932bd26d6fa64ddee31fdd069f014284"
+version = "0.10.2"
dependencies = [
"blake2s_simd",
"smallvec",
@@ -2281,9 +2264,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-collections"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2a4d074e20484b10a82755429aca879d6887a399b358af3c64fd8fe514bb9062"
+version = "0.10.2"
dependencies = [
"aleo-std",
"rayon",
@@ -2293,9 +2274,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-network"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be3213fa6407162a4280048f6fc5cd3132fe019b384724ef8a0d93c8f4d8e8d9"
+version = "0.10.2"
dependencies = [
"anyhow",
"indexmap",
@@ -2317,9 +2296,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-network-environment"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6fce81ef18f9f8464c576561203b01b2e514613d005bfb5d8eac2dd95f84e6f3"
+version = "0.10.2"
dependencies = [
"anyhow",
"bech32",
@@ -2335,9 +2312,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-program"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "740b0c22ceb96df55c9cc7e85d1431f3da2da6f8ecfa7277b3b2da27d4583703"
+version = "0.10.2"
dependencies = [
"enum_index",
"enum_index_derive",
@@ -2355,9 +2330,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09f9c717deedb471c51eb29b96a898ba9c1b4cc29ef9daacc6549d9ed0c7ef52"
+version = "0.10.2"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-address",
@@ -2371,9 +2344,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-address"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed3a481bcff24c35b14940cb7ca97944f3426bff31e0dd267e95e6af5c63ce75"
+version = "0.10.2"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@@ -2383,18 +2354,14 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-boolean"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f31f22f5cb9f6b2a5a47b7df4e77c8b63f873b52356666a75568908a67346585"
+version = "0.10.2"
dependencies = [
"snarkvm-console-network-environment",
]
[[package]]
name = "snarkvm-console-types-field"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b4d98e0e7afb3deadf3221b3700c0385533b69fc32b2a1ccf7622d6858b1def"
+version = "0.10.2"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@@ -2402,9 +2369,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-group"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d266f6ce35d14946d98e27a5eba6de0bf565626396d161b9e318c46bd4446556"
+version = "0.10.2"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@@ -2414,9 +2379,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-integers"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f95e929a67bb5e0be38fc435acd293f68e539d583f927d4c59f8885a7c0133f"
+version = "0.10.2"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@@ -2425,9 +2388,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-scalar"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9de584696534d3495235aae9dc08bcd416ad526f057f4fb16ac73f7f6a2143dd"
+version = "0.10.2"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@@ -2436,9 +2397,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-string"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bf39608562f0d9f546b3e21957e9e6bdf1652da33ba070a6a89ba800213029bf"
+version = "0.10.2"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@@ -2448,9 +2407,7 @@ dependencies = [
[[package]]
name = "snarkvm-curves"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "15207cc7eab86e4b1b7aed4b20dbaf26f8cbd9918b19dc84ec97652a8aa70d48"
+version = "0.10.2"
dependencies = [
"rand",
"rayon",
@@ -2463,9 +2420,7 @@ dependencies = [
[[package]]
name = "snarkvm-fields"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1d8160d1cd923d81fd9f7c4463a07707ccd4bcd429f9e12459098422cf0812d"
+version = "0.10.2"
dependencies = [
"aleo-std",
"anyhow",
@@ -2481,9 +2436,7 @@ dependencies = [
[[package]]
name = "snarkvm-parameters"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10c030fc55bfce30b7e39ac88f5c5c0214dad03c4de9f079f4a972bc469e1f55"
+version = "0.10.2"
dependencies = [
"aleo-std",
"anyhow",
@@ -2509,9 +2462,7 @@ dependencies = [
[[package]]
name = "snarkvm-r1cs"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6bf45f2a4a7aedc3d6bff6b408db79cdbc9dbfdef9b43d2454ee1bb2cd9a7612"
+version = "0.10.2"
dependencies = [
"anyhow",
"cfg-if",
@@ -2526,12 +2477,11 @@ dependencies = [
[[package]]
name = "snarkvm-synthesizer"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b3314a3e494522e1e0f64d9d5cd05ae1af23c5b4e2d88611780e0783f1b71c38"
+version = "0.10.2"
dependencies = [
"aleo-std",
"anyhow",
+ "bincode",
"blake2",
"colored",
"indexmap",
@@ -2555,9 +2505,7 @@ dependencies = [
[[package]]
name = "snarkvm-utilities"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e34038d6351815ade16f1d7fe6d34fc723b990a9e200ee7dda5c8e3785f914f8"
+version = "0.10.2"
dependencies = [
"aleo-std",
"anyhow",
@@ -2575,9 +2523,7 @@ dependencies = [
[[package]]
name = "snarkvm-utilities-derives"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "541b2488455c3194799b66349714f7891c47d7a7d16413c3b46c0ab280102d4f"
+version = "0.10.2"
dependencies = [
"proc-macro2 1.0.54",
"quote 1.0.26",
@@ -2586,15 +2532,16 @@ dependencies = [
[[package]]
name = "snarkvm-wasm"
-version = "0.9.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07b5da8cad05cc7173de0b32f6acdeacbdd34ff5b1db05dc5b4096583d37c6c3"
+version = "0.10.2"
dependencies = [
"getrandom",
"rand",
"serde",
+ "snarkvm-circuit",
"snarkvm-console",
+ "snarkvm-curves",
"snarkvm-fields",
+ "snarkvm-synthesizer",
"snarkvm-utilities",
"wasm-bindgen",
]
@@ -2615,6 +2562,12 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
+[[package]]
+name = "spmc"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "02a8428da277a8e3a15271d79943e80ccc2ef254e78813a166a08d65e4c3ece5"
+
[[package]]
name = "strsim"
version = "0.10.0"
@@ -2777,9 +2730,9 @@ dependencies = [
[[package]]
name = "tinyvec_macros"
-version = "0.1.1"
+version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
+checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
@@ -2813,9 +2766,9 @@ dependencies = [
[[package]]
name = "tokio-native-tls"
-version = "0.3.1"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
+checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
dependencies = [
"native-tls",
"tokio",
@@ -2846,9 +2799,9 @@ dependencies = [
[[package]]
name = "tokio-util"
-version = "0.7.7"
+version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2"
+checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740"
dependencies = [
"bytes",
"futures-core",
@@ -3199,6 +3152,18 @@ dependencies = [
"wasm-bindgen-shared",
]
+[[package]]
+name = "wasm-bindgen-rayon"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df87c67450805c305d3ae44a3ac537b0253d029153c25afc3ecd2edc36ccafb1"
+dependencies = [
+ "js-sys",
+ "rayon",
+ "spmc",
+ "wasm-bindgen",
+]
+
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.84"
diff --git a/Cargo.toml b/Cargo.toml
index d5f8fbb6e..e19331e5b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,14 +26,21 @@ path = "rust"
default-features = false
[workspace.dependencies.snarkvm]
-version = "0.9.16"
+version = "0.10.2"
+path="../snarkVM"
[workspace.dependencies.snarkvm-console]
-version = "0.9.16"
+version = "0.10.2"
+path="../snarkVM/console"
[workspace.dependencies.snarkvm-wasm]
-version = "0.9.16"
+version = "0.10.2"
default-features = false
+path="../snarkVM/wasm"
+
+[workspace.dependencies.snarkvm-synthesizer]
+path="../snarkVM/synthesizer"
+version = "0.10.2"
[lib]
path = "cli/lib.rs"
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index bbfec06b9..eacb07cbb 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -49,11 +49,29 @@ version = "2.6.2"
version = "1.0.91"
[dependencies.snarkvm]
+version = "0.10.2"
+path="../../snarkVM"
+optional=true
+
+[dependencies.snarkvm-wasm]
+version = "0.10.2"
+path="../../snarkVM/wasm"
+
+[dependencies.snarkvm-utilities]
+version = "0.10.2"
+path="../../snarkVM/utilities"
+
+[dependencies.snarkvm-synthesizer]
+version = "0.10.2"
+path = "../../snarkVM/synthesizer"
+default-features = false
+features = [ "wasm" ]
optional = true
-workspace = true
[dependencies.snarkvm-console]
-workspace = true
+path = "../../snarkVM/console"
+default-features = false
+version = "0.10.2"
[dev-dependencies.bencher]
version = "0.1.5"
diff --git a/rust/src/api/asynchronous.rs b/rust/src/api/asynchronous.rs
new file mode 100644
index 000000000..719fe35c8
--- /dev/null
+++ b/rust/src/api/asynchronous.rs
@@ -0,0 +1,127 @@
+// Copyright (C) 2019-2023 Aleo Systems Inc.
+// This file is part of the Aleo library.
+
+// The Aleo library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// The Aleo library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with the Aleo library. If not, see .
+
+use crate::AleoAPIClient;
+
+use anyhow::{anyhow, bail, Result};
+use snarkvm_console::{
+ program::{Network, ProgramID},
+ types::Field,
+};
+use snarkvm_synthesizer::{Block, Program, Transaction};
+use std::convert::TryInto;
+
+impl AleoAPIClient {
+ pub async fn latest_height(&self) -> Result {
+ let url = format!("{}/{}/latest/height", self.base_url, self.chain);
+ match self.client.get(url).send().await?.json().await {
+ Ok(height) => Ok(height),
+ Err(error) => bail!("Failed to parse the latest block height: {error}"),
+ }
+ }
+
+ pub async fn latest_hash(&self) -> Result {
+ let url = format!("{}/{}/latest/hash", self.base_url, self.chain);
+ match self.client.get(url).send().await?.json().await {
+ Ok(hash) => Ok(hash),
+ Err(error) => bail!("Failed to parse the latest block hash: {error}"),
+ }
+ }
+
+ pub async fn latest_block(&self) -> Result> {
+ let url = format!("{}/{}/latest/block", self.base_url, self.chain);
+ match self.client.get(url).send().await?.json().await {
+ Ok(block) => Ok(block),
+ Err(error) => bail!("Failed to parse the latest block: {error}"),
+ }
+ }
+
+ pub async fn get_block(&self, height: u32) -> Result> {
+ let url = format!("{}/{}/block/{height}", self.base_url, self.chain);
+ match self.client.get(url).send().await?.json().await {
+ Ok(block) => Ok(block),
+ Err(error) => bail!("Failed to parse block {height}: {error}"),
+ }
+ }
+
+ pub async fn get_blocks(&self, start_height: u32, end_height: u32) -> Result>> {
+ if start_height >= end_height {
+ bail!("Start height must be less than end height");
+ } else if end_height - start_height > 50 {
+ bail!("Cannot request more than 50 blocks at a time");
+ }
+
+ let url = format!("{}/{}/blocks?start={start_height}&end={end_height}", self.base_url, self.chain);
+ match self.client.get(url).send().await?.json().await {
+ Ok(blocks) => Ok(blocks),
+ Err(error) => {
+ bail!("Failed to parse blocks {start_height} (inclusive) to {end_height} (exclusive): {error}")
+ }
+ }
+ }
+
+ pub async fn get_transaction(&self, transaction_id: N::TransactionID) -> Result> {
+ let url = format!("{}/{}/transaction/{transaction_id}", self.base_url, self.chain);
+ match self.client.get(url).send().await?.json().await {
+ Ok(transaction) => Ok(transaction),
+ Err(error) => bail!("Failed to parse transaction '{transaction_id}': {error}"),
+ }
+ }
+
+ pub async fn get_memory_pool_transactions(&self) -> Result>> {
+ let url = format!("{}/{}/memoryPool/transactions", self.base_url, self.chain);
+ match self.client.get(url).send().await?.json().await {
+ Ok(transactions) => Ok(transactions),
+ Err(error) => bail!("Failed to parse memory pool transactions: {error}"),
+ }
+ }
+
+ pub async fn get_program(&self, program_id: impl TryInto>) -> Result> {
+ // Prepare the program ID.
+ let program_id = program_id.try_into().map_err(|_| anyhow!("Invalid program ID"))?;
+ // Perform the request.
+ let url = format!("{}/{}/program/{program_id}", self.base_url, self.chain);
+ match self.client.get(url).send().await?.json().await {
+ Ok(program) => Ok(program),
+ Err(error) => bail!("Failed to parse program {program_id}: {error}"),
+ }
+ }
+
+ pub async fn find_block_hash(&self, transaction_id: N::TransactionID) -> Result {
+ let url = format!("{}/{}/find/blockHash/{transaction_id}", self.base_url, self.chain);
+ match self.client.get(url).send().await?.json().await {
+ Ok(hash) => Ok(hash),
+ Err(error) => bail!("Failed to parse block hash: {error}"),
+ }
+ }
+
+ /// Returns the transition ID that contains the given `input ID` or `output ID`.
+ pub async fn find_transition_id(&self, input_or_output_id: Field) -> Result {
+ let url = format!("{}/{}/find/transitionID/{input_or_output_id}", self.base_url, self.chain);
+ match self.client.get(url).send().await?.json().await {
+ Ok(transition_id) => Ok(transition_id),
+ Err(error) => bail!("Failed to parse transition ID: {error}"),
+ }
+ }
+
+ pub async fn transaction_broadcast(&self, transaction: Transaction) -> Result> {
+ let url = format!("{}/{}/transaction/broadcast", self.base_url, self.chain);
+ match self.client.post(url).body(serde_json::to_string(&transaction)?).send().await?.json().await {
+ Ok(block) => Ok(block),
+ Err(error) => bail!("Failed to parse memory pool transactions: {error}"),
+ }
+ }
+}
diff --git a/sdk/jestconfig.json b/sdk/jestconfig.json
new file mode 100644
index 000000000..20c25c0f7
--- /dev/null
+++ b/sdk/jestconfig.json
@@ -0,0 +1,7 @@
+{
+ "transform": {
+ "^.+\\.(t|j)sx?$": "ts-jest"
+ },
+ "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
+ "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
+}
diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml
index 2f1daecb8..a82dff649 100644
--- a/wasm/Cargo.toml
+++ b/wasm/Cargo.toml
@@ -20,9 +20,22 @@ edition = "2021"
[lib]
crate-type = [ "cdylib", "rlib" ]
+[features]
+default = [
+ "snarkvm-synthesizer/serial",
+ "snarkvm-console/serial",
+ "snarkvm-wasm/serial",
+]
+frontend-parallel = [
+ "wasm-bindgen-rayon",
+ "snarkvm-synthesizer/web",
+]
+
[dependencies.aleo-rust]
+version = "0.3.4"
+path = "../rust"
features = [ "wasm" ]
-workspace = true
+default-features = false
[dependencies.anyhow]
version = "1.0"
@@ -39,17 +52,65 @@ version = "0.8"
[dependencies.serde_json]
version = "1.0"
+features = [ "preserve_order" ]
+
+[dependencies.snarkvm-synthesizer]
+path="../../snarkVM/synthesizer"
+version = "0.10.2"
+default-features = false
+features = [ "wasm" ]
+
+[dependencies.snarkvm-console]
+path="../../snarkVM/console"
+version = "0.10.2"
+default-features = false
+features = [ ]
[dependencies.snarkvm-wasm]
-workspace = true
-features = [ "console", "fields", "utilities" ]
+path="../../snarkVM/wasm"
+version = "0.10.2"
[dependencies.wasm-bindgen]
version = "0.2"
features = [ "serde-serialize" ]
+[dependencies.js-sys]
+version = "0.3"
+
+[dependencies.web-sys]
+version = "0.3"
+features = ["console"]
+
+[dependencies.serde]
+version = "1.0"
+features = ["derive"]
+
+[dependencies.serde-wasm-bindgen]
+version = "0.4"
+
[dependencies.console_error_panic_hook]
version = "0.1.7"
+[dependencies.rand_chacha]
+version = "0.3.1"
+
+[dependencies.wasm-bindgen-rayon]
+version = "1.0"
+optional = true
+
+[dependencies.rayon]
+version = "1.5"
+optional = true
+
[dev-dependencies.wasm-bindgen-test]
version = "0.3.33"
+
+[profile.release]
+opt-level = 3
+lto = true
+
+[package.metadata.wasm-pack.profile.debug]
+wasm-opt = ["-O4"]
+
+[package.metadata.wasm-pack.profile.release]
+wasm-opt = ["-O4"]
\ No newline at end of file
diff --git a/wasm/rust-toolchain b/wasm/rust-toolchain
new file mode 100644
index 000000000..467f338ce
--- /dev/null
+++ b/wasm/rust-toolchain
@@ -0,0 +1 @@
+nightly-2022-12-12
\ No newline at end of file
diff --git a/wasm/src/account/view_key.rs b/wasm/src/account/view_key.rs
index 31f622711..bc9a42fb8 100644
--- a/wasm/src/account/view_key.rs
+++ b/wasm/src/account/view_key.rs
@@ -80,21 +80,15 @@ mod tests {
use wasm_bindgen_test::*;
- const OWNER_PLAINTEXT: &str = r"{
- owner: aleo1y50whk20gjtltkte2qcqz9dd6uaet8thhlj3t8utewp0j3hhmg8qae7s5a.public,
- gates: 1159017656332810u64.public,
- a: 6875465154712544327395236939215127424077297244802949502285127742492653680374field.private,
- b: 603076889203566020456049671526074557206943911693533670547825725507132399266scalar.private,
- _nonce: 1635890755607797813652478911794003479783620859881520791852904112255813473142group.public
-}";
- const OWNER_CIPHERTEXT: &str = "record1qqj3a67efazf0awe09grqqg44htnh9vaw7l729vl309c972x7ldquqq2k2cax8s7qsqqyqtpgvqqyqsq4seyrzvfa98fkggzccqr68af8e9m0q8rzeqh8a8aqql3a854v58sgrygdv4jn9s8ckwfd48vujrmv0rtfasqh8ygn88ch34ftck8szspvfpsqqszqzvxx9t8s9g66teeepgxmvnw5ymgapcwt2lpy9d5eus580k08wpq544jcl437wjv206u5pxst6few9ll4yhufwldgpx80rlwq8nhssqywmfsd85skg564vqhm3gxsp8q6r30udmqxrxmxx2v8xycdg8pn5ps3dhfvv";
- const OWNER_VIEW_KEY: &str = "AViewKey1ghtvuJQQzQ31xSiVh6X1PK8biEVhQBygRGV4KdYmq4JT";
+ const OWNER_PLAINTEXT: &str = "{\n owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private,\n microcredits: 374999900000000u64.private,\n _nonce: 2740969152411805314773998757266754905498340517856884701781803565459552168415group.public\n}";
+ const OWNER_CIPHERTEXT: &str = "record1qyqspsy0qghu8wqmf8wq2w4ccqqg8zsgxc3ge2znf4uklh8tutq2swgqqyxx66trwfhkxun9v35hguerqqpqzq9c6u30j7srax79wdvdqt2ytpne4vyvae6z9fq85rs09nj2f72uqm0kn9tx5t3znnj7hrqffzdcquacgyrqdfuuum2km7wvxcmy258svvkjzsh";
+ const OWNER_VIEW_KEY: &str = "AViewKey1mSnpFFC8Mj4fXbK5YiWgZ3mjiV8CxA79bYNa8ymUpTrw";
const NON_OWNER_VIEW_KEY: &str = "AViewKey1e2WyreaH5H4RBcioLL2GnxvHk5Ud46EtwycnhTdXLmXp";
#[wasm_bindgen_test]
pub fn test_from_private_key() {
- let given_private_key = "APrivateKey1zkp4RyQ8Utj7aRcJgPQGEok8RMzWwUZzBhhgX6rhmBT8dcP";
- let given_view_key = "AViewKey1i3fn5SECcVBtQMCVtTPSvdApoMYmg3ToJfNDfgHJAuoD";
+ let given_private_key = "APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH";
+ let given_view_key = "AViewKey1mSnpFFC8Mj4fXbK5YiWgZ3mjiV8CxA79bYNa8ymUpTrw";
let private_key = PrivateKey::from_string(given_private_key).unwrap();
let view_key = ViewKey::from_private_key(&private_key);
assert_eq!(given_view_key, view_key.to_string());
diff --git a/wasm/src/lib.rs b/wasm/src/lib.rs
index 762d731eb..46981a1ad 100644
--- a/wasm/src/lib.rs
+++ b/wasm/src/lib.rs
@@ -20,4 +20,10 @@ pub use account::*;
pub mod record;
pub use record::*;
+pub mod program;
+pub use program::*;
+
pub(crate) mod types;
+
+#[cfg(feature = "frontend-parallel")]
+pub use wasm_bindgen_rayon::init_thread_pool;
\ No newline at end of file
diff --git a/wasm/src/program/decrypt.rs b/wasm/src/program/decrypt.rs
new file mode 100644
index 000000000..bc351fe0b
--- /dev/null
+++ b/wasm/src/program/decrypt.rs
@@ -0,0 +1,302 @@
+// Copyright (C) 2019-2023 Aleo Systems Inc.
+// This file is part of the Aleo library.
+
+// The Aleo library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// The Aleo library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with the Aleo library. If not, see .
+
+use std::str::FromStr;
+
+use crate::{
+ account::ViewKey,
+ types::{
+ TransitionNative,
+ CurrentNetwork, ProgramIDNative, CiphertextNative, IdentifierNative
+ }
+};
+use snarkvm_console::{prelude::Network, types::{U16, Field, Group}, program::ToBits};
+use snarkvm_synthesizer::{Input, Output};
+
+use wasm_bindgen::prelude::*;
+
+#[wasm_bindgen]
+pub struct DecryptTransition {}
+
+#[wasm_bindgen]
+impl DecryptTransition {
+ pub fn owns_transition(
+ view_key: ViewKey,
+ tpk_str: &str,
+ tcm_str: &str,
+ ) -> Result {
+ console_error_panic_hook::set_once();
+
+ let tpk = Group::::from_str(tpk_str)
+ .map_err(|_| "Could not deserialize transition public key".to_string())?;
+
+ let tcm = Field::::from_str(tcm_str)
+ .map_err(|_| "Could not deserialize transition commitment".to_string())?;
+
+ let scalar = *view_key;
+ let tvk = (tpk * *scalar).to_x_coordinate();
+
+ let tcm_derived = CurrentNetwork::hash_psd2(&[tvk])
+ .map_err(|_| "Could not deserialize transition".to_string())?;
+
+ return Ok(tcm == tcm_derived);
+ }
+
+ pub fn decrypt_ciphertext(
+ view_key: ViewKey,
+ ciphertext_str: &str,
+ tpk_str: &str,
+ program_id: &str,
+ function_name_str: &str,
+ index: usize,
+ ) -> Result {
+ console_error_panic_hook::set_once();
+
+ let tpk = Group::::from_str(tpk_str)
+ .map_err(|_| "Could not deserialize transition public key".to_string())?;
+
+ let program_id = ProgramIDNative::from_str(program_id)
+ .map_err(|_| "Could not deserialize program id".to_string())?;
+
+ let function_name = IdentifierNative::from_str(function_name_str)
+ .map_err(|_| "Could not deserialize function name".to_string())?;
+
+ let scalar = *view_key;
+ let tvk = (tpk * *scalar).to_x_coordinate();
+
+ let function_id = CurrentNetwork::hash_bhp1024(
+ &(U16::::new(CurrentNetwork::ID), program_id.name(), program_id.network(), function_name).to_bits_le(),
+ ).map_err(|_| "Could not create function id".to_string())?;
+
+ let index_field = Field::from_u16(u16::try_from(index).unwrap());
+ let ciphertext_view_key = CurrentNetwork::hash_psd4(&[function_id, tvk, index_field])
+ .map_err(|_| "Could not create ciphertext view key".to_string())?;
+
+ let ciphertext = CiphertextNative::from_str(ciphertext_str)
+ .map_err(|_| "Could not deserialize ciphertext".to_string())?;
+
+ let plaintext = ciphertext.decrypt_symmetric(ciphertext_view_key)
+ .map_err(|_| "Could not decrypt ciphertext".to_string())?;
+
+ Ok(plaintext.to_string())
+ }
+
+ pub fn decrypt_transition(
+ view_key: ViewKey,
+ transition_str: &str
+ ) -> Result {
+ console_error_panic_hook::set_once();
+
+ let transition: TransitionNative = serde_json::from_str(transition_str)
+ .map_err(|_| "Could not deserialize transition".to_string())?;
+
+ let scalar = *view_key;
+ let tvk = (*transition.tpk() * *scalar).to_x_coordinate();
+
+ let function_id = CurrentNetwork::hash_bhp1024(
+ &(U16::::new(CurrentNetwork::ID), transition.program_id().name(), transition.program_id().network(), transition.function_name()).to_bits_le(),
+ ).map_err(|_| "Could not create function id".to_string())?;
+
+ let mut decrypted_inputs: Vec> = vec![];
+ let mut decrypted_outputs: Vec