diff --git a/relations/Cargo.lock b/relations/Cargo.lock new file mode 100644 index 0000000..f113852 --- /dev/null +++ b/relations/Cargo.lock @@ -0,0 +1,870 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "colored", + "num-traits", + "rand", +] + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "colored" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +dependencies = [ + "lazy_static", + "windows-sys", +] + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "bitvec", + "rand_core", + "subtle", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getset" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e45727250e75cc04ff2846a66397da8ef2b3db8e40e0cef4df67950a07621eb9" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "halo2-axiom" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea1da345120b2651db0dd59be8fdf30b7e7472f00c8322203023caa2e6903e2" +dependencies = [ + "blake2b_simd", + "crossbeam", + "ff", + "group", + "halo2curves-axiom", + "itertools", + "maybe-rayon", + "pairing", + "rand", + "rand_core", + "rustc-hash", + "sha3", + "tracing", +] + +[[package]] +name = "halo2-base" +version = "0.4.1" +source = "git+https://github.com/Cardinal-Cryptography/halo2-lib?branch=aleph#97afc4a9cd94101e52acd6f08a8cd44f64c2c6cf" +dependencies = [ + "ark-std", + "getset", + "halo2-axiom", + "itertools", + "log", + "num-bigint", + "num-integer", + "num-traits", + "poseidon-primitives", + "rand", + "rand_chacha", + "rayon", + "rustc-hash", + "serde", + "serde_json", +] + +[[package]] +name = "halo2curves" +version = "0.6.0" +source = "git+https://github.com/privacy-scaling-explorations/halo2curves.git?tag=v0.6.0#e4185d64e49e7a0733ca5109fc68c3ad87be9788" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "lazy_static", + "num-bigint", + "num-traits", + "pairing", + "pasta_curves", + "paste", + "rand", + "rand_core", + "rayon", + "static_assertions", + "subtle", +] + +[[package]] +name = "halo2curves-axiom" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1f0b8f4b7dc27d1e438dae6573e8d95c9f6ee568d1d21146a4c34c17db2ad38" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "hex", + "lazy_static", + "maybe-rayon", + "num-bigint", + "num-traits", + "pairing", + "pasta_curves", + "paste", + "rand", + "rand_core", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" + +[[package]] +name = "liminal-halo2-relations" +version = "0.0.0" +dependencies = [ + "halo2-base", + "poseidon", + "rand", + "serde", + "serde_json", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", + "rand", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group", +] + +[[package]] +name = "pasta_curves" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "lazy_static", + "rand", + "static_assertions", + "subtle", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "poseidon" +version = "0.2.0" +source = "git+https://github.com/zemse/pse-poseidon#d9fc8c785fe48d1177b11eb9c785ea648c28e464" +dependencies = [ + "halo2curves", + "subtle", +] + +[[package]] +name = "poseidon-primitives" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd95570f7ea849b4187298b5bb229643e44e1d47ddf3979d0db8a1c28be26a8" +dependencies = [ + "bitvec", + "ff", + "lazy_static", + "log", + "rand", + "rand_xorshift", + "thiserror", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rayon" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "ryu" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" + +[[package]] +name = "serde" +version = "1.0.195" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_arrays" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.195" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "serde_json" +version = "1.0.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "thiserror" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] diff --git a/relations/Cargo.toml b/relations/Cargo.toml new file mode 100644 index 0000000..44c8f6b --- /dev/null +++ b/relations/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "liminal-halo2-relations" +version = "0.0.0" +edition = "2021" +authors = ["Cardinal"] +documentation = "https://docs.rs/?" +homepage = "https://alephzero.org" +license = "Apache-2.0" +categories = ["cryptography"] +keywords = ["cryptography", "snark", "zero-knowledge", "liminal", "shielder"] +repository = "https://github.com/Cardinal-Cryptography/zk-apps" +description = "A collection of halo2-based relations for use in liminal." + +[dependencies] +rand = "=0.8" +serde = { version = "=1.0", default-features = false, features = ["derive"] } +serde_json = "=1.0" + +halo2-base = { package = "halo2-base", git = "https://github.com/Cardinal-Cryptography/halo2-lib", branch = "aleph" } + + +#[dev-dependencies] +# Fork with halo2curves = 0.6 to match the version of halo2-base +poseidon = { git = "https://github.com/zemse/pse-poseidon" } diff --git a/relations/README.md b/relations/README.md new file mode 100644 index 0000000..ae5b0b9 --- /dev/null +++ b/relations/README.md @@ -0,0 +1,11 @@ +#Notes and Accounts + +#Relations + +#Tests + +``` +cargo test +``` + +#Benchmarks \ No newline at end of file diff --git a/relations/rust-toolchain.toml b/relations/rust-toolchain.toml new file mode 100644 index 0000000..8fda2d9 --- /dev/null +++ b/relations/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly-2023-12-21" diff --git a/relations/src/account.rs b/relations/src/account.rs new file mode 100644 index 0000000..5732ac8 --- /dev/null +++ b/relations/src/account.rs @@ -0,0 +1,21 @@ +use halo2_base::{gates::GateChip, utils::BigPrimeField, AssignedValue, Context}; + +use crate::{ + operation::{CircuitOperation, Operation}, + CloneToVec, +}; + +pub trait Account: CloneToVec { + type CircuitAccount: CircuitAccount; + type Op: Operation; + + fn update(&self, op: &Self::Op) -> Self; + + fn load(&self, ctx: &mut Context) -> Self::CircuitAccount; +} + +pub trait CircuitAccount: CloneToVec> { + type Op: CircuitOperation; + + fn update(&self, op: Self::Op, ctx: &mut Context, gate: &GateChip) -> Self; +} diff --git a/relations/src/lib.rs b/relations/src/lib.rs new file mode 100644 index 0000000..a1e73bd --- /dev/null +++ b/relations/src/lib.rs @@ -0,0 +1,26 @@ +pub mod account; +pub mod merkle_proof; +pub mod note; +pub mod operation; +pub mod relations; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum Token { + AZERO, + USDT, +} + +pub trait CloneToVec { + fn clone_to_vec(&self) -> Vec; +} + +pub mod poseidon_consts { + /// Has to be greater than 1 and equal to RATE + 1, due to the outer Poseidon implementation. + pub const T_WIDTH: usize = RATE + 1; + + pub const RATE: usize = 4; + + pub const R_F: usize = 8; + + pub const R_P: usize = 56; +} diff --git a/relations/src/merkle_proof.rs b/relations/src/merkle_proof.rs new file mode 100644 index 0000000..8e70117 --- /dev/null +++ b/relations/src/merkle_proof.rs @@ -0,0 +1,62 @@ +use halo2_base::{ + gates::{GateChip, GateInstructions}, + poseidon::hasher::PoseidonHasher, + utils::BigPrimeField, + AssignedValue, Context, +}; + +use crate::poseidon_consts::{RATE, T_WIDTH}; + +#[derive(Clone, Debug)] +pub struct MerkleProof { + pub path_shape: [bool; TREE_HEIGHT], + pub path: [F; TREE_HEIGHT], +} + +#[derive(Clone, Debug)] +pub struct CircuitMerkleProof { + pub path_shape: [AssignedValue; TREE_HEIGHT], + pub path: [AssignedValue; TREE_HEIGHT], +} + +impl MerkleProof { + pub fn new(path_shape: [bool; TREE_HEIGHT], path: [F; TREE_HEIGHT]) -> Self { + Self { path_shape, path } + } + + pub fn load(&self, ctx: &mut Context) -> CircuitMerkleProof { + let path_shape = self + .path_shape + .map(|x| ctx.load_witness(F::from_u128(x as u128))); + let path = self.path.map(|x| ctx.load_witness(x)); + + CircuitMerkleProof { path_shape, path } + } +} + +impl CircuitMerkleProof { + pub fn verify( + &self, + ctx: &mut Context, + gate: &GateChip, + poseidon: &mut PoseidonHasher, + root: AssignedValue, + leaf: AssignedValue, + ) { + let mut current_node = leaf; + + // TREE_HIGHT is definied in a way that path[TREE_HIGHT] would be the root + for i in 0..TREE_HEIGHT { + let sibling = self.path[i]; + let shape = self.path_shape[i]; + + let selector = gate.is_zero(ctx, shape); + let left = gate.select(ctx, sibling, current_node, selector); + let right = gate.select(ctx, current_node, sibling, selector); + current_node = poseidon.hash_fix_len_array(ctx, gate, &[left, right]); + } + + let eq = gate.is_equal(ctx, current_node, root); + gate.assert_is_const(ctx, &eq, &F::ONE); + } +} diff --git a/relations/src/note.rs b/relations/src/note.rs new file mode 100644 index 0000000..692bf5c --- /dev/null +++ b/relations/src/note.rs @@ -0,0 +1,51 @@ +use halo2_base::{utils::ScalarField, AssignedValue, Context}; + +use crate::CloneToVec; + +#[derive(Clone, Copy, Debug)] +pub struct Note { + pub zk_id: F, + pub trapdoor: F, + pub nullifier: F, + pub account_hash: F, +} + +impl Note { + pub fn new(note_id: F, trapdoor: F, nullifier: F, account_hash: F) -> Self { + Self { + zk_id: note_id, + trapdoor, + nullifier, + account_hash, + } + } + + pub fn load(&self, ctx: &mut Context) -> CircuitNote { + CircuitNote { + zk_id: ctx.load_witness(self.zk_id), + trapdoor: ctx.load_witness(self.trapdoor), + nullifier: ctx.load_witness(self.nullifier), + account_hash: ctx.load_witness(self.account_hash), + } + } +} + +impl CloneToVec for Note { + fn clone_to_vec(&self) -> Vec { + vec![self.zk_id, self.trapdoor, self.nullifier, self.account_hash] + } +} + +#[derive(Clone, Copy, Debug)] +pub struct CircuitNote { + pub zk_id: AssignedValue, + pub trapdoor: AssignedValue, + pub nullifier: AssignedValue, + pub account_hash: AssignedValue, +} + +impl CloneToVec> for CircuitNote { + fn clone_to_vec(&self) -> Vec> { + vec![self.zk_id, self.trapdoor, self.nullifier, self.account_hash] + } +} diff --git a/relations/src/operation.rs b/relations/src/operation.rs new file mode 100644 index 0000000..970b3aa --- /dev/null +++ b/relations/src/operation.rs @@ -0,0 +1,23 @@ +use halo2_base::{utils::BigPrimeField, AssignedValue, Context}; + +pub trait Operation +where + Self: Sized, + F: BigPrimeField, +{ + type OpPriv: Into>; + type OpPub: Into>; + + fn combine(op_priv: Self::OpPriv, op_pub: Self::OpPub) -> Option; +} + +pub trait CircuitOperation +where + Self: Sized, + F: BigPrimeField, +{ + type OpPriv: From>>; + type OpPub: From>> + Into>> + Clone; + + fn combine(op_priv: Self::OpPriv, op_pub: Self::OpPub) -> Option; +} diff --git a/relations/src/relations/mod.rs b/relations/src/relations/mod.rs new file mode 100644 index 0000000..5216424 --- /dev/null +++ b/relations/src/relations/mod.rs @@ -0,0 +1,2 @@ +pub mod update_account; +pub mod update_note; diff --git a/relations/src/relations/update_account.rs b/relations/src/relations/update_account.rs new file mode 100644 index 0000000..a47ccd6 --- /dev/null +++ b/relations/src/relations/update_account.rs @@ -0,0 +1,95 @@ +use halo2_base::{ + gates::{GateChip, GateInstructions}, + poseidon::hasher::{spec::OptimizedPoseidonSpec, PoseidonHasher}, + utils::BigPrimeField, + AssignedValue, +}; +#[allow(unused_imports)] +use halo2_base::{ + Context, + QuantumCell::{Constant, Existing, Witness}, +}; + +use crate::{ + account::CircuitAccount, + poseidon_consts::{RATE, R_F, R_P, T_WIDTH}, +}; + +pub struct UpdateAccountInput +where + F: BigPrimeField, + A: CircuitAccount, +{ + //public inputs + pub old_account_hash: AssignedValue, + pub new_account_hash: AssignedValue, + pub operation: A::Op, + + //witnesses + pub old_account: A, +} + +impl UpdateAccountInput +where + F: BigPrimeField, + A: CircuitAccount, +{ + pub fn new( + old_account_hash: AssignedValue, + new_account_hash: AssignedValue, + operation: A::Op, + old_account: A, + ) -> Self { + Self { + old_account_hash, + new_account_hash, + operation, + old_account, + } + } +} + +pub fn verify_account_circuit( + ctx: &mut Context, + gate: &GateChip, + poseidon: &mut PoseidonHasher, + account: &A, + account_hash: AssignedValue, +) where + F: BigPrimeField, + A: CircuitAccount, +{ + let inner_account_hash = poseidon.hash_fix_len_array(ctx, gate, &account.clone_to_vec()); + let eq = gate.is_equal(ctx, account_hash, inner_account_hash); + gate.assert_is_const(ctx, &eq, &F::ONE); +} + +#[allow(dead_code)] +pub fn update_account_circuit(ctx: &mut Context, input: UpdateAccountInput) +where + F: BigPrimeField, + A: CircuitAccount, +{ + let gate = GateChip::::default(); + let mut poseidon = + PoseidonHasher::::new(OptimizedPoseidonSpec::new::()); + poseidon.initialize_consts(ctx, &gate); + + let old_account = input.old_account; + verify_account_circuit( + ctx, + &gate, + &mut poseidon, + &old_account, + input.old_account_hash, + ); + + let new_account = old_account.update(input.operation, ctx, &gate); + verify_account_circuit( + ctx, + &gate, + &mut poseidon, + &new_account, + input.new_account_hash, + ); +} diff --git a/relations/src/relations/update_note.rs b/relations/src/relations/update_note.rs new file mode 100644 index 0000000..d6e6249 --- /dev/null +++ b/relations/src/relations/update_note.rs @@ -0,0 +1,149 @@ +use halo2_base::{ + gates::{GateChip, GateInstructions}, + poseidon::hasher::{spec::OptimizedPoseidonSpec, PoseidonHasher}, + utils::BigPrimeField, + AssignedValue, Context, +}; + +use super::update_account::{update_account_circuit, UpdateAccountInput}; +use crate::{ + account::{Account, CircuitAccount}, + merkle_proof::{CircuitMerkleProof, MerkleProof}, + note::{CircuitNote, Note}, + operation::{CircuitOperation, Operation}, + poseidon_consts::{RATE, R_F, R_P, T_WIDTH}, + CloneToVec, +}; + +type OpFor = <>::CircuitAccount as CircuitAccount>::Op; + +pub struct UpdateNoteInput +where + F: BigPrimeField, + A: Account, +{ + //public inputs + pub op_pub: as CircuitOperation>::OpPub, + pub new_note_hash: AssignedValue, + pub merkle_root: AssignedValue, + //old_note.nullifier is also a public input + + //witnesses + pub new_note: CircuitNote, + pub old_note: CircuitNote, + pub merkle_proof: CircuitMerkleProof, + pub op_priv: as CircuitOperation>::OpPriv, + + pub old_account: >::CircuitAccount, +} + +//helper functions +#[allow(clippy::too_many_arguments)] +impl UpdateNoteInput +where + F: BigPrimeField, + A: Account, +{ + pub fn new( + ctx: &mut Context, + op_pub: >::OpPub, + new_note_hash: F, + merkle_root: F, + new_note: Note, + old_note: Note, + merkle_proof: MerkleProof, + op_priv: >::OpPriv, + old_account: A, + ) -> Self { + let op_pub = op_pub + .into() + .iter() + .map(|x| ctx.load_witness(*x)) + .collect::>>() + .into(); + let new_note_hash = ctx.load_witness(new_note_hash); + let merkle_root = ctx.load_witness(merkle_root); + let new_note = new_note.load(ctx); + let old_note = old_note.load(ctx); + let merkle_proof = merkle_proof.load(ctx); + let op_priv = op_priv + .into() + .iter() + .map(|x| ctx.load_witness(*x)) + .collect::>>() + .into(); + + let old_account = old_account.load(ctx); + + Self { + op_pub, + new_note_hash, + merkle_root, + new_note, + old_note, + merkle_proof, + op_priv, + old_account, + } + } +} + +fn verify_note_circuit( + ctx: &mut Context, + gate: &GateChip, + poseidon: &mut PoseidonHasher, + note: &CircuitNote, + note_hash: AssignedValue, +) where + F: BigPrimeField, +{ + let inner_note_hash = poseidon.hash_fix_len_array(ctx, gate, ¬e.clone_to_vec()); + let eq = gate.is_equal(ctx, note_hash, inner_note_hash); + gate.assert_is_const(ctx, &eq, &F::ONE); +} + +#[allow(dead_code)] +pub fn update_note_circuit( + ctx: &mut Context, + input: UpdateNoteInput, + make_public: &mut Vec>, +) where + F: BigPrimeField, + A: Account, +{ + let gate = GateChip::::default(); + let mut poseidon = + PoseidonHasher::::new(OptimizedPoseidonSpec::new::()); + poseidon.initialize_consts(ctx, &gate); + + let op_pub = input.op_pub; + + make_public.extend(op_pub.clone().into()); + + let new_note_hash = input.new_note_hash; + let merkle_root = input.merkle_root; + let old_nullifier = input.old_note.nullifier; + + make_public.extend([new_note_hash, merkle_root, old_nullifier]); + + verify_note_circuit(ctx, &gate, &mut poseidon, &input.new_note, new_note_hash); + + let old_note_hash = poseidon.hash_fix_len_array(ctx, &gate, &input.old_note.clone_to_vec()); + + let merkle_proof = input.merkle_proof; + + merkle_proof.verify(ctx, &gate, &mut poseidon, merkle_root, old_note_hash); + + let op_priv = input.op_priv; + + let operation = CircuitOperation::combine(op_priv, op_pub).unwrap(); + + let update_account_input = UpdateAccountInput::new( + input.old_note.account_hash, + input.new_note.account_hash, + operation, + input.old_account, + ); + + update_account_circuit(ctx, update_account_input); +}