diff --git a/Cargo.lock b/Cargo.lock index b2a791d4c9..81d80c7a70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96e669320c520d87931e752d603dd442b4709c73b1b8b1fcba838f9c5acc1791" dependencies = [ "abnf-core", - "nom 6.1.2", + "nom", ] [[package]] @@ -18,7 +18,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b514944cb7199c4201f54406bc58676a3e4f37d40bf8e3dbe30652ca82e3ddb4" dependencies = [ - "nom 6.1.2", + "nom", ] [[package]] @@ -83,9 +83,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "assert_cmd" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2475b58cd94eb4f70159f4fd8844ba3b807532fe3131b3373fae060bbe30396" +checksum = "8f57fec1ac7e4de72dcc69811795f1a7172ed06012f80a5d1ee651b62484f588" dependencies = [ "bstr", "doc-comment", @@ -140,9 +140,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bech32" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58946044516aa9dc922182e0d6e9d124a31aafe6b421614654eb27cf90cec09c" +checksum = "6c7f7096bc256f5e5cb960f60dfc4f4ef979ca65abe7fb9d5a4f77150d3783d4" [[package]] name = "bincode" @@ -153,30 +153,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bindgen" -version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c0bb6167449588ff70803f4127f0684f9063097eca5016f37eb52b92c2cf36" -dependencies = [ - "bitflags", - "cexpr", - "cfg-if 0.1.10", - "clang-sys", - "clap", - "env_logger", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "proc-macro2 1.0.24", - "quote 1.0.9", - "regex", - "rustc-hash", - "shlex", - "which", -] - [[package]] name = "bitflags" version = "1.2.1" @@ -307,18 +283,6 @@ name = "cc" version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" -dependencies = [ - "jobserver", -] - -[[package]] -name = "cexpr" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" -dependencies = [ - "nom 5.1.2", -] [[package]] name = "cfg-if" @@ -355,17 +319,6 @@ dependencies = [ "envmnt", ] -[[package]] -name = "clang-sys" -version = "0.29.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "2.33.3" @@ -425,9 +378,12 @@ checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" [[package]] name = "cpufeatures" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cd5a7748210e7ec1a9696610b1015e6e31fbf58f77a160801f124bd1c36592a" +checksum = "dec1028182c380cc45a2e2c5ec841134f2dfd0f8f5f0a5bcd68004f81b5efdf4" +dependencies = [ + "libc", +] [[package]] name = "crc32fast" @@ -551,36 +507,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "curl" -version = "0.4.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a872858e9cb9e3b96c80dd78774ad9e32e44d3b05dc31e142b858d14aebc82c" -dependencies = [ - "curl-sys", - "libc", - "openssl-probe", - "openssl-sys", - "schannel", - "socket2", - "winapi 0.3.9", -] - -[[package]] -name = "curl-sys" -version = "0.4.41+curl-7.75.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ec466abd277c7cab2905948f3e94d10bc4963f1f5d47921c1cc4ffd2028fe65" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", - "winapi 0.3.9", -] - [[package]] name = "derivative" version = "2.2.0" @@ -669,19 +595,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "envmnt" version = "0.8.4" @@ -955,12 +868,6 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - [[package]] name = "h2" version = "0.3.0" @@ -1050,15 +957,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hyper" version = "0.14.4" @@ -1150,15 +1048,6 @@ dependencies = [ "libc", ] -[[package]] -name = "instant" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" -dependencies = [ - "cfg-if 1.0.0", -] - [[package]] name = "iovec" version = "0.1.4" @@ -1207,15 +1096,6 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" -[[package]] -name = "jobserver" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.47" @@ -1444,7 +1324,6 @@ dependencies = [ "snarkvm-algorithms", "snarkvm-curves", "snarkvm-dpc", - "snarkvm-storage", "snarkvm-utilities", "thiserror", ] @@ -1492,55 +1371,12 @@ version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "538c092e5586f4cdd7dd8078c4a79220e3e168880218124dcbce860f0ea938c6" -[[package]] -name = "libloading" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -dependencies = [ - "cc", - "winapi 0.3.9", -] - -[[package]] -name = "librocksdb-sys" -version = "6.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b56f651c204634b936be2f92dbb42c36867e00ff7fe2405591f3b9fa66f09" -dependencies = [ - "bindgen", - "cc", - "glob", - "libc", -] - -[[package]] -name = "libz-sys" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linked-hash-map" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" -[[package]] -name = "lock_api" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" -dependencies = [ - "scopeguard", -] - [[package]] name = "log" version = "0.4.14" @@ -1734,16 +1570,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab250442c86f1850815b5d268639dff018c0627022bc1940eb2d642ca1ce12f0" -[[package]] -name = "nom" -version = "5.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" -dependencies = [ - "memchr", - "version_check", -] - [[package]] name = "nom" version = "6.1.2" @@ -1759,9 +1585,9 @@ dependencies = [ [[package]] name = "notify" -version = "4.0.16" +version = "4.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2599080e87c9bd051ddb11b10074f4da7b1223298df65d4c2ec5bcf309af1533" +checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257" dependencies = [ "bitflags", "filetime", @@ -1893,37 +1719,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "parking_lot" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" -dependencies = [ - "cfg-if 1.0.0", - "instant", - "libc", - "redox_syscall", - "smallvec", - "winapi 0.3.9", -] - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "percent-encoding" version = "2.1.0" @@ -2135,12 +1930,6 @@ dependencies = [ "unicode-xid 0.2.1", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quick-xml" version = "0.20.0" @@ -2380,28 +2169,12 @@ dependencies = [ "winreg", ] -[[package]] -name = "rocksdb" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d83c02c429044d58474eaf5ae31e062d0de894e21125b47437ec0edc1397e6" -dependencies = [ - "libc", - "librocksdb-sys", -] - [[package]] name = "rustc-demangle" version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc_version" version = "0.2.3" @@ -2539,9 +2312,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.125" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" dependencies = [ "serde_derive", ] @@ -2558,9 +2331,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.125" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.9", @@ -2616,9 +2389,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f6b75b17576b792bef0db1bcc4b8b8bcdf9506744cf34b974195487af6cff2" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", @@ -2636,12 +2409,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shlex" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" - [[package]] name = "single" version = "1.0.0" @@ -2665,9 +2432,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "snarkvm-algorithms" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf8ca73d429824090b96f751846e37e539f24c527f1f1ce0254984ade6d17b2" +checksum = "99f8349fad4f4e9a05ab4fde6baa99aad8542fcaf10320128114fdc26798a0ad" dependencies = [ "blake2", "derivative", @@ -2688,9 +2455,9 @@ dependencies = [ [[package]] name = "snarkvm-curves" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64610b135b8b1152439d5dfa4f745515933366082f08651961344aa0bb5abfca" +checksum = "3a8f71e6243e588507a7935512bcd79e28906ad89553671151eaf721e42b1513" dependencies = [ "derivative", "rand 0.8.3", @@ -2704,9 +2471,9 @@ dependencies = [ [[package]] name = "snarkvm-derives" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c9829b6e2023b4c7c4d6c55e88fe755dd997171a6c9c063b75c28161d04326" +checksum = "d1b3ad83bcd981531a29e8e70bac4cf34126b1031f42bc529975a46e49100383" dependencies = [ "proc-macro-crate", "proc-macro-error", @@ -2717,9 +2484,9 @@ dependencies = [ [[package]] name = "snarkvm-dpc" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "491ae936e24e17c358d112ff8638b260500b5a982ecefc804861e28b5279f552" +checksum = "54268e972e18e7a1508418f29fe3f64201f86acf2131ed28b1bc9f8891fc1bbb" dependencies = [ "anyhow", "base58", @@ -2743,9 +2510,9 @@ dependencies = [ [[package]] name = "snarkvm-fields" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c49c69d02df11be58e07f626c9d6f5804c6dd4ccf42e425f2be8d79fe6e5bb7" +checksum = "04b885226e300d6a237905038fba681eaa2a851e5cb45a22b685c0bc87c574b6" dependencies = [ "bincode", "derivative", @@ -2758,9 +2525,9 @@ dependencies = [ [[package]] name = "snarkvm-gadgets" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6f9ac2a166d926e1755a06fdae21ce40ce6164c75c89120401b8d78f3b7ba4" +checksum = "0322e4fd5fe0b0b7499a6b1dbd47d20cf65e0904a23094ba087662253ed60ff0" dependencies = [ "derivative", "digest 0.9.0", @@ -2775,9 +2542,9 @@ dependencies = [ [[package]] name = "snarkvm-objects" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd9779ec6ab9211f34a6ba25566feb575a396f4c41cc0e002ec2d48d7560a2a" +checksum = "345b2dd86a3d036d09608e7493c7a14bf17a59648e567cd08414d2520a627d07" dependencies = [ "anyhow", "bincode", @@ -2796,11 +2563,10 @@ dependencies = [ [[package]] name = "snarkvm-parameters" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98378f612206fc7dd44a26f4e345bd1f3ba51bd325acad1e5cc3785d14750ec5" +checksum = "7932c7d7fd7b9572a1acaad3c9622f6849c414e5ac8bdb599a504ef4330bb857" dependencies = [ - "curl", "hex", "snarkvm-algorithms", "snarkvm-utilities", @@ -2809,15 +2575,15 @@ dependencies = [ [[package]] name = "snarkvm-profiler" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2460ac01c25f79f5ea306e4de82a1d4105e811f868206b4fd31c0c9b62a3d7b" +checksum = "877f7ee215903aa4da2343f6d82fd5ec7426210a33f4773770ab35dbdddd3bd9" [[package]] name = "snarkvm-r1cs" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3a0d54b15802976aff7522765dd29d5733f338612449629cc57c5a4a4d51f05" +checksum = "f5695a57009b1b79f32df22d88f5d5dabf7a84f6a953280896ae4edb8b9db76d" dependencies = [ "cfg-if 1.0.0", "fxhash", @@ -2828,32 +2594,11 @@ dependencies = [ "snarkvm-utilities", ] -[[package]] -name = "snarkvm-storage" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d76881939f008d7bba4c8cc4118d29567b5c71908ad66bef9880f8aa7c52881" -dependencies = [ - "anyhow", - "bincode", - "hex", - "parking_lot", - "rand 0.8.3", - "rocksdb", - "serde", - "snarkvm-algorithms", - "snarkvm-dpc", - "snarkvm-objects", - "snarkvm-parameters", - "snarkvm-utilities", - "thiserror", -] - [[package]] name = "snarkvm-utilities" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c763843fa67a3aa4ce68173c8cd96b4f04aaa135a5792bc051c36eec0fe1cd73" +checksum = "996ba23293c9288d983003c224450db8a6acd875f9fe7f6d839ab91897023b5b" dependencies = [ "bincode", "rand 0.8.3", @@ -2979,15 +2724,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "termcolor" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" -dependencies = [ - "winapi-util", -] - [[package]] name = "terminal_size" version = "0.1.16" @@ -3462,15 +3198,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "which" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" -dependencies = [ - "libc", -] - [[package]] name = "winapi" version = "0.2.8" diff --git a/Cargo.toml b/Cargo.toml index 7f07b95181..c58bb03efb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,22 +70,22 @@ path = "./synthesizer" version = "1.4.0" [dependencies.snarkvm-algorithms] -version = "0.2.2" +version = "0.3.1" [dependencies.snarkvm-curves] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-gadgets] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-r1cs] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-utilities] -version = "0.2.2" +version = "0.3.1" [dependencies.anyhow] version = "1.0" @@ -112,7 +112,7 @@ version = "0.3.1" version = "1.4.0" [dependencies.notify] -version = "4.0.16" +version = "4.0.17" [dependencies.rand] version = "0.8" @@ -158,7 +158,7 @@ version = "0.12.1" version = "0.11.2" [dev-dependencies.assert_cmd] -version = "1.0.3" +version = "1.0.4" [dev-dependencies.test_dir] version = "0.1.0" diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index 9ddc4fa28c..a2d7e8824a 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -57,27 +57,27 @@ version = "1.4.0" version = "0.4" [dependencies.snarkvm-curves] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-fields] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-dpc] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-gadgets] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-r1cs] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-utilities] -version = "0.2.2" +version = "0.3.1" [dependencies.bincode] version = "1.3" @@ -118,7 +118,7 @@ version = "0.3" default-features = false [dev-dependencies.snarkvm-algorithms] -version = "0.2.2" +version = "0.3.1" default-features = false [dev-dependencies.tempfile] diff --git a/compiler/src/expression/expression.rs b/compiler/src/expression/expression.rs index 6eb48fb9be..2d441ef15a 100644 --- a/compiler/src/expression/expression.rs +++ b/compiler/src/expression/expression.rs @@ -44,9 +44,9 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { ConstValue::Address(value) => ConstrainedValue::Address(Address::constant(value.to_string(), span)?), ConstValue::Boolean(value) => ConstrainedValue::Boolean(Boolean::Constant(*value)), ConstValue::Char(value) => { - ConstrainedValue::Char(Char::constant(*value, format!("{}", *value as u32), span)?) + ConstrainedValue::Char(Char::constant(cs, *value, format!("{}", *value as u32), span)?) } - ConstValue::Field(value) => ConstrainedValue::Field(FieldType::constant(value.to_string(), span)?), + ConstValue::Field(value) => ConstrainedValue::Field(FieldType::constant(cs, value.to_string(), span)?), ConstValue::Group(value) => ConstrainedValue::Group(G::constant(value, span)?), ConstValue::Int(value) => ConstrainedValue::Integer(Integer::new(value)), ConstValue::Tuple(values) => ConstrainedValue::Tuple( diff --git a/compiler/src/expression/relational/eq.rs b/compiler/src/expression/relational/eq.rs index 8c4661bf17..1db313a516 100644 --- a/compiler/src/expression/relational/eq.rs +++ b/compiler/src/expression/relational/eq.rs @@ -39,6 +39,10 @@ pub fn evaluate_eq<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( let unique_namespace = cs.ns(|| namespace_string); bool_1.evaluate_equal(unique_namespace, &bool_2) } + (ConstrainedValue::Char(char_1), ConstrainedValue::Char(char_2)) => { + let unique_namespace = cs.ns(|| namespace_string); + char_1.evaluate_equal(unique_namespace, &char_2) + } (ConstrainedValue::Integer(num_1), ConstrainedValue::Integer(num_2)) => { let unique_namespace = cs.ns(|| namespace_string); num_1.evaluate_equal(unique_namespace, &num_2) diff --git a/compiler/src/function/input/main_function_input.rs b/compiler/src/function/input/main_function_input.rs index 1e27a4057c..13ce4b9e5a 100644 --- a/compiler/src/function/input/main_function_input.rs +++ b/compiler/src/function/input/main_function_input.rs @@ -72,7 +72,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { pub fn constant_main_function_input>( &mut self, - _cs: &mut CS, + cs: &mut CS, type_: &Type, name: &str, input_option: Option, @@ -84,11 +84,14 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { (Type::Address, InputValue::Address(addr)) => Ok(ConstrainedValue::Address(Address::constant(addr, span)?)), (Type::Boolean, InputValue::Boolean(value)) => Ok(ConstrainedValue::Boolean(Boolean::constant(value))), (Type::Char, InputValue::Char(character)) => Ok(ConstrainedValue::Char(Char::constant( + cs, character, format!("{}", character as u32), span, )?)), - (Type::Field, InputValue::Field(value)) => Ok(ConstrainedValue::Field(FieldType::constant(value, span)?)), + (Type::Field, InputValue::Field(value)) => { + Ok(ConstrainedValue::Field(FieldType::constant(cs, value, span)?)) + } (Type::Group, InputValue::Group(value)) => Ok(ConstrainedValue::Group(G::constant(&value.into(), span)?)), (Type::Integer(integer_type), InputValue::Integer(_, value)) => Ok(ConstrainedValue::Integer( Integer::new(&ConstInt::parse(integer_type, &value, span)?), @@ -105,7 +108,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { Ok(ConstrainedValue::Array( values .iter() - .map(|x| self.constant_main_function_input(_cs, type_, name, Some(x.clone()), span)) + .map(|x| self.constant_main_function_input(cs, type_, name, Some(x.clone()), span)) .collect::, _>>()?, )) } @@ -119,7 +122,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { .iter() .enumerate() .map(|(i, x)| { - self.constant_main_function_input(_cs, types.get(i).unwrap(), name, Some(x.clone()), span) + self.constant_main_function_input(cs, types.get(i).unwrap(), name, Some(x.clone()), span) }) .collect::, _>>()?, )) diff --git a/compiler/src/value/char/char.rs b/compiler/src/value/char/char.rs index d6696a6928..11eade5c91 100644 --- a/compiler/src/value/char/char.rs +++ b/compiler/src/value/char/char.rs @@ -23,24 +23,117 @@ use crate::{ use leo_ast::{InputValue, Span}; use snarkvm_fields::PrimeField; -use snarkvm_r1cs::ConstraintSystem; +use snarkvm_gadgets::utilities::{ + bits::comparator::{ComparatorGadget, EvaluateLtGadget}, + boolean::Boolean, + eq::{ConditionalEqGadget, EqGadget, EvaluateEqGadget, NEqGadget}, + select::CondSelectGadget, +}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; /// A char -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug)] pub struct Char { pub character: char, pub field: FieldType, } impl Char { - pub fn constant(character: char, field: String, span: &Span) -> Result { + pub fn constant>( + cs: CS, + character: char, + field: String, + span: &Span, + ) -> Result { Ok(Self { character, - field: FieldType::constant(field, span)?, + field: FieldType::constant(cs, field, span)?, }) } } +impl PartialEq for Char { + fn eq(&self, other: &Self) -> bool { + self.field.eq(&other.field) + } +} + +impl Eq for Char {} + +impl PartialOrd for Char { + fn partial_cmp(&self, other: &Self) -> Option { + self.field.partial_cmp(&other.field) + } +} + +impl EvaluateLtGadget for Char { + fn less_than>(&self, cs: CS, other: &Self) -> Result { + self.field.less_than(cs, &other.field) + } +} + +impl ComparatorGadget for Char {} + +impl EvaluateEqGadget for Char { + fn evaluate_equal>(&self, cs: CS, other: &Self) -> Result { + self.field.evaluate_equal(cs, &other.field) + } +} + +impl EqGadget for Char {} + +impl ConditionalEqGadget for Char { + fn conditional_enforce_equal>( + &self, + cs: CS, + other: &Self, + condition: &Boolean, + ) -> Result<(), SynthesisError> { + self.field.conditional_enforce_equal(cs, &other.field, condition) + } + + fn cost() -> usize { + as ConditionalEqGadget>::cost() + } +} + +impl NEqGadget for Char { + fn enforce_not_equal>(&self, cs: CS, other: &Self) -> Result<(), SynthesisError> { + self.field.enforce_not_equal(cs, &other.field) + } + + fn cost() -> usize { + as NEqGadget>::cost() + } +} + +impl CondSelectGadget for Char { + fn conditionally_select>( + cs: CS, + cond: &Boolean, + first: &Self, + second: &Self, + ) -> Result { + let field = FieldType::::conditionally_select(cs, cond, &first.field, &second.field)?; + + if field == first.field { + return Ok(Char { + character: first.character, + field, + }); + } + + Ok(Char { + character: second.character, + field, + }) + } + + fn cost() -> usize { + as CondSelectGadget>::cost() + } +} + pub(crate) fn char_from_input<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, name: &str, diff --git a/compiler/src/value/field/field_type.rs b/compiler/src/value/field/field_type.rs index 1280518aeb..ddf6177304 100644 --- a/compiler/src/value/field/field_type.rs +++ b/compiler/src/value/field/field_type.rs @@ -21,13 +21,14 @@ use leo_ast::Span; use snarkvm_fields::PrimeField; use snarkvm_gadgets::{ - fields::{AllocatedFp, FpGadget}, + fields::FpGadget, traits::{ fields::FieldGadget, utilities::{ alloc::AllocGadget, + bits::comparator::{ComparatorGadget, EvaluateLtGadget}, boolean::Boolean, - eq::{ConditionalEqGadget, EqGadget, EvaluateEqGadget}, + eq::{ConditionalEqGadget, EqGadget, EvaluateEqGadget, NEqGadget}, select::CondSelectGadget, uint::UInt8, ToBitsBEGadget, @@ -36,131 +37,83 @@ use snarkvm_gadgets::{ }, }; use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; - use std::{borrow::Borrow, cmp::Ordering}; #[derive(Clone, Debug)] -pub enum FieldType { - Constant(F), - Allocated(FpGadget), -} +pub struct FieldType(FpGadget); impl FieldType { + /// Returns the value of the field. pub fn get_value(&self) -> Option { - match self { - FieldType::Constant(field) => Some(*field), - FieldType::Allocated(gadget) => gadget.get_value(), - } + self.0.get_value() } - pub fn constant(string: String, span: &Span) -> Result { + /// Returns a new `FieldType` from the given `String` or returns a `FieldError`. + pub fn constant>(cs: CS, string: String, span: &Span) -> Result { let number_info = number_string_typing(&string); let value = match number_info { - (number, neg) if neg => -F::from_str(&number).map_err(|_| FieldError::invalid_field(string, span))?, - (number, _) => F::from_str(&number).map_err(|_| FieldError::invalid_field(string, span))?, + (number, neg) if neg => { + -F::from_str(&number).map_err(|_| FieldError::invalid_field(string.clone(), span))? + } + (number, _) => F::from_str(&number).map_err(|_| FieldError::invalid_field(string.clone(), span))?, }; - Ok(FieldType::Constant(value)) + let value = FpGadget::alloc_constant(cs, || Ok(value)).map_err(|_| FieldError::invalid_field(string, span))?; + + Ok(FieldType(value)) } + /// Returns a new `FieldType` by calling the `FpGadget` `negate` function. pub fn negate>(&self, cs: CS, span: &Span) -> Result { - match self { - FieldType::Constant(field) => Ok(FieldType::Constant(field.neg())), - FieldType::Allocated(field) => { - let result = field.negate(cs).map_err(|e| FieldError::negate_operation(e, span))?; + let result = self.0.negate(cs).map_err(|e| FieldError::negate_operation(e, span))?; - Ok(FieldType::Allocated(result)) - } - } + Ok(FieldType(result)) } + /// Returns a new `FieldType` by calling the `FpGadget` `add` function. pub fn add>(&self, cs: CS, other: &Self, span: &Span) -> Result { - match (self, other) { - (FieldType::Constant(self_value), FieldType::Constant(other_value)) => { - Ok(FieldType::Constant(self_value.add(other_value))) - } + let value = self + .0 + .add(cs, &other.0) + .map_err(|e| FieldError::binary_operation("+".to_string(), e, span))?; - (FieldType::Allocated(self_value), FieldType::Allocated(other_value)) => { - let result = self_value - .add(cs, other_value) - .map_err(|e| FieldError::binary_operation("+".to_string(), e, span))?; - - Ok(FieldType::Allocated(result)) - } - - (FieldType::Constant(constant_value), FieldType::Allocated(allocated_value)) - | (FieldType::Allocated(allocated_value), FieldType::Constant(constant_value)) => Ok(FieldType::Allocated( - allocated_value - .add_constant(cs, constant_value) - .map_err(|e| FieldError::binary_operation("+".to_string(), e, span))?, - )), - } + Ok(FieldType(value)) } + /// Returns a new `FieldType` by calling the `FpGadget` `sub` function. pub fn sub>(&self, cs: CS, other: &Self, span: &Span) -> Result { - match (self, other) { - (FieldType::Constant(self_value), FieldType::Constant(other_value)) => { - Ok(FieldType::Constant(self_value.sub(other_value))) - } + let value = self + .0 + .sub(cs, &other.0) + .map_err(|e| FieldError::binary_operation("-".to_string(), e, span))?; - (FieldType::Allocated(self_value), FieldType::Allocated(other_value)) => { - let result = self_value - .sub(cs, other_value) - .map_err(|e| FieldError::binary_operation("-".to_string(), e, span))?; - - Ok(FieldType::Allocated(result)) - } - - (FieldType::Constant(constant_value), FieldType::Allocated(allocated_value)) - | (FieldType::Allocated(allocated_value), FieldType::Constant(constant_value)) => Ok(FieldType::Allocated( - allocated_value - .sub_constant(cs, constant_value) - .map_err(|e| FieldError::binary_operation("+".to_string(), e, span))?, - )), - } + Ok(FieldType(value)) } + /// Returns a new `FieldType` by calling the `FpGadget` `mul` function. pub fn mul>(&self, cs: CS, other: &Self, span: &Span) -> Result { - match (self, other) { - (FieldType::Constant(self_value), FieldType::Constant(other_value)) => { - Ok(FieldType::Constant(self_value.mul(other_value))) - } + let value = self + .0 + .mul(cs, &other.0) + .map_err(|e| FieldError::binary_operation("*".to_string(), e, span))?; - (FieldType::Allocated(self_value), FieldType::Allocated(other_value)) => { - let result = self_value - .mul(cs, other_value) - .map_err(|e| FieldError::binary_operation("*".to_string(), e, span))?; - - Ok(FieldType::Allocated(result)) - } - - (FieldType::Constant(constant_value), FieldType::Allocated(allocated_value)) - | (FieldType::Allocated(allocated_value), FieldType::Constant(constant_value)) => Ok(FieldType::Allocated( - allocated_value - .mul_by_constant(cs, constant_value) - .map_err(|e| FieldError::binary_operation("*".to_string(), e, span))?, - )), - } + Ok(FieldType(value)) } + /// Returns a new `FieldType` by calling the `FpGadget` `inverse` function. + pub fn inverse>(&self, cs: CS, span: &Span) -> Result { + let value = self + .0 + .inverse(cs) + .map_err(|e| FieldError::binary_operation("inv".to_string(), e, span))?; + + Ok(FieldType(value)) + } + + /// Returns a new `FieldType` by calling the `FpGadget` `div` function. pub fn div>(&self, mut cs: CS, other: &Self, span: &Span) -> Result { - let inverse = match other { - FieldType::Constant(constant) => { - let constant_inverse = constant - .inverse() - .ok_or_else(|| FieldError::no_inverse(constant.to_string(), span))?; - - FieldType::Constant(constant_inverse) - } - FieldType::Allocated(allocated) => { - let allocated_inverse = allocated - .inverse(&mut cs) - .map_err(|e| FieldError::binary_operation("+".to_string(), e, span))?; - - FieldType::Allocated(allocated_inverse) - } - }; + let inverse = other.inverse(cs.ns(|| "division inverse"), span)?; self.mul(cs, &inverse, span) } @@ -178,15 +131,6 @@ impl FieldType { F::from_str(&field_string).map_err(|_| SynthesisError::AssignmentMissing) } - - pub fn allocated>(&self, mut cs: CS) -> Result, SynthesisError> { - match self { - FieldType::Constant(constant) => FpGadget::alloc(&mut cs.ns(|| format!("{:?}", constant)), || Ok(constant)), - FieldType::Allocated(allocated) => FpGadget::alloc(&mut cs.ns(|| format!("{:?}", allocated)), || { - allocated.get_value().ok_or(SynthesisError::AssignmentMissing) - }), - } - } } impl AllocGadget for FieldType { @@ -196,7 +140,7 @@ impl AllocGadget for FieldType { ) -> Result { let value = FpGadget::alloc(cs, || Self::alloc_helper(value_gen))?; - Ok(FieldType::Allocated(value)) + Ok(FieldType(value)) } fn alloc_input Result, T: Borrow, CS: ConstraintSystem>( @@ -205,16 +149,13 @@ impl AllocGadget for FieldType { ) -> Result { let value = FpGadget::alloc_input(cs, || Self::alloc_helper(value_gen))?; - Ok(FieldType::Allocated(value)) + Ok(FieldType(value)) } } impl PartialEq for FieldType { fn eq(&self, other: &Self) -> bool { - let self_value = self.get_value(); - let other_value = other.get_value(); - - self_value.is_some() && other_value.is_some() && self_value.eq(&other_value) + self.0.eq(&other.0) } } @@ -229,19 +170,17 @@ impl PartialOrd for FieldType { } } +impl EvaluateLtGadget for FieldType { + fn less_than>(&self, _cs: CS, _other: &Self) -> Result { + unimplemented!() + } +} + +impl ComparatorGadget for FieldType {} + impl EvaluateEqGadget for FieldType { - fn evaluate_equal>(&self, mut _cs: CS, other: &Self) -> Result { - match (self, other) { - (FieldType::Constant(first), FieldType::Constant(second)) => Ok(Boolean::constant(first.eq(second))), - _ => unimplemented!(), - // (FieldType::Allocated(first), FieldType::Allocated(second)) => first.evaluate_equal(cs, second), - // (FieldType::Constant(constant_value), FieldType::Allocated(allocated_value)) - // | (FieldType::Allocated(allocated_value), FieldType::Constant(constant_value)) => { - // let allocated_constant_value = - // FpGadget::alloc(&mut cs.ns(|| format!("alloc constant for eq")), || Ok(constant_value))?; - // allocated_value.evaluate_equal(cs, &allocated_constant_value) - // } - } + fn evaluate_equal>(&self, cs: CS, other: &Self) -> Result { + self.0.is_eq(cs, &other.0) } } @@ -250,30 +189,11 @@ impl EqGadget for FieldType {} impl ConditionalEqGadget for FieldType { fn conditional_enforce_equal>( &self, - mut cs: CS, + cs: CS, other: &Self, condition: &Boolean, ) -> Result<(), SynthesisError> { - match (self, other) { - // c - c - (FieldType::Constant(self_value), FieldType::Constant(other_value)) => { - if self_value == other_value { - return Ok(()); - } - Err(SynthesisError::AssignmentMissing) - } - // a - a - (FieldType::Allocated(self_value), FieldType::Allocated(other_value)) => { - self_value.conditional_enforce_equal(cs, other_value, condition) - } - // c - a = a - c - (FieldType::Constant(constant_value), FieldType::Allocated(allocated_value)) - | (FieldType::Allocated(allocated_value), FieldType::Constant(constant_value)) => { - let constant_gadget = FpGadget::from(AllocatedFp::from(&mut cs, constant_value)); - - constant_gadget.conditional_enforce_equal(cs, allocated_value, condition) - } - } + self.0.conditional_enforce_equal(cs, &other.0, condition) } fn cost() -> usize { @@ -281,22 +201,26 @@ impl ConditionalEqGadget for FieldType { } } +impl NEqGadget for FieldType { + fn enforce_not_equal>(&self, cs: CS, other: &Self) -> Result<(), SynthesisError> { + self.0.enforce_not_equal(cs, &other.0) + } + + fn cost() -> usize { + as NEqGadget>::cost() + } +} + impl CondSelectGadget for FieldType { fn conditionally_select>( - mut cs: CS, + cs: CS, cond: &Boolean, first: &Self, second: &Self, ) -> Result { - if let Boolean::Constant(cond) = *cond { - if cond { Ok(first.clone()) } else { Ok(second.clone()) } - } else { - let first_gadget = first.allocated(&mut cs)?; - let second_gadget = second.allocated(&mut cs)?; - let result = FpGadget::conditionally_select(cs, cond, &first_gadget, &second_gadget)?; + let value = FpGadget::conditionally_select(cs, cond, &first.0, &second.0)?; - Ok(FieldType::Allocated(result)) - } + Ok(FieldType(value)) } fn cost() -> usize { @@ -305,26 +229,22 @@ impl CondSelectGadget for FieldType { } impl ToBitsBEGadget for FieldType { - fn to_bits_be>(&self, mut cs: CS) -> Result, SynthesisError> { - let self_gadget = self.allocated(&mut cs)?; - self_gadget.to_bits_be(cs) + fn to_bits_be>(&self, cs: CS) -> Result, SynthesisError> { + self.0.to_bits_be(cs) } - fn to_bits_be_strict>(&self, mut cs: CS) -> Result, SynthesisError> { - let self_gadget = self.allocated(&mut cs)?; - self_gadget.to_bits_be_strict(cs) + fn to_bits_be_strict>(&self, cs: CS) -> Result, SynthesisError> { + self.0.to_bits_be(cs) } } impl ToBytesGadget for FieldType { - fn to_bytes>(&self, mut cs: CS) -> Result, SynthesisError> { - let self_gadget = self.allocated(&mut cs)?; - self_gadget.to_bytes(cs) + fn to_bytes>(&self, cs: CS) -> Result, SynthesisError> { + self.0.to_bytes(cs) } - fn to_bytes_strict>(&self, mut cs: CS) -> Result, SynthesisError> { - let self_gadget = self.allocated(&mut cs)?; - self_gadget.to_bytes_strict(cs) + fn to_bytes_strict>(&self, cs: CS) -> Result, SynthesisError> { + self.0.to_bytes_strict(cs) } } diff --git a/compiler/src/value/value.rs b/compiler/src/value/value.rs index 9a71e7f5d6..1bb94ed34b 100644 --- a/compiler/src/value/value.rs +++ b/compiler/src/value/value.rs @@ -148,7 +148,7 @@ impl<'a, F: PrimeField, G: GroupType> ConditionalEqGadget for ConstrainedV bool_1.conditional_enforce_equal(cs, bool_2, condition) } (ConstrainedValue::Char(char_1), ConstrainedValue::Char(char_2)) => { - char_1.field.conditional_enforce_equal(cs, &char_2.field, condition) + char_1.conditional_enforce_equal(cs, char_2, condition) } (ConstrainedValue::Field(field_1), ConstrainedValue::Field(field_2)) => { field_1.conditional_enforce_equal(cs, field_2, condition) @@ -195,7 +195,7 @@ impl<'a, F: PrimeField, G: GroupType> CondSelectGadget for ConstrainedValu ConstrainedValue::Boolean(Boolean::conditionally_select(cs, cond, bool_1, bool_2)?) } (ConstrainedValue::Char(char_1), ConstrainedValue::Char(char_2)) => { - ConstrainedValue::Field(FieldType::conditionally_select(cs, cond, &char_1.field, &char_2.field)?) + ConstrainedValue::Char(Char::conditionally_select(cs, cond, char_1, char_2)?) } (ConstrainedValue::Field(field_1), ConstrainedValue::Field(field_2)) => { ConstrainedValue::Field(FieldType::conditionally_select(cs, cond, field_1, field_2)?) diff --git a/package/src/root/manifest.rs b/package/src/root/manifest.rs index 4ec11007fd..9167f402bb 100644 --- a/package/src/root/manifest.rs +++ b/package/src/root/manifest.rs @@ -104,7 +104,7 @@ description = "The {name} package" license = "MIT" [remote] -author = "{author}" # Add your Aleo Package Manager username, team's name, or organization's name. +author = "{author}" # Add your Aleo Package Manager username or team name. "#, name = self.project.name, author = author diff --git a/parser/src/tokenizer/lexer.rs b/parser/src/tokenizer/lexer.rs index b966d48591..96c6807bb6 100644 --- a/parser/src/tokenizer/lexer.rs +++ b/parser/src/tokenizer/lexer.rs @@ -173,6 +173,9 @@ impl Token { /// Returns a new `StrTendril` string if an character can be eaten, otherwise returns [`None`]. /// fn eat_char(input_tendril: &StrTendril) -> (usize, Option) { + // Probably better to move this logic to a parse_char. + // Would give better errors, and isolates logic from lexer. + // Lexer can just return content between single quotes. if input_tendril.is_empty() { return (0, None); } @@ -247,6 +250,19 @@ impl Token { } return match characters.len() { + 1 | 2 | 3 | 4 | 5 if unicode => { + if let Ok(string) = std::str::from_utf8(&characters[..]) { + if let Ok(hex) = u32::from_str_radix(&string, 16) { + if hex <= 0x10FFFF { + if let Some(unicode_char) = std::char::from_u32(hex) { + return (i, Some(Token::CharLit(unicode_char))); + } + } + } + } + + (0, None) + } 1 => { if hex { return (0, None); @@ -254,28 +270,19 @@ impl Token { (i, Some(Token::CharLit(characters[0] as char))) } - 2 => { - if hex { - if let Ok(string) = std::str::from_utf8(&characters[..]) { - if let Ok(number) = u8::from_str_radix(&string, 16) { - if number <= 127 { - return (i, Some(Token::CharLit(number as char))); - } - } - } - } - - if unicode { - if let Ok(string) = std::str::from_utf8(&characters[..]) { - if let Some(character) = string.chars().next() { - return (i, Some(Token::CharLit(character))); + 2 if hex => { + if let Ok(string) = std::str::from_utf8(&characters[..]) { + if let Ok(number) = u8::from_str_radix(&string, 16) { + if number <= 127 { + return (i, Some(Token::CharLit(number as char))); } } } (0, None) } - 3 => { + 3 | 4 => { + // direct unicode symbol if let Ok(string) = std::str::from_utf8(&characters[..]) { if let Some(character) = string.chars().next() { return (i, Some(Token::CharLit(character))); @@ -284,17 +291,6 @@ impl Token { (0, None) } - 4 | 5 | 6 => { - if let Ok(unicode_string) = std::str::from_utf8(&characters[..]) { - if let Ok(hex) = u32::from_str_radix(&unicode_string, 16) { - if let Some(unicode_char) = std::char::from_u32(hex) { - return (i, Some(Token::CharLit(unicode_char))); - } - } - } - - (0, None) - } _ => (0, None), }; } diff --git a/state/Cargo.toml b/state/Cargo.toml index 918478ee42..721be21d86 100644 --- a/state/Cargo.toml +++ b/state/Cargo.toml @@ -26,18 +26,18 @@ path = "../ast" version = "1.4.0" [dependencies.snarkvm-algorithms] -version = "0.2.2" +version = "0.3.1" [dependencies.snarkvm-curves] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-dpc] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-utilities] -version = "0.2.2" +version = "0.3.1" [dependencies.indexmap] version = "1.6.2" @@ -52,8 +52,8 @@ version = "0.3" [dependencies.thiserror] version = "1.0" -[dev-dependencies.snarkvm-storage] -version = "0.2.2" +#[dev-dependencies.snarkos-storage] +#version = "1.3.3" [dev-dependencies.rand_core] version = "0.6.2" diff --git a/state/tests/mod.rs b/state/tests/mod.rs index 2c287a3b13..94f0a47fd9 100644 --- a/state/tests/mod.rs +++ b/state/tests/mod.rs @@ -14,6 +14,6 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -mod test_verify_local_data_commitment; +// mod test_verify_local_data_commitment; -mod test_verify_record_commitment; +// mod test_verify_record_commitment; diff --git a/state/tests/test_verify_local_data_commitment.rs b/state/tests/test_verify_local_data_commitment.rs index f0a8e6b431..bdf45033a9 100644 --- a/state/tests/test_verify_local_data_commitment.rs +++ b/state/tests/test_verify_local_data_commitment.rs @@ -14,206 +14,206 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::Input; -use leo_input::LeoInputParser; -use leo_state::verify_local_data_commitment; - -use snarkvm_algorithms::traits::{CommitmentScheme, CRH}; -use snarkvm_dpc::{ - base_dpc::{instantiated::*, record_payload::RecordPayload, DPC}, - Account, - AccountScheme, - Record, -}; -use snarkvm_utilities::{bytes::ToBytes, to_bytes}; - -use rand::Rng; -use rand_core::SeedableRng; -use rand_xorshift::XorShiftRng; -use snarkvm_dpc::DPCScheme; -use snarkvm_storage::Ledger; - -// TODO (Collin): Update input to reflect new parameter ordering. -#[test] -#[ignore] -fn test_verify_local_data_commitment_from_file() { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); - - // Generate parameters for the record commitment scheme - let system_parameters = InstantiatedDPC::generate_system_parameters(&mut rng).unwrap(); - - // Load test record state file from `inputs/test.state` - let file_bytes = include_bytes!("inputs/test_state.state"); - let file_string = String::from_utf8_lossy(file_bytes); - let file = LeoInputParser::parse_file(&file_string).unwrap(); - - let mut program_input = Input::new(); - program_input.parse_state(file).unwrap(); - - // check record state is correct by verifying commitment - let result = verify_local_data_commitment(&system_parameters, &program_input).unwrap(); - - assert!(result); -} - -#[test] -#[ignore] -fn test_generate_values_from_dpc() { - type L = Ledger; - - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); - - // Specify network_id - let network_id: u8 = 0; - - // Generate parameters for the ledger, commitment schemes, CRH, and the - // "always-accept" program. - let system_parameters = InstantiatedDPC::generate_system_parameters(&mut rng).unwrap(); - let noop_program_snark_pp = - InstantiatedDPC::generate_noop_program_snark_parameters(&system_parameters, &mut rng).unwrap(); - - let noop_program_id = to_bytes![ - ProgramVerificationKeyCRH::hash( - &system_parameters.program_verification_key_crh, - &to_bytes![noop_program_snark_pp.verification_key].unwrap() - ) - .unwrap() - ] - .unwrap(); - - let signature_parameters = &system_parameters.account_signature; - let commitment_parameters = &system_parameters.account_commitment; - let encryption_parameters = &system_parameters.account_encryption; - - // Generate metadata and an account for a dummy initial record. - let dummy_account = Account::new( - signature_parameters, - commitment_parameters, - encryption_parameters, - &mut rng, - ) - .unwrap(); - - let sn_nonce = SerialNumberNonce::hash(&system_parameters.serial_number_nonce, &[0u8; 1]).unwrap(); - let value = rng.gen(); - let payload: [u8; 32] = rng.gen(); - - let old_record = DPC::generate_record( - &system_parameters, - sn_nonce, - dummy_account.address, - false, - value, - RecordPayload::from_bytes(&payload), - noop_program_id.clone(), - noop_program_id.clone(), - &mut rng, - ) - .unwrap(); - - // Set the input records for our transaction to be the initial dummy records. - let old_records = vec![old_record; NUM_INPUT_RECORDS]; - let old_account_private_keys = vec![dummy_account.private_key; NUM_INPUT_RECORDS]; - - // Construct new records. - - // Create an account for an actual new record. - - let new_account = Account::new( - signature_parameters, - commitment_parameters, - encryption_parameters, - &mut rng, - ) - .unwrap(); - - // Set the new record's program to be the "always-accept" program. - - let new_record_owners = vec![new_account.address; NUM_OUTPUT_RECORDS]; - let new_is_dummy_flags = vec![false; NUM_OUTPUT_RECORDS]; - let new_values = vec![10; NUM_OUTPUT_RECORDS]; - let new_payloads = vec![RecordPayload::default(); NUM_OUTPUT_RECORDS]; - let new_birth_program_ids = vec![noop_program_id.clone(); NUM_OUTPUT_RECORDS]; - let new_death_program_ids = vec![noop_program_id; NUM_OUTPUT_RECORDS]; - let memo = [0u8; 32]; - - let context = >::execute_offline( - system_parameters.clone(), - old_records, - old_account_private_keys, - new_record_owners, - &new_is_dummy_flags, - &new_values, - new_payloads, - new_birth_program_ids, - new_death_program_ids, - memo, - network_id, - &mut rng, - ) - .unwrap(); - - let local_data = context.into_local_data(); - let leaf_index = 0; - let record = &local_data.old_records[leaf_index]; - - let root = local_data.local_data_merkle_tree.root(); - - let serial_number = local_data.old_serial_numbers[0]; - let serial_number_bytes = to_bytes![serial_number].unwrap(); - - let memorandum = local_data.memorandum; - let network_id = local_data.network_id; - let input_bytes = to_bytes![serial_number, record.commitment(), memorandum, network_id].unwrap(); - let leaf_randomness = local_data.local_data_commitment_randomizers[0]; - - let old_record_leaf = ::commit( - &system_parameters.local_data_commitment, - &input_bytes, - &leaf_randomness, - ) - .unwrap(); - - // generate the path - - let path = local_data - .local_data_merkle_tree - .generate_proof(&old_record_leaf) - .unwrap(); - - println!("////////////////////////////////////////////////////"); - println!(); - println!("[state]"); - println!("leaf index {}", leaf_index); - println!("root {:?}", to_bytes![root].unwrap()); - println!(); - println!("[record]"); - println!( - "serial number {:?} len {}", - serial_number_bytes, - serial_number_bytes.len() - ); - println!("commitment {:?}", to_bytes![record.commitment()].unwrap()); - println!("owner {}", record.owner()); - println!("is_dummy {:?}", record.is_dummy()); - println!("value {:?}", record.value()); - println!("payload {:?}", record.payload()); - println!("birth_program_id {:?}", record.birth_program_id()); - println!("death_program_id {:?}", record.death_program_id()); - println!( - "serial number nonce {:?}", - to_bytes![record.serial_number_nonce()].unwrap() - ); - println!( - "commitment randomness {:?}", - to_bytes![record.commitment_randomness()].unwrap() - ); - println!(); - println!("[state_leaf]"); - println!("path {:?}", to_bytes![path].unwrap()); - println!("memo {:?}", memorandum); - println!("network id {:?}", network_id); - println!("leaf randomness {:?}", to_bytes![leaf_randomness].unwrap()); - println!(); - println!("////////////////////////////////////////////////////"); -} +// use leo_ast::Input; +// use leo_input::LeoInputParser; +// use leo_state::verify_local_data_commitment; +// +// use snarkos_storage::{mem::MemDb, Ledger}; +// use snarkvm_algorithms::traits::{CommitmentScheme, CRH}; +// use snarkvm_dpc::{ +// base_dpc::{instantiated::*, record_payload::RecordPayload, DPC}, +// traits::DPCScheme, +// Account, +// AccountScheme, +// Record, +// }; +// use snarkvm_utilities::{bytes::ToBytes, to_bytes}; +// +// use rand::Rng; +// use rand_core::SeedableRng; +// use rand_xorshift::XorShiftRng; +// +// // TODO (Collin): Update input to reflect new parameter ordering. +// #[test] +// #[ignore] +// fn test_verify_local_data_commitment_from_file() { +// let mut rng = XorShiftRng::seed_from_u64(1231275789u64); +// +// // Generate parameters for the record commitment scheme +// let system_parameters = InstantiatedDPC::generate_system_parameters(&mut rng).unwrap(); +// +// // Load test record state file from `inputs/test.state` +// let file_bytes = include_bytes!("inputs/test_state.state"); +// let file_string = String::from_utf8_lossy(file_bytes); +// let file = LeoInputParser::parse_file(&file_string).unwrap(); +// +// let mut program_input = Input::new(); +// program_input.parse_state(file).unwrap(); +// +// // check record state is correct by verifying commitment +// let result = verify_local_data_commitment(&system_parameters, &program_input).unwrap(); +// +// assert!(result); +// } +// +// #[test] +// #[ignore] +// fn test_generate_values_from_dpc() { +// type L = Ledger; +// +// let mut rng = XorShiftRng::seed_from_u64(1231275789u64); +// +// // Specify network_id +// let network_id: u8 = 0; +// +// // Generate parameters for the ledger, commitment schemes, CRH, and the +// // "always-accept" program. +// let system_parameters = InstantiatedDPC::generate_system_parameters(&mut rng).unwrap(); +// let noop_program_snark_pp = +// InstantiatedDPC::generate_noop_program_snark_parameters(&system_parameters, &mut rng).unwrap(); +// +// let noop_program_id = to_bytes![ +// ProgramVerificationKeyCRH::hash( +// &system_parameters.program_verification_key_crh, +// &to_bytes![noop_program_snark_pp.verification_key].unwrap() +// ) +// .unwrap() +// ] +// .unwrap(); +// +// let signature_parameters = &system_parameters.account_signature; +// let commitment_parameters = &system_parameters.account_commitment; +// let encryption_parameters = &system_parameters.account_encryption; +// +// // Generate metadata and an account for a dummy initial record. +// let dummy_account = Account::new( +// signature_parameters, +// commitment_parameters, +// encryption_parameters, +// &mut rng, +// ) +// .unwrap(); +// +// let sn_nonce = SerialNumberNonce::hash(&system_parameters.serial_number_nonce, &[0u8; 1]).unwrap(); +// let value = rng.gen(); +// let payload: [u8; 32] = rng.gen(); +// +// let old_record = DPC::generate_record( +// &system_parameters, +// sn_nonce, +// dummy_account.address, +// false, +// value, +// RecordPayload::from_bytes(&payload), +// noop_program_id.clone(), +// noop_program_id.clone(), +// &mut rng, +// ) +// .unwrap(); +// +// // Set the input records for our transaction to be the initial dummy records. +// let old_records = vec![old_record; NUM_INPUT_RECORDS]; +// let old_account_private_keys = vec![dummy_account.private_key; NUM_INPUT_RECORDS]; +// +// // Construct new records. +// +// // Create an account for an actual new record. +// +// let new_account = Account::new( +// signature_parameters, +// commitment_parameters, +// encryption_parameters, +// &mut rng, +// ) +// .unwrap(); +// +// // Set the new record's program to be the "always-accept" program. +// +// let new_record_owners = vec![new_account.address; NUM_OUTPUT_RECORDS]; +// let new_is_dummy_flags = vec![false; NUM_OUTPUT_RECORDS]; +// let new_values = vec![10; NUM_OUTPUT_RECORDS]; +// let new_payloads = vec![RecordPayload::default(); NUM_OUTPUT_RECORDS]; +// let new_birth_program_ids = vec![noop_program_id.clone(); NUM_OUTPUT_RECORDS]; +// let new_death_program_ids = vec![noop_program_id; NUM_OUTPUT_RECORDS]; +// let memo = [0u8; 32]; +// +// let context = >::execute_offline( +// system_parameters.clone(), +// old_records, +// old_account_private_keys, +// new_record_owners, +// &new_is_dummy_flags, +// &new_values, +// new_payloads, +// new_birth_program_ids, +// new_death_program_ids, +// memo, +// network_id, +// &mut rng, +// ) +// .unwrap(); +// +// let local_data = context.into_local_data(); +// let leaf_index = 0; +// let record = &local_data.old_records[leaf_index]; +// +// let root = local_data.local_data_merkle_tree.root(); +// +// let serial_number = local_data.old_serial_numbers[0]; +// let serial_number_bytes = to_bytes![serial_number].unwrap(); +// +// let memorandum = local_data.memorandum; +// let network_id = local_data.network_id; +// let input_bytes = to_bytes![serial_number, record.commitment(), memorandum, network_id].unwrap(); +// let leaf_randomness = local_data.local_data_commitment_randomizers[0]; +// +// let old_record_leaf = ::commit( +// &system_parameters.local_data_commitment, +// &input_bytes, +// &leaf_randomness, +// ) +// .unwrap(); +// +// // generate the path +// +// let path = local_data +// .local_data_merkle_tree +// .generate_proof(&old_record_leaf) +// .unwrap(); +// +// println!("////////////////////////////////////////////////////"); +// println!(); +// println!("[state]"); +// println!("leaf index {}", leaf_index); +// println!("root {:?}", to_bytes![root].unwrap()); +// println!(); +// println!("[record]"); +// println!( +// "serial number {:?} len {}", +// serial_number_bytes, +// serial_number_bytes.len() +// ); +// println!("commitment {:?}", to_bytes![record.commitment()].unwrap()); +// println!("owner {}", record.owner()); +// println!("is_dummy {:?}", record.is_dummy()); +// println!("value {:?}", record.value()); +// println!("payload {:?}", record.payload()); +// println!("birth_program_id {:?}", record.birth_program_id()); +// println!("death_program_id {:?}", record.death_program_id()); +// println!( +// "serial number nonce {:?}", +// to_bytes![record.serial_number_nonce()].unwrap() +// ); +// println!( +// "commitment randomness {:?}", +// to_bytes![record.commitment_randomness()].unwrap() +// ); +// println!(); +// println!("[state_leaf]"); +// println!("path {:?}", to_bytes![path].unwrap()); +// println!("memo {:?}", memorandum); +// println!("network id {:?}", network_id); +// println!("leaf randomness {:?}", to_bytes![leaf_randomness].unwrap()); +// println!(); +// println!("////////////////////////////////////////////////////"); +// } diff --git a/state/tests/test_verify_record_commitment.rs b/state/tests/test_verify_record_commitment.rs index 1871e71859..52d97781e6 100644 --- a/state/tests/test_verify_record_commitment.rs +++ b/state/tests/test_verify_record_commitment.rs @@ -14,34 +14,34 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::Input; -use leo_input::LeoInputParser; -use leo_state::verify_record_commitment; - -use snarkvm_dpc::base_dpc::instantiated::*; - -use rand_core::SeedableRng; -use rand_xorshift::XorShiftRng; - -// TODO (Collin): Update input to reflect new parameter ordering. -#[test] -#[ignore] -fn test_verify_record_from_file() { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); - - // Generate parameters for the record commitment scheme - let system_parameters = InstantiatedDPC::generate_system_parameters(&mut rng).unwrap(); - - // Load test record state file from `inputs/test.state` - let file_bytes = include_bytes!("inputs/test_record.state"); - let file_string = String::from_utf8_lossy(file_bytes); - let file = LeoInputParser::parse_file(&file_string).unwrap(); - - let mut program_input = Input::new(); - program_input.parse_state(file).unwrap(); - - let typed_record = program_input.get_record(); - - // check record state is correct by verifying commitment - let _values = verify_record_commitment(&system_parameters, typed_record).unwrap(); -} +// use leo_ast::Input; +// use leo_input::LeoInputParser; +// use leo_state::verify_record_commitment; +// +// use snarkvm_dpc::base_dpc::instantiated::*; +// +// use rand_core::SeedableRng; +// use rand_xorshift::XorShiftRng; +// +// // TODO (Collin): Update input to reflect new parameter ordering. +// #[test] +// #[ignore] +// fn test_verify_record_from_file() { +// let mut rng = XorShiftRng::seed_from_u64(1231275789u64); +// +// // Generate parameters for the record commitment scheme +// let system_parameters = InstantiatedDPC::generate_system_parameters(&mut rng).unwrap(); +// +// // Load test record state file from `inputs/test.state` +// let file_bytes = include_bytes!("inputs/test_record.state"); +// let file_string = String::from_utf8_lossy(file_bytes); +// let file = LeoInputParser::parse_file(&file_string).unwrap(); +// +// let mut program_input = Input::new(); +// program_input.parse_state(file).unwrap(); +// +// let typed_record = program_input.get_record(); +// +// // check record state is correct by verifying commitment +// let _values = verify_record_commitment(&system_parameters, typed_record).unwrap(); +// } diff --git a/synthesizer/Cargo.toml b/synthesizer/Cargo.toml index b78dbf1860..6a73079e44 100644 --- a/synthesizer/Cargo.toml +++ b/synthesizer/Cargo.toml @@ -18,18 +18,18 @@ license = "GPL-3.0" edition = "2018" [dependencies.snarkvm-curves] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-fields] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.snarkvm-gadgets] -version = "0.2.2" +version = "0.3.1" [dependencies.snarkvm-r1cs] -version = "0.2.2" +version = "0.3.1" default-features = false [dependencies.num-bigint] diff --git a/tests/compiler/_field/add.leo b/tests/compiler/_field/add.leo deleted file mode 100644 index 8dc2c7df4e..0000000000 --- a/tests/compiler/_field/add.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field, c: field) { - console.assert(a + b == c); -} \ No newline at end of file diff --git a/tests/compiler/_field/console_assert.leo b/tests/compiler/_field/console_assert.leo deleted file mode 100644 index c7224bcea5..0000000000 --- a/tests/compiler/_field/console_assert.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field) { - console.assert(a == b); -} \ No newline at end of file diff --git a/tests/compiler/_field/div.leo b/tests/compiler/_field/div.leo deleted file mode 100644 index 028b06fad2..0000000000 --- a/tests/compiler/_field/div.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field, c: field) { - console.assert(a / b == c); -} \ No newline at end of file diff --git a/tests/compiler/_field/eq.leo b/tests/compiler/_field/eq.leo deleted file mode 100644 index e64307d8de..0000000000 --- a/tests/compiler/_field/eq.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field, c: bool) { - console.assert(a == b == c); -} \ No newline at end of file diff --git a/tests/compiler/_field/field.leo b/tests/compiler/_field/field.leo deleted file mode 100644 index 5d5732e906..0000000000 --- a/tests/compiler/_field/field.leo +++ /dev/null @@ -1,4 +0,0 @@ -function main() { - const negOneField: field = -1field; - const oneField = 1field; -} \ No newline at end of file diff --git a/tests/compiler/_field/mul.leo b/tests/compiler/_field/mul.leo deleted file mode 100644 index 7df7c83830..0000000000 --- a/tests/compiler/_field/mul.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field, c: field) { - console.assert(a * b == c); -} \ No newline at end of file diff --git a/tests/compiler/_field/negate.leo b/tests/compiler/_field/negate.leo deleted file mode 100644 index 94c730207a..0000000000 --- a/tests/compiler/_field/negate.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field) { - console.assert(-a == b); -} \ No newline at end of file diff --git a/tests/compiler/_field/no_space_between_literal.leo b/tests/compiler/_field/no_space_between_literal.leo deleted file mode 100644 index 9ac9dcd5db..0000000000 --- a/tests/compiler/_field/no_space_between_literal.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main() { - const f = 1 field; -} \ No newline at end of file diff --git a/tests/compiler/_field/output_register.leo b/tests/compiler/_field/output_register.leo deleted file mode 100644 index e27a3947bd..0000000000 --- a/tests/compiler/_field/output_register.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(registers) -> field { - return registers.r; -} \ No newline at end of file diff --git a/tests/compiler/_field/sub.leo b/tests/compiler/_field/sub.leo deleted file mode 100644 index 2c84b24647..0000000000 --- a/tests/compiler/_field/sub.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main(a: field, b: field, c: field) { - console.assert(a - b == c); -} \ No newline at end of file diff --git a/tests/compiler/_field/ternary.leo b/tests/compiler/_field/ternary.leo deleted file mode 100644 index 05cb161b46..0000000000 --- a/tests/compiler/_field/ternary.leo +++ /dev/null @@ -1,5 +0,0 @@ -function main(s: bool, a: field, b: field, c: field) { - const r = s ? a : b; - - console.assert(r == c); -} \ No newline at end of file diff --git a/tests/compiler/char/circuit.leo b/tests/compiler/char/circuit.leo index c2ffad791a..7bdcd1119f 100644 --- a/tests/compiler/char/circuit.leo +++ b/tests/compiler/char/circuit.leo @@ -1,6 +1,6 @@ /* namespace: Compile -expectation: Fail +expectation: Pass input_file: - inputs/ascii.in - inputs/escaped_unicode.in @@ -15,5 +15,7 @@ circuit Foo { function main(character: char) -> char { let f = Foo { character }; - return f.character; + + let character = f.character == 'a' ? 'a' : f.character; + return character; } \ No newline at end of file diff --git a/tests/compiler/char/neq.leo b/tests/compiler/char/neq.leo new file mode 100644 index 0000000000..5605ce31b4 --- /dev/null +++ b/tests/compiler/char/neq.leo @@ -0,0 +1,14 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/ascii.in + - inputs/escaped_unicode.in + - inputs/escaped.in + - inputs/hex.in + - inputs/unicode.in +*/ + +function main(character: char) -> char { + return character != 'a' ? 'a' : 'Z'; +} \ No newline at end of file diff --git a/tests/compiler/char/output/output_char.out b/tests/compiler/char/output/output_char.out index 8c5c6ba182..323925e081 100644 --- a/tests/compiler/char/output/output_char.out +++ b/tests/compiler/char/output/output_char.out @@ -1,2 +1,2 @@ [registers] -r: char = a; +r: char = 'a'; diff --git a/tests/compiler/core/blake2s.leo b/tests/compiler/core/blake2s.leo index 8286c68fdd..2786313eba 100644 --- a/tests/compiler/core/blake2s.leo +++ b/tests/compiler/core/blake2s.leo @@ -1,9 +1,7 @@ -/* -namespace: Compile -expectation: Fail -input_files: - - input/dummy.in -*/ +// namespace: Compile +// expectation: Fail +// input_files: +// - input/dummy.in import core.unstable.blake2s.BadCircuit; // `BadCircuit` is not included in the blake2s package diff --git a/tests/compiler/core/unstable_blake2s.leo b/tests/compiler/core/unstable_blake2s.leo index 1229f457c4..6776d8a6ea 100644 --- a/tests/compiler/core/unstable_blake2s.leo +++ b/tests/compiler/core/unstable_blake2s.leo @@ -1,14 +1,12 @@ -/* -namespace: Compile -expectation: Pass -inputs: - - blake.in: | - [main] - message: [u8; 32] = [0; 32]; +// namespace: Compile +// expectation: Pass +// inputs: +// - blake.in: | +// [main] +// message: [u8; 32] = [0; 32]; - [registers] - r0: [u8; 32] = [0; 32]; -*/ +// [registers] +// r0: [u8; 32] = [0; 32]; import core.unstable.blake2s.Blake2s; diff --git a/tests/compiler/field/add.leo b/tests/compiler/field/add.leo new file mode 100644 index 0000000000..72633674a0 --- /dev/null +++ b/tests/compiler/field/add.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field, b: field, c: field) -> bool { + return a + b == c; +} \ No newline at end of file diff --git a/tests/compiler/field/div.leo b/tests/compiler/field/div.leo new file mode 100644 index 0000000000..4121623d52 --- /dev/null +++ b/tests/compiler/field/div.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field, b: field, c: field) -> bool { + return a / b != c; +} \ No newline at end of file diff --git a/tests/compiler/field/eq.leo b/tests/compiler/field/eq.leo new file mode 100644 index 0000000000..eed7a98757 --- /dev/null +++ b/tests/compiler/field/eq.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field, b: field) -> bool { + return a == b; +} \ No newline at end of file diff --git a/tests/compiler/field/field.leo b/tests/compiler/field/field.leo new file mode 100644 index 0000000000..89f6d7f84b --- /dev/null +++ b/tests/compiler/field/field.leo @@ -0,0 +1,11 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field) -> bool { + const negOneField: field = -1field; + return negOneField + a == 0field; +} \ No newline at end of file diff --git a/tests/compiler/field/inputs/fields.in b/tests/compiler/field/inputs/fields.in new file mode 100644 index 0000000000..8fed43e1cf --- /dev/null +++ b/tests/compiler/field/inputs/fields.in @@ -0,0 +1,7 @@ +[main] +a: field = 1field; +b: field = 1field; +c: field = 2field; + +[registers] +r: bool = false; \ No newline at end of file diff --git a/tests/compiler/_field/input/register_one.in b/tests/compiler/field/inputs/register_one.in similarity index 100% rename from tests/compiler/_field/input/register_one.in rename to tests/compiler/field/inputs/register_one.in diff --git a/tests/compiler/_field/input/register_zero.in b/tests/compiler/field/inputs/register_zero.in similarity index 100% rename from tests/compiler/_field/input/register_zero.in rename to tests/compiler/field/inputs/register_zero.in diff --git a/tests/compiler/field/mul.leo b/tests/compiler/field/mul.leo new file mode 100644 index 0000000000..26dcaf37f4 --- /dev/null +++ b/tests/compiler/field/mul.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field, b: field, c: field) -> bool { + return a * b == c; +} \ No newline at end of file diff --git a/tests/compiler/field/negate.leo b/tests/compiler/field/negate.leo new file mode 100644 index 0000000000..badf9c3da6 --- /dev/null +++ b/tests/compiler/field/negate.leo @@ -0,0 +1,10 @@ +/* +namespace: Compile +expectation: Pass +input_file: + - inputs/fields.in +*/ + +function main(a: field, b: field) -> bool { + return -a == -b; +} \ No newline at end of file diff --git a/tests/compiler/field/no_space_between_literal.leo b/tests/compiler/field/no_space_between_literal.leo new file mode 100644 index 0000000000..4f93b287be --- /dev/null +++ b/tests/compiler/field/no_space_between_literal.leo @@ -0,0 +1,8 @@ +/* +namespace: Compile +expectation: Fail +*/ + +function main() { + const f = 1 field; +} \ No newline at end of file diff --git a/tests/compiler/_field/output/register_one.out b/tests/compiler/field/output/register_one.out similarity index 100% rename from tests/compiler/_field/output/register_one.out rename to tests/compiler/field/output/register_one.out diff --git a/tests/compiler/_field/output/register_zero.out b/tests/compiler/field/output/register_zero.out similarity index 100% rename from tests/compiler/_field/output/register_zero.out rename to tests/compiler/field/output/register_zero.out diff --git a/tests/compiler/field/sub.leo b/tests/compiler/field/sub.leo new file mode 100644 index 0000000000..fe11701161 --- /dev/null +++ b/tests/compiler/field/sub.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field, c: field) -> bool { + return a - b == c; +} \ No newline at end of file diff --git a/tests/compiler/field/ternary.leo b/tests/compiler/field/ternary.leo new file mode 100644 index 0000000000..980b878248 --- /dev/null +++ b/tests/compiler/field/ternary.leo @@ -0,0 +1,3 @@ +function main(a: field, b: field, c: field) -> bool { + return b == 1field ? a == 1field : c == 2field; +} \ No newline at end of file diff --git a/tests/expectations/compiler/compiler/char/circuit.leo.out b/tests/expectations/compiler/compiler/char/circuit.leo.out index aaffccc60a..9a578e2249 100644 --- a/tests/expectations/compiler/compiler/char/circuit.leo.out +++ b/tests/expectations/compiler/compiler/char/circuit.leo.out @@ -1,5 +1,42 @@ --- namespace: Compile -expectation: Fail +expectation: Pass outputs: - - "- Circuit has no constraints, use inputs and registers in program to produce them" + - circuit: + num_public_variables: 0 + num_private_variables: 6 + num_constraints: 4 + at: 2859fe6f24016b5634df2791da7de932e68ec32c73b5b573e0c39e968c7a4e12 + bt: 8143508f19c8eee208a7fbbcfb833aeeace6ba0a761e41d028599d2237cc60fa + ct: d0c6feeed1e6b8d5c0e03dc9e25641b7fdc34ad912e2b1488296d4a99ed6cbf5 + output: + - input_file: inputs/ascii.in + output: + registers: + r: + type: char + value: a + - input_file: inputs/escaped_unicode.in + output: + registers: + r: + type: char + value: ❤ + - input_file: inputs/escaped.in + output: + registers: + r: + type: char + value: "'" + - input_file: inputs/hex.in + output: + registers: + r: + type: char + value: "\n" + - input_file: inputs/unicode.in + output: + registers: + r: + type: char + value: ❤ diff --git a/tests/expectations/compiler/compiler/char/neq.leo.out b/tests/expectations/compiler/compiler/char/neq.leo.out new file mode 100644 index 0000000000..48f1729114 --- /dev/null +++ b/tests/expectations/compiler/compiler/char/neq.leo.out @@ -0,0 +1,42 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 6 + num_constraints: 3 + at: cc1286e0b6fa2e90fb6f0880431a7c1e2cc37a329fae3aff1c13f51036c66f12 + bt: 02c492cb6df07172e56cffd0cfd902a8443921e1256a2d907bbabd30bf6b8f6d + ct: a1f8e2b168c0f2f28f0ca3f16ce9b25ba7f7c410cfd68b0912bf19c90b53f2a2 + output: + - input_file: inputs/ascii.in + output: + registers: + r: + type: char + value: Z + - input_file: inputs/escaped_unicode.in + output: + registers: + r: + type: char + value: a + - input_file: inputs/escaped.in + output: + registers: + r: + type: char + value: a + - input_file: inputs/hex.in + output: + registers: + r: + type: char + value: a + - input_file: inputs/unicode.in + output: + registers: + r: + type: char + value: a diff --git a/tests/expectations/compiler/compiler/core/blake2s.leo.out b/tests/expectations/compiler/compiler/core/blake2s.leo.out deleted file mode 100644 index 07c482845a..0000000000 --- a/tests/expectations/compiler/compiler/core/blake2s.leo.out +++ /dev/null @@ -1,5 +0,0 @@ ---- -namespace: Compile -expectation: Fail -outputs: - - " --> compiler-test:3:30\n |\n 3 | import core.unstable.blake2s.BadCircuit; // `BadCircuit` is not included in the blake2s package\n | ^^^^^^^^^^\n |\n = failed to resolve import: 'core.unstable.blake2s.BadCircuit'" diff --git a/tests/expectations/compiler/compiler/core/unstable_blake2s.leo.out b/tests/expectations/compiler/compiler/core/unstable_blake2s.leo.out deleted file mode 100644 index 32b64e0840..0000000000 --- a/tests/expectations/compiler/compiler/core/unstable_blake2s.leo.out +++ /dev/null @@ -1,18 +0,0 @@ ---- -namespace: Compile -expectation: Pass -outputs: - - circuit: - num_public_variables: 0 - num_private_variables: 20168 - num_constraints: 20472 - at: 43b5f7bd5efbf13ae0684e3c506e5e28866ce7a29f5d6b1442925913bb07a73b - bt: 4d435c1eac471fb7b40b0d83503e2aa13f49db68fc71d64be84ddc9cb053a15d - ct: 081e529f5d26cb4cea2d8288ad454a8d0b381f2fb81e0bd21b47d4186777504f - output: - - input_file: blake.in - output: - registers: - r0: - type: "[u8; 32]" - value: "[213, 24, 235, 180, 216, 116, 28, 65, 88, 162, 204, 6, 23, 8, 66, 112, 214, 239, 242, 134, 165, 39, 172, 247, 65, 130, 155, 2, 97, 147, 14, 57]" diff --git a/tests/expectations/compiler/compiler/field/add.leo.out b/tests/expectations/compiler/compiler/field/add.leo.out new file mode 100644 index 0000000000..b2d25bf815 --- /dev/null +++ b/tests/expectations/compiler/compiler/field/add.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 5 + num_constraints: 3 + at: 58e404664f2d64d2fd5fee64bf6e997f542a822b8b17e394fcdd7bed05386db8 + bt: f91b8601243dbd0d25e7df8f34ff304ca78a295fdfafbe0102ec6ce4fcb3c0f0 + ct: fe68b86a12c0b8c1585a656d7c4b8c47fbe19677b5da7ce0aae1d80dffb2a2ca + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/field/div.leo.out b/tests/expectations/compiler/compiler/field/div.leo.out new file mode 100644 index 0000000000..49a15b380a --- /dev/null +++ b/tests/expectations/compiler/compiler/field/div.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 7 + num_constraints: 5 + at: 545f3730dcbdb3a3dff41db4263dd41f9be9cf279fdc3cde9518973db0c88685 + bt: 0a5ae5a6be6351f852bbcc193e57320be38fff279cf6fd65a3239c3a64239b27 + ct: f25b05da849d0d7fcaab89d41d9624efacb48b7ba983f73a0d5f383b16f7009b + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/field/eq.leo.out b/tests/expectations/compiler/compiler/field/eq.leo.out new file mode 100644 index 0000000000..9dcbe87829 --- /dev/null +++ b/tests/expectations/compiler/compiler/field/eq.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 4 + num_constraints: 3 + at: ca775a363045cd405dd1d60cd10edb6cc6e4c0b164934951dab0977509b8225c + bt: 02c492cb6df07172e56cffd0cfd902a8443921e1256a2d907bbabd30bf6b8f6d + ct: a1f8e2b168c0f2f28f0ca3f16ce9b25ba7f7c410cfd68b0912bf19c90b53f2a2 + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/field/field.leo.out b/tests/expectations/compiler/compiler/field/field.leo.out new file mode 100644 index 0000000000..f7461da86f --- /dev/null +++ b/tests/expectations/compiler/compiler/field/field.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 4 + num_constraints: 3 + at: cfcc3adf871aef0910034c4c3478746733a9746d44fd678971ee2e1e5e69dffd + bt: 02c492cb6df07172e56cffd0cfd902a8443921e1256a2d907bbabd30bf6b8f6d + ct: a1f8e2b168c0f2f28f0ca3f16ce9b25ba7f7c410cfd68b0912bf19c90b53f2a2 + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/field/mul.leo.out b/tests/expectations/compiler/compiler/field/mul.leo.out new file mode 100644 index 0000000000..6c7beec523 --- /dev/null +++ b/tests/expectations/compiler/compiler/field/mul.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 6 + num_constraints: 4 + at: 7dcea624bdc7a6e6fb5f5e93395e84a96db66898779eb3f5595c4e30e3684f17 + bt: c21a8e9f463d2fad68fd3a88904dd88f2a3dc7dcb01835357fa4ee457ef1673b + ct: 4b4ef106804964b8a1ee7c1dad3d4682d20a0d07f576130bfec9989b353bf596 + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "false" diff --git a/tests/expectations/compiler/compiler/field/negate.leo.out b/tests/expectations/compiler/compiler/field/negate.leo.out new file mode 100644 index 0000000000..eb7c04c512 --- /dev/null +++ b/tests/expectations/compiler/compiler/field/negate.leo.out @@ -0,0 +1,18 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - circuit: + num_public_variables: 0 + num_private_variables: 4 + num_constraints: 3 + at: cc1286e0b6fa2e90fb6f0880431a7c1e2cc37a329fae3aff1c13f51036c66f12 + bt: 02c492cb6df07172e56cffd0cfd902a8443921e1256a2d907bbabd30bf6b8f6d + ct: a1f8e2b168c0f2f28f0ca3f16ce9b25ba7f7c410cfd68b0912bf19c90b53f2a2 + output: + - input_file: inputs/fields.in + output: + registers: + r: + type: bool + value: "true" diff --git a/tests/expectations/compiler/compiler/field/no_space_between_literal.leo.out b/tests/expectations/compiler/compiler/field/no_space_between_literal.leo.out new file mode 100644 index 0000000000..ad72f642e2 --- /dev/null +++ b/tests/expectations/compiler/compiler/field/no_space_between_literal.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - " --> compiler-test:4:13\n |\n 4 | const f = 1 field;\n | ^\n |\n = Unexpected white space between terms 1 and field"