Skip to content

Conversation

@johnathan79717
Copy link
Contributor

@johnathan79717 johnathan79717 commented Jan 21, 2026

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

# 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

  • Build passes
  • Tested verify with JSON files
  • Tested verify with binary files (no false positive JSON detection)
  • Tested verify with mixed JSON and binary files
  • acir_tests bb_prove tests pass

Auto-detects JSON format by inspecting file content (starts with '{')
rather than relying on file extension.
@johnathan79717 johnathan79717 changed the base branch from next to merge-train/barretenberg January 21, 2026 15:00
}

std::vector<uint256_t> result;
result.reserve(json["fields"].size());
Copy link
Collaborator

@ludamad ludamad Jan 22, 2026

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

Copy link
Collaborator

@ludamad ludamad left a 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
@johnathan79717 johnathan79717 merged commit c1b30da into merge-train/barretenberg Jan 23, 2026
8 checks passed
@johnathan79717 johnathan79717 deleted the jh/json-input-format branch January 23, 2026 12:26
johnathan79717 added a commit that referenced this pull request Jan 27, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 27, 2026
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
danielntmd pushed a commit that referenced this pull request Jan 27, 2026
## 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
danielntmd pushed a commit that referenced this pull request Jan 27, 2026
johnathan79717 added a commit that referenced this pull request Jan 28, 2026
## 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
github-merge-queue bot pushed a commit that referenced this pull request Jan 28, 2026
## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants