Skip to content

Commit 65db976

Browse files
feat(FFI): Adds Halo2-IPA FFI Bindings (#194)
Co-authored-by: jotabulacios <jbulacios@fi.uba.ar>
1 parent 4076339 commit 65db976

30 files changed

Lines changed: 3531 additions & 23 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
cache: false
2020
- name: Build SP1 bindings
2121
run: make build_sp1_linux
22+
- name: Build Halo2-IPA bindings
23+
run: make build_halo2_ipa_linux
2224
- name: Build operator
2325
run: go build operator/cmd/main.go
2426
- name: Build aggregator
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: test-halo2-ipa
2+
3+
on:
4+
merge_group:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: ["*"]
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Clear device space
15+
run: |
16+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
17+
sudo rm -rf /usr/local/lib/android
18+
sudo rm -rf /opt/ghc
19+
sudo rm -rf /usr/local/.ghcup
20+
sudo rm -rf /usr/share/dotnet
21+
sudo rm -rf /opt/ghc
22+
sudo rm -rf "/usr/local/share/boost"
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-go@v5
25+
with:
26+
go-version: '1.22'
27+
cache: false
28+
29+
- name: Test Halo2-IPA go bindings
30+
run: make test_halo2_ipa_go_bindings_linux

Makefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,23 @@ batcher_send_burst_groth16: build_batcher_client
185185
@echo "Sending a burst of tasks to Batcher..."
186186
@./batcher/client/send_burst_tasks.sh $(BURST_SIZE)
187187

188+
batcher_send_halo2_ipa_task: batcher/client/target/release/batcher-client
189+
@echo "Sending Halo2 IPA 1!=0 task to Batcher..."
190+
@cd batcher/client/ && cargo run --release -- \
191+
--proving_system Halo2IPA \
192+
--proof test_files/halo2_ipa/proof.bin \
193+
--public_input test_files/halo2_ipa/pub_input.bin \
194+
--vk test_files/halo2_ipa/params.bin \
195+
196+
batcher_send_halo2_ipa_task_burst_5: batcher/client/target/release/batcher-client
197+
@echo "Sending Halo2 IPA 1!=0 task to Batcher..."
198+
@cd batcher/client/ && cargo run --release -- \
199+
--proving_system Halo2IPA \
200+
--proof test_files/halo2_ipa/proof.bin \
201+
--public_input test_files/halo2_ipa/pub_input.bin \
202+
--vk test_files/halo2_ipa/params.bin \
203+
--repetitions 5
204+
188205
__TASK_SENDERS__:
189206
# TODO add a default proving system
190207

@@ -287,6 +304,27 @@ send_sp1_proof:
287304
--config config-files/config.yaml \
288305
2>&1 | zap-pretty
289306

307+
send_halo2_ipa_proof: ## Send a Halo2 IPA proof using the task sender
308+
@echo "Sending Halo2 IPA proof..."
309+
@go run task_sender/cmd/main.go send-task \
310+
--proving-system halo2_ipa \
311+
--proof task_sender/test_examples/halo2_ipa/proof.bin \
312+
--public-input task_sender/test_examples/halo2_ipa/pub_input.bin \
313+
--verification-key task_sender/test_examples/halo2_ipa/params.bin \
314+
--config config-files/config.yaml \
315+
2>&1 | zap-pretty
316+
317+
send_halo2_ipa_proof_loop: ## Send a Halo2 IPA proof using the task sender every 10 seconds
318+
@echo "Sending Halo2 IPA proof in a loop every 10 seconds..."
319+
@go run task_sender/cmd/main.go loop-tasks \
320+
--proving-system halo2_ipa \
321+
--proof task_sender/test_examples/halo2_ipa/proof.bin \
322+
--public-input task_sender/test_examples/halo2_ipa/pub_input.bin \
323+
--verification-key task_sender/test_examples/halo2_ipa/params.bin \
324+
--config config-files/config.yaml \
325+
--interval 10 \
326+
2>&1 | zap-pretty
327+
290328
__METRICS__:
291329
run_metrics: ## Run metrics using metrics-docker-compose.yaml
292330
@echo "Running metrics..."
@@ -398,3 +436,34 @@ test_merkle_tree_go_bindings_macos: build_merkle_tree_macos
398436
test_merkle_tree_go_bindings_linux: build_merkle_tree_linux
399437
@echo "Testing Merkle Tree Go bindings..."
400438
go test ./operator/merkle_tree/... -v
439+
440+
__HALO2_IPA_FFI__: ##
441+
build_halo2_ipa_macos:
442+
@cd operator/halo2ipa/lib && cargo build --release
443+
@cp operator/halo2ipa/lib/target/release/libhalo2ipa_verifier_ffi.dylib operator/halo2ipa/lib/libhalo2ipa_verifier.dylib
444+
@cp operator/halo2ipa/lib/target/release/libhalo2ipa_verifier_ffi.a operator/halo2ipa/lib/libhalo2ipa_verifier.a
445+
446+
build_halo2_ipa_linux:
447+
@cd operator/halo2ipa/lib && cargo build --release
448+
@cp operator/halo2ipa/lib/target/release/libhalo2ipa_verifier_ffi.so operator/halo2ipa/lib/libhalo2ipa_verifier.so
449+
@cp operator/halo2ipa/lib/target/release/libhalo2ipa_verifier_ffi.a operator/halo2ipa/lib/libhalo2ipa_verifier.a
450+
451+
test_halo2_ipa_rust_ffi:
452+
@echo "Testing Halo2-KZG Rust FFI source code..."
453+
@cd operator/halo2ipa/lib && cargo t --release
454+
455+
test_halo2_ipa_go_bindings_macos: build_halo2_ipa_macos
456+
@echo "Testing Halo2-KZG Go bindings..."
457+
go test ./operator/halo2ipa/... -v
458+
459+
test_halo2_ipa_go_bindings_linux: build_halo2_ipa_linux
460+
@echo "Testing Halo2-KZG Go bindings..."
461+
go test ./operator/halo2ipa/... -v
462+
463+
generate_halo2_ipa_proof:
464+
@cd task_sender/test_examples/halo2_ipa && \
465+
cargo clean && \
466+
rm params.bin proof.bin pub_input.bin && \
467+
RUST_LOG=info cargo run --release && \
468+
echo "Generating halo2 plonk proof..." && \
469+
echo "Generated halo2 plonk proof!"

0 commit comments

Comments
 (0)