-
Notifications
You must be signed in to change notification settings - Fork 131
Solidity verifier from bb CLI rejects proofs from bb.js (ProofLengthWrongWithLogN) #1649
Description
Bug Report
Source: User report from ETHDenver workshop (@georgeh0x)
Description
The optimized Solidity verifier generated by bb CLI does not verify keccak-based proofs generated by bb.js (via noirjs). Verification reverts with ProofLengthWrongWithLogN.
The user's workaround is generating the Solidity verifier from bb.js instead, but bb.js does not support the --optimized verifier variant.
Steps to Reproduce
- Compile a Noir circuit
- Generate a keccak proof using bb.js with
keccak: true - Generate an optimized Solidity verifier using bb CLI (
bb contract) - Attempt to verify the bb.js proof against the bb CLI verifier on-chain
- Verification reverts with
ProofLengthWrongWithLogN
Root Cause Analysis
There is a PAIRING_POINTS_SIZE mismatch between bb.js and the Solidity contracts:
- bb.js (barretenberg/ts/src/proof/index.ts:12):
PAIRING_POINTS_SIZE = 16 - Solidity (barretenberg/sol/src/honk/HonkTypes.sol:19):
PAIRING_POINTS_SIZE = 8
This constant is used in calculateProofSize() which determines the expected proof byte length. The mismatch causes the Solidity verifier's length check to fail:
BaseHonkVerifier.sol:53-54:if (proof.length != expectedProofSize * 32) { revert ProofLengthWrongWithLogN(...) }BaseZKHonkVerifier.sol:85-86:require(proof.length == expectedProofSize, ProofLengthWrongWithLogN(...))
The discrepancy likely stems from different field element encodings — bb.js may use 4 limbs per BN254 G1 coordinate (FrCodec-style) while the Solidity verifier expects 2 elements per coordinate (U256Codec-style, native 256-bit encoding).
Expected Behavior
Proofs generated by bb.js should be verifiable by Solidity contracts generated by bb CLI (and vice versa), since both tools are part of the same Barretenberg suite.
Additional Context
The user also noted that bb.js can generate a working Solidity verifier, but it doesn't support the --optimized flag, which is only available via bb CLI.