diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index add3c71..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "marlin"] - path = marlin - url = git@github.com:o1-labs/marlin.git diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..6ca9273 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1249 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.3", + "once_cell", + "version_check", +] + +[[package]] +name = "alga" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f823d037a7ec6ea2197046bafd4ae150e6bc36f9ca347404f46a46823fa84f2" +dependencies = [ + "approx", + "num-complex", + "num-traits 0.2.14", +] + +[[package]] +name = "algebra" +version = "0.1.0" +source = "git+https://github.com/o1-labs/zexe#2f61b6082b1faa4969fb05efdf3f46e1b7de96d1" +dependencies = [ + "algebra-core", +] + +[[package]] +name = "algebra-core" +version = "0.1.0" +source = "git+https://github.com/o1-labs/zexe#2f61b6082b1faa4969fb05efdf3f46e1b7de96d1" +dependencies = [ + "derivative", + "field-assembly", + "num-traits 0.2.14", + "rand 0.7.3", + "rayon", + "rustc_version 0.2.3", + "unroll", +] + +[[package]] +name = "approx" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" +dependencies = [ + "num-traits 0.2.14", +] + +[[package]] +name = "ark-ec" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea978406c4b1ca13c2db2373b05cc55429c3575b8b21f1b9ee859aa5b03dd42" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "num-traits 0.2.14", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "num-bigint", + "num-traits 0.2.14", + "paste", + "rayon", + "rustc_version 0.3.3", + "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", +] + +[[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 0.2.14", + "quote", + "syn", +] + +[[package]] +name = "ark-poly" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0f78f47537c2f15706db7e98fe64cc1711dbf9def81218194e17239e53e5aa" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown", + "rayon", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd4e5f0bf8285d5ed538d27fab7411f3e297908fd93c62195de8bee3f199e82" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits 0.2.14", + "rand 0.8.4", + "rayon", +] + +[[package]] +name = "array-init" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30bbe2f5e3d117f55bd8c7a1f9191e4a5deba9f15f595bbea4f670c59c765db" + +[[package]] +name = "array-init" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a51c983d65b6691893a791e55aa8bda43bbd9b11f947e5a9581710362277cc95" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "blake2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +dependencies = [ + "crypto-mac", + "digest", + "opaque-debug", +] + +[[package]] +name = "brave-poc" +version = "0.1.0" +dependencies = [ + "algebra", + "algebra-core", + "ark-ec", + "ark-ff", + "ark-serialize", + "array-init 0.1.1", + "commitment_dlog", + "ff-fft", + "groupmap 0.1.0 (git+https://github.com/o1-labs/zexe)", + "kimchi", + "kimchi-circuits", + "mina-curves", + "oracle", + "plonk_circuits", + "plonk_protocol_dlog", + "rand_core 0.5.1", + "rayon", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "colored" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + +[[package]] +name = "colored" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + +[[package]] +name = "commitment_dlog" +version = "0.1.0" +source = "git+https://github.com/o1-labs/proof-systems#106c6ddfa913dac683daf3369788808f0a75c4f9" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "array-init 1.0.0", + "blake2", + "colored 1.9.3", + "groupmap 0.1.0 (git+https://github.com/o1-labs/proof-systems)", + "itertools 0.8.2", + "mina-curves", + "o1-utils", + "oracle", + "rand 0.8.4", + "rand_core 0.6.3", + "rayon", + "serde", + "serde_with", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +dependencies = [ + "cfg-if", + "lazy_static", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "darling" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "ff-fft" +version = "0.1.0" +source = "git+https://github.com/o1-labs/zexe#2f61b6082b1faa4969fb05efdf3f46e1b7de96d1" +dependencies = [ + "algebra-core", + "rand 0.7.3", + "rayon", +] + +[[package]] +name = "field-assembly" +version = "0.1.0" +source = "git+https://github.com/o1-labs/zexe#2f61b6082b1faa4969fb05efdf3f46e1b7de96d1" +dependencies = [ + "mince", +] + +[[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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", +] + +[[package]] +name = "groupmap" +version = "0.1.0" +source = "git+https://github.com/o1-labs/proof-systems#106c6ddfa913dac683daf3369788808f0a75c4f9" +dependencies = [ + "ark-ec", + "ark-ff", + "rand 0.8.4", +] + +[[package]] +name = "groupmap" +version = "0.1.0" +source = "git+https://github.com/o1-labs/zexe#2f61b6082b1faa4969fb05efdf3f46e1b7de96d1" +dependencies = [ + "algebra", + "rand 0.7.3", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "itertools" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "kimchi" +version = "0.1.0" +source = "git+https://github.com/o1-labs/proof-systems#106c6ddfa913dac683daf3369788808f0a75c4f9" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "array-init 1.0.0", + "colored 2.0.0", + "commitment_dlog", + "groupmap 0.1.0 (git+https://github.com/o1-labs/proof-systems)", + "kimchi-circuits", + "mina-curves", + "o1-utils", + "oracle", + "rand 0.8.4", + "rand_core 0.5.1", + "rayon", + "rmp-serde", + "serde", + "serde_with", + "sprs 0.9.4", +] + +[[package]] +name = "kimchi-circuits" +version = "0.1.0" +source = "git+https://github.com/o1-labs/proof-systems#106c6ddfa913dac683daf3369788808f0a75c4f9" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "array-init 1.0.0", + "blake2", + "itertools 0.10.3", + "mina-curves", + "num-derive", + "num-traits 0.2.14", + "o1-utils", + "oracle", + "rand 0.8.4", + "rand_core 0.5.1", + "rayon", + "serde", + "serde_with", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" + +[[package]] +name = "libm" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" + +[[package]] +name = "matrixmultiply" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "916806ba0031cd542105d916a97c8572e1fa6dd79c9c51e7eb43a09ec2dd84c1" +dependencies = [ + "rawpointer", +] + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mina-curves" +version = "0.1.0" +source = "git+https://github.com/o1-labs/proof-systems#106c6ddfa913dac683daf3369788808f0a75c4f9" +dependencies = [ + "ark-ec", + "ark-ff", +] + +[[package]] +name = "mince" +version = "0.1.0" +source = "git+https://github.com/o1-labs/zexe#2f61b6082b1faa4969fb05efdf3f46e1b7de96d1" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "ndarray" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac06db03ec2f46ee0ecdca1a1c34a99c0d188a0d83439b84bf0cb4b386e4ab09" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits 0.2.14", + "rawpointer", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits 0.2.14", +] + +[[package]] +name = "num-complex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" +dependencies = [ + "autocfg", + "num-traits 0.2.14", +] + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits 0.2.14", +] + +[[package]] +name = "num-traits" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" +dependencies = [ + "num-traits 0.2.14", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "o1-utils" +version = "0.1.0" +source = "git+https://github.com/o1-labs/proof-systems#106c6ddfa913dac683daf3369788808f0a75c4f9" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "rayon", + "serde", + "serde_with", +] + +[[package]] +name = "once_cell" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "oracle" +version = "0.1.0" +source = "git+https://github.com/o1-labs/proof-systems#106c6ddfa913dac683daf3369788808f0a75c4f9" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "hex", + "mina-curves", + "num-bigint", + "o1-utils", + "rand 0.8.4", + "rayon", + "serde", + "serde_json", + "serde_with", +] + +[[package]] +name = "paste" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "plonk_circuits" +version = "0.1.0" +source = "git+https://github.com/o1-labs/proof-systems#106c6ddfa913dac683daf3369788808f0a75c4f9" +dependencies = [ + "ark-ff", + "ark-poly", + "array-init 1.0.0", + "blake2", + "mina-curves", + "num-derive", + "num-traits 0.2.14", + "o1-utils", + "oracle", + "rand_core 0.5.1", + "rayon", +] + +[[package]] +name = "plonk_protocol_dlog" +version = "0.1.0" +source = "git+https://github.com/o1-labs/proof-systems#106c6ddfa913dac683daf3369788808f0a75c4f9" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "array-init 1.0.0", + "colored 1.9.3", + "commitment_dlog", + "mina-curves", + "o1-utils", + "oracle", + "plonk_circuits", + "rand 0.8.4", + "rand_core 0.6.3", + "rayon", + "sprs 0.7.1", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" + +[[package]] +name = "proc-macro2" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.3", + "rand_hc 0.3.1", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[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 0.6.3", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom 0.2.3", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +dependencies = [ + "rand_core 0.6.3", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "rayon" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + +[[package]] +name = "rmp" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f55e5fa1446c4d5dd1f5daeed2a4fe193071771a2636274d0d7a3b082aa7ad6" +dependencies = [ + "byteorder", + "num-traits 0.2.14", +] + +[[package]] +name = "rmp-serde" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723ecff9ad04f4ad92fe1c8ca6c20d2196d9286e9c60727c4cb5511629260e9d" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + +[[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 = "rustversion" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" + +[[package]] +name = "ryu" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[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.2", +] + +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.131" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.131" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ffa0837f2dfa6fb90868c2b5468cad482e175f7dad97e7421951e663f2b527" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad6056b4cb69b6e43e3a0f055def223380baecc99da683884f205bf347f7c4b3" +dependencies = [ + "rustversion", + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12e47be9471c72889ebafb5e14d5ff930d89ae7a67bbdb5f8abb564f845a927e" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "smallvec" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" + +[[package]] +name = "sprs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec63571489873d4506683915840eeb1bb16b3198ee4894cc6f2fe3013d505e56" +dependencies = [ + "alga", + "ndarray", + "num-complex", + "num-traits 0.1.43", +] + +[[package]] +name = "sprs" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed3b0e2c934e8eb2592a534134c1149869e4b2e55bd4086017d342be6afaea4" +dependencies = [ + "alga", + "ndarray", + "num-complex", + "num-traits 0.2.14", + "num_cpus", + "rayon", + "smallvec", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "typenum" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "unroll" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ad948c1cb799b1a70f836077721a92a35ac177d4daddf4c20a633786d4cf618" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zeroize" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65f1a51723ec88c66d5d1fe80c841f17f63587d6691901d66be9bec6c3b51f73" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] diff --git a/Cargo.toml b/Cargo.toml index bb9cf6f..5a694da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,14 +7,26 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -oracle = { path = "./marlin/oracle" } -groupmap = { path = "./marlin/zexe/groupmap" } -algebra = { path = "./marlin/zexe/algebra", features = [ "parallel", "pasta", "asm" ] } -commitment_dlog = { path = "./marlin/dlog/commitment" } -plonk_5_wires_protocol_dlog = { path = "./marlin/dlog/plonk-5-wires" } -plonk_5_wires_circuits = { path = "./marlin/circuits/plonk-5-wires" } - -ff-fft = { path = "./marlin/zexe/ff-fft" } +oracle = { git = "https://github.com/o1-labs/proof-systems" } +groupmap= { git = "https://github.com/o1-labs/zexe" } +commitment_dlog = { git = "https://github.com/o1-labs/proof-systems" } + +plonk_protocol_dlog = { git = "https://github.com/o1-labs/proof-systems" } +plonk_circuits = { git = "https://github.com/o1-labs/proof-systems" } + +kimchi = { git = "https://github.com/o1-labs/proof-systems" } +kimchi-circuits = { git = "https://github.com/o1-labs/proof-systems" } + +algebra-core = { git = "https://github.com/o1-labs/zexe", default-features = false } +algebra = { git = "https://github.com/o1-labs/zexe", features = [ "parallel", "pasta", "asm" ] } + +ff-fft = { git = "https://github.com/o1-labs/zexe" } + +mina-curves = { git = "https://github.com/o1-labs/proof-systems" } +ark-ff = { version = "0.3.0", features = [ "parallel", "asm" ] } +ark-ec = { version = "0.3.0", features = [ "parallel" ] } + +ark-serialize = "0.3.0" rand_core = "0.5" array-init = "0.1.1" diff --git a/marlin b/marlin deleted file mode 160000 index 6ca6a25..0000000 --- a/marlin +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6ca6a25050e2f3f64150aa48e0aa7a1408606f13 diff --git a/src/bba.rs b/src/bba.rs index 9c35476..64d44e7 100644 --- a/src/bba.rs +++ b/src/bba.rs @@ -6,20 +6,32 @@ use crate::endo::EndoScalar; use crate::fft::lagrange_commitments; use crate::proof_system; use crate::schnorr; -use algebra::{AffineCurve, PrimeField, ProjectiveCurve, UniformRand, VariableBaseMSM, Zero}; + +use ark_ff::{SquareRootField, PrimeField, UniformRand, Zero}; +use ark_ec::{ + msm::VariableBaseMSM, + AffineCurve, + ProjectiveCurve +}; + use array_init::array_init; use commitment_dlog::{ - commitment::{CommitmentCurve, PolyComm}, + commitment::{CommitmentCurve, PolyComm, CommitmentField}, srs::SRS, }; use oracle::FqSponge; -use plonk_5_wires_protocol_dlog::{ + +//use plonk_protocol_dlog::{ +use kimchi::{ + prover::ProverProof, index::{Index, VerifierIndex}, plonk_sponge::FrSponge, - prover::ProverProof, }; + use schnorr::SignatureParams; +use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; + #[derive(Clone)] pub struct Params { pub h: G, @@ -90,7 +102,9 @@ pub struct UpdateRequest { // size in bytes pub fn proof_size(proof: &ProverProof) -> usize { - fn poly_comm(pc: &PolyComm) -> usize { + fn poly_comm(pc: &PolyComm) -> usize + where A: CanonicalDeserialize + CanonicalSerialize + { match &pc.shifted { None => pc.unshifted.len(), Some(_) => 1 + pc.unshifted.len(), @@ -133,34 +147,42 @@ pub struct UpdateResponse { signature: schnorr::Signature, } -pub struct UpdateAuthority<'a, G: schnorr::CoordinateCurve, Other: CommitmentCurve> { +pub struct UpdateAuthority { pub signing_key: schnorr::PrivateKey, pub signer: schnorr::Signer, pub lgr_comms: Vec, - pub update_vk: VerifierIndex<'a, Other>, - pub init_vk: VerifierIndex<'a, Other>, + pub update_vk: VerifierIndex, + pub init_vk: VerifierIndex, pub other_lgr_comms: Vec>, pub big_other_lgr_comms: Vec>, pub group_map: Other::Map, } -pub struct UserProver<'a, G: CommitmentCurve, Other: CommitmentCurve> { +pub struct UserProver + where + ::ScalarField: CommitmentField, + ::ScalarField: CommitmentField +{ pub proof_system_constants: proof_system::Constants, pub group_map: Other::Map, pub g_group_map: G::Map, - pub init_pk: Index<'a, Other>, - pub update_pk: Index<'a, Other>, - pub open_pk: Index<'a, G>, + pub init_pk: Index, + pub update_pk: Index, + pub open_pk: Index, pub update_params: bba_update_proof::Params, pub init_params: bba_init_proof::Params, pub open_params: bba_open_proof::Params, } -pub struct UserConfig<'a, G: CommitmentCurve, Other: CommitmentCurve> { +pub struct UserConfig + where + ::ScalarField: CommitmentField, + ::ScalarField: CommitmentField +{ pub signer: schnorr::Signer, pub authority_public_key: schnorr::PublicKey, pub bba: Params, - pub prover: UserProver<'a, G, Other>, + pub prover: UserProver, } pub struct UserState { @@ -175,9 +197,12 @@ pub struct UserState { pub pending_update_witness: Option>, } -pub struct User<'a, C: proof_system::Cycle> { +pub struct User + where ::InnerField: CommitmentField, + ::OuterField: CommitmentField +{ // G: CommitmentCurve, Other: CommitmentCurve - pub config: UserConfig<'a, C::Inner, C::Outer>, + pub config: UserConfig, pub state: UserState, } @@ -193,7 +218,6 @@ pub struct Payout { impl RewardOpening { pub fn verify_batch< - 'a, EFqSponge: Clone + FqSponge, EFrSponge: FrSponge, >( @@ -201,7 +225,7 @@ impl RewardOpening { bba: &Params, authority_public_key: C::Inner, group_map: &C::InnerMap, - vk: &VerifierIndex<'a, C::Inner>, + vk: &VerifierIndex, openings: Vec<&Self> ) -> Result<(), String> { let lgr_comms: Vec> = bba @@ -236,7 +260,6 @@ impl RewardOpening { } pub fn verify< - 'a, EFqSponge: Clone + FqSponge, EFrSponge: FrSponge, >( @@ -245,7 +268,7 @@ impl RewardOpening { bba: &Params, authority_public_key: C::Inner, group_map: &C::InnerMap, - vk: &VerifierIndex<'a, C::Inner>, + vk: &VerifierIndex, ) -> Result, &str> { let lgr_comms: Vec> = bba .lagrange_commitments @@ -311,7 +334,10 @@ pub fn init_secrets() -> bba_init_proof::Witness { } } -impl<'a, C: proof_system::Cycle> User<'a, C> { +impl User + where ::InnerField: CommitmentField, + ::OuterField: CommitmentField +{ pub fn check_invariant(&self) { let reward = self .state @@ -348,17 +374,17 @@ impl<'a, C: proof_system::Cycle> User<'a, C> { } pub fn init( - config: UserConfig<'a, C::Inner, C::Outer>, + config: UserConfig, secrets: bba_init_proof::Witness, signature: schnorr::Signature, - ) -> Result { + ) -> Result { let acc = config.bba.secret_commitment(&secrets); if !config .signer .verify(config.authority_public_key, acc, signature) { - return Err("init signature failed to verify"); + return Err("init signature failed to verify".to_string()); } let counters = vec![0; MAX_COUNTERS]; @@ -466,11 +492,13 @@ impl<'a, C: proof_system::Cycle> User<'a, C> { } impl<'a, G: CommitmentCurve, Other: CommitmentCurve> - UserConfig<'a, G, Other> + UserConfig where - G::BaseField: algebra::SquareRootField + algebra::PrimeField, - ::Projective: - std::ops::MulAssign<::BaseField>, + G::BaseField: SquareRootField + PrimeField, + ::Projective: + std::ops::MulAssign<::BaseField>, + ::BaseField: CommitmentField, + ::ScalarField: CommitmentField { pub fn request_init< EFqSponge: Clone + FqSponge, @@ -495,7 +523,10 @@ where } } -impl<'a, C: proof_system::Cycle> User<'a, C> { +impl User + where ::InnerField: CommitmentField, + ::OuterField: CommitmentField +{ pub fn request_update< EFqSponge: Clone + FqSponge, EFrSponge: FrSponge, @@ -577,11 +608,11 @@ fn batch_verify_proofs< // This code would run on brave's server for instance impl<'a, G: CommitmentCurve, Other: CommitmentCurve> - UpdateAuthority<'a, G, Other> + UpdateAuthority where - G::BaseField: algebra::SquareRootField + algebra::PrimeField, - ::Projective: - std::ops::MulAssign<::BaseField>, + G::BaseField: SquareRootField + PrimeField, + ::Projective: + std::ops::MulAssign<::BaseField>, { pub fn perform_init< EFqSponge: Clone + FqSponge, diff --git a/src/bba_init_proof.rs b/src/bba_init_proof.rs index 81c2fb1..3a91b57 100644 --- a/src/bba_init_proof.rs +++ b/src/bba_init_proof.rs @@ -1,6 +1,9 @@ use crate::proof_system::*; use crate::schnorr; -use algebra::{AffineCurve, FftField, PrimeField}; + +use ark_ec::AffineCurve; +use ark_ff::{FftField, PrimeField}; + use schnorr::CoordinateCurve; // Proof spec: diff --git a/src/bba_open_proof.rs b/src/bba_open_proof.rs index 19597a3..b2e7624 100644 --- a/src/bba_open_proof.rs +++ b/src/bba_open_proof.rs @@ -1,9 +1,12 @@ use crate::bba; use crate::proof_system::*; use crate::schnorr; -use algebra::{AffineCurve, FftField, PrimeField}; + +use ark_ff::{FftField, PrimeField}; +use ark_ec::AffineCurve; + use array_init::array_init; -use plonk_5_wires_circuits::gate::GateType; +use plonk_circuits::gate::GateType; use schnorr::CoordinateCurve; // c, total value diff --git a/src/bba_update_proof.rs b/src/bba_update_proof.rs index b975f55..c6c5164 100644 --- a/src/bba_update_proof.rs +++ b/src/bba_update_proof.rs @@ -1,6 +1,9 @@ use crate::proof_system::*; use crate::schnorr; -use algebra::{AffineCurve, FftField, PrimeField}; + +use ark_ec::AffineCurve; +use ark_ff::{FftField, PrimeField}; + use schnorr::CoordinateCurve; // Parameters for the update proof circuit. diff --git a/src/endo.rs b/src/endo.rs index 4b9203a..407bea1 100644 --- a/src/endo.rs +++ b/src/endo.rs @@ -1,4 +1,5 @@ -use algebra::{BigInteger, PrimeField}; +use ark_ff::PrimeField; +use groupmap::GroupMap; #[derive(Hash, Eq, PartialEq, Debug, Clone, Copy)] pub struct EndoScalar(pub A); diff --git a/src/fft.rs b/src/fft.rs index 3918f3a..5928149 100644 --- a/src/fft.rs +++ b/src/fft.rs @@ -1,4 +1,8 @@ -use algebra::{AffineCurve, FftField, Field, One, ProjectiveCurve}; +use ark_ec::{AffineCurve, ProjectiveCurve}; + +use ark_ff::{FftField as f, Field, One}; +use algebra_core::FftField; + use commitment_dlog::{commitment::CommitmentCurve, srs::SRS}; use ff_fft::{ domain::{DomainCoeff, EvaluationDomain}, diff --git a/src/main.rs b/src/main.rs index 1719b21..6983c89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,13 @@ -use algebra::{ - pasta::{ - fp::Fp, - fq::Fq, - pallas::{Affine as Other, PallasParameters}, - vesta::{Affine, VestaParameters}, - }, - AffineCurve, ProjectiveCurve, UniformRand, +use mina_curves::pasta::{ + fp::Fp, + fq::Fq, + pallas::{Affine as Other, PallasParameters}, + vesta::{Affine, VestaParameters}, }; + +use ark_ec::{AffineCurve, ProjectiveCurve}; +use ark_ff::UniformRand; + use array_init::array_init; use commitment_dlog::{ commitment::{ceil_log2, CommitmentCurve, PolyComm}, @@ -14,9 +15,10 @@ use commitment_dlog::{ }; use groupmap::GroupMap; use oracle::{ - poseidon_5_wires::*, - sponge_5_wires::{DefaultFqSponge, DefaultFrSponge}, + poseidon::*, + sponge::{DefaultFqSponge, DefaultFrSponge}, }; +use groupmap::GroupMap; mod bba; mod bba_init_proof; @@ -33,11 +35,11 @@ use util::*; use schnorr::*; -type SpongeQ = DefaultFqSponge; -type SpongeR = DefaultFrSponge; +type SpongeQ = DefaultFqSponge; +type SpongeR = DefaultFrSponge; -type PSpongeQ = DefaultFqSponge; -type PSpongeR = DefaultFrSponge; +type PSpongeQ = DefaultFqSponge; +type PSpongeR = DefaultFrSponge; fn main() { let (_endo_q, endo_r) = endos::(); diff --git a/src/proof_system.rs b/src/proof_system.rs index d82cf53..352af12 100644 --- a/src/proof_system.rs +++ b/src/proof_system.rs @@ -1,21 +1,30 @@ use crate::random_oracle; -use algebra::{ - pasta::{fp::Fp, fq::Fq, pallas::Affine as Other, vesta::Affine}, - AffineCurve, BigInteger, FftField, Field, One, PrimeField, ProjectiveCurve, SquareRootField, - Zero, -}; + +use mina_curves::pasta::{fp::Fp, fq::Fq, pallas::Affine as Other, vesta::Affine}; +use ark_ec::{AffineCurve, ProjectiveCurve}; +use ark_ff::{biginteger::BigInteger, SquareRootField, Zero, PrimeField, FftField, Field, One}; + use array_init::array_init; use commitment_dlog::{ - commitment::{ceil_log2, CommitmentCurve, PolyComm}, - srs::{endos, SRSSpec, SRS}, + commitment::{ceil_log2, CommitmentCurve, PolyComm, CommitmentField}, + srs::{endos, SRS}, }; -use oracle::{poseidon::ArithmeticSpongeParams, poseidon_5_wires::*, FqSponge}; -use plonk_5_wires_circuits::{ - constraints::ConstraintSystem, + +use oracle::{poseidon::ArithmeticSpongeParams, poseidon::*, FqSponge}; + +use plonk_circuits::constraints::ConstraintSystem; +use kimchi_circuits::{ gate::{CircuitGate, GateType}, wires::Wire, }; -use plonk_5_wires_protocol_dlog::{index::Index, plonk_sponge::FrSponge, prover::ProverProof}; + +use plonk_protocol_dlog::index::SRSSpec; + +use kimchi::{ + index::Index, + plonk_sponge::FrSponge, + prover::ProverProof +}; use std::collections::HashMap; pub const COLUMNS: usize = 5; @@ -259,7 +268,7 @@ pub trait Cs { fn assert_add_group(&mut self, (x1, y1): (Var, Var), (x2, y2): (Var, Var), (x3, y3): (Var, Var)) { let inv = self.var(|| (x2.val() - x1.val()).inverse().unwrap()); self.gate(GateSpec { - typ: GateType::Add, + typ: GateType::CompleteAdd, row: [x1, y1, x2, y2, inv], c: vec![], }); @@ -515,7 +524,7 @@ pub trait Cs { self.var(|| { // TODO: Lift out let this: [F; COLUMNS] = - array_init(|j| sbox::(prev[j].value.unwrap())); + array_init(|j| sbox::(prev[j].value.unwrap())); rc[i] + &this .iter() @@ -651,13 +660,12 @@ impl System { } pub fn prove< - 'a, G: CommitmentCurve, H, EFqSponge: Clone + FqSponge, EFrSponge: FrSponge, >( - index: &Index<'a, G>, + index: &Index, group_map: &G::Map, blinders: Option<[Option; COLUMNS]>, public_input: Vec, @@ -665,6 +673,7 @@ pub fn prove< ) -> ProverProof where H: FnOnce(&mut WitnessGenerator, Vec>) -> (), + ::ScalarField: CommitmentField { let mut gen: WitnessGenerator = WitnessGenerator { rows: public_input @@ -706,9 +715,10 @@ pub fn generate_proving_key<'a, C: Cycle, H>( poseidon_params: &ArithmeticSpongeParams, public: usize, main: H, -) -> Index<'a, C::Outer> +) -> Index where H: FnOnce(&mut System, Vec>) -> (), + ::InnerField: CommitmentField { let mut system: System = System { next_variable: 0, diff --git a/src/schnorr.rs b/src/schnorr.rs index bd9c84e..4a3d1a9 100644 --- a/src/schnorr.rs +++ b/src/schnorr.rs @@ -1,7 +1,14 @@ -use algebra::{AffineCurve, BigInteger, PrimeField, ProjectiveCurve, UniformRand, Zero}; +use ark_ec::{AffineCurve, ProjectiveCurve}; +use ark_ff::{ + biginteger::BigInteger, + PrimeField, + Zero, + UniformRand, +}; + use array_init::array_init; use commitment_dlog::commitment::CommitmentCurve; -use oracle::{poseidon::ArithmeticSpongeParams, poseidon_5_wires::*}; +use oracle::{poseidon::ArithmeticSpongeParams, poseidon::*}; use crate::{endo, random_oracle}; @@ -95,7 +102,7 @@ where let input = [x, y, r, G::BaseField::zero(), G::BaseField::zero()]; let res = (0..random_oracle::POSEIDON_ROUNDS).fold(input, |prev, round| { let rc = &self.sponge.round_constants[round]; - let s: [_; COLUMNS] = array_init(|j| sbox::<_, PlonkSpongeConstants>(prev[j])); + let s: [_; COLUMNS] = array_init(|j| sbox::<_, PlonkSpongeConstants5W>(prev[j])); array_init(|i| { let m = &self.sponge.mds[i]; rc[i]