-
Notifications
You must be signed in to change notification settings - Fork 585
feat: support JSON input files for bb verify command #19800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support JSON input files for bb verify command #19800
Conversation
Auto-detects JSON format by inspecting file content (starts with '{')
rather than relying on file extension.
ecb001c to
580353a
Compare
| } | ||
|
|
||
| std::vector<uint256_t> result; | ||
| result.reserve(json["fields"].size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would expect this field to be 'proof', 'vk' etc not just fields maybe. and that we'd have proper structs that represent the different forms, so this would look more like the rest of our deserialization. Those structs could have a method for reading a json object
ludamad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good overall left some comments
Address review comment: use `proof`, `vk`, and `public_inputs` as the JSON field names instead of generic `fields` array. Also use `hash` instead of `vk_hash` in VkJson since the context is already clear. Each type now has its own struct with build/parse methods: - VkJson: build() for output, parse_to_bytes() for input - ProofJson: build() for output, parse() for input - PublicInputsJson: build() for output, parse() for input
This reverts commit c1b30da.
BEGIN_COMMIT_OVERRIDE feat: support JSON input files for bb verify command (#19800) fix: update bootstrap.sh to use new JSON field names chore: Update `index.js` so that `HAS_ZK` and `PUBLIC_INPUTS` variables must always be set in tests (#19884) chore: pippenger int audit (#19302) chore: deduplicate batch affine addition trick (#19788) chore: transcript+codec+poseidon2 fixes (#19419) chore!: explicitly constrain inputs and intermediate witnesses (#19826) fix: exclude nlohmann/json from WASM builds in json_output.hpp chore: translator circuit builder and flavor audit (#19798) Revert "fix: exclude nlohmann/json from WASM builds in json_output.hpp" Revert "feat: support JSON input files for bb verify command (#19800)" Revert "fix: update bootstrap.sh to use new JSON field names" END_COMMIT_OVERRIDE
## Summary Adds support for reading JSON-formatted proof, public inputs, and VK files in the `bb verify` command. This complements the existing `--output_format json` feature by allowing the JSON files to be consumed for verification. This enables users who receive JSON proof artifacts from third parties to verify the proof before using it in their circuits (e.g., for recursive verification). ### Format Detection The format is **auto-detected by attempting to parse as JSON**. If parsing succeeds, the file is treated as JSON; otherwise it falls back to binary format. This is robust and works regardless of file extension. ### Usage ```bash # Verify using JSON files bb verify --scheme ultra_honk -p proof.json -i public_inputs.json -k vk.json # Works even without .json extension (content-based detection) bb verify --scheme ultra_honk -p my_proof -i my_inputs -k my_vk # Mix and match: JSON proof with binary VK bb verify --scheme ultra_honk -p proof.json -i public_inputs.json -k vk ``` ## Test plan - [x] Build passes - [x] Tested verify with JSON files - [x] Tested verify with binary files (no false positive JSON detection) - [x] Tested verify with mixed JSON and binary files - [x] acir_tests bb_prove tests pass
This reverts commit c1b30da.
## Summary - Re-land of #19800 with fixes for WASM build and bootstrap.sh field names - Add type-specific JSON structs (VkJson, ProofJson, PublicInputsJson) with named fields per review feedback - Auto-detect JSON vs binary format in verify command - Update bootstrap.sh to use new field names (.vk, .proof, .public_inputs, .hash) - Suppress nlohmann/json sign-conversion warnings for WASM builds using pragma ## Size Impact | Build | Without nlohmann/json | With nlohmann/json | Difference | |-------|----------------------|-------------------|------------| | Native `bb` | 63.18 MB | 63.20 MB | **+19 KB (0.03%)** | | WASM `bb` | 13.49 MB | 13.52 MB | **+30 KB (0.22%)** | ## Test plan - [x] Native build passes - [x] WASM build passes (with `--target bb`) - [x] `regenerate_recursive_inputs` passes - [x] JSON prove and verify works end-to-end
## Summary - Re-land of #19800 with fixes for WASM build and bootstrap.sh field names - Add type-specific JSON structs (VkJson, ProofJson, PublicInputsJson) with named fields per review feedback - Auto-detect JSON vs binary format in verify command - Update bootstrap.sh to use new field names (.vk, .proof, .public_inputs, .hash) - Suppress nlohmann/json sign-conversion warnings for WASM builds using pragma ## Size Impact | Build | Without nlohmann/json | With nlohmann/json | Difference | |-------|----------------------|-------------------|------------| | Native `bb` | 63.18 MB | 63.20 MB | **+19 KB (0.03%)** | | WASM `bb` | 13.49 MB | 13.52 MB | **+30 KB (0.22%)** | ## Test plan - [x] Native build passes - [x] WASM build passes (with `--target bb`) - [x] `regenerate_recursive_inputs` passes - [x] JSON prove and verify works end-to-end
Summary
Adds support for reading JSON-formatted proof, public inputs, and VK files in the
bb verifycommand. This complements the existing--output_format jsonfeature by allowing the JSON files to be consumed for verification.This enables users who receive JSON proof artifacts from third parties to verify the proof before using it in their circuits (e.g., for recursive verification).
Format Detection
The format is auto-detected by attempting to parse as JSON. If parsing succeeds, the file is treated as JSON; otherwise it falls back to binary format. This is robust and works regardless of file extension.
Usage
Test plan