diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d5a5e811d2..5a57baa503 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,8 @@ jobs: cache: false - name: Build SP1 bindings run: make build_sp1_linux + - name: Build Halo2-IPA bindings + run: make build_halo2_ipa_linux - name: Build operator run: go build operator/cmd/main.go - name: Build aggregator diff --git a/.github/workflows/test-halo2-ipa.yml b/.github/workflows/test-halo2-ipa.yml new file mode 100644 index 0000000000..09eef32551 --- /dev/null +++ b/.github/workflows/test-halo2-ipa.yml @@ -0,0 +1,30 @@ +name: test-halo2-ipa + +on: + merge_group: + push: + branches: [main] + pull_request: + branches: ["*"] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Clear device space + run: | + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/ghc + sudo rm -rf /usr/local/.ghcup + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: false + + - name: Test Halo2-IPA go bindings + run: make test_halo2_ipa_go_bindings_linux diff --git a/Makefile b/Makefile index 76f880a9e7..ae38bd371a 100644 --- a/Makefile +++ b/Makefile @@ -185,6 +185,23 @@ batcher_send_burst_groth16: build_batcher_client @echo "Sending a burst of tasks to Batcher..." @./batcher/client/send_burst_tasks.sh $(BURST_SIZE) +batcher_send_halo2_ipa_task: batcher/client/target/release/batcher-client + @echo "Sending Halo2 IPA 1!=0 task to Batcher..." + @cd batcher/client/ && cargo run --release -- \ + --proving_system Halo2IPA \ + --proof test_files/halo2_ipa/proof.bin \ + --public_input test_files/halo2_ipa/pub_input.bin \ + --vk test_files/halo2_ipa/params.bin \ + +batcher_send_halo2_ipa_task_burst_5: batcher/client/target/release/batcher-client + @echo "Sending Halo2 IPA 1!=0 task to Batcher..." + @cd batcher/client/ && cargo run --release -- \ + --proving_system Halo2IPA \ + --proof test_files/halo2_ipa/proof.bin \ + --public_input test_files/halo2_ipa/pub_input.bin \ + --vk test_files/halo2_ipa/params.bin \ + --repetitions 5 + __TASK_SENDERS__: # TODO add a default proving system @@ -287,6 +304,27 @@ send_sp1_proof: --config config-files/config.yaml \ 2>&1 | zap-pretty +send_halo2_ipa_proof: ## Send a Halo2 IPA proof using the task sender + @echo "Sending Halo2 IPA proof..." + @go run task_sender/cmd/main.go send-task \ + --proving-system halo2_ipa \ + --proof task_sender/test_examples/halo2_ipa/proof.bin \ + --public-input task_sender/test_examples/halo2_ipa/pub_input.bin \ + --verification-key task_sender/test_examples/halo2_ipa/params.bin \ + --config config-files/config.yaml \ + 2>&1 | zap-pretty + +send_halo2_ipa_proof_loop: ## Send a Halo2 IPA proof using the task sender every 10 seconds + @echo "Sending Halo2 IPA proof in a loop every 10 seconds..." + @go run task_sender/cmd/main.go loop-tasks \ + --proving-system halo2_ipa \ + --proof task_sender/test_examples/halo2_ipa/proof.bin \ + --public-input task_sender/test_examples/halo2_ipa/pub_input.bin \ + --verification-key task_sender/test_examples/halo2_ipa/params.bin \ + --config config-files/config.yaml \ + --interval 10 \ + 2>&1 | zap-pretty + __METRICS__: run_metrics: ## Run metrics using metrics-docker-compose.yaml @echo "Running metrics..." @@ -398,3 +436,34 @@ test_merkle_tree_go_bindings_macos: build_merkle_tree_macos test_merkle_tree_go_bindings_linux: build_merkle_tree_linux @echo "Testing Merkle Tree Go bindings..." go test ./operator/merkle_tree/... -v + +__HALO2_IPA_FFI__: ## +build_halo2_ipa_macos: + @cd operator/halo2ipa/lib && cargo build --release + @cp operator/halo2ipa/lib/target/release/libhalo2ipa_verifier_ffi.dylib operator/halo2ipa/lib/libhalo2ipa_verifier.dylib + @cp operator/halo2ipa/lib/target/release/libhalo2ipa_verifier_ffi.a operator/halo2ipa/lib/libhalo2ipa_verifier.a + +build_halo2_ipa_linux: + @cd operator/halo2ipa/lib && cargo build --release + @cp operator/halo2ipa/lib/target/release/libhalo2ipa_verifier_ffi.so operator/halo2ipa/lib/libhalo2ipa_verifier.so + @cp operator/halo2ipa/lib/target/release/libhalo2ipa_verifier_ffi.a operator/halo2ipa/lib/libhalo2ipa_verifier.a + +test_halo2_ipa_rust_ffi: + @echo "Testing Halo2-KZG Rust FFI source code..." + @cd operator/halo2ipa/lib && cargo t --release + +test_halo2_ipa_go_bindings_macos: build_halo2_ipa_macos + @echo "Testing Halo2-KZG Go bindings..." + go test ./operator/halo2ipa/... -v + +test_halo2_ipa_go_bindings_linux: build_halo2_ipa_linux + @echo "Testing Halo2-KZG Go bindings..." + go test ./operator/halo2ipa/... -v + +generate_halo2_ipa_proof: + @cd task_sender/test_examples/halo2_ipa && \ + cargo clean && \ + rm params.bin proof.bin pub_input.bin && \ + RUST_LOG=info cargo run --release && \ + echo "Generating halo2 plonk proof..." && \ + echo "Generated halo2 plonk proof!" \ No newline at end of file diff --git a/batcher/Cargo.lock b/batcher/Cargo.lock index a3ddc2b5bf..ae029979bb 100644 --- a/batcher/Cargo.lock +++ b/batcher/Cargo.lock @@ -1280,8 +1280,12 @@ dependencies = [ "dotenv", "env_logger", "ethers", + "ff 0.13.0", "futures-channel", "futures-util", + "halo2_backend", + "halo2_proofs 0.3.0", + "halo2curves", "hex", "lambdaworks-crypto", "lazy_static", @@ -1290,7 +1294,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "sha3", + "sha3 0.10.8", "sp1-sdk", "tokio", "tokio-tungstenite 0.21.0", @@ -1389,6 +1393,16 @@ name = "blake3-zkvm" version = "0.1.0" source = "git+https://github.com/sp1-patches/BLAKE3.git?branch=patch-blake3_zkvm/v.1.0.0#bac2d59f9122b07a4d91475560b4c3214ae62444" +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "block-padding", + "generic-array 0.14.7", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -1398,6 +1412,12 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + [[package]] name = "bls12_381" version = "0.7.1" @@ -1406,7 +1426,7 @@ checksum = "a3c196a77437e7cc2fb515ce413a6401291578b5afc8ecb29a3c7ab957f05941" dependencies = [ "ff 0.12.1", "group 0.12.1", - "pairing", + "pairing 0.22.0", "rand_core", "subtle", ] @@ -1665,7 +1685,7 @@ dependencies = [ "serde", "serde_derive", "sha2", - "sha3", + "sha3 0.10.8", "thiserror", ] @@ -2023,7 +2043,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", + "block-buffer 0.10.4", "const-oid", "crypto-common", "subtle", @@ -2204,7 +2224,7 @@ dependencies = [ "rand", "rlp", "serde", - "sha3", + "sha3 0.10.8", "zeroize", ] @@ -2276,7 +2296,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "sha3", + "sha3 0.10.8", "thiserror", "uuid 0.8.2", ] @@ -2293,7 +2313,7 @@ dependencies = [ "regex", "serde", "serde_json", - "sha3", + "sha3 0.10.8", "thiserror", "uint", ] @@ -2991,7 +3011,49 @@ version = "0.1.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a23c779b38253fe1538102da44ad5bd5378495a61d2c4ee18d64eaa61ae5995" dependencies = [ - "halo2_proofs", + "halo2_proofs 0.1.0", +] + +[[package]] +name = "halo2_backend" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "halo2_middleware", + "halo2curves", + "rand_chacha", + "rand_core", + "rayon", + "serde", + "sha3 0.9.1", + "tracing", +] + +[[package]] +name = "halo2_frontend" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "halo2_middleware", + "halo2curves", + "tracing", +] + +[[package]] +name = "halo2_middleware" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "ff 0.13.0", + "halo2curves", + "rayon", + "serde", ] [[package]] @@ -3008,6 +3070,46 @@ dependencies = [ "rayon", ] +[[package]] +name = "halo2_proofs" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "bincode", + "group 0.13.0", + "halo2_backend", + "halo2_frontend", + "halo2_middleware", + "halo2curves", + "rand_core", + "serde", +] + +[[package]] +name = "halo2curves" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db81d01d0bbfec9f624d7590fc6929ee2537a64ec1e080d8f8c9e2d2da291405" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "hex", + "lazy_static", + "num-bigint 0.4.5", + "num-traits", + "pairing 0.23.0", + "pasta_curves 0.5.1", + "paste", + "rand", + "rand_core", + "rayon", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -3645,7 +3747,7 @@ dependencies = [ "lambdaworks-math", "serde", "sha2", - "sha3", + "sha3 0.10.8", ] [[package]] @@ -4051,6 +4153,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + [[package]] name = "open-fastrlp" version = "0.1.4" @@ -4404,6 +4512,15 @@ dependencies = [ "group 0.12.1", ] +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group 0.13.0", +] + [[package]] name = "parity-scale-codec" version = "3.6.12" @@ -4488,8 +4605,10 @@ dependencies = [ "blake2b_simd", "ff 0.13.0", "group 0.13.0", + "hex", "lazy_static", "rand", + "serde", "static_assertions", "subtle", ] @@ -5553,6 +5672,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_arrays" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.202" @@ -5696,6 +5824,18 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "keccak", + "opaque-debug", +] + [[package]] name = "sha3" version = "0.10.8" @@ -7434,7 +7574,7 @@ dependencies = [ "rand", "serde", "sha2", - "sha3", + "sha3 0.10.8", "subtle", ] diff --git a/batcher/Cargo.toml b/batcher/Cargo.toml index f18c7f5ed1..de184270b1 100644 --- a/batcher/Cargo.toml +++ b/batcher/Cargo.toml @@ -24,6 +24,10 @@ serde_json = "1.0.117" serde = { version = "1.0.201", features = ["derive"] } clap = { version = "4.5.4", features = ["derive"] } sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", rev = "v1.0.0-testnet" } +halo2curves = { version = "0.6.0", default-features = false } +halo2_backend = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.git", branch = "feat/serde_constraint_system"} +halo2_proofs = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.git", branch = "feat/serde_constraint_system" } +ff = "0.13" bincode = "1.3.3" sha3 = "0.10.8" aws-config = "1.4.0" diff --git a/batcher/client/Cargo.lock b/batcher/client/Cargo.lock index 4c5555f89d..783aba7d8c 100644 --- a/batcher/client/Cargo.lock +++ b/batcher/client/Cargo.lock @@ -1280,8 +1280,12 @@ dependencies = [ "dotenv", "env_logger", "ethers", + "ff 0.13.0", "futures-channel", "futures-util", + "halo2_backend", + "halo2_proofs 0.3.0", + "halo2curves", "hex", "lambdaworks-crypto", "lazy_static", @@ -1290,7 +1294,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "sha3", + "sha3 0.10.8", "sp1-sdk", "tokio", "tokio-tungstenite 0.21.0", @@ -1410,6 +1414,16 @@ name = "blake3-zkvm" version = "0.1.0" source = "git+https://github.com/sp1-patches/BLAKE3.git?branch=patch-blake3_zkvm/v.1.0.0#bac2d59f9122b07a4d91475560b4c3214ae62444" +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "block-padding", + "generic-array 0.14.7", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -1419,6 +1433,12 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + [[package]] name = "bls12_381" version = "0.7.1" @@ -1427,7 +1447,7 @@ checksum = "a3c196a77437e7cc2fb515ce413a6401291578b5afc8ecb29a3c7ab957f05941" dependencies = [ "ff 0.12.1", "group 0.12.1", - "pairing", + "pairing 0.22.0", "rand_core", "subtle", ] @@ -1686,7 +1706,7 @@ dependencies = [ "serde", "serde_derive", "sha2", - "sha3", + "sha3 0.10.8", "thiserror", ] @@ -2044,7 +2064,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", + "block-buffer 0.10.4", "const-oid", "crypto-common", "subtle", @@ -2225,7 +2245,7 @@ dependencies = [ "rand", "rlp", "serde", - "sha3", + "sha3 0.10.8", "zeroize", ] @@ -2297,7 +2317,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "sha3", + "sha3 0.10.8", "thiserror", "uuid 0.8.2", ] @@ -2314,7 +2334,7 @@ dependencies = [ "regex", "serde", "serde_json", - "sha3", + "sha3 0.10.8", "thiserror", "uint", ] @@ -3012,7 +3032,49 @@ version = "0.1.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a23c779b38253fe1538102da44ad5bd5378495a61d2c4ee18d64eaa61ae5995" dependencies = [ - "halo2_proofs", + "halo2_proofs 0.1.0", +] + +[[package]] +name = "halo2_backend" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "halo2_middleware", + "halo2curves", + "rand_chacha", + "rand_core", + "rayon", + "serde", + "sha3 0.9.1", + "tracing", +] + +[[package]] +name = "halo2_frontend" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "halo2_middleware", + "halo2curves", + "tracing", +] + +[[package]] +name = "halo2_middleware" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "ff 0.13.0", + "halo2curves", + "rayon", + "serde", ] [[package]] @@ -3029,6 +3091,46 @@ dependencies = [ "rayon", ] +[[package]] +name = "halo2_proofs" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "bincode", + "group 0.13.0", + "halo2_backend", + "halo2_frontend", + "halo2_middleware", + "halo2curves", + "rand_core", + "serde", +] + +[[package]] +name = "halo2curves" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db81d01d0bbfec9f624d7590fc6929ee2537a64ec1e080d8f8c9e2d2da291405" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "hex", + "lazy_static", + "num-bigint 0.4.5", + "num-traits", + "pairing 0.23.0", + "pasta_curves 0.5.1", + "paste", + "rand", + "rand_core", + "rayon", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -3666,7 +3768,7 @@ dependencies = [ "lambdaworks-math", "serde", "sha2", - "sha3", + "sha3 0.10.8", ] [[package]] @@ -4072,6 +4174,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + [[package]] name = "open-fastrlp" version = "0.1.4" @@ -4425,6 +4533,15 @@ dependencies = [ "group 0.12.1", ] +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group 0.13.0", +] + [[package]] name = "parity-scale-codec" version = "3.6.12" @@ -4509,8 +4626,10 @@ dependencies = [ "blake2b_simd", "ff 0.13.0", "group 0.13.0", + "hex", "lazy_static", "rand", + "serde", "static_assertions", "subtle", ] @@ -5574,6 +5693,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_arrays" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.202" @@ -5717,6 +5845,18 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "keccak", + "opaque-debug", +] + [[package]] name = "sha3" version = "0.10.8" @@ -7455,7 +7595,7 @@ dependencies = [ "rand", "serde", "sha2", - "sha3", + "sha3 0.10.8", "subtle", ] diff --git a/batcher/client/test_files/halo2_ipa/params.bin b/batcher/client/test_files/halo2_ipa/params.bin new file mode 100644 index 0000000000..8a5ea17b6c Binary files /dev/null and b/batcher/client/test_files/halo2_ipa/params.bin differ diff --git a/batcher/client/test_files/halo2_ipa/proof.bin b/batcher/client/test_files/halo2_ipa/proof.bin new file mode 100644 index 0000000000..9e7458682c Binary files /dev/null and b/batcher/client/test_files/halo2_ipa/proof.bin differ diff --git a/batcher/client/test_files/halo2_ipa/pub_input.bin b/batcher/client/test_files/halo2_ipa/pub_input.bin new file mode 100644 index 0000000000..015f0873ec --- /dev/null +++ b/batcher/client/test_files/halo2_ipa/pub_input.bin @@ -0,0 +1 @@ +s> ri^j=oh@\.4^pq) \ No newline at end of file diff --git a/batcher/src/halo2/ipa/mod.rs b/batcher/src/halo2/ipa/mod.rs new file mode 100644 index 0000000000..5f9ad06cd5 --- /dev/null +++ b/batcher/src/halo2/ipa/mod.rs @@ -0,0 +1,111 @@ +use halo2_proofs::{ + plonk::{verify_proof, VerifyingKey}, + poly::{ + commitment::Params, + ipa::{commitment::IPACommitmentScheme, multiopen::VerifierIPA, strategy::SingleStrategy}, + VerificationStrategy, + }, + transcript::{Blake2bRead, Challenge255, TranscriptReadBuffer}, + SerdeFormat, +}; +use halo2curves::bn256::{Fr, G1Affine}; +use std::io::{BufReader, ErrorKind, Read}; + +// MaxProofSize 4KB +pub const MAX_PROOF_SIZE: usize = 4 * 1024; + +// MaxConstraintSystemSize 2KB +pub const MAX_CONSTRAINT_SYSTEM_SIZE: usize = 2 * 1024; + +// MaxVerificationKeySize 1KB +pub const MAX_VERIFIER_KEY_SIZE: usize = 1024; + +// MaxipaParamsSize 4KB +pub const MAX_IPA_PARAMS_SIZE: usize = 4 * 1024; + +// MaxPublicInputSize 4KB +pub const MAX_PUBLIC_INPUT_SIZE: usize = 4 * 1024; + +pub fn verify_halo2_ipa(proof: &[u8], public_input: &[u8], verification_key: &[u8]) -> bool { + let mut cs_buffer = [0u8; MAX_CONSTRAINT_SYSTEM_SIZE]; + let cs_len_buf: [u8; 4] = verification_key[..4] + .try_into() + .map_err(|_| "Failed to convert slice to [u8; 4]") + .unwrap(); + let cs_len = u32::from_le_bytes(cs_len_buf) as usize; + let cs_offset = 12; + cs_buffer[..cs_len].clone_from_slice(&verification_key[cs_offset..(cs_offset + cs_len)]); + + // Select Verifier Key Bytes + let mut vk_buffer = [0u8; MAX_VERIFIER_KEY_SIZE]; + let vk_len_buf: [u8; 4] = verification_key[4..8] + .try_into() + .map_err(|_| "Failed to convert slice to [u8; 4]") + .unwrap(); + let vk_len = u32::from_le_bytes(vk_len_buf) as usize; + let vk_offset = cs_offset + cs_len; + vk_buffer[..vk_len].clone_from_slice(&verification_key[vk_offset..(vk_offset + vk_len)]); + + // Select IPA Params Bytes + let mut ipa_params_buffer = [0u8; MAX_IPA_PARAMS_SIZE]; + let ipa_len_buf: [u8; 4] = verification_key[8..12] + .try_into() + .map_err(|_| "Failed to convert slice to [u8; 4]") + .unwrap(); + let ipa_params_len = u32::from_le_bytes(ipa_len_buf) as usize; + let ipa_offset = vk_offset + vk_len; + ipa_params_buffer[..ipa_params_len].clone_from_slice(&verification_key[ipa_offset..]); + + if let Ok(cs) = bincode::deserialize(&cs_buffer[..]) { + if let Ok(vk) = VerifyingKey::::read( + &mut BufReader::new(&vk_buffer[..]), + SerdeFormat::RawBytes, + cs, + ) { + if let Ok(params) = Params::read::<_>(&mut BufReader::new(&ipa_params_buffer[..])) { + if let Ok(res) = read_fr(&public_input[..]) { + let strategy = SingleStrategy::new(¶ms); + let instances = res.as_slice(); + let mut transcript = + Blake2bRead::<&[u8], G1Affine, Challenge255<_>>::init(&proof[..]); + return verify_proof::< + IPACommitmentScheme, + VerifierIPA, + Challenge255, + Blake2bRead<&[u8], G1Affine, Challenge255>, + SingleStrategy, + >( + ¶ms, &vk, strategy, &[&[instances]], &mut transcript + ) + .is_ok(); + } + } + } + } + false +} + +fn read_fr(mut buf: &[u8]) -> Result, ErrorKind> { + let mut instances = Vec::with_capacity(buf.len() / 32); + // Buffer to store each 32-byte slice + let mut buffer = [0; 32]; + + loop { + // Read 32 bytes into the buffer + match buf.read_exact(&mut buffer) { + Ok(_) => { + instances.push(Fr::from_bytes(&buffer).unwrap()); + } + Err(ref e) if e.kind() == ErrorKind::UnexpectedEof => { + // If end of file reached, break the loop + break; + } + Err(e) => { + eprintln!("Error Deserializing Public Inputs: {}", e); + return Err(ErrorKind::Other); + } + } + } + + Ok(instances) +} diff --git a/batcher/src/halo2/mod.rs b/batcher/src/halo2/mod.rs new file mode 100644 index 0000000000..2dff432669 --- /dev/null +++ b/batcher/src/halo2/mod.rs @@ -0,0 +1 @@ +pub mod ipa; diff --git a/batcher/src/lib.rs b/batcher/src/lib.rs index cb709af3f8..05a36fe969 100644 --- a/batcher/src/lib.rs +++ b/batcher/src/lib.rs @@ -23,6 +23,7 @@ use crate::types::VerificationData; mod config; mod eth; pub mod gnark; +pub mod halo2; pub mod s3; pub mod types; diff --git a/batcher/src/types/mod.rs b/batcher/src/types/mod.rs index 5d0a0a973d..5baae81116 100644 --- a/batcher/src/types/mod.rs +++ b/batcher/src/types/mod.rs @@ -8,6 +8,7 @@ use sha3::{Digest, Keccak256}; use sp1_sdk::ProverClient; use crate::gnark::verify_gnark; +use crate::halo2::ipa::verify_halo2_ipa; lazy_static! { static ref SP1_PROVER_CLIENT: ProverClient = ProverClient::new(); @@ -20,6 +21,7 @@ pub enum ProvingSystemId { Groth16Bn254, #[default] SP1, + Halo2IPA, } #[derive(Debug, Serialize, Deserialize, Default, Clone)] @@ -43,6 +45,17 @@ impl VerificationData { false } + ProvingSystemId::Halo2IPA => { + let vk = &self + .verification_key + .as_ref() + .expect("Verification key is required"); + + let pub_input = &self.pub_input.as_ref().expect("Public input is required"); + let is_valid = verify_halo2_ipa(&self.proof, pub_input, vk); + debug!("Halo2-IPA proof is valid: {}", is_valid); + is_valid + } ProvingSystemId::GnarkPlonkBls12_381 | ProvingSystemId::GnarkPlonkBn254 | ProvingSystemId::Groth16Bn254 => { @@ -165,7 +178,8 @@ pub fn parse_proving_system(proving_system: &str) -> anyhow::Result Ok(ProvingSystemId::GnarkPlonkBn254), "Groth16Bn254" => Ok(ProvingSystemId::Groth16Bn254), "SP1" => Ok(ProvingSystemId::SP1), - _ => Err(anyhow!("Invalid proving system: {}, Available proving systems are: [GnarkPlonkBls12_381, GnarkPlonkBn254, Groth16Bn254, SP1]", proving_system)) + "Halo2IPA" => Ok(ProvingSystemId::Halo2IPA), + _ => Err(anyhow!("Invalid proving system: {}, Available proving systems are: [GnarkPlonkBls12_381, GnarkPlonkBn254, Groth16Bn254, SP1, Halo2IPA]", proving_system)) } } diff --git a/common/proving_systems.go b/common/proving_systems.go index c4a14169bf..5bce74da0d 100644 --- a/common/proving_systems.go +++ b/common/proving_systems.go @@ -12,10 +12,11 @@ const ( GnarkPlonkBn254 Groth16Bn254 SP1 + Halo2IPA ) func (t *ProvingSystemId) String() string { - return [...]string{"GnarkPlonkBls12_381", "GnarkPlonkBn254", "Groth16Bn254", "SP1"}[*t] + return [...]string{"GnarkPlonkBls12_381", "GnarkPlonkBn254", "Groth16Bn254", "SP1", "Halo2IPA"}[*t] } func ProvingSystemIdFromString(provingSystem string) (ProvingSystemId, error) { @@ -28,6 +29,8 @@ func ProvingSystemIdFromString(provingSystem string) (ProvingSystemId, error) { return Groth16Bn254, nil case "SP1": return SP1, nil + case "Halo2IPA": + return Halo2IPA, nil } return 0, fmt.Errorf("unknown proving system: %s", provingSystem) @@ -43,6 +46,8 @@ func ProvingSystemIdToString(provingSystem ProvingSystemId) (string, error) { return "Groth16Bn254", nil case SP1: return "SP1", nil + case Halo2IPA: + return "Halo2IPA", nil } return "", fmt.Errorf("unknown proving system: %d", provingSystem) diff --git a/operator/halo2ipa/.gitignore b/operator/halo2ipa/.gitignore new file mode 100644 index 0000000000..9599ee3f1c --- /dev/null +++ b/operator/halo2ipa/.gitignore @@ -0,0 +1,3 @@ +lib/libhalo2ipa_verifier.so +lib/libhalo2ipa_verifier.a +lib/libhalo2ipa_verifier.dylib diff --git a/operator/halo2ipa/halo2ipa.go b/operator/halo2ipa/halo2ipa.go new file mode 100644 index 0000000000..84e112bc1c --- /dev/null +++ b/operator/halo2ipa/halo2ipa.go @@ -0,0 +1,59 @@ +package halo2ipa + +/* +#cgo linux LDFLAGS: ${SRCDIR}/lib/libhalo2ipa_verifier.a -ldl -lrt -lm -lssl -lcrypto -Wl,--allow-multiple-definition +#cgo darwin LDFLAGS: -L./lib -lhalo2ipa_verifier + +#include "lib/halo2ipa.h" +*/ +import "C" +import "unsafe" + +// MaxProofSize 4KB +const MaxProofSize = 8 * 1024; + +// MaxProofSize 4KB +const MaxParamsSize = 8 * 1024; + +// MaxConstraintSystemSize 2KB +const MaxConstraintSystemSize = 2 * 1024; + +// MaxVerificationKeySize 1KB +const MaxVerifierKeySize = 1024; + +// MaxKzgParamsSize 4KB +const MaxIpaParamsSize = 4 * 1024; + +// MaxPublicInputSize 4KB +const MaxPublicInputSize = 4 * 1024; + +//Merge all pointers into one array and send across interface +func VerifyHalo2IpaProof( + proofBuffer [MaxProofSize]byte, proofLen_u32 uint32, + csBuffer [MaxConstraintSystemSize]byte, csLen_u32 uint32, + vkBuffer [MaxVerifierKeySize]byte, vkLen_u32 uint32, + ipaParamBuffer [MaxIpaParamsSize]byte, ipaParamLen_u32 uint32, + publicInputBuffer [MaxPublicInputSize]byte, publicInputLen_u32 uint32, +) bool { + // Cast data pointers to C-types + proofPtr := (*C.uchar)(unsafe.Pointer(&proofBuffer[0])) + csPtr := (*C.uchar)(unsafe.Pointer(&csBuffer[0])) + vkPtr := (*C.uchar)(unsafe.Pointer(&vkBuffer[0])) + ipaParamPtr := (*C.uchar)(unsafe.Pointer(&ipaParamBuffer[0])) + publicInputPtr := (*C.uchar)(unsafe.Pointer(&publicInputBuffer[0])) + + // Cast data length to C-types + proofLen := (C.uint32_t)(proofLen_u32) + csLen := (C.uint32_t)(csLen_u32) + vkLen := (C.uint32_t)(vkLen_u32) + ipaParamLen := (C.uint32_t)(ipaParamLen_u32) + publicInputLen := (C.uint32_t)(publicInputLen_u32) + + return (bool)(C.verify_halo2_ipa_proof_ffi( + proofPtr, proofLen, + csPtr, csLen, + vkPtr, vkLen, + ipaParamPtr, ipaParamLen, + publicInputPtr, publicInputLen), + ) +} \ No newline at end of file diff --git a/operator/halo2ipa/halo2ipa_test.go b/operator/halo2ipa/halo2ipa_test.go new file mode 100644 index 0000000000..a7cc7c83ef --- /dev/null +++ b/operator/halo2ipa/halo2ipa_test.go @@ -0,0 +1,82 @@ +package halo2ipa_test + +import ( + "os" + "testing" + "encoding/binary" + "github.com/yetanotherco/aligned_layer/operator/halo2ipa" +) + +const ProofFilePath = "../../task_sender/test_examples/halo2_ipa/proof.bin"; + +const PublicInputPath = "../../task_sender/test_examples/halo2_ipa/pub_input.bin"; + +const ParamsFilePath = "../../task_sender/test_examples/halo2_ipa/params.bin"; + +func TestHalo2IpaProofVerifies(t *testing.T) { + proofFile, err := os.Open(ProofFilePath) + if err != nil { + t.Errorf("could not open proof file: %s", err) + } + proofBytes := make([]byte, halo2ipa.MaxProofSize) + nReadProofBytes, err := proofFile.Read(proofBytes) + if err != nil { + t.Errorf("could not read bytes from file") + } + defer proofFile.Close() + + paramsFile, err := os.Open(ParamsFilePath) + if err != nil { + t.Errorf("could not open proof file: %s", err) + } + paramsFileBytes := make([]byte, halo2ipa.MaxParamsSize) + _, err = paramsFile.Read(paramsFileBytes) + if err != nil { + t.Errorf("could not read bytes from file") + } + defer paramsFile.Close() + + csLenBuffer := make([]byte, 4) + vkLenBuffer := make([]byte, 4) + ipaParamLenBuffer := make([]byte, 4) + csBytes := make([]byte, halo2ipa.MaxConstraintSystemSize) + vkBytes := make([]byte, halo2ipa.MaxVerifierKeySize) + ipaParamsBytes := make([]byte, halo2ipa.MaxIpaParamsSize) + + // Deserialize lengths of values + copy(csLenBuffer, paramsFileBytes[:4]) + copy(vkLenBuffer, paramsFileBytes[4:8]) + copy(ipaParamLenBuffer, paramsFileBytes[8:12]) + + csLen := binary.LittleEndian.Uint32(csLenBuffer) + vkLen := binary.LittleEndian.Uint32(vkLenBuffer) + ipaParamsLen := binary.LittleEndian.Uint32(ipaParamLenBuffer) + + // Select bytes + csOffset := uint32(12) + copy(csBytes, paramsFileBytes[csOffset:(csOffset + csLen)]) + vkOffset := csOffset + csLen + copy(vkBytes, paramsFileBytes[vkOffset:(vkOffset + vkLen)]) + ipaParamsOffset := vkOffset + vkLen + copy(ipaParamsBytes, paramsFileBytes[ipaParamsOffset:]) + + publicInputFile, err := os.Open(PublicInputPath) + if err != nil { + t.Errorf("could not open proof file: %s", err) + } + publicInputBytes := make([]byte, halo2ipa.MaxPublicInputSize) + nReadPublicInputBytes, err := publicInputFile.Read(publicInputBytes) + if err != nil { + t.Errorf("could not read bytes from file") + } + + if !halo2ipa.VerifyHalo2IpaProof( + ([halo2ipa.MaxProofSize]byte)(proofBytes), uint32(nReadProofBytes), + ([halo2ipa.MaxConstraintSystemSize]byte)(csBytes), uint32(csLen), + ([halo2ipa.MaxVerifierKeySize]byte)(vkBytes), uint32(vkLen), + ([halo2ipa.MaxIpaParamsSize]byte)(ipaParamsBytes), uint32(ipaParamsLen), + ([halo2ipa.MaxPublicInputSize]byte)(publicInputBytes), uint32(nReadPublicInputBytes), + ) { + t.Errorf("proof did not verify") + } +} \ No newline at end of file diff --git a/operator/halo2ipa/lib/Cargo.lock b/operator/halo2ipa/lib/Cargo.lock new file mode 100644 index 0000000000..b18ed40503 --- /dev/null +++ b/operator/halo2ipa/lib/Cargo.lock @@ -0,0 +1,1055 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "block-padding", + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "cc" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "dhat" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cd11d84628e233de0ce467de10b8633f4ddaecafadefc86e13b84b8739b827" +dependencies = [ + "backtrace", + "lazy_static", + "mintex", + "parking_lot", + "rustc-hash", + "serde", + "serde_json", + "thousands", +] + +[[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.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "bitvec", + "rand_core", + "subtle", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "gumdrop" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bc700f989d2f6f0248546222d9b4258f5b02a171a431f8285a81c08142629e3" +dependencies = [ + "gumdrop_derive", +] + +[[package]] +name = "gumdrop_derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "729f9bd3449d77e7831a18abfb7ba2f99ee813dfd15b8c2167c9a54ba20aa99d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "halo2_backend" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "halo2_middleware", + "halo2curves", + "rand_chacha", + "rand_core", + "rayon", + "serde", + "sha3", + "tracing", +] + +[[package]] +name = "halo2_frontend" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "halo2_middleware", + "halo2curves", + "tracing", +] + +[[package]] +name = "halo2_middleware" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "ff", + "halo2curves", + "rayon", + "serde", +] + +[[package]] +name = "halo2_proofs" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "bincode", + "group", + "halo2_backend", + "halo2_frontend", + "halo2_middleware", + "halo2curves", + "rand_core", + "serde", +] + +[[package]] +name = "halo2curves" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db81d01d0bbfec9f624d7590fc6929ee2537a64ec1e080d8f8c9e2d2da291405" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "hex", + "lazy_static", + "num-bigint", + "num-traits", + "pairing", + "pasta_curves", + "paste", + "rand", + "rand_core", + "rayon", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] + +[[package]] +name = "halo2ipa-verifier-ffi" +version = "0.1.0" +dependencies = [ + "assert_matches", + "bincode", + "dhat", + "ff", + "group", + "gumdrop", + "halo2_backend", + "halo2_proofs", + "halo2curves", + "proptest", + "rand_chacha", + "rand_core", + "rayon", + "serde_json", + "tracing", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "miniz_oxide" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +dependencies = [ + "adler", +] + +[[package]] +name = "mintex" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bec4598fddb13cc7b528819e697852653252b760f1228b7642679bf2ff2cd07" + +[[package]] +name = "num-bigint" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group", +] + +[[package]] +name = "parking_lot" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "pasta_curves" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "hex", + "lazy_static", + "rand", + "serde", + "static_assertions", + "subtle", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proptest" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +dependencies = [ + "bit-set", + "bit-vec", + "bitflags", + "lazy_static", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax", + "rusty-fork", + "tempfile", + "unarray", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rusty-fork" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +dependencies = [ + "fnv", + "quick-error", + "tempfile", + "wait-timeout", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_arrays" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + +[[package]] +name = "serde_json" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer", + "digest", + "keccak", + "opaque-debug", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys", +] + +[[package]] +name = "thousands" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] diff --git a/operator/halo2ipa/lib/Cargo.toml b/operator/halo2ipa/lib/Cargo.toml new file mode 100644 index 0000000000..a0ea2a3914 --- /dev/null +++ b/operator/halo2ipa/lib/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "halo2ipa-verifier-ffi" +version = "0.1.0" +edition = "2021" + +[dependencies] +bincode = "1.3.3" +halo2curves = { version = "0.6.0", default-features = false } +rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } +halo2_backend = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.git", branch = "feat/serde_constraint_system"} +halo2_proofs = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.git", branch = "feat/serde_constraint_system" } +ff = "0.13" + +[dev-dependencies] +group = "0.13" +tracing = "0.1" +rand_chacha = "0.3" +rayon = "1.8" +assert_matches = "1.5" +gumdrop = "0.8" +proptest = "1" +dhat = "0.3.2" +serde_json = "1" + +[lib] +crate-type = ["cdylib", "staticlib", "lib"] diff --git a/operator/halo2ipa/lib/halo2ipa.h b/operator/halo2ipa/lib/halo2ipa.h new file mode 100644 index 0000000000..a24e750650 --- /dev/null +++ b/operator/halo2ipa/lib/halo2ipa.h @@ -0,0 +1,8 @@ +#include +#include + +bool verify_halo2_ipa_proof_ffi(unsigned char *proof_bytes, uint32_t proof_len, + unsigned char *constraint_system_bytes, uint32_t cs_len, + unsigned char *verifier_params_bytes, uint32_t vk_len, + unsigned char *ipa_params_bytes, uint32_t ipa_params_len, + unsigned char *public_input_bytes, uint32_t public_input_len); \ No newline at end of file diff --git a/operator/halo2ipa/lib/rust-toolchain b/operator/halo2ipa/lib/rust-toolchain new file mode 100644 index 0000000000..989860f406 --- /dev/null +++ b/operator/halo2ipa/lib/rust-toolchain @@ -0,0 +1,3 @@ +[toolchain] +channel = "nightly-2024-04-17" +components = ["llvm-tools", "rustc-dev"] diff --git a/operator/halo2ipa/lib/src/lib.rs b/operator/halo2ipa/lib/src/lib.rs new file mode 100644 index 0000000000..75c85ebd22 --- /dev/null +++ b/operator/halo2ipa/lib/src/lib.rs @@ -0,0 +1,432 @@ +use std::io::{BufReader, ErrorKind, Read}; +use halo2_proofs::{ + circuit::{Layouter, SimpleFloorPlanner, Value}, + plonk::{ + verify_proof, Advice, Circuit, Column, + ConstraintSystem, ErrorFront, Fixed, Instance, VerifyingKey + }, + poly::{ + VerificationStrategy, + ipa::{ + commitment::IPACommitmentScheme, + multiopen::VerifierIPA, + strategy::SingleStrategy, + }, + commitment::Params, + Rotation, + }, + transcript::{ + Blake2bRead, Challenge255, TranscriptReadBuffer, + }, + SerdeFormat, +}; +use halo2curves::bn256::{Fr, G1Affine}; + +// MaxProofSize 4KB +pub const MAX_PROOF_SIZE: usize = 4 * 1024; + +// MaxConstraintSystemSize 2KB +pub const MAX_CONSTRAINT_SYSTEM_SIZE: usize = 2 * 1024; + +// MaxVerificationKeySize 1KB +pub const MAX_VERIFIER_KEY_SIZE: usize = 1024; + +// MaxipaParamsSize 4KB +pub const MAX_IPA_PARAMS_SIZE: usize = 4 * 1024; + +// MaxPublicInputSize 4KB +pub const MAX_PUBLIC_INPUT_SIZE: usize = 4 * 1024; + +#[no_mangle] +pub extern "C" fn verify_halo2_ipa_proof_ffi( +proof_buf: &[u8; MAX_PROOF_SIZE], +proof_len: u32, +cs_buf: &[u8; MAX_CONSTRAINT_SYSTEM_SIZE], +cs_len: u32, +verifier_key_buf: &[u8; MAX_VERIFIER_KEY_SIZE], +vk_len: u32, +ipa_params_buf: &[u8; MAX_IPA_PARAMS_SIZE], +ipa_params_len: u32, +public_input_buf: &[u8; MAX_PUBLIC_INPUT_SIZE], +public_input_len: u32, +) -> bool { + if let Ok(cs) = bincode::deserialize(&cs_buf[..(cs_len as usize)]) { + if let Ok(vk) = VerifyingKey::::read(&mut BufReader::new(&verifier_key_buf[..(vk_len as usize)]), SerdeFormat::RawBytes, cs) { + if let Ok(params) = Params::read::<_>(&mut BufReader::new(&ipa_params_buf[..(ipa_params_len as usize)])) { + if let Ok(res) = read_fr(&public_input_buf[..(public_input_len as usize)]) { + let strategy = SingleStrategy::new(¶ms); + let instances = res.as_slice(); + let mut transcript = Blake2bRead::<&[u8], G1Affine, Challenge255<_>>::init(&proof_buf[..(proof_len as usize)]); + return verify_proof::< + IPACommitmentScheme, + VerifierIPA, + Challenge255, + Blake2bRead<&[u8], G1Affine, Challenge255>, + SingleStrategy, + >(¶ms, &vk, strategy, &[&[instances]], &mut transcript).is_ok() + } + } + } + } + false +} + +fn read_fr(mut buf: &[u8]) -> Result, ErrorKind> { + //TODO: make this capacity the size of the file / 32 + let mut instances = Vec::with_capacity(buf.len() / 32); + // Buffer to store each 32-byte slice + let mut buffer = [0; 32]; + + loop { + // Read 32 bytes into the buffer + match buf.read_exact(&mut buffer) { + Ok(_) => { + instances.push(Fr::from_bytes(&buffer).unwrap()); + }, + Err(ref e) if e.kind() == ErrorKind::UnexpectedEof => { + // If end of file reached, break the loop + break; + }, + Err(e) => { + eprintln!("Error Deserializing Public Inputs: {}", e); + return Err(ErrorKind::Other) + } + } + } + + Ok(instances) +} + +// HALO2 Circuit Example +#[derive(Clone, Copy)] +struct StandardPlonkConfig { + a: Column, + b: Column, + c: Column, + q_a: Column, + q_b: Column, + q_c: Column, + q_ab: Column, + constant: Column, + #[allow(dead_code)] + instance: Column, +} + +impl StandardPlonkConfig { + fn configure(meta: &mut ConstraintSystem) -> Self { + let [a, b, c] = [(); 3].map(|_| meta.advice_column()); + let [q_a, q_b, q_c, q_ab, constant] = [(); 5].map(|_| meta.fixed_column()); + let instance = meta.instance_column(); + + [a, b, c].map(|column| meta.enable_equality(column)); + + meta.create_gate( + "q_a·a + q_b·b + q_c·c + q_ab·a·b + constant + instance = 0", + |meta| { + let [a, b, c] = [a, b, c].map(|column| meta.query_advice(column, Rotation::cur())); + let [q_a, q_b, q_c, q_ab, constant] = [q_a, q_b, q_c, q_ab, constant] + .map(|column| meta.query_fixed(column, Rotation::cur())); + let instance = meta.query_instance(instance, Rotation::cur()); + Some( + q_a * a.clone() + + q_b * b.clone() + + q_c * c + + q_ab * a * b + + constant + + instance, + ) + }, + ); + + StandardPlonkConfig { + a, + b, + c, + q_a, + q_b, + q_c, + q_ab, + constant, + instance, + } + } +} + +#[derive(Clone, Default)] +struct StandardPlonk(Fr); + +impl Circuit for StandardPlonk { + type Config = StandardPlonkConfig; + type FloorPlanner = SimpleFloorPlanner; + + fn without_witnesses(&self) -> Self { + Self::default() + } + + fn configure(meta: &mut ConstraintSystem) -> Self::Config { + StandardPlonkConfig::configure(meta) + } + + fn synthesize( + &self, + config: Self::Config, + mut layouter: impl Layouter, + ) -> Result<(), ErrorFront> { + layouter.assign_region( + || "", + |mut region| { + region.assign_advice(|| "", config.a, 0, || Value::known(self.0))?; + region.assign_fixed(|| "", config.q_a, 0, || Value::known(-Fr::one()))?; + + region.assign_advice(|| "", config.a, 1, || Value::known(-Fr::from(5u64)))?; + for (idx, column) in (1..).zip([ + config.q_a, + config.q_b, + config.q_c, + config.q_ab, + config.constant, + ]) { + region.assign_fixed(|| "", column, 1, || Value::known(Fr::from(idx as u64)))?; + } + + let a = region.assign_advice(|| "", config.a, 2, || Value::known(Fr::one()))?; + a.copy_advice(|| "", &mut region, config.b, 3)?; + a.copy_advice(|| "", &mut region, config.c, 4)?; + Ok(()) + }, + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + use rand_core::OsRng; + use std::{ + fs::File, + io::{BufWriter, Write, Read}, + }; + use ff::{Field, PrimeField}; + use halo2_backend::poly::commitment::ParamsProver; + use halo2_proofs::{ + plonk::{ + create_proof, keygen_pk, keygen_vk_custom, verify_proof, + }, + poly::{ + ipa::{ + commitment::{IPACommitmentScheme, ParamsIPA}, + multiopen::ProverIPA, + + }, + }, + transcript::{ + Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, + } + }; + + const PROOF: &[u8] = include_bytes!("../../../../task_sender/test_examples/halo2_ipa/proof.bin"); + + const PROOF_FILE_PATH: &str = "../../../task_sender/test_examples/halo2_ipa/proof.bin"; + + const PUB_INPUT: &[u8] = include_bytes!("../../../../task_sender/test_examples/halo2_ipa/pub_input.bin"); + + const PUB_INPUT_PATH: &str = "../../../task_sender/test_examples/halo2_ipa/pub_input.bin"; + + const PARAMS: &[u8] = include_bytes!("../../../../task_sender/test_examples/halo2_ipa/params.bin"); + + const PARAMS_FILE_PATH: &str = "../../../task_sender/test_examples/halo2_ipa/params.bin"; + + #[test] + fn halo2_serialization_works() { + let k = 4; + let circuit = StandardPlonk(Fr::random(OsRng)); + let params = ParamsIPA::::new(k); + let compress_selectors = true; + let vk = keygen_vk_custom(¶ms, &circuit, compress_selectors).expect("vk should not fail"); + let cs = vk.clone().cs; + let pk = keygen_pk(¶ms, vk.clone(), &circuit).expect("pk should not fail"); + + let instances: &[&[Fr]] = &[&[circuit.0]]; + let mut transcript = Blake2bWrite::<_, _, Challenge255<_>>::init(vec![]); + create_proof::< + IPACommitmentScheme, + ProverIPA, + Challenge255, + _, + Blake2bWrite, G1Affine, Challenge255<_>>, + _, + >( + ¶ms, + &pk, + &[circuit.clone()], + &[instances], + OsRng, + &mut transcript, + ) + .expect("prover should not fail"); + let proof = transcript.finalize(); + + //write proof + std::fs::write(PROOF_FILE_PATH, &proof[..]) + .expect("should succeed to write new proof"); + + //read proof + let proof = std::fs::read(PROOF_FILE_PATH).expect("should succeed to read proof"); + + //write public input + let f = File::create(PUB_INPUT_PATH).unwrap(); + let mut writer = BufWriter::new(f); + instances.to_vec().into_iter().flatten().for_each(|fp| { writer.write(&fp.to_repr()).unwrap(); }); + writer.flush().unwrap(); + + //read instances + let mut f = File::open(PUB_INPUT_PATH).unwrap(); + let mut buf = Vec::new(); + f.read_to_end(&mut buf).unwrap(); + let res = read_fr(&buf).unwrap(); + let instances = res.as_slice(); + + let mut vk_buf = Vec::new(); + vk.write(&mut vk_buf, SerdeFormat::RawBytes).unwrap(); + let vk_len = vk_buf.len(); + let mut ipa_params_buf = Vec::new(); + params.write(&mut ipa_params_buf).unwrap(); + let ipa_params_len = ipa_params_buf.len(); + + //Write everything to parameters file + let params_file = File::create(PARAMS_FILE_PATH).unwrap(); + let mut writer = BufWriter::new(params_file); + let cs_buf = bincode::serialize(&cs).unwrap(); + //Write Parameter Lengths as u32 + writer.write_all(&(cs_buf.len() as u32).to_le_bytes()).unwrap(); + writer.write_all(&(vk_len as u32).to_le_bytes()).unwrap(); + writer.write_all(&(ipa_params_len as u32).to_le_bytes()).unwrap(); + //Write Parameters + writer.write_all(&cs_buf).unwrap(); + writer.write_all(&vk_buf).unwrap(); + writer.write_all(&ipa_params_buf).unwrap(); + writer.flush().unwrap(); + + let mut f = File::open(PARAMS_FILE_PATH).unwrap(); + let mut params_buf = Vec::new(); + f.read_to_end(&mut params_buf).unwrap(); + println!("params_buf len: {:?}", params_buf.len()); + + // Select Constraint System Bytes + let mut cs_buffer = [0u8; MAX_CONSTRAINT_SYSTEM_SIZE]; + let cs_len_buf: [u8; 4] = params_buf[..4].try_into().map_err(|_| "Failed to convert slice to [u8; 4]").unwrap(); + let cs_len = u32::from_le_bytes(cs_len_buf) as usize; + let cs_offset = 12; + cs_buffer[..cs_len].clone_from_slice(¶ms_buf[cs_offset..(cs_offset + cs_len)]); + + // Select Verifier Key Bytes + let mut vk_buffer = [0u8; MAX_VERIFIER_KEY_SIZE]; + let vk_len_buf: [u8; 4] = params_buf[4..8].try_into().map_err(|_| "Failed to convert slice to [u8; 4]").unwrap(); + let vk_len = u32::from_le_bytes(vk_len_buf) as usize; + let vk_offset = cs_offset + cs_len; + vk_buffer[..vk_len].clone_from_slice(¶ms_buf[vk_offset..(vk_offset + vk_len)]); + + // Select ipa Params Bytes + let mut ipa_params_buffer = [0u8; MAX_IPA_PARAMS_SIZE]; + let ipa_len_buf: [u8; 4] = params_buf[8..12].try_into().map_err(|_| "Failed to convert slice to [u8; 4]").unwrap(); + let ipa_params_len = u32::from_le_bytes(ipa_len_buf) as usize; + let ipa_offset = vk_offset + vk_len; + ipa_params_buffer[..ipa_params_len].clone_from_slice(¶ms_buf[ipa_offset..]); + + let cs = bincode::deserialize(&cs_buf[..cs_len]).unwrap(); + let vk = VerifyingKey::::read(&mut BufReader::new(&vk_buffer[..vk_len]), SerdeFormat::RawBytes, cs).unwrap(); + let params = Params::read::<_>(&mut BufReader::new(&ipa_params_buffer[..ipa_params_len])).unwrap(); + + let strategy = SingleStrategy::new(¶ms); + let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]); + assert!(verify_proof::< + IPACommitmentScheme, + VerifierIPA, + Challenge255, + Blake2bRead<&[u8], G1Affine, Challenge255>, + SingleStrategy, + >( + ¶ms, + &vk, + strategy, + &[&[instances]], + &mut transcript + ) + .is_ok()); + } + + #[test] + fn verify_halo2_plonk_proof() { + // Select Proof Bytes + let mut proof_buffer = [0u8; MAX_PROOF_SIZE]; + let proof_len = PROOF.len(); + proof_buffer[..proof_len].clone_from_slice(PROOF); + + // Select Constraint System Bytes + let mut cs_buffer = [0u8; MAX_CONSTRAINT_SYSTEM_SIZE]; + let cs_len_buf: [u8; 4] = PARAMS[..4].try_into().map_err(|_| "Failed to convert slice to [u8; 4]").unwrap(); + let cs_len = u32::from_le_bytes(cs_len_buf) as usize; + let cs_offset = 12; + cs_buffer[..cs_len].clone_from_slice(&PARAMS[cs_offset..(cs_offset + cs_len)]); + + // Select Verifier Key Bytes + let mut vk_buffer = [0u8; MAX_VERIFIER_KEY_SIZE]; + let vk_len_buf: [u8; 4] = PARAMS[4..8].try_into().map_err(|_| "Failed to convert slice to [u8; 4]").unwrap(); + let vk_len = u32::from_le_bytes(vk_len_buf) as usize; + let vk_offset = cs_offset + cs_len; + vk_buffer[..vk_len].clone_from_slice(&PARAMS[vk_offset..(vk_offset + vk_len)]); + + // Select ipa Params Bytes + let mut ipa_params_buffer = [0u8; MAX_IPA_PARAMS_SIZE]; + let ipa_len_buf: [u8; 4] = PARAMS[8..12].try_into().map_err(|_| "Failed to convert slice to [u8; 4]").unwrap(); + let ipa_params_len = u32::from_le_bytes(ipa_len_buf) as usize; + let ipa_offset = vk_offset + vk_len; + ipa_params_buffer[..ipa_params_len].clone_from_slice(&PARAMS[ipa_offset..]); + + // Select Public Input Bytes + let mut public_input_buffer = [0u8; MAX_PUBLIC_INPUT_SIZE]; + let public_input_len = PUB_INPUT.len(); + public_input_buffer[..public_input_len].clone_from_slice(PUB_INPUT); + + let result = verify_halo2_ipa_proof_ffi(&proof_buffer, proof_len as u32, &cs_buffer, cs_len as u32, &vk_buffer, vk_len as u32, &ipa_params_buffer, ipa_params_len as u32, &public_input_buffer, public_input_len as u32); + assert!(result) + } + + #[test] + fn verify_halo2_plonk_proof_aborts_with_bad_proof() { + // Select Proof Bytes + let mut proof_buffer = [42u8; MAX_PROOF_SIZE]; + let proof_len = PROOF.len(); + proof_buffer[..proof_len].clone_from_slice(PROOF); + + // Select Constraint System Bytes + let mut cs_buffer = [0u8; MAX_CONSTRAINT_SYSTEM_SIZE]; + let cs_len_buf: [u8; 4] = PARAMS[..4].try_into().map_err(|_| "Failed to convert slice to array").unwrap(); + let cs_len = u32::from_le_bytes(cs_len_buf) as usize; + let cs_offset = 12; + cs_buffer[..cs_len].clone_from_slice(&PARAMS[cs_offset..(cs_offset + cs_len)]); + + // Select Verifier Key Bytes + let mut vk_buffer = [0u8; MAX_VERIFIER_KEY_SIZE]; + let vk_len_buf: [u8; 4] = PARAMS[4..8].try_into().map_err(|_| "Failed to convert slice to array").unwrap(); + let vk_len = u32::from_le_bytes(vk_len_buf) as usize; + let vk_offset = cs_offset + cs_len; + vk_buffer[..vk_len].clone_from_slice(&PARAMS[vk_offset..(vk_offset + vk_len)]); + + // Select ipa Params Bytes + let mut ipa_params_buffer = [0u8; MAX_IPA_PARAMS_SIZE]; + let ipa_len_buf: [u8; 4] = PARAMS[8..12].try_into().map_err(|_| "Failed to convert slice to array").unwrap(); + let ipa_params_len = u32::from_le_bytes(ipa_len_buf) as usize; + let ipa_offset = vk_offset + vk_len; + ipa_params_buffer[..ipa_params_len].clone_from_slice(&PARAMS[ipa_offset..]); + + // Select Public Input Bytes + let mut public_input_buffer = [0u8; MAX_PUBLIC_INPUT_SIZE]; + let public_input_len = PUB_INPUT.len(); + public_input_buffer[..public_input_len].clone_from_slice(PUB_INPUT); + + let result = verify_halo2_ipa_proof_ffi(&proof_buffer, (proof_len - 1) as u32, &cs_buffer, cs_len as u32, &vk_buffer, vk_len as u32, &ipa_params_buffer, ipa_params_len as u32, &public_input_buffer, public_input_len as u32); + assert!(!result) + } +} \ No newline at end of file diff --git a/operator/pkg/operator.go b/operator/pkg/operator.go index e64a8f1b95..6bd821bab4 100644 --- a/operator/pkg/operator.go +++ b/operator/pkg/operator.go @@ -3,6 +3,7 @@ package operator import ( "bytes" "context" + "encoding/binary" "crypto/ecdsa" "fmt" "github.com/prometheus/client_golang/prometheus" @@ -12,6 +13,7 @@ import ( "time" "github.com/yetanotherco/aligned_layer/operator/sp1" + "github.com/yetanotherco/aligned_layer/operator/halo2ipa" "github.com/Layr-Labs/eigensdk-go/crypto/bls" "github.com/Layr-Labs/eigensdk-go/logging" @@ -222,7 +224,60 @@ func (o *Operator) verify(verificationData VerificationData, results chan bool) verificationResult := sp1.VerifySp1Proof(([sp1.MaxProofSize]byte)(proofBytes), proofLen, ([sp1.MaxElfBufferSize]byte)(elfBytes), elfLen) o.Logger.Infof("SP1 proof verification result: %t", verificationResult) - + results <- verificationResult + case common.Halo2IPA: + // Extract Proof Bytes + proofBytes := make([]byte, halo2ipa.MaxProofSize) + copy(proofBytes, verificationData.Proof) + proofLen := (uint32)(len(verificationData.Proof)) + + // Extract Verification Key Bytes + paramsBytes := verificationData.VerificationKey + + // Deserialize csLen + csLenBuffer := make([]byte, 4) + copy(csLenBuffer, paramsBytes[:4]) + csLen := (uint32)(binary.LittleEndian.Uint32(csLenBuffer)) + + // Deserialize vkLen + vkLenBuffer := make([]byte, 4) + copy(vkLenBuffer, paramsBytes[4:8]) + vkLen := (uint32)(binary.LittleEndian.Uint32(vkLenBuffer)) + + // Deserialize ipaParamLen + IpaParamsLenBuffer := make([]byte, 4) + copy(IpaParamsLenBuffer, paramsBytes[8:12]) + IpaParamsLen := (uint32)(binary.LittleEndian.Uint32(IpaParamsLenBuffer)) + + // Extract Constraint System Bytes + csBytes := make([]byte, halo2ipa.MaxConstraintSystemSize) + csOffset := uint32(12) + copy(csBytes, paramsBytes[csOffset:(csOffset + csLen)]) + + // Extract Verification Key Bytes + vkBytes := make([]byte, halo2ipa.MaxVerifierKeySize) + vkOffset := csOffset + csLen + copy(vkBytes, paramsBytes[vkOffset:(vkOffset + vkLen)]) + + // Extract ipa Parameter Bytes + IpaParamsBytes := make([]byte,(halo2ipa.MaxIpaParamsSize)) + IpaParamsOffset := vkOffset + vkLen + copy(IpaParamsBytes, paramsBytes[IpaParamsOffset:]) + + // Extract Public Input Bytes + publicInput := verificationData.PubInput + publicInputBytes := make([]byte, halo2ipa.MaxPublicInputSize) + copy(publicInputBytes, publicInput) + publicInputLen := (uint32)(len(publicInput)) + + verificationResult := halo2ipa.VerifyHalo2IpaProof( + ([halo2ipa.MaxProofSize]byte)(proofBytes), proofLen, + ([halo2ipa.MaxConstraintSystemSize]byte)(csBytes), csLen, + ([halo2ipa.MaxVerifierKeySize]byte)(vkBytes), vkLen, + ([halo2ipa.MaxIpaParamsSize]byte)(IpaParamsBytes), IpaParamsLen, + ([halo2ipa.MaxPublicInputSize]byte)(publicInputBytes), publicInputLen,) + + o.Logger.Infof("Halo2-ipa proof verification result: %t", verificationResult) results <- verificationResult default: o.Logger.Error("Unrecognized proving system ID") diff --git a/task_sender/cmd/main.go b/task_sender/cmd/main.go index 1e16628bc2..4069044cf6 100644 --- a/task_sender/cmd/main.go +++ b/task_sender/cmd/main.go @@ -323,6 +323,8 @@ func ParseProvingSystem(provingSystemStr string) (common.ProvingSystemId, error) return common.Groth16Bn254, nil case "sp1": return common.SP1, nil + case "halo2_ipa": + return common.Halo2IPA, nil default: var unknownValue common.ProvingSystemId return unknownValue, fmt.Errorf("unsupported proving system: %s", provingSystemStr) diff --git a/task_sender/test_examples/halo2_ipa/Cargo.lock b/task_sender/test_examples/halo2_ipa/Cargo.lock new file mode 100644 index 0000000000..ba49671b81 --- /dev/null +++ b/task_sender/test_examples/halo2_ipa/Cargo.lock @@ -0,0 +1,1055 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "block-padding", + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "cc" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "dhat" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cd11d84628e233de0ce467de10b8633f4ddaecafadefc86e13b84b8739b827" +dependencies = [ + "backtrace", + "lazy_static", + "mintex", + "parking_lot", + "rustc-hash", + "serde", + "serde_json", + "thousands", +] + +[[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.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "bitvec", + "rand_core", + "subtle", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "gumdrop" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bc700f989d2f6f0248546222d9b4258f5b02a171a431f8285a81c08142629e3" +dependencies = [ + "gumdrop_derive", +] + +[[package]] +name = "gumdrop_derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "729f9bd3449d77e7831a18abfb7ba2f99ee813dfd15b8c2167c9a54ba20aa99d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "halo2_backend" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "halo2_middleware", + "halo2curves", + "rand_chacha", + "rand_core", + "rayon", + "serde", + "sha3", + "tracing", +] + +[[package]] +name = "halo2_frontend" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "halo2_middleware", + "halo2curves", + "tracing", +] + +[[package]] +name = "halo2_ipa" +version = "0.1.0" +dependencies = [ + "assert_matches", + "bincode", + "dhat", + "ff", + "group", + "gumdrop", + "halo2_backend", + "halo2_proofs", + "halo2curves", + "proptest", + "rand_chacha", + "rand_core", + "rayon", + "serde_json", + "tracing", +] + +[[package]] +name = "halo2_middleware" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "ff", + "halo2curves", + "rayon", + "serde", +] + +[[package]] +name = "halo2_proofs" +version = "0.3.0" +source = "git+https://github.com/yetanotherco/yet-another-halo2-fork.git?branch=feat/serde_constraint_system#597a9745f48fbcae37dc116697d88045e2e0a83d" +dependencies = [ + "bincode", + "group", + "halo2_backend", + "halo2_frontend", + "halo2_middleware", + "halo2curves", + "rand_core", + "serde", +] + +[[package]] +name = "halo2curves" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db81d01d0bbfec9f624d7590fc6929ee2537a64ec1e080d8f8c9e2d2da291405" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "hex", + "lazy_static", + "num-bigint", + "num-traits", + "pairing", + "pasta_curves", + "paste", + "rand", + "rand_core", + "rayon", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "miniz_oxide" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +dependencies = [ + "adler", +] + +[[package]] +name = "mintex" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bec4598fddb13cc7b528819e697852653252b760f1228b7642679bf2ff2cd07" + +[[package]] +name = "num-bigint" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group", +] + +[[package]] +name = "parking_lot" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "pasta_curves" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "hex", + "lazy_static", + "rand", + "serde", + "static_assertions", + "subtle", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proptest" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +dependencies = [ + "bit-set", + "bit-vec", + "bitflags", + "lazy_static", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax", + "rusty-fork", + "tempfile", + "unarray", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rusty-fork" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +dependencies = [ + "fnv", + "quick-error", + "tempfile", + "wait-timeout", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_arrays" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + +[[package]] +name = "serde_json" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer", + "digest", + "keccak", + "opaque-debug", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys", +] + +[[package]] +name = "thousands" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] diff --git a/task_sender/test_examples/halo2_ipa/Cargo.toml b/task_sender/test_examples/halo2_ipa/Cargo.toml new file mode 100644 index 0000000000..a1b50826f7 --- /dev/null +++ b/task_sender/test_examples/halo2_ipa/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "halo2_ipa" +version = "0.1.0" +edition = "2021" + +[dependencies] +bincode = "1.3.3" +halo2curves = { version = "0.6.0", default-features = false } +rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } +halo2_backend = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.git", branch = "feat/serde_constraint_system"} +halo2_proofs = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.git", branch = "feat/serde_constraint_system" } +ff = "0.13" + +[dev-dependencies] +group = "0.13" +tracing = "0.1" +rand_chacha = "0.3" +rayon = "1.8" +assert_matches = "1.5" +gumdrop = "0.8" +proptest = "1" +dhat = "0.3.2" +serde_json = "1" \ No newline at end of file diff --git a/task_sender/test_examples/halo2_ipa/params.bin b/task_sender/test_examples/halo2_ipa/params.bin new file mode 100644 index 0000000000..8a5ea17b6c Binary files /dev/null and b/task_sender/test_examples/halo2_ipa/params.bin differ diff --git a/task_sender/test_examples/halo2_ipa/proof.bin b/task_sender/test_examples/halo2_ipa/proof.bin new file mode 100644 index 0000000000..9e7458682c Binary files /dev/null and b/task_sender/test_examples/halo2_ipa/proof.bin differ diff --git a/task_sender/test_examples/halo2_ipa/pub_input.bin b/task_sender/test_examples/halo2_ipa/pub_input.bin new file mode 100644 index 0000000000..015f0873ec --- /dev/null +++ b/task_sender/test_examples/halo2_ipa/pub_input.bin @@ -0,0 +1 @@ +s> ri^j=oh@\.4^pq) \ No newline at end of file diff --git a/task_sender/test_examples/halo2_ipa/src/main.rs b/task_sender/test_examples/halo2_ipa/src/main.rs new file mode 100644 index 0000000000..48a3b153e2 --- /dev/null +++ b/task_sender/test_examples/halo2_ipa/src/main.rs @@ -0,0 +1,186 @@ +use std::{fs::File, io::{BufWriter, Write}}; +use halo2_proofs::{ + circuit::{Layouter, SimpleFloorPlanner, Value}, + plonk::{ + create_proof, keygen_pk, keygen_vk_custom, Advice, Circuit, Column, + ConstraintSystem, ErrorFront, Fixed, Instance + }, + poly::{ + commitment::ParamsProver, + ipa::{ + commitment::{IPACommitmentScheme, ParamsIPA}, + multiopen::ProverIPA, + }, + commitment::Params, + Rotation, + }, + transcript::{ + Blake2bWrite, Challenge255, TranscriptWriterBuffer + }, + SerdeFormat, +}; +use halo2curves::bn256::{Fr, G1Affine}; +use rand_core::OsRng; +use ff::{Field, PrimeField}; + +// HALO2 Circuit Example +#[derive(Clone, Copy)] +struct StandardPlonkConfig { + a: Column, + b: Column, + c: Column, + q_a: Column, + q_b: Column, + q_c: Column, + q_ab: Column, + constant: Column, + #[allow(dead_code)] + instance: Column, +} + +impl StandardPlonkConfig { + fn configure(meta: &mut ConstraintSystem) -> Self { + let [a, b, c] = [(); 3].map(|_| meta.advice_column()); + let [q_a, q_b, q_c, q_ab, constant] = [(); 5].map(|_| meta.fixed_column()); + let instance = meta.instance_column(); + + [a, b, c].map(|column| meta.enable_equality(column)); + + meta.create_gate( + "q_a·a + q_b·b + q_c·c + q_ab·a·b + constant + instance = 0", + |meta| { + let [a, b, c] = [a, b, c].map(|column| meta.query_advice(column, Rotation::cur())); + let [q_a, q_b, q_c, q_ab, constant] = [q_a, q_b, q_c, q_ab, constant] + .map(|column| meta.query_fixed(column, Rotation::cur())); + let instance = meta.query_instance(instance, Rotation::cur()); + Some( + q_a * a.clone() + + q_b * b.clone() + + q_c * c + + q_ab * a * b + + constant + + instance, + ) + }, + ); + + StandardPlonkConfig { + a, + b, + c, + q_a, + q_b, + q_c, + q_ab, + constant, + instance, + } + } +} + +#[derive(Clone, Default)] +struct StandardPlonk(Fr); + +impl Circuit for StandardPlonk { + type Config = StandardPlonkConfig; + type FloorPlanner = SimpleFloorPlanner; + + fn without_witnesses(&self) -> Self { + Self::default() + } + + fn configure(meta: &mut ConstraintSystem) -> Self::Config { + StandardPlonkConfig::configure(meta) + } + + fn synthesize( + &self, + config: Self::Config, + mut layouter: impl Layouter, + ) -> Result<(), ErrorFront> { + layouter.assign_region( + || "", + |mut region| { + region.assign_advice(|| "", config.a, 0, || Value::known(self.0))?; + region.assign_fixed(|| "", config.q_a, 0, || Value::known(-Fr::one()))?; + + region.assign_advice(|| "", config.a, 1, || Value::known(-Fr::from(5u64)))?; + for (idx, column) in (1..).zip([ + config.q_a, + config.q_b, + config.q_c, + config.q_ab, + config.constant, + ]) { + region.assign_fixed(|| "", column, 1, || Value::known(Fr::from(idx as u64)))?; + } + + let a = region.assign_advice(|| "", config.a, 2, || Value::known(Fr::one()))?; + a.copy_advice(|| "", &mut region, config.b, 3)?; + a.copy_advice(|| "", &mut region, config.c, 4)?; + Ok(()) + }, + ) + } +} + +fn main() { + let k = 4; + let circuit = StandardPlonk(Fr::random(OsRng)); + let params = ParamsIPA::::new(k); + let compress_selectors = true; + let vk = keygen_vk_custom(¶ms, &circuit, compress_selectors).expect("vk should not fail"); + let cs = vk.clone().cs; + let pk = keygen_pk(¶ms, vk.clone(), &circuit).expect("pk should not fail"); + + let instances: &[&[Fr]] = &[&[circuit.0]]; + let mut transcript = Blake2bWrite::<_, _, Challenge255<_>>::init(vec![]); + create_proof::< + IPACommitmentScheme, + ProverIPA, + Challenge255, + _, + Blake2bWrite, G1Affine, Challenge255<_>>, + _, + >( + ¶ms, + &pk, + &[circuit.clone()], + &[instances], + OsRng, + &mut transcript, + ) + .expect("prover should not fail"); + let proof = transcript.finalize(); + + //write proof + std::fs::write("proof.bin", &proof[..]) + .expect("should succeed to write new proof"); + + //write instances + let f = File::create("pub_input.bin").unwrap(); + let mut writer = BufWriter::new(f); + instances.to_vec().into_iter().flatten().for_each(|fp| { writer.write(&fp.to_repr()).unwrap(); }); + writer.flush().unwrap(); + + let mut vk_buf = Vec::new(); + vk.write(&mut vk_buf, SerdeFormat::RawBytes).unwrap(); + let vk_len = vk_buf.len(); + let mut ipa_params_buf = Vec::new(); + params.write(&mut ipa_params_buf).unwrap(); + let ipa_params_len = ipa_params_buf.len(); + + //Write everything to parameters file + let params_file = File::create("params.bin").unwrap(); + let mut writer = BufWriter::new(params_file); + let cs_buf = bincode::serialize(&cs).unwrap(); + //Write Parameter Lengths as u32 + writer.write_all(&(cs_buf.len() as u32).to_le_bytes()).unwrap(); + writer.write_all(&(vk_len as u32).to_le_bytes()).unwrap(); + writer.write_all(&(ipa_params_len as u32).to_le_bytes()).unwrap(); + //Write Parameters + writer.write_all(&cs_buf).unwrap(); + writer.write_all(&vk_buf).unwrap(); + writer.write_all(&ipa_params_buf).unwrap(); + writer.flush().unwrap(); +} \ No newline at end of file