From a6369818fa36070e67fc98080391c4c334209df8 Mon Sep 17 00:00:00 2001 From: alv-around Date: Fri, 1 Nov 2024 19:55:42 +0100 Subject: [PATCH] reorganise repository --- .gitignore | 6 +- .../2_integer_arithmetic.ipynb | 0 .../3_modular_arithmetic.ipynb | 0 .../4_polynomial_arithmetic.ipynb | 0 .../1_commutative_groups.ipynb | 0 .../3_fields.ipynb | 0 .../4_projective_planes.ipynb | 0 .../1_short_weierstrass_curves.ipynb | 0 .../2_montgomery_curves.ipynb | 0 .../3_twisted_edwards_curves.ipynb | 0 .../4_eliptic_curve_pairings.ipynb | 8 +- .../README.md | 0 .../Statements.ipynb | 0 .../ex100.circom | 0 .../ex100_witness.json | 0 .../ex101.circom | 0 .../ex101_witness.json | 0 .../helper.circom | 0 .../package.json | 0 .../circuit_compilers.ipynb | 0 .../ch8_groth16 => ch8_groth16}/Groth16.ipynb | 0 {MMM/ch8_groth16 => ch8_groth16}/ex114.circom | 0 .../ex114_witness.json | 0 proofs-args-zk/.gitignore | 21 - proofs-args-zk/Cargo.lock | 412 ------------------ proofs-args-zk/Cargo.toml | 11 - proofs-args-zk/src/lib.rs | 83 ---- random/grand_product_argument.ipynb | 373 ---------------- 28 files changed, 9 insertions(+), 905 deletions(-) rename {MMM/ch3_arithmetic => ch3_arithmetic}/2_integer_arithmetic.ipynb (100%) rename {MMM/ch3_arithmetic => ch3_arithmetic}/3_modular_arithmetic.ipynb (100%) rename {MMM/ch3_arithmetic => ch3_arithmetic}/4_polynomial_arithmetic.ipynb (100%) rename {MMM/ch4_algebra => ch4_algebra}/1_commutative_groups.ipynb (100%) rename {MMM/ch4_algebra => ch4_algebra}/3_fields.ipynb (100%) rename {MMM/ch4_algebra => ch4_algebra}/4_projective_planes.ipynb (100%) rename {MMM/ch5_eliptic_curves => ch5_eliptic_curves}/1_short_weierstrass_curves.ipynb (100%) rename {MMM/ch5_eliptic_curves => ch5_eliptic_curves}/2_montgomery_curves.ipynb (100%) rename {MMM/ch5_eliptic_curves => ch5_eliptic_curves}/3_twisted_edwards_curves.ipynb (100%) rename {MMM/ch5_eliptic_curves => ch5_eliptic_curves}/4_eliptic_curve_pairings.ipynb (99%) rename {MMM/ch6_statements => ch6_statements}/README.md (100%) rename {MMM/ch6_statements => ch6_statements}/Statements.ipynb (100%) rename {MMM/ch6_statements => ch6_statements}/ex100.circom (100%) rename {MMM/ch6_statements => ch6_statements}/ex100_witness.json (100%) rename {MMM/ch6_statements => ch6_statements}/ex101.circom (100%) rename {MMM/ch6_statements => ch6_statements}/ex101_witness.json (100%) rename {MMM/ch6_statements => ch6_statements}/helper.circom (100%) rename {MMM/ch6_statements => ch6_statements}/package.json (100%) rename {MMM/ch7_circuit_compilers => ch7_circuit_compilers}/circuit_compilers.ipynb (100%) rename {MMM/ch8_groth16 => ch8_groth16}/Groth16.ipynb (100%) rename {MMM/ch8_groth16 => ch8_groth16}/ex114.circom (100%) rename {MMM/ch8_groth16 => ch8_groth16}/ex114_witness.json (100%) delete mode 100644 proofs-args-zk/.gitignore delete mode 100644 proofs-args-zk/Cargo.lock delete mode 100644 proofs-args-zk/Cargo.toml delete mode 100644 proofs-args-zk/src/lib.rs delete mode 100644 random/grand_product_argument.ipynb diff --git a/.gitignore b/.gitignore index 58461f2..c199441 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -.ipynb_checkpoints \ No newline at end of file +.ipynb_checkpoints + +# Added by cargo + +/target diff --git a/MMM/ch3_arithmetic/2_integer_arithmetic.ipynb b/ch3_arithmetic/2_integer_arithmetic.ipynb similarity index 100% rename from MMM/ch3_arithmetic/2_integer_arithmetic.ipynb rename to ch3_arithmetic/2_integer_arithmetic.ipynb diff --git a/MMM/ch3_arithmetic/3_modular_arithmetic.ipynb b/ch3_arithmetic/3_modular_arithmetic.ipynb similarity index 100% rename from MMM/ch3_arithmetic/3_modular_arithmetic.ipynb rename to ch3_arithmetic/3_modular_arithmetic.ipynb diff --git a/MMM/ch3_arithmetic/4_polynomial_arithmetic.ipynb b/ch3_arithmetic/4_polynomial_arithmetic.ipynb similarity index 100% rename from MMM/ch3_arithmetic/4_polynomial_arithmetic.ipynb rename to ch3_arithmetic/4_polynomial_arithmetic.ipynb diff --git a/MMM/ch4_algebra/1_commutative_groups.ipynb b/ch4_algebra/1_commutative_groups.ipynb similarity index 100% rename from MMM/ch4_algebra/1_commutative_groups.ipynb rename to ch4_algebra/1_commutative_groups.ipynb diff --git a/MMM/ch4_algebra/3_fields.ipynb b/ch4_algebra/3_fields.ipynb similarity index 100% rename from MMM/ch4_algebra/3_fields.ipynb rename to ch4_algebra/3_fields.ipynb diff --git a/MMM/ch4_algebra/4_projective_planes.ipynb b/ch4_algebra/4_projective_planes.ipynb similarity index 100% rename from MMM/ch4_algebra/4_projective_planes.ipynb rename to ch4_algebra/4_projective_planes.ipynb diff --git a/MMM/ch5_eliptic_curves/1_short_weierstrass_curves.ipynb b/ch5_eliptic_curves/1_short_weierstrass_curves.ipynb similarity index 100% rename from MMM/ch5_eliptic_curves/1_short_weierstrass_curves.ipynb rename to ch5_eliptic_curves/1_short_weierstrass_curves.ipynb diff --git a/MMM/ch5_eliptic_curves/2_montgomery_curves.ipynb b/ch5_eliptic_curves/2_montgomery_curves.ipynb similarity index 100% rename from MMM/ch5_eliptic_curves/2_montgomery_curves.ipynb rename to ch5_eliptic_curves/2_montgomery_curves.ipynb diff --git a/MMM/ch5_eliptic_curves/3_twisted_edwards_curves.ipynb b/ch5_eliptic_curves/3_twisted_edwards_curves.ipynb similarity index 100% rename from MMM/ch5_eliptic_curves/3_twisted_edwards_curves.ipynb rename to ch5_eliptic_curves/3_twisted_edwards_curves.ipynb diff --git a/MMM/ch5_eliptic_curves/4_eliptic_curve_pairings.ipynb b/ch5_eliptic_curves/4_eliptic_curve_pairings.ipynb similarity index 99% rename from MMM/ch5_eliptic_curves/4_eliptic_curve_pairings.ipynb rename to ch5_eliptic_curves/4_eliptic_curve_pairings.ipynb index fbf7123..d970877 100644 --- a/MMM/ch5_eliptic_curves/4_eliptic_curve_pairings.ipynb +++ b/ch5_eliptic_curves/4_eliptic_curve_pairings.ipynb @@ -391,9 +391,9 @@ ], "metadata": { "kernelspec": { - "display_name": "SageMath 10.3", - "language": "sage", - "name": "sagemath-10.3" + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -405,7 +405,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/MMM/ch6_statements/README.md b/ch6_statements/README.md similarity index 100% rename from MMM/ch6_statements/README.md rename to ch6_statements/README.md diff --git a/MMM/ch6_statements/Statements.ipynb b/ch6_statements/Statements.ipynb similarity index 100% rename from MMM/ch6_statements/Statements.ipynb rename to ch6_statements/Statements.ipynb diff --git a/MMM/ch6_statements/ex100.circom b/ch6_statements/ex100.circom similarity index 100% rename from MMM/ch6_statements/ex100.circom rename to ch6_statements/ex100.circom diff --git a/MMM/ch6_statements/ex100_witness.json b/ch6_statements/ex100_witness.json similarity index 100% rename from MMM/ch6_statements/ex100_witness.json rename to ch6_statements/ex100_witness.json diff --git a/MMM/ch6_statements/ex101.circom b/ch6_statements/ex101.circom similarity index 100% rename from MMM/ch6_statements/ex101.circom rename to ch6_statements/ex101.circom diff --git a/MMM/ch6_statements/ex101_witness.json b/ch6_statements/ex101_witness.json similarity index 100% rename from MMM/ch6_statements/ex101_witness.json rename to ch6_statements/ex101_witness.json diff --git a/MMM/ch6_statements/helper.circom b/ch6_statements/helper.circom similarity index 100% rename from MMM/ch6_statements/helper.circom rename to ch6_statements/helper.circom diff --git a/MMM/ch6_statements/package.json b/ch6_statements/package.json similarity index 100% rename from MMM/ch6_statements/package.json rename to ch6_statements/package.json diff --git a/MMM/ch7_circuit_compilers/circuit_compilers.ipynb b/ch7_circuit_compilers/circuit_compilers.ipynb similarity index 100% rename from MMM/ch7_circuit_compilers/circuit_compilers.ipynb rename to ch7_circuit_compilers/circuit_compilers.ipynb diff --git a/MMM/ch8_groth16/Groth16.ipynb b/ch8_groth16/Groth16.ipynb similarity index 100% rename from MMM/ch8_groth16/Groth16.ipynb rename to ch8_groth16/Groth16.ipynb diff --git a/MMM/ch8_groth16/ex114.circom b/ch8_groth16/ex114.circom similarity index 100% rename from MMM/ch8_groth16/ex114.circom rename to ch8_groth16/ex114.circom diff --git a/MMM/ch8_groth16/ex114_witness.json b/ch8_groth16/ex114_witness.json similarity index 100% rename from MMM/ch8_groth16/ex114_witness.json rename to ch8_groth16/ex114_witness.json diff --git a/proofs-args-zk/.gitignore b/proofs-args-zk/.gitignore deleted file mode 100644 index 64bf0eb..0000000 --- a/proofs-args-zk/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - -# These are backup files generated by rustfmt -**/*.rs.bk - -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb - -# RustRover -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ diff --git a/proofs-args-zk/Cargo.lock b/proofs-args-zk/Cargo.lock deleted file mode 100644 index 03f0245..0000000 --- a/proofs-args-zk/Cargo.lock +++ /dev/null @@ -1,412 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "ark-ec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" -dependencies = [ - "ark-ff", - "ark-poly", - "ark-serialize", - "ark-std", - "derivative", - "hashbrown", - "itertools", - "num-traits", - "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", - "ark-ff-macros", - "ark-serialize", - "ark-std", - "derivative", - "digest", - "itertools", - "num-bigint", - "num-traits", - "paste", - "rustc_version", - "zeroize", -] - -[[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.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-poly" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" -dependencies = [ - "ark-ff", - "ark-serialize", - "ark-std", - "derivative", - "hashbrown", -] - -[[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", - "digest", - "num-bigint", -] - -[[package]] -name = "ark-serialize-derive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[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 = "ark-test-curves" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c22c2469f93dfcace9a98baabb7af1bc0c40de82c07cffbc0deba4acf41a90" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-std", -] - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[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 = "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 = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "crypto-common", -] - -[[package]] -name = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[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", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - -[[package]] -name = "ppv-lite86" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "proofs-args-zk" -version = "0.1.0" -dependencies = [ - "ark-ff", - "ark-std", - "ark-test-curves", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "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" - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - -[[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.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[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.77", -] - -[[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.77", -] diff --git a/proofs-args-zk/Cargo.toml b/proofs-args-zk/Cargo.toml deleted file mode 100644 index e5f416a..0000000 --- a/proofs-args-zk/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "proofs-args-zk" -version = "0.1.0" -edition = "2021" - -[dependencies] -ark-ff = "0.4.2" -ark-std = "0.4.0" - -[dev-dependencies] -ark-test-curves = {version = "0.4.2", features = ["bls12_381_scalar_field"] } diff --git a/proofs-args-zk/src/lib.rs b/proofs-args-zk/src/lib.rs deleted file mode 100644 index 39ede6f..0000000 --- a/proofs-args-zk/src/lib.rs +++ /dev/null @@ -1,83 +0,0 @@ -use ark_ff::Field; - -pub struct ReedSolomon { - a: Vec, -} - -impl ReedSolomon { - pub fn new(a: Vec) -> Self { - ReedSolomon { a } - } - - pub fn draw_random() -> F { - let mut rng = ark_std::test_rng(); - F::rand(&mut rng) - } - - // calculates h(a1, ..., an) = sum^{n}_{i=1} a_i * r^{i-1)} - pub fn univariate_fingerprint(&self, r: &F) -> F { - let mut h = F::ZERO; - let mut x = F::ONE; - for a_i in self.a.iter() { - h += *a_i * x; - x *= r; - } - - h - } -} - - -#[cfg(test)] -mod tests { - use super::*; - use ark_ff::fields::{Fp64, MontBackend, MontConfig}; - use ark_test_curves::bls12_381::Fr as F; - - #[test] - fn test_custom_field() { - #[derive(MontConfig)] - #[modulus = "17"] - #[generator = "3"] - pub struct FqConfig; - pub type Fq = Fp64>; - - let a = Fq::from(9); - let b = Fq::from(10); - - let rs = ReedSolomon::new(vec![a, b]); - let r = Fq::from(8); - let result = Fq::from(9 + 80); - assert_eq!(rs.univariate_fingerprint(&r), result); - } - - #[test] - fn test_inconsistent_data() { - #[derive(MontConfig)] - #[modulus = "17"] - #[generator = "3"] - pub struct FqConfig; - pub type Fq = Fp64>; - - let a = vec![Fq::from(9), Fq::from(10)]; - let rs_a = ReedSolomon::new(a); - let rs_b = ReedSolomon::new(vec![Fq::from(9), Fq::from(11)]); - - let r = Fq::from(8); - assert_ne!( - rs_a.univariate_fingerprint(&r), - rs_b.univariate_fingerprint(&r) - ); - } - - #[test] - fn test_with_arkcurve() { - let a = F::from(9); - let b = F::from(10); - - let rs = ReedSolomon::new(vec![a, b]); - let r = F::from(8); - assert_eq!(rs.univariate_fingerprint(&r), F::from(89)); - } - -} diff --git a/random/grand_product_argument.ipynb b/random/grand_product_argument.ipynb deleted file mode 100644 index cd97050..0000000 --- a/random/grand_product_argument.ipynb +++ /dev/null @@ -1,373 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 35, - "id": "72df047f-768f-4ee2-a35d-280212d67612", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "23*x^14 + 82*x^13 + 27*x^12 + 74*x^11 + 45*x^10 + 29*x^9 + 59*x^8 + 24*x^7 + 16*x^6 + 6*x^5 + 37*x^4 + 73*x^3 + 95*x^2 + 29*x + 87" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "def calculate_tree(elements):\n", - " if len(elements) != 8:\n", - " raise ValueError(\"The list must contain exactly 8 elements.\")\n", - " \n", - " # Create the tree nodes\n", - " x = elements\n", - " \n", - " # Calculate the intermediate nodes\n", - " x_1 = x[0] * x[1]\n", - " x_2 = x[2] * x[3]\n", - " x_3 = x[4] * x[5]\n", - " x_4 = x[6] * x[7]\n", - " \n", - " # Calculate the next level of nodes\n", - " x_5 = x_1 * x_2\n", - " x_6 = x_3 * x_4\n", - " \n", - " # Calculate the root node\n", - " ROOT = x_5 * x_6\n", - " \n", - " # Return the calculated tree\n", - " return [x_1, x_2, x_3, x_4, x_5, x_6, ROOT]\n", - "\n", - "p = 120.next_prime()\n", - "F = GF(p)\n", - "R = PolynomialRing(F, 'x')\n", - "x = R.gen()\n", - "\n", - "child_nodes = [F(x) for x in [87, 71, 59, 88, 55, 102, 2, 109]]\n", - "tree = calculate_tree(child_nodes)\n", - "\n", - "g = enumerate(child_nodes + tree)\n", - "low_degree_extension = R.lagrange_polynomial(g)\n", - "low_degree_extension" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "id": "20db319f-a5b0-4883-a40b-3be79ed38029", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "input left: 2*x + 111\n", - "input left: 2*x + 112\n", - "h_i: 71*x^14 + 117*x^13 + 15*x^12 + 69*x^11 + 29*x^10 + 13*x^9 + 17*x^8 + 15*x^7 + 92*x^6 + 70*x^5 + 116*x^4 + 92*x^3 + x^2 + 72*x + 72\n", - "vanishing polynomial: x^7 + 50*x^6 + 114*x^5 + 32*x^4 + 117*x^3 + 4*x^2 + 3*x + 120\n" - ] - } - ], - "source": [ - "def input(j):\n", - " assert 8 <= j <= 14\n", - " if j == 8: return (0, 1)\n", - " elif j == 9: return (2, 3)\n", - " elif j == 10: return (4, 5)\n", - " elif j == 11: return (6, 7)\n", - " elif j == 12: return (8, 9)\n", - " elif j == 13: return (10, 11)\n", - " elif j == 14: return (12, 13)\n", - "\n", - "input_l = R.lagrange_polynomial([(i, input(i)[0]) for i in range(8, 15)])\n", - "print(f\"input left: {input_l}\")\n", - "input_r = R.lagrange_polynomial([(i, input(i)[1]) for i in range(8, 15)])\n", - "print(f\"input left: {input_r}\")\n", - "\n", - "\n", - "h = lambda x: low_degree_extension(x) - low_degree_extension(input_l(x)) * low_degree_extension(input_r(x))\n", - "assert all([h(i) == 0 for i in range(8, 15)])\n", - "\n", - "h_i = R.lagrange_polynomial(enumerate([h(i) for i in range(15)]))\n", - "print(f\"h_i: {h_i}\")\n", - "\n", - "vanishing_poly = prod([(x - i) for i in range(8, 15)])\n", - "print(f\"vanishing polynomial: {vanishing_poly}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "id": "4575457a-b9bf-4073-993a-5c345a62305e", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(71*x^7 + 123*x^6 + 122*x^5 + 27*x^4 + 87*x^3 + 41*x^2 + 19*x + 26, 0)" - ] - }, - "execution_count": 41, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "quotient, remainder = h_i.quo_rem(banishing_poly)\n", - "quotient, remainder" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "id": "75fc757e-5cc2-416b-a431-449d1bbebea6", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Lagrange Polynomial:\n", - "5*x^14 + 9*x^13 + 15*x^12 + 5*x^11 + 3*x^10 + 10*x^9 + 8*x^8 + 9*x^7 + 7*x^6 + 5*x^5 + 5*x^4 + 9*x^3 + 13*x^2 + 1\n", - "Vanishing Polynomial:\n", - "x^15 + 14*x^14 + 7*x^13 + 2*x^12 + 14*x^11 + 5*x^10 + 8*x^9 + x^7 + 14*x^6 + 7*x^5 + 2*x^4 + 14*x^3 + 5*x^2 + 8*x\n", - "Quotient Polynomial:\n", - "0\n", - "Remainder:\n", - "5*x^14 + 9*x^13 + 15*x^12 + 5*x^11 + 3*x^10 + 10*x^9 + 8*x^8 + 9*x^7 + 7*x^6 + 5*x^5 + 5*x^4 + 9*x^3 + 13*x^2 + 1\n" - ] - } - ], - "source": [ - "# Import necessary libraries\n", - "from sage.all import *\n", - "\n", - "# Initialize the list of 8 elements\n", - "elements = [1, 2, 3, 4, 5, 6, 7, 8]\n", - "\n", - "# Calculate the values in the binary tree\n", - "def calculate_tree(elements):\n", - " if len(elements) != 8:\n", - " raise ValueError(\"The list must contain exactly 8 elements.\")\n", - " \n", - " # Create the tree nodes\n", - " x = elements\n", - " \n", - " # Calculate the intermediate nodes\n", - " x_1 = x[0] * x[1]\n", - " x_2 = x[2] * x[3]\n", - " x_3 = x[4] * x[5]\n", - " x_4 = x[6] * x[7]\n", - " \n", - " # Calculate the next level of nodes\n", - " x_5 = x_1 * x_2\n", - " x_6 = x_3 * x_4\n", - " \n", - " # Calculate the root node\n", - " ROOT = x_5 * x_6\n", - " \n", - " # Return the calculated tree\n", - " return x + [x_1, x_2, x_3, x_4, x_5, x_6, ROOT]\n", - "\n", - "# Calculate the tree values\n", - "tree_values = calculate_tree(elements)\n", - "\n", - "# Enumerate the values\n", - "enumerated_values = list(enumerate(tree_values))\n", - "\n", - "# Create the field\n", - "F = GF(17) # Example with a finite field of order 17\n", - "\n", - "# Interpolation points\n", - "points = [(F(i), F(v)) for i, v in enumerated_values]\n", - "\n", - "# Create the Lagrange polynomial\n", - "P = PolynomialRing(F, 'x', mod = )\n", - "x = P.gen()\n", - "L = P.lagrange_polynomial(points)\n", - "\n", - "# Print the Lagrange polynomial\n", - "print(\"Lagrange Polynomial:\")\n", - "print(L)\n", - "\n", - "# Get the vanishing polynomial from the interpolation points\n", - "def vanishing_polynomial(points):\n", - " z = 1\n", - " for a, _ in points:\n", - " z *= (x - a)\n", - " return z\n", - "\n", - "# Calculate the vanishing polynomial\n", - "Z = vanishing_polynomial(points)\n", - "\n", - "# Print the vanishing polynomial\n", - "print(\"Vanishing Polynomial:\")\n", - "print(Z)\n", - "\n", - "# Calculate the quotient polynomial\n", - "quotient, remainder = L.quo_rem(Z)\n", - "\n", - "# Print the quotient polynomial\n", - "print(\"Quotient Polynomial:\")\n", - "print(quotient)\n", - "\n", - "# Print the remainder to ensure it is zero\n", - "print(\"Remainder:\")\n", - "print(remainder)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "id": "2f5e880e-9cbc-430c-9a54-ce3919b15bd4", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Lagrange Polynomial:\n", - "5*x^14 + 9*x^13 + 15*x^12 + 5*x^11 + 3*x^10 + 10*x^9 + 8*x^8 + 9*x^7 + 7*x^6 + 5*x^5 + 5*x^4 + 9*x^3 + 13*x^2 + 1\n", - "Vanishing Polynomial:\n", - "x^15 + 14*x^14 + 7*x^13 + 2*x^12 + 14*x^11 + 5*x^10 + 8*x^9 + x^7 + 14*x^6 + 7*x^5 + 2*x^4 + 14*x^3 + 5*x^2 + 8*x\n", - "Quotient Polynomial:\n", - "0\n", - "Remainder:\n", - "5*x^14 + 9*x^13 + 15*x^12 + 5*x^11 + 3*x^10 + 10*x^9 + 8*x^8 + 9*x^7 + 7*x^6 + 5*x^5 + 5*x^4 + 9*x^3 + 13*x^2 + 1\n", - "Evaluation of f at 10: 13\n", - "Quotient Polynomial at 10: 0\n" - ] - }, - { - "ename": "AssertionError", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[32], line 83\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[38;5;66;03m# Verify the proof by recomputing and checking the value\u001b[39;00m\n\u001b[1;32m 82\u001b[0m recomputed_value \u001b[38;5;241m=\u001b[39m Z(evaluation_point) \u001b[38;5;241m*\u001b[39m quotient_proof \n\u001b[0;32m---> 83\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m recomputed_value \u001b[38;5;241m==\u001b[39m f_evaluation\n\u001b[1;32m 84\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mVerification successful: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mrecomputed_value\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m == \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mf_evaluation\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", - "\u001b[0;31mAssertionError\u001b[0m: " - ] - } - ], - "source": [ - "# Import necessary libraries\n", - "from sage.all import *\n", - "\n", - "# Finite field of order 17\n", - "F = GF(17)\n", - "\n", - "# List of 8 elements\n", - "elements = [1, 2, 3, 4, 5, 6, 7, 8]\n", - "\n", - "# Binary tree multiplication (to simulate a function output)\n", - "def calculate_tree(elements):\n", - " if len(elements) != 8:\n", - " raise ValueError(\"The list must contain exactly 8 elements.\")\n", - " \n", - " x = elements\n", - " x_1 = x[0] * x[1]\n", - " x_2 = x[2] * x[3]\n", - " x_3 = x[4] * x[5]\n", - " x_4 = x[6] * x[7]\n", - " x_5 = x_1 * x_2\n", - " x_6 = x_3 * x_4\n", - " ROOT = x_5 * x_6\n", - " \n", - " return x + [x_1, x_2, x_3, x_4, x_5, x_6, ROOT]\n", - "\n", - "# Calculate the tree values\n", - "tree_values = calculate_tree(elements)\n", - "\n", - "# Interpolation points\n", - "points = [(F(i), F(v)) for i, v in enumerate(tree_values)]\n", - "\n", - "# Create the polynomial ring\n", - "P = PolynomialRing(F, 'x')\n", - "x = P.gen()\n", - "\n", - "# Create the Lagrange polynomial\n", - "L = P.lagrange_polynomial(points)\n", - "\n", - "# Print the Lagrange polynomial\n", - "print(\"Lagrange Polynomial:\")\n", - "print(L)\n", - "\n", - "\n", - "# Get the vanishing polynomial from the interpolation points\n", - "def vanishing_polynomial(points):\n", - " z = 1\n", - " for a, _ in points:\n", - " z *= (x - a)\n", - " return z\n", - "\n", - "# Calculate the vanishing polynomial\n", - "Z = vanishing_polynomial(points)\n", - "\n", - "# Print the vanishing polynomial\n", - "print(\"Vanishing Polynomial:\")\n", - "print(Z)\n", - "\n", - "# Calculate the quotient polynomial\n", - "quotient, remainder = L.quo_rem(Z)\n", - "\n", - "# Print the quotient polynomial\n", - "print(\"Quotient Polynomial:\")\n", - "print(quotient)\n", - "\n", - "# Print the remainder to ensure it is zero\n", - "print(\"Remainder:\")\n", - "print(remainder)\n", - "\n", - "# Example polynomial to be used in PIOP SNARK (f is an example)\n", - "f = L # In a real SNARK, this would be a function that computes the witness polynomial\n", - "\n", - "# Evaluate polynomial f at some point\n", - "evaluation_point = F(10)\n", - "f_evaluation = f(evaluation_point)\n", - "print(f\"Evaluation of f at {evaluation_point}: {f_evaluation}\")\n", - "\n", - "# Proof for the evaluation using the quotient polynomial\n", - "quotient_proof = quotient(evaluation_point)\n", - "print(f\"Quotient Polynomial at {evaluation_point}: {quotient_proof}\")\n", - "\n", - "# Verify the proof by recomputing and checking the value\n", - "recomputed_value = Z(evaluation_point) * quotient_proof \n", - "assert recomputed_value == f_evaluation\n", - "print(f\"Verification successful: {recomputed_value} == {f_evaluation}\")\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cbb86c2d-6c4e-41ad-9c01-8ea2812d71d8", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "SageMath 10.3", - "language": "sage", - "name": "sagemath-10.3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.8" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -}