From e6025177034d2e0885fe5abadbf41d091a935ecf Mon Sep 17 00:00:00 2001 From: Gabriel Barreto Date: Tue, 4 Feb 2025 14:01:49 -0300 Subject: [PATCH] eiur migration --- Cargo.lock | 1885 ++++++++++++++++++++++++++++++++++ Cargo.toml | 11 + src/eiur/binius.rs | 13 + src/eiur/execute.rs | 373 +++++++ src/eiur/gadgets/mod.rs | 55 + src/eiur/gadgets/uint_add.rs | 178 ++++ src/eiur/gadgets/uint_sub.rs | 169 +++ src/eiur/ir.rs | 69 ++ src/eiur/mod.rs | 4 + src/lib.rs | 2 + 10 files changed, 2759 insertions(+) create mode 100644 src/eiur/binius.rs create mode 100644 src/eiur/execute.rs create mode 100644 src/eiur/gadgets/mod.rs create mode 100644 src/eiur/gadgets/uint_add.rs create mode 100644 src/eiur/gadgets/uint_sub.rs create mode 100644 src/eiur/ir.rs create mode 100644 src/eiur/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 85a54803..adc0dc65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,1891 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "alloy-primitives" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc1360603efdfba91151e623f13a4f4d3dc4af4adc1cbd90bf37c81e84db4c77" +dependencies = [ + "alloy-rlp", + "bytes", + "cfg-if", + "const-hex", + "derive_more 1.0.0", + "foldhash", + "hashbrown", + "indexmap", + "itoa", + "k256", + "keccak-asm", + "paste", + "proptest", + "rand", + "ruint", + "rustc-hash", + "serde", + "sha3", + "tiny-keccak", +] + +[[package]] +name = "alloy-rlp" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6c1d995bff8d011f7cd6c81820d51825e6e06d6db73914c1630ecf544d83d6" +dependencies = [ + "arrayvec", + "bytes", +] + +[[package]] +name = "anyhow" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" + +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm 0.3.0", + "ark-ff-macros 0.3.0", + "ark-serialize 0.3.0", + "ark-std 0.3.0", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.3.3", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm 0.4.2", + "ark-ff-macros 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.4.1", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-std 0.3.0", + "digest 0.9.0", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-std 0.4.0", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + +[[package]] +name = "auto_impl" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12882f59de5360c748c4cbf569a042d5fb0eb515f7bea9c1f470b47f6ffbd73" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "binius_circuits" +version = "0.2.0" +source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +dependencies = [ + "alloy-primitives", + "anyhow", + "binius_core", + "binius_field", + "binius_hash", + "binius_macros", + "binius_math", + "binius_utils", + "bumpalo", + "bytemuck", + "itertools 0.13.0", + "rand", + "rayon", + "tiny-keccak", + "tracing", +] + +[[package]] +name = "binius_core" +version = "0.2.0" +source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +dependencies = [ + "assert_matches", + "auto_impl", + "binius_field", + "binius_hal", + "binius_hash", + "binius_math", + "binius_ntt", + "binius_utils", + "bytemuck", + "bytes", + "derive_more 0.99.19", + "digest 0.10.7", + "either", + "getset", + "itertools 0.13.0", + "rand", + "rayon", + "stackalloc", + "thiserror", + "tracing", + "trait-set", + "transpose", +] + +[[package]] +name = "binius_field" +version = "0.2.0" +source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +dependencies = [ + "binius_utils", + "bytemuck", + "bytes", + "cfg-if", + "derive_more 0.99.19", + "rand", + "rayon", + "seq-macro", + "subtle", + "thiserror", + "tracing", + "transpose", +] + +[[package]] +name = "binius_hal" +version = "0.2.0" +source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +dependencies = [ + "auto_impl", + "binius_field", + "binius_math", + "binius_utils", + "bytemuck", + "itertools 0.13.0", + "rand", + "rayon", + "stackalloc", + "thiserror", + "tracing", +] + +[[package]] +name = "binius_hash" +version = "0.2.0" +source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +dependencies = [ + "binius_field", + "binius_ntt", + "binius_utils", + "bytemuck", + "bytes", + "cfg-if", + "digest 0.10.7", + "groestl", + "lazy_static", + "sha2", + "thiserror", +] + +[[package]] +name = "binius_macros" +version = "0.2.0" +source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "binius_math" +version = "0.2.0" +source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +dependencies = [ + "auto_impl", + "binius_field", + "binius_utils", + "bytemuck", + "either", + "getset", + "itertools 0.13.0", + "rand", + "rayon", + "stackalloc", + "thiserror", + "tracing", +] + +[[package]] +name = "binius_ntt" +version = "0.2.0" +source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +dependencies = [ + "binius_field", + "binius_math", + "binius_utils", + "rand", + "rayon", + "thiserror", +] + +[[package]] +name = "binius_utils" +version = "0.2.0" +source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +dependencies = [ + "bytemuck", + "bytes", + "generic-array", + "itertools 0.13.0", + "rayon", + "thiserror", + "thread_local", +] + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" + +[[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 = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "bytemuck" +version = "1.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" + +[[package]] +name = "cc" +version = "1.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "755717a7de9ec452bf7f3f1a3099085deabd7f2962b861dae91ecd7a365903d2" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-hex" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b0485bab839b018a8f1723fc5391819fea5f8f0f32288ef8a735fd096b6160c" +dependencies = [ + "cfg-if", + "cpufeatures", + "hex", + "proptest", + "serde", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +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-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crunchy" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[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 = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da29a38df43d6f156149c9b43ded5e018ddff2a855cf2cfd62e8cd7d079c69f" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version 0.4.1", + "syn 2.0.98", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", + "unicode-xid", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fastrlp" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + +[[package]] +name = "fastrlp" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce8dba4714ef14b8274c371879b175aa55b16b30f269663f19d576f380018dc4" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" + +[[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", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", +] + +[[package]] +name = "getset" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded738faa0e88d3abc9d1a13cb11adc2073c400969eeb8793cf7132589959fc" +dependencies = [ + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "groestl" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343cfc165f92a988fd60292f7a0bfde4352a5a0beff9fbec29251ca4e9676e4d" +dependencies = [ + "digest 0.10.7", +] + +[[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 = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "indexmap" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + [[package]] name = "ix" version = "0.1.0" +dependencies = [ + "anyhow", + "binius_circuits", + "binius_core", + "binius_field", + "binius_macros", + "binius_math", + "bumpalo", + "bytemuck", + "proptest", + "rayon", + "rustc-hash", +] + +[[package]] +name = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "keccak-asm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "505d1856a39b200489082f90d897c3f07c455563880bc5952e38eabf731c83b6" +dependencies = [ + "digest 0.10.7", + "sha3-asm", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "libm" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "parity-scale-codec" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pest" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proptest" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" +dependencies = [ + "bit-set", + "bit-vec", + "bitflags", + "lazy_static", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax", + "rusty-fork", + "tempfile", + "unarray", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +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 0.2.15", +] + +[[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.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +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 = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "ruint" +version = "1.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5ef8fb1dd8de3870cb8400d51b4c2023854bbafd5431a3ac7e7317243e22d2f" +dependencies = [ + "alloy-rlp", + "ark-ff 0.3.0", + "ark-ff 0.4.2", + "bytes", + "fastrlp 0.3.1", + "fastrlp 0.4.0", + "num-bigint", + "num-integer", + "num-traits", + "parity-scale-codec", + "primitive-types", + "proptest", + "rand", + "rlp", + "ruint-macro", + "serde", + "valuable", + "zeroize", +] + +[[package]] +name = "ruint-macro" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" + +[[package]] +name = "rustc-hash" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver 1.0.25", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rusty-fork" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +dependencies = [ + "fnv", + "quick-error", + "tempfile", + "wait-timeout", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser 0.7.0", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser 0.10.3", +] + +[[package]] +name = "semver" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "semver-parser" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9900206b54a3527fdc7b8a938bffd94a568bac4f4aa8113b209df75a09c0dec2" +dependencies = [ + "pest", +] + +[[package]] +name = "seq-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" + +[[package]] +name = "serde" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + +[[package]] +name = "sha3-asm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28efc5e327c837aa837c59eae585fc250715ef939ac32881bcc11677cd02d46" +dependencies = [ + "cc", + "cfg-if", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "stackalloc" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b5b7088084b7f78305a42468c9a3693918620f0b8ec86260f1132dc0521e78" +dependencies = [ + "cc", + "rustc_version 0.2.3", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[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.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +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 = "tempfile" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +dependencies = [ + "cfg-if", + "fastrand", + "getrandom 0.3.1", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "thiserror" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" + +[[package]] +name = "toml_edit" +version = "0.22.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", +] + +[[package]] +name = "trait-set" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b79e2e9c9ab44c6d7c20d5976961b47e8f49ac199154daa514b77cd1ab536625" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "transpose" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" +dependencies = [ + "num-integer", + "strength_reduce", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wait-timeout" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" +dependencies = [ + "libc", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] diff --git a/Cargo.toml b/Cargo.toml index 5e0d5391..1ff23c1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,14 @@ version = "0.1.0" edition = "2021" [dependencies] +anyhow = "1" +rustc-hash = "2" +binius_core = { git = "https://gitlab.com/IrreducibleOSS/binius.git", rev = "0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" } +binius_circuits = { git = "https://gitlab.com/IrreducibleOSS/binius.git", rev = "0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" } +binius_field = { git = "https://gitlab.com/IrreducibleOSS/binius.git", rev = "0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" } +binius_macros = { git = "https://gitlab.com/IrreducibleOSS/binius.git", rev = "0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" } +binius_math = { git = "https://gitlab.com/IrreducibleOSS/binius.git", rev = "0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" } +bytemuck = "1" +bumpalo = "3" +proptest = "1" +rayon = "1" diff --git a/src/eiur/binius.rs b/src/eiur/binius.rs new file mode 100644 index 00000000..a06fc1e0 --- /dev/null +++ b/src/eiur/binius.rs @@ -0,0 +1,13 @@ +use binius_circuits::builder::witness::Builder; +use binius_core::constraint_system::ConstraintSystem; +use binius_field::{as_packed_field::PackScalar, TowerField}; +use bumpalo::Bump; +use std::{cell::RefCell, rc::Rc}; + +#[inline] +pub fn witness_builder<'a, F: TowerField, U: PackScalar>( + allocator: &'a Bump, + cs: &ConstraintSystem, +) -> Builder<'a, U, F> { + Builder::new(allocator, Rc::new(RefCell::new(cs.oracles.clone()))) +} diff --git a/src/eiur/execute.rs b/src/eiur/execute.rs new file mode 100644 index 00000000..e598cfef --- /dev/null +++ b/src/eiur/execute.rs @@ -0,0 +1,373 @@ +use rustc_hash::FxHashMap; + +use super::ir::{Ctrl, FuncIdx, Op, Prim, Toplevel, ValIdx}; + +/// `Value` defines actual primitive types supported by Eiur-rs +#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] +pub enum Value { + U32(u32), + Bool(bool), +} + +/// `QueryResult` is an output of the particular function. The `TopLevel` may contain multiply +/// functions, and for each one executed, it generates one `QueryResult` objects that contains +/// output for a given function +#[derive(PartialEq, Debug)] +pub struct QueryResult { + pub values: Vec, + pub multiplicity: u32, +} + +/// `QueryRecord` is a collection of `QueryResult` objects that can be referenced by the input tuple +/// used while invoking `TopLevel` execution algorithm +#[derive(Default)] +pub struct QueryRecord { + pub queries: FxHashMap<(FuncIdx, Vec), QueryResult>, + // pub queries_inv: FxHashMap<(FuncIdx, Vec), Vec>, +} + +enum ExecEntry<'a> { + Op(&'a Op), + Ctrl(&'a Ctrl), +} + +struct CallerState { + func_idx: FuncIdx, + map: Vec, +} + +impl Toplevel { + /// Implementation of the execution algorithm + /// + /// 1) The values from the input are the very first values in the inner stack of the execution + /// algorithm + /// 2) You can write additional input values (for example if you need some constants) into the + /// stack while implementing particular block of the program + pub fn execute(&self, input: (FuncIdx, Vec)) -> QueryRecord { + let mut record = QueryRecord::default(); + let mut exec_entries_stack = vec![]; + let mut callers_states_stack = vec![]; + let (mut func_idx, mut map) = input; + + macro_rules! stack_block_exec_entries { + ($block:expr) => { + exec_entries_stack.push(ExecEntry::Ctrl(&$block.ctrl)); + exec_entries_stack.extend($block.ops.iter().rev().map(ExecEntry::Op)); + }; + } + + stack_block_exec_entries!(&self.functions[func_idx.to_usize()].body); + + while let Some(exec_entry) = exec_entries_stack.pop() { + match exec_entry { + ExecEntry::Op(Op::Prim(Prim::Bool(x))) => map.push(Value::Bool(*x)), + ExecEntry::Op(Op::Prim(Prim::U32(x))) => map.push(Value::U32(*x)), + ExecEntry::Op(Op::Add(ValIdx(a), ValIdx(b))) => { + match (&map[*a as usize], &map[*b as usize]) { + (Value::U32(a), Value::U32(b)) => map.push(Value::U32(*a + *b)), + _ => panic!(), + } + } + ExecEntry::Op(Op::Sub(ValIdx(a), ValIdx(b))) => { + match (&map[*a as usize], &map[*b as usize]) { + (Value::U32(a), Value::U32(b)) => map.push(Value::U32(*a - *b)), + _ => panic!(), + } + } + ExecEntry::Op(Op::Mul(ValIdx(a), ValIdx(b))) => { + match (&map[*a as usize], &map[*b as usize]) { + (Value::U32(a), Value::U32(b)) => map.push(Value::U32(*a * *b)), + _ => panic!(), + } + } + ExecEntry::Op(Op::And(ValIdx(a), ValIdx(b))) => { + match (&map[*a as usize], &map[*b as usize]) { + (Value::U32(a), Value::U32(b)) => map.push(Value::U32(*a & *b)), + (Value::Bool(a), Value::Bool(b)) => map.push(Value::Bool(*a & *b)), + _ => panic!(), + } + } + ExecEntry::Op(Op::Xor(ValIdx(a), ValIdx(b))) => { + match (&map[*a as usize], &map[*b as usize]) { + (Value::U32(a), Value::U32(b)) => map.push(Value::U32(*a ^ *b)), + (Value::Bool(a), Value::Bool(b)) => map.push(Value::Bool(*a ^ *b)), + _ => panic!(), + } + } + ExecEntry::Op(Op::Call(called_func_idx, args)) => { + let args = args.iter().map(|ValIdx(v)| map[*v as usize]).collect(); + let query_input = (*called_func_idx, args); + if let Some(query_result) = record.queries.get_mut(&query_input) { + query_result.multiplicity += 1; + map.extend(query_result.values.clone()); + } else { + // `map_buffer` will become the map for the called function + let (called_func_idx, mut map_buffer) = query_input; + // Swap so we can save the old map in `map_buffer` and move on + // with `map` already set. + std::mem::swap(&mut map_buffer, &mut map); + callers_states_stack.push(CallerState { + func_idx, + map: map_buffer, + }); + // Prepare outer variables to go into the new func scope. + func_idx = called_func_idx; + stack_block_exec_entries!(&self.functions[func_idx.to_usize()].body); + } + } + ExecEntry::Ctrl(Ctrl::Return(_, out)) => { + let out = out + .iter() + .map(|ValIdx(v)| map[*v as usize]) + .collect::>(); + + // Register the result for the current function index. + let query_result = QueryResult { + values: out.clone(), + multiplicity: 1, + }; + let num_inp = self.functions[func_idx.to_usize()].num_inp as usize; + let args = map[..num_inp].to_vec(); + record.queries.insert((func_idx, args), query_result); + + // Recover the state of the caller + if let Some(CallerState { + func_idx: caller_func_idx, + map: caller_map, + }) = callers_states_stack.pop() + { + func_idx = caller_func_idx; + map = caller_map; + map.extend(out); + } else { + // No outer caller... about to exit! + assert!(exec_entries_stack.is_empty()); + assert!(callers_states_stack.is_empty()); + break; + } + } + ExecEntry::Ctrl(Ctrl::If(ValIdx(v), tt, ff)) => { + let cond = match &map[*v as usize] { + Value::Bool(b) => *b, + Value::U32(u) => u != &0, + }; + if cond { + stack_block_exec_entries!(tt); + } else { + stack_block_exec_entries!(ff); + } + } + } + } + record + } +} + +#[cfg(test)] +mod tests { + use crate::eiur::execute::Value::U32; + use crate::eiur::{ + execute::{QueryResult, Value}, + ir::{Block, Ctrl, FuncIdx, Function, Op, Prim, SelIdx, Toplevel, ValIdx}, + }; + + fn factorial_function() -> Function { + let inp_val_idx = ValIdx(0); // the input is at index 0 + let one_val_idx = ValIdx(1); // a constant `1` value + let pre_val_idx = ValIdx(2); // inp - one + let rec_val_idx = ValIdx(3); // factorial(pre) + let res_val_idx = ValIdx(4); // inp * rec + + let true_block = Block { + ops: vec![ + Op::Sub(inp_val_idx, one_val_idx), + Op::Call(FuncIdx(0), vec![pre_val_idx]), + Op::Mul(inp_val_idx, rec_val_idx), + ], + ctrl: Box::new(Ctrl::Return(SelIdx(0), vec![res_val_idx])), // Recursive return + }; + + let false_block = Block { + ops: vec![], + ctrl: Box::new(Ctrl::Return(SelIdx(1), vec![one_val_idx])), + }; + + let main_block = Block { + ops: vec![Op::Prim(Prim::U32(1))], + ctrl: Box::new(Ctrl::If(inp_val_idx, true_block, false_block)), + }; + + Function { + num_inp: 1, + num_out: 1, + body: main_block, + } + } + + fn square_function() -> Function { + let input = ValIdx(0); + let output = ValIdx(1); + + let main_block = Block { + ops: vec![Op::Mul(input, input)], + ctrl: Box::new(Ctrl::Return(SelIdx(0), vec![output])), + }; + + Function { + num_inp: 1, + num_out: 1, + body: main_block, + } + } + + fn cube_function() -> Function { + let input = ValIdx(0); + let tmp = ValIdx(1); + let output = ValIdx(2); + + let main_block = Block { + ops: vec![Op::Mul(input, input), Op::Mul(tmp, input)], + ctrl: Box::new(Ctrl::Return(SelIdx(0), vec![output])), + }; + + Function { + num_inp: 1, + num_out: 1, + body: main_block, + } + } + + fn double_function() -> Function { + let input = ValIdx(0); + let two = ValIdx(1); // constant = 2 + let output = ValIdx(2); + + let main_block = Block { + ops: vec![Op::Prim(Prim::U32(2)), Op::Mul(input, two)], + ctrl: Box::new(Ctrl::Return(SelIdx(0), vec![output])), + }; + + Function { + num_inp: 1, + num_out: 1, + body: main_block, + } + } + + fn addition_function() -> Function { + let input = ValIdx(0); + let output = ValIdx(1); + + let main_block = Block { + ops: vec![Op::Add(input, input)], + ctrl: Box::new(Ctrl::Return(SelIdx(0), vec![output])), + }; + + Function { + num_inp: 1, + num_out: 1, + body: main_block, + } + } + + #[test] + fn test_addition() { + // Regular computation + let val_in = 100u32; + let val_out = val_in + val_in; + + // Euir-rs program + let input = (FuncIdx(0), vec![U32(val_in)]); + let toplevel = Toplevel { + functions: vec![addition_function()], + }; + + let result = toplevel.execute(input.clone()); + let out = result.queries.get(&input).unwrap(); + assert_eq!(out.values.len(), 1); + assert_eq!(out.values[0], U32(val_out)); + } + + #[test] + fn test_double() { + // Regular computation + let val_in = 50u32; + let val_out = val_in * 2; + + // Euir-rs program + let toplevel = Toplevel { + functions: vec![double_function()], + }; + + let input = (FuncIdx(0), vec![U32(val_in)]); + let result = toplevel.execute(input.clone()); + let out = result + .queries + .get(&input) + .expect("requested item is unavailable"); + assert_eq!(out.values.len(), 1); + assert_eq!(out.values[0], U32(val_out)); + } + + #[test] + fn test_cube() { + // Regular program + let val_in = 3u32; + let val_out = val_in * val_in * val_in; + + // Eiur-rs program + let top_level = Toplevel { + functions: vec![cube_function()], + }; + + let input = (FuncIdx(0), vec![U32(val_in)]); + let record = top_level.execute(input.clone()); + let out = record + .queries + .get(&input) + .expect("output of Lair / Eiur program is unavailable"); + + assert_eq!(out.values.len(), 1); + assert_eq!(out.values[0], U32(val_out)); + } + + #[test] + fn test_square() { + // Regular computation + let value_in = 6u32; + let value_out = value_in * value_in; + + // Eiur-rs program + let top_level = Toplevel { + functions: vec![square_function()], + }; + + let input = (FuncIdx(0), vec![Value::U32(value_in)]); + let record = top_level.execute(input.clone()); + + let out = record.queries.get(&input).expect("no out available"); + + assert_eq!(out.values.len(), 1); + assert_eq!(out.values[0], Value::U32(value_out)); + } + + #[test] + fn test_factorial() { + let toplevel = Toplevel { + functions: vec![factorial_function()], + }; + + let record = toplevel.execute((FuncIdx(0), vec![U32(5)])); + let pairs = [(0, 1), (1, 1), (2, 2), (3, 6), (4, 24), (5, 120)]; + for (i, o) in pairs { + let query_result = QueryResult { + values: vec![U32(o)], + multiplicity: 1, + }; + assert_eq!( + record.queries.get(&(FuncIdx(0), vec![U32(i)])), + Some(&query_result) + ); + } + } +} diff --git a/src/eiur/gadgets/mod.rs b/src/eiur/gadgets/mod.rs new file mode 100644 index 00000000..9a58e9da --- /dev/null +++ b/src/eiur/gadgets/mod.rs @@ -0,0 +1,55 @@ +pub mod uint_add; +pub mod uint_sub; + +use anyhow::Result; +use binius_circuits::builder::{witness::Builder, ConstraintSystemBuilder}; +use binius_core::oracle::OracleId; +use binius_field::{ + as_packed_field::PackScalar, underlier::UnderlierType, BinaryField1b as B1, TowerField, +}; +use bytemuck::Pod; + +/// Trait for Eiur-compatible gadgets +pub trait Gadget { + /// Type for the set of input oracles, usually associated with committed columns + type InputOracles; + /// Type for the set of virtual columns, returned by the constraining algorithm + type VirtualOracles; + /// Type for arbitrary configurations that a gadget may receive + type Config; + /// Creates the constraints for the gadget. New columns, if needed, should be + /// transparent and returned. The constraints should be relaxed where `enabled` + /// is zero. + fn constrain>( + builder: &mut ConstraintSystemBuilder, + name: impl ToString, + input: Self::InputOracles, + enabled: OracleId, + config: Self::Config, + ) -> Result; + /// Populates the columns with witness data that satisfy the constraints. + fn generate_witness + PackScalar + Pod>( + builder: &mut Builder, + input: Self::InputOracles, + vrtual: Self::VirtualOracles, + config: Self::Config, + ) -> Result<()>; +} + +pub enum UIntType { + U8, + U16, + U32, + U64, +} + +impl UIntType { + const fn n_vars(&self) -> usize { + match self { + Self::U8 => 3, + Self::U16 => 4, + Self::U32 => 5, + Self::U64 => 6, + } + } +} diff --git a/src/eiur/gadgets/uint_add.rs b/src/eiur/gadgets/uint_add.rs new file mode 100644 index 00000000..5f729f19 --- /dev/null +++ b/src/eiur/gadgets/uint_add.rs @@ -0,0 +1,178 @@ +use anyhow::Result; +use binius_circuits::builder::{witness::Builder, ConstraintSystemBuilder}; +use binius_core::oracle::{OracleId, ShiftVariant}; +use binius_field::{ + as_packed_field::PackScalar, underlier::UnderlierType, BinaryField1b as B1, TowerField, +}; +use binius_macros::arith_expr; +use bytemuck::Pod; +use rayon::prelude::*; + +use super::{Gadget, UIntType}; + +/// Gadget for overflowing addition over unsigned integers +pub struct UIntAdd; + +#[derive(Clone, Copy)] +pub struct UIntAddInput { + pub xin: OracleId, + pub yin: OracleId, + pub zout: OracleId, + pub cout: OracleId, +} + +pub struct UIntAddVirtual { + pub cin: OracleId, +} + +impl Gadget for UIntAdd { + type InputOracles = UIntAddInput; + type VirtualOracles = UIntAddVirtual; + type Config = UIntType; + + fn constrain>( + builder: &mut ConstraintSystemBuilder, + name: impl ToString, + input: UIntAddInput, + enabled: OracleId, + config: UIntType, + ) -> Result { + builder.push_namespace(name); + let UIntAddInput { + xin, + yin, + zout, + cout, + } = input; + let n_vars = config.n_vars(); + let cin = builder.add_shifted("cin", cout, 1, n_vars, ShiftVariant::LogicalLeft)?; + + builder.assert_zero( + "sum", + [xin, yin, cin, zout, enabled], + arith_expr!([xin, yin, cin, zout, enabled] = enabled * (xin + yin + cin - zout)) + .convert_field(), + ); + + builder.assert_zero( + "carry", + [xin, yin, cin, cout, enabled], + arith_expr!( + [xin, yin, cin, cout, enabled] = enabled * ((xin + cin) * (yin + cin) + cin - cout) + ) + .convert_field(), + ); + + builder.pop_namespace(); + Ok(UIntAddVirtual { cin }) + } + + /// Populates new columns for `zout`, `cout` and `cin` based on the values + /// from `xin` and `yin`. + fn generate_witness + PackScalar + Pod>( + builder: &mut Builder, + input: UIntAddInput, + vrtual: UIntAddVirtual, + config: UIntType, + ) -> Result<()> { + let UIntAddInput { + xin, + yin, + zout, + cout, + } = input; + let UIntAddVirtual { cin } = vrtual; + macro_rules! witgen { + ($t:ty, $lsbits:expr) => { + ( + builder.get::(xin)?.as_slice::<$t>(), + builder.get::(yin)?.as_slice::<$t>(), + builder.new_column::(zout).as_mut_slice::<$t>(), + builder.new_column::(cout).as_mut_slice::<$t>(), + builder.new_column::(cin).as_mut_slice::<$t>(), + ) + .into_par_iter() + .for_each(|(xin, yin, zout, cout, cin)| { + let carry; + (*zout, carry) = xin.overflowing_add(*yin); + *cin = xin ^ yin ^ *zout; + *cout = ((carry as $t) << $lsbits) | (*cin >> 1); + }) + }; + } + match config { + UIntType::U8 => witgen!(u8, 7), + UIntType::U16 => witgen!(u16, 15), + UIntType::U32 => witgen!(u32, 31), + UIntType::U64 => witgen!(u64, 63), + } + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use binius_circuits::builder::{witness::Builder, ConstraintSystemBuilder}; + use binius_core::constraint_system::validate::validate_witness; + use binius_field::{ + arch::OptimalUnderlier, underlier::SmallU, BinaryField128b, BinaryField1b as B1, TowerField, + }; + use bumpalo::Bump; + use proptest::{collection::vec, prelude::*}; + + use crate::eiur::{ + binius::witness_builder, + gadgets::{ + uint_add::{UIntAdd, UIntAddInput, UIntType}, + Gadget, + }, + }; + const LEN: usize = 16; + + macro_rules! auto_test { + ($fn:ident, $cfg:expr, $t:ty) => { + #[test] + fn $fn() { + const N_VARS: usize = $cfg.n_vars() + LEN.ilog2() as usize; + + proptest!(|( + vec1 in vec(any::<$t>(), LEN), + vec2 in vec(any::<$t>(), LEN), + )| { + let mut csb = ConstraintSystemBuilder::::new(); + let xin = csb.add_committed("xin", N_VARS, B1::TOWER_LEVEL); + let yin = csb.add_committed("yin", N_VARS, B1::TOWER_LEVEL); + let cout = csb.add_committed("cout", N_VARS, B1::TOWER_LEVEL); + let zout = csb.add_committed("zout", N_VARS, B1::TOWER_LEVEL); + let enabled = csb.add_committed("enabled", N_VARS, B1::TOWER_LEVEL); + + let input = UIntAddInput {xin, yin, zout, cout}; + let transparent = UIntAdd::constrain(&mut csb, "add", input, enabled, $cfg).unwrap(); + + let cs = csb.build().unwrap(); + + let allocator = Bump::new(); + let mut wb: Builder = witness_builder(&allocator, &cs); + + wb.new_column::(xin).as_mut_slice().copy_from_slice(&vec1); + wb.new_column::(yin).as_mut_slice().copy_from_slice(&vec2); + wb.new_column_with_default(enabled, B1::new(SmallU::new(1))); + + UIntAdd::generate_witness(&mut wb, input, transparent, $cfg).unwrap(); + + let res = vec1.into_iter().zip(vec2).map(|(a, b)| a.overflowing_add(b).0).collect::>(); + prop_assert_eq!(wb.get::(zout).unwrap().as_slice::<$t>(), &res); + + let w = wb.build().unwrap(); + + prop_assert!(validate_witness(&cs, &[], &w).is_ok()); + }); + } + }; + } + + auto_test!(test_add_u8, UIntType::U8, u8); + auto_test!(test_add_u16, UIntType::U16, u16); + auto_test!(test_add_u32, UIntType::U32, u32); + auto_test!(test_add_u64, UIntType::U64, u64); +} diff --git a/src/eiur/gadgets/uint_sub.rs b/src/eiur/gadgets/uint_sub.rs new file mode 100644 index 00000000..28aae628 --- /dev/null +++ b/src/eiur/gadgets/uint_sub.rs @@ -0,0 +1,169 @@ +use anyhow::Result; +use binius_circuits::builder::{witness::Builder, ConstraintSystemBuilder}; +use binius_core::oracle::OracleId; +use binius_field::{ + as_packed_field::PackScalar, underlier::UnderlierType, BinaryField1b as B1, TowerField, +}; +use bytemuck::Pod; +use rayon::prelude::*; + +use super::{ + uint_add::{UIntAdd, UIntAddInput, UIntAddVirtual}, + Gadget, UIntType, +}; + +/// Gadget for underflowing subtraction over unsigned integers +pub struct UIntSub; + +#[derive(Clone, Copy)] +pub struct UIntSubInput { + zin: OracleId, + yin: OracleId, + cout: OracleId, + xout: OracleId, +} + +pub struct UIntSubVirtual { + cin: OracleId, +} + +impl Gadget for UIntSub { + type InputOracles = UIntSubInput; + type VirtualOracles = UIntSubVirtual; + type Config = UIntType; + + fn constrain>( + builder: &mut ConstraintSystemBuilder, + name: impl ToString, + input: UIntSubInput, + enabled: OracleId, + config: UIntType, + ) -> Result { + builder.push_namespace(name); + let UIntSubInput { + zin, + yin, + cout, + xout, + } = input; + let add_input = UIntAddInput { + xin: xout, + yin, + cout, + zout: zin, + }; + let UIntAddVirtual { cin } = + UIntAdd::constrain(builder, "add", add_input, enabled, config)?; + builder.pop_namespace(); + Ok(UIntSubVirtual { cin }) + } + + /// Populates new columns for `xout`, `cout` and `cin` based on the values + /// from `zin` and `yin`. + fn generate_witness + PackScalar + Pod>( + builder: &mut Builder, + input: UIntSubInput, + vrtual: UIntSubVirtual, + config: UIntType, + ) -> Result<()> { + let UIntSubInput { + zin, + yin, + cout, + xout, + } = input; + let UIntSubVirtual { cin } = vrtual; + macro_rules! witgen { + ($t:ty, $lsbits:expr) => { + ( + builder.get::(zin)?.as_slice::<$t>(), + builder.get::(yin)?.as_slice::<$t>(), + builder.new_column::(xout).as_mut_slice::<$t>(), + builder.new_column::(cout).as_mut_slice::<$t>(), + builder.new_column::(cin).as_mut_slice::<$t>(), + ) + .into_par_iter() + .for_each(|(zout, yin, xin, cout, cin)| { + let carry; + (*xin, carry) = (*zout).overflowing_sub(*yin); + *cin = (*xin) ^ (*yin) ^ (*zout); + *cout = ((carry as $t) << $lsbits) | (*cin >> 1); + }) + }; + } + match config { + UIntType::U8 => witgen!(u8, 7), + UIntType::U16 => witgen!(u16, 15), + UIntType::U32 => witgen!(u32, 31), + UIntType::U64 => witgen!(u64, 63), + } + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use binius_circuits::builder::{witness::Builder, ConstraintSystemBuilder}; + use binius_core::constraint_system::validate::validate_witness; + use binius_field::{ + arch::OptimalUnderlier, underlier::SmallU, BinaryField128b, BinaryField1b as B1, TowerField, + }; + use bumpalo::Bump; + use proptest::{collection::vec, prelude::*}; + + use crate::eiur::{ + binius::witness_builder, + gadgets::{ + uint_sub::{UIntSub, UIntSubInput}, + Gadget, UIntType, + }, + }; + const LEN: usize = 16; + + macro_rules! auto_test { + ($fn:ident, $cfg:expr, $t:ty) => { + #[test] + fn $fn() { + const N_VARS: usize = $cfg.n_vars() + LEN.ilog2() as usize; + + proptest!(|( + vec1 in vec(any::<$t>(), LEN), + vec2 in vec(any::<$t>(), LEN), + )| { + let mut csb = ConstraintSystemBuilder::::new(); + let zin = csb.add_committed("zin", N_VARS, B1::TOWER_LEVEL); + let yin = csb.add_committed("yin", N_VARS, B1::TOWER_LEVEL); + let cout = csb.add_committed("cout", N_VARS, B1::TOWER_LEVEL); + let xout = csb.add_committed("xout", N_VARS, B1::TOWER_LEVEL); + let enabled = csb.add_committed("enabled", N_VARS, B1::TOWER_LEVEL); + + let input = UIntSubInput {zin, yin, cout, xout}; + let transparent = UIntSub::constrain(&mut csb, "sub", input, enabled, $cfg).unwrap(); + + let cs = csb.build().unwrap(); + + let allocator = Bump::new(); + let mut wb: Builder = witness_builder(&allocator, &cs); + + wb.new_column::(zin).as_mut_slice().copy_from_slice(&vec1); + wb.new_column::(yin).as_mut_slice().copy_from_slice(&vec2); + wb.new_column_with_default(enabled, B1::new(SmallU::new(1))); + + UIntSub::generate_witness(&mut wb, input, transparent, $cfg).unwrap(); + + let res = vec1.into_iter().zip(vec2).map(|(a, b)| a.overflowing_sub(b).0).collect::>(); + prop_assert_eq!(wb.get::(xout).unwrap().as_slice::<$t>(), &res); + + let w = wb.build().unwrap(); + + prop_assert!(validate_witness(&cs, &[], &w).is_ok()); + }); + } + }; + } + + auto_test!(test_sub_u8, UIntType::U8, u8); + auto_test!(test_sub_u16, UIntType::U16, u16); + auto_test!(test_sub_u32, UIntType::U32, u32); + auto_test!(test_sub_u64, UIntType::U64, u64); +} diff --git a/src/eiur/ir.rs b/src/eiur/ir.rs new file mode 100644 index 00000000..c3de60d8 --- /dev/null +++ b/src/eiur/ir.rs @@ -0,0 +1,69 @@ +/// The `TopLevel` is an abstraction that allows executing arbitrary Eiur-rs program. +/// Roughly it works as following: user instantiates the `TopLevel` object using one or +/// more functions (of type `Function`) that express one or more finite computations. +/// The `TopLevel` implementation defines an execution algorithm which takes a tuple +/// (`FuncIdx`, `Vec`) as input and returns `QueryRecord` as output. The input +/// provides information about what exact function to invoke (`FuncIdx`) as well as what +/// data (`Vec`) to use for this function. The output (`QueryRecord`) contains +/// result of the provided function execution over provided data. +/// +pub struct Toplevel { + pub functions: Vec, +} + +/// `Function` is an abstraction that expresses some finite computation +pub struct Function { + pub num_inp: u32, + pub num_out: u32, + pub body: Block, +} + +/// `Prim` defines primitive data types currently supported by Eiur-rs language +pub enum Prim { + U32(u32), + Bool(bool), +} + +/// `ValIdx` is a pointer to a particular value stored in the inner stack of the +/// `TopLevel` execution algorithm +#[derive(Clone, Copy)] +pub struct ValIdx(pub u32); + +/// `FuncIdx` is a pointer to a function that needs to be executed by a `TopLevel` execution +/// algorithm +#[derive(PartialEq, Eq, Hash, Clone, Copy)] +pub struct FuncIdx(pub u32); + +impl FuncIdx { + pub fn to_usize(self) -> usize { + self.0 as usize + } +} + +/// `Op` enumerates operations currently supported by Eiur-rs +pub enum Op { + Prim(Prim), + Add(ValIdx, ValIdx), + Sub(ValIdx, ValIdx), + Mul(ValIdx, ValIdx), + And(ValIdx, ValIdx), + Xor(ValIdx, ValIdx), + Call(FuncIdx, Vec), +} + +/// `SelIdx` serves as a selector of the particular code branch that is executed and +/// requires constraining for the proving system +pub struct SelIdx(pub u32); + +/// `Ctrl` expresses the control flows of the program +pub enum Ctrl { + If(ValIdx, Block, Block), + Return(SelIdx, Vec), +} + +/// `Block` serves as a body of the user-defined Eiur program / computation. May reference inner +/// blocks via `Ctrl` +pub struct Block { + pub ops: Vec, + pub ctrl: Box, +} diff --git a/src/eiur/mod.rs b/src/eiur/mod.rs new file mode 100644 index 00000000..8eabaed5 --- /dev/null +++ b/src/eiur/mod.rs @@ -0,0 +1,4 @@ +pub mod binius; +pub mod execute; +pub mod gadgets; +pub mod ir; diff --git a/src/lib.rs b/src/lib.rs index 8c1636fb..35cdeacd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +pub mod eiur; + #[cfg(test)] mod tests { #[test]