diff --git a/Cargo.lock b/Cargo.lock index c88ce21..d7c29ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,9 +36,64 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "ark-bls12-381" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df4dcc01ff89867cd86b0da835f23c3f02738353aaee7dde7495af71363b8d5" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize 0.5.0", + "ark-std 0.5.0", +] + +[[package]] +name = "ark-ec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d68f2d516162846c1238e755a7c4d131b892b70cc70c471a8e3ca3ed818fce" +dependencies = [ + "ahash", + "ark-ff", + "ark-poly", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "educe", + "fnv", + "hashbrown 0.15.2", + "itertools 0.13.0", + "num-bigint", + "num-integer", + "num-traits", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a177aba0ed1e0fbb62aa9f6d0502e9b46dad8c2eab04c14258a1212d2557ea70" +dependencies = [ + "ark-ff-asm 0.5.0", + "ark-ff-macros 0.5.0", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "arrayvec", + "digest", + "educe", + "itertools 0.13.0", + "num-bigint", + "num-traits", + "paste", + "rayon", + "zeroize", +] [[package]] name = "ark-ff-asm" @@ -50,6 +105,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-ff-asm" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" +dependencies = [ + "quote", + "syn 2.0.90", +] + [[package]] name = "ark-ff-macros" version = "0.4.2" @@ -63,18 +128,61 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-ff-macros" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 2.0.90", +] + +[[package]] +name = "ark-poly" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579305839da207f02b89cd1679e50e67b4331e2f9294a57693e5051b7703fe27" +dependencies = [ + "ahash", + "ark-ff", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "educe", + "fnv", + "hashbrown 0.15.2", + "rayon", +] + [[package]] name = "ark-serialize" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ - "ark-serialize-derive", - "ark-std", + "ark-serialize-derive 0.4.2", + "ark-std 0.4.0", "digest", "num-bigint", ] +[[package]] +name = "ark-serialize" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f4d068aaf107ebcd7dfb52bc748f8030e0fc930ac8e360146ca54c1203088f7" +dependencies = [ + "ark-serialize-derive 0.5.0", + "ark-std 0.5.0", + "arrayvec", + "digest", + "num-bigint", + "rayon", +] + [[package]] name = "ark-serialize-derive" version = "0.4.2" @@ -86,6 +194,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-serialize-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "ark-std" version = "0.4.0" @@ -97,6 +216,17 @@ dependencies = [ "rayon", ] +[[package]] +name = "ark-std" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246a225cc6131e9ee4f24619af0f19d67761fff15d7ccc22e42b80846e69449a" +dependencies = [ + "num-traits", + "rand", + "rayon", +] + [[package]] name = "arrayvec" version = "0.7.6" @@ -150,9 +280,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" [[package]] name = "byteorder" @@ -214,16 +344,6 @@ dependencies = [ "rayon", ] -[[package]] -name = "concrete-csprng" -version = "0.4.1" -source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/rename_pp_crs#62ec37221312b6a20ee80b28051224be5aec16a1" -dependencies = [ - "aes", - "libc", - "rayon", -] - [[package]] name = "concrete-fft" version = "0.5.1" @@ -251,9 +371,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -330,12 +450,50 @@ dependencies = [ "reborrow", ] +[[package]] +name = "educe" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "either" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "enum-ordinalize" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "generic-array" version = "0.14.7" @@ -377,6 +535,15 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "allocator-api2", +] + [[package]] name = "heck" version = "0.5.0" @@ -410,12 +577,22 @@ 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 = "js-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -430,9 +607,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libm" @@ -508,9 +685,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -618,22 +795,22 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -665,7 +842,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -681,9 +858,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -699,7 +876,7 @@ dependencies = [ "aligned-vec", "bincode", "bytemuck", - "concrete-csprng 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "concrete-csprng", "concrete-fft", "concrete-ntt", "dyn-stack", @@ -723,7 +900,7 @@ dependencies = [ "aligned-vec", "bincode", "bytemuck", - "concrete-csprng 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "concrete-csprng", "concrete-fft", "concrete-ntt", "dyn-stack", @@ -741,14 +918,11 @@ dependencies = [ [[package]] name = "tfhe" version = "0.11.0" -source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/rename_pp_crs#62ec37221312b6a20ee80b28051224be5aec16a1" +source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2#74813d9a05f24efaa0e4c61c56ae28a565d2eae2" dependencies = [ "aligned-vec", "bincode", "bytemuck", - "concrete-csprng 0.4.1 (git+https://github.com/zama-ai/tfhe-rs/?branch=ns/rename_pp_crs)", - "concrete-fft", - "concrete-ntt", "dyn-stack", "itertools 0.11.0", "paste", @@ -757,7 +931,10 @@ dependencies = [ "rayon", "serde", "sha3", - "tfhe-versionable 0.3.2 (git+https://github.com/zama-ai/tfhe-rs/?branch=ns/rename_pp_crs)", + "tfhe-csprng", + "tfhe-fft", + "tfhe-ntt", + "tfhe-versionable 0.3.2 (git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2)", "tfhe-zk-pok 0.3.1", ] @@ -767,8 +944,8 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6769557a36c7d9b2313052badc55562b0e260a0dcca745150b15c3bae65a4957" dependencies = [ - "ark-serialize", - "ark-std", + "ark-serialize 0.4.2", + "ark-std 0.4.0", "tfhe-ark-ec", "tfhe-ark-ff", ] @@ -779,10 +956,10 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ff6eb48b47e2cd6a2db68909cc62888516a7c1c4faaa894cb8dff7d48029b3f" dependencies = [ - "ark-serialize", - "ark-std", + "ark-serialize 0.4.2", + "ark-std 0.4.0", "derivative", - "hashbrown", + "hashbrown 0.14.5", "itertools 0.12.1", "num-bigint", "num-integer", @@ -799,10 +976,10 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08ab3109583fa162a9c83082ad4006a877786da8d76ad3cd9180bcb3d7ac9e9" dependencies = [ - "ark-ff-asm", - "ark-ff-macros", - "ark-serialize", - "ark-std", + "ark-ff-asm 0.4.2", + "ark-ff-macros 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", "arrayvec", "derivative", "digest", @@ -820,10 +997,10 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4849a880457e8562e759fae62462a8be506f8ce1b8a0d5f90061583c4f6d25de" dependencies = [ - "ark-serialize", - "ark-std", + "ark-serialize 0.4.2", + "ark-std 0.4.0", "derivative", - "hashbrown", + "hashbrown 0.14.5", "rayon", "tfhe-ark-ff", ] @@ -842,7 +1019,41 @@ dependencies = [ "tfhe 0.11.0", "tfhe 0.8.7", "tfhe-versionable 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tfhe-versionable 0.3.2 (git+https://github.com/zama-ai/tfhe-rs/?branch=ns/rename_pp_crs)", + "tfhe-versionable 0.3.2 (git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2)", +] + +[[package]] +name = "tfhe-csprng" +version = "0.4.1" +source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2#74813d9a05f24efaa0e4c61c56ae28a565d2eae2" +dependencies = [ + "aes", + "libc", + "rayon", +] + +[[package]] +name = "tfhe-fft" +version = "0.6.0" +source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2#74813d9a05f24efaa0e4c61c56ae28a565d2eae2" +dependencies = [ + "aligned-vec", + "bytemuck", + "dyn-stack", + "js-sys", + "num-complex", + "pulp", + "serde", +] + +[[package]] +name = "tfhe-ntt" +version = "0.3.0" +source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2#74813d9a05f24efaa0e4c61c56ae28a565d2eae2" +dependencies = [ + "aligned-vec", + "bytemuck", + "pulp", ] [[package]] @@ -860,12 +1071,12 @@ dependencies = [ [[package]] name = "tfhe-versionable" version = "0.3.2" -source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/rename_pp_crs#62ec37221312b6a20ee80b28051224be5aec16a1" +source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2#74813d9a05f24efaa0e4c61c56ae28a565d2eae2" dependencies = [ "aligned-vec", "num-complex", "serde", - "tfhe-versionable-derive 0.3.2 (git+https://github.com/zama-ai/tfhe-rs/?branch=ns/rename_pp_crs)", + "tfhe-versionable-derive 0.3.2 (git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2)", ] [[package]] @@ -876,34 +1087,34 @@ checksum = "a463428890873548472daba5bdcecfe34b89c98518b4bd6cbd8595ac48fc0771" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "tfhe-versionable-derive" version = "0.3.2" -source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/rename_pp_crs#62ec37221312b6a20ee80b28051224be5aec16a1" +source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2#74813d9a05f24efaa0e4c61c56ae28a565d2eae2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "tfhe-zk-pok" version = "0.3.1" -source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/rename_pp_crs#62ec37221312b6a20ee80b28051224be5aec16a1" +source = "git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2#74813d9a05f24efaa0e4c61c56ae28a565d2eae2" dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-poly", "num-bigint", "rand", "rayon", "serde", "sha3", - "tfhe-ark-bls12-381", - "tfhe-ark-ec", - "tfhe-ark-ff", - "tfhe-ark-poly", - "tfhe-versionable 0.3.2 (git+https://github.com/zama-ai/tfhe-rs/?branch=ns/rename_pp_crs)", + "tfhe-versionable 0.3.2 (git+https://github.com/zama-ai/tfhe-rs/?branch=ns/plug_zk_v2)", "zeroize", ] @@ -934,9 +1145,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "version_check" @@ -952,9 +1163,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" dependencies = [ "cfg-if", "once_cell", @@ -963,24 +1174,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -988,22 +1199,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" [[package]] name = "zerocopy" @@ -1023,7 +1234,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1043,5 +1254,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] diff --git a/Cargo.toml b/Cargo.toml index a1a2678..192ef03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,11 +32,11 @@ tfhe_0_11 = { version = "0.11", features = [ "x86_64-unix", "zk-pok", "experimental-force_fft_algo_dif4", -], package = "tfhe", optional = true, git = "https://github.com/zama-ai/tfhe-rs/", branch = "ns/rename_pp_crs" } +], package = "tfhe", optional = true, git = "https://github.com/zama-ai/tfhe-rs/", branch = "ns/plug_zk_v2" } # TFHE-rs 0.8 and 0.10 use the same version of versionable tfhe-versionable = { version = "0.3.2", optional = true } -tfhe_0_11-versionable = { version = "0.3.2", optional = true, package = "tfhe-versionable", git = "https://github.com/zama-ai/tfhe-rs/", branch = "ns/rename_pp_crs" } +tfhe_0_11-versionable = { version = "0.3.2", optional = true, package = "tfhe-versionable", git = "https://github.com/zama-ai/tfhe-rs/", branch = "ns/plug_zk_v2" } # other deps serde = { version = "1.0", features = ["derive"] } diff --git a/data/0_11/high_level_api/client_key.cbor b/data/0_11/high_level_api/client_key.cbor new file mode 100644 index 0000000..3039761 --- /dev/null +++ b/data/0_11/high_level_api/client_key.cbor @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0665c8fd54940bb07b3b77520666840c8b5c24be1e5a09ba45bdedb1c064dc72 +size 3578 diff --git a/data/0_11/high_level_api/hl_proven_heterogeneous_list_zkv2.bcode b/data/0_11/high_level_api/hl_proven_heterogeneous_list_zkv2.bcode new file mode 100644 index 0000000..ae74836 --- /dev/null +++ b/data/0_11/high_level_api/hl_proven_heterogeneous_list_zkv2.bcode @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15bbcc8caf2de5bfaf8c19f84f380664e92094b49f5f0728d08abb8d781d03c3 +size 19241 diff --git a/data/0_11/high_level_api/hl_proven_heterogeneous_list_zkv2.cbor b/data/0_11/high_level_api/hl_proven_heterogeneous_list_zkv2.cbor new file mode 100644 index 0000000..501a223 --- /dev/null +++ b/data/0_11/high_level_api/hl_proven_heterogeneous_list_zkv2.cbor @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d70134cca9b2a0e68cc4b147a0177e6475831dda57e58405323c8a0f58cc5506 +size 21985 diff --git a/data/0_11/high_level_api/public_key.cbor b/data/0_11/high_level_api/public_key.cbor new file mode 100644 index 0000000..ebdb318 --- /dev/null +++ b/data/0_11/high_level_api/public_key.cbor @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f09c16efaae028e4bdefb27609fc310630fde7c2cdc141dded1eba4e1cb4777 +size 37281 diff --git a/data/0_11/high_level_api/zk_pke_crs.bcode b/data/0_11/high_level_api/zk_pke_crs.bcode index 58cac0e..5bc3d7e 100644 --- a/data/0_11/high_level_api/zk_pke_crs.bcode +++ b/data/0_11/high_level_api/zk_pke_crs.bcode @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8266d6a67a066d8fc4293fd585ca47a2d37aaf1f92f2529188f56a5c41cee650 -size 71361608 +oid sha256:a399e9866ffe9110e6c42914daf246a551c06fa70f64f9b3f9b109a802db2e9d +size 5569088 diff --git a/data/0_11/high_level_api/zk_pke_crs.cbor b/data/0_11/high_level_api/zk_pke_crs.cbor index bd00e9b..12c387e 100644 --- a/data/0_11/high_level_api/zk_pke_crs.cbor +++ b/data/0_11/high_level_api/zk_pke_crs.cbor @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e97570c813f155afd26e67fd1ddd6da9c36ba27927f6e2afb1c98c39de051cfb -size 83628033 +oid sha256:8e615cbcbe08eeaf16688f2bd8bad302b7d7f1d6fe6c0b1ca061419c9aed5f06 +size 6528206 diff --git a/data/high_level_api.ron b/data/high_level_api.ron index f0b4142..ff8c68c 100644 --- a/data/high_level_api.ron +++ b/data/high_level_api.ron @@ -379,4 +379,30 @@ padding_bit_count: 1, )), ), + ( + tfhe_version_min: "0.11", + tfhe_module: "high_level_api", + metadata: HlHeterogeneousCiphertextList(( + test_filename: "hl_proven_heterogeneous_list_zkv2", + key_filename: "client_key", + compressed: false, + proof_info: Some(( + public_key_filename: "public_key", + params_filename: "zk_pke_crs", + metadata: "2vdrawkcab", + )), + clear_values: [ + 17, + 18446744073709551604, + 0, + 1, + ], + data_kinds: [ + Unsigned, + Signed, + Bool, + Bool, + ], + )), + ), ] \ No newline at end of file diff --git a/src/data_0_11.rs b/src/data_0_11.rs index f90c860..4d147fe 100644 --- a/src/data_0_11.rs +++ b/src/data_0_11.rs @@ -1,13 +1,15 @@ use crate::generate::{ - store_versioned_test_tfhe_011, TfhersVersion, PRNG_SEED, VALID_TEST_PARAMS_TUNIFORM, + store_versioned_auxiliary_tfhe_011, store_versioned_test_tfhe_011, TfhersVersion, PRNG_SEED, + VALID_TEST_PARAMS_TUNIFORM, }; use crate::{ + DataKind, HlClientKeyTest, HlHeterogeneousCiphertextListTest, PkeZkProofAuxilliaryInfo, TestDistribution, TestMetadata, TestParameterSet, ZkPkePublicParamsTest, HL_MODULE_NAME, }; use std::{borrow::Cow, fs::create_dir_all}; use tfhe_0_11::core_crypto::commons::math::random::RandomGenerator; use tfhe_0_11::core_crypto::prelude::TUniform; -use tfhe_0_11::zk::{CompactPkeCrs, ZkMSBZeroPaddingBitCount}; +use tfhe_0_11::zk::{CompactPkeCrs, ZkComputeLoad, ZkMSBZeroPaddingBitCount}; use tfhe_0_11::{ boolean::engine::BooleanEngine, core_crypto::commons::generators::DeterministicSeeder, @@ -18,8 +20,9 @@ use tfhe_0_11::{ DecompositionLevelCount, DynamicDistribution, EncryptionKeyChoice, GlweDimension, LweDimension, MaxNoiseLevel, MessageModulus, PBSParameters, PolynomialSize, StandardDev, }, - Seed, + ClientKey, Seed, }; +use tfhe_0_11::{set_server_key, CompactPublicKey, ProvenCompactCiphertextList, ServerKey}; macro_rules! store_versioned_test { ($msg:expr, $dir:expr, $test_filename:expr $(,)? ) => { @@ -27,6 +30,12 @@ macro_rules! store_versioned_test { }; } +macro_rules! store_versioned_auxiliary { + ($msg:expr, $dir:expr, $test_filename:expr $(,)? ) => { + store_versioned_auxiliary_tfhe_011($msg, $dir, $test_filename) + }; +} + impl From for DynamicDistribution { fn from(value: TestDistribution) -> Self { match value { @@ -52,9 +61,9 @@ impl From for ClassicPBSParameters { pbs_level: DecompositionLevelCount(value.pbs_level), ks_base_log: DecompositionBaseLog(value.ks_base_log), ks_level: DecompositionLevelCount(value.ks_level), - message_modulus: MessageModulus(value.message_modulus), - carry_modulus: CarryModulus(value.carry_modulus), - max_noise_level: MaxNoiseLevel::new(value.max_noise_level), + message_modulus: MessageModulus(value.message_modulus as u64), + carry_modulus: CarryModulus(value.carry_modulus as u64), + max_noise_level: MaxNoiseLevel::new(value.max_noise_level as u64), log2_p_fail: value.log2_p_fail, ciphertext_modulus: CiphertextModulus::try_new(value.ciphertext_modulus).unwrap(), encryption_key_choice: { @@ -75,6 +84,11 @@ impl From for PBSParameters { } } +const HL_CLIENTKEY_TEST: HlClientKeyTest = HlClientKeyTest { + test_filename: Cow::Borrowed("client_key"), + parameters: VALID_TEST_PARAMS_TUNIFORM, +}; + // The CRS is structurally equivalent to the public params type so we reuse the test const ZK_PKE_CRS_TEST: ZkPkePublicParamsTest = ZkPkePublicParamsTest { test_filename: Cow::Borrowed("zk_pke_crs"), @@ -92,6 +106,25 @@ const ZK_PKE_CRS_TEST: ZkPkePublicParamsTest = ZkPkePublicParamsTest { padding_bit_count: 1, }; +const HL_PROVEN_COMPACTLIST_TEST_ZKV2: HlHeterogeneousCiphertextListTest = + HlHeterogeneousCiphertextListTest { + test_filename: Cow::Borrowed("hl_proven_heterogeneous_list_zkv2"), + key_filename: HL_CLIENTKEY_TEST.test_filename, + clear_values: Cow::Borrowed(&[17u8 as u64, -12i8 as u64, false as u64, true as u64]), + data_kinds: Cow::Borrowed(&[ + DataKind::Unsigned, + DataKind::Signed, + DataKind::Bool, + DataKind::Bool, + ]), + compressed: false, + proof_info: Some(PkeZkProofAuxilliaryInfo { + public_key_filename: Cow::Borrowed("public_key"), + params_filename: Cow::Borrowed("zk_pke_crs"), + metadata: Cow::Borrowed("2vdrawkcab"), + }), + }; + pub struct V0_11; impl TfhersVersion for V0_11 { @@ -119,6 +152,14 @@ impl TfhersVersion for V0_11 { let mut zk_rng: RandomGenerator = RandomGenerator::new(Seed(PRNG_SEED)); + // Generate a compact public key needed to create a compact list + let config = + tfhe_0_11::ConfigBuilder::with_custom_parameters(VALID_TEST_PARAMS_TUNIFORM).build(); + let hl_client_key = ClientKey::generate(config); + let hl_server_key = ServerKey::new(&hl_client_key); + set_server_key(hl_server_key.clone()); + let compact_pub_key = CompactPublicKey::new(&hl_client_key); + let crs = CompactPkeCrs::new( LweDimension(ZK_PKE_CRS_TEST.lwe_dimension), ZK_PKE_CRS_TEST.max_num_cleartext, @@ -132,6 +173,50 @@ impl TfhersVersion for V0_11 { store_versioned_test!(&crs, &dir, &ZK_PKE_CRS_TEST.test_filename,); - vec![TestMetadata::ZkPkePublicParams(ZK_PKE_CRS_TEST)] + // Store the associated client key to be able to decrypt the ciphertexts in the list + store_versioned_auxiliary!( + &hl_client_key, + &dir, + &HL_PROVEN_COMPACTLIST_TEST_ZKV2.key_filename + ); + + store_versioned_auxiliary!( + &compact_pub_key, + &dir, + &HL_PROVEN_COMPACTLIST_TEST_ZKV2 + .proof_info + .unwrap() + .public_key_filename + ); + + let mut proven_builder = ProvenCompactCiphertextList::builder(&compact_pub_key); + proven_builder + .push(HL_PROVEN_COMPACTLIST_TEST_ZKV2.clear_values[0] as u8) + .push(HL_PROVEN_COMPACTLIST_TEST_ZKV2.clear_values[1] as i8) + .push(HL_PROVEN_COMPACTLIST_TEST_ZKV2.clear_values[2] != 0) + .push(HL_PROVEN_COMPACTLIST_TEST_ZKV2.clear_values[3] != 0); + + let proven_list_packed = proven_builder + .build_with_proof_packed( + &crs, + HL_PROVEN_COMPACTLIST_TEST_ZKV2 + .proof_info + .unwrap() + .metadata + .as_bytes(), + ZkComputeLoad::Proof, + ) + .unwrap(); + + store_versioned_test!( + &proven_list_packed, + &dir, + &HL_PROVEN_COMPACTLIST_TEST_ZKV2.test_filename, + ); + + vec![ + TestMetadata::ZkPkePublicParams(ZK_PKE_CRS_TEST), + TestMetadata::HlHeterogeneousCiphertextList(HL_PROVEN_COMPACTLIST_TEST_ZKV2), + ] } } diff --git a/src/generate.rs b/src/generate.rs index 9eb4bf8..313e42d 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -184,6 +184,7 @@ macro_rules! define_store_versioned_auxiliary_fn { } define_store_versioned_auxiliary_fn!(store_versioned_auxiliary_tfhe_08, VersionizeTfhe08); define_store_versioned_auxiliary_fn!(store_versioned_auxiliary_tfhe_010, VersionizeTfhe010); +define_store_versioned_auxiliary_fn!(store_versioned_auxiliary_tfhe_011, VersionizeTfhe011); pub fn store_metadata>(value: &Meta, path: P) { let serialized = ron::ser::to_string_pretty(value, ron::ser::PrettyConfig::default()).unwrap();