Skip to content

Solidity verifier from bb CLI rejects proofs from bb.js (ProofLengthWrongWithLogN) #1649

@johnathan79717

Description

@johnathan79717

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

  1. Compile a Noir circuit
  2. Generate a keccak proof using bb.js with keccak: true
  3. Generate an optimized Solidity verifier using bb CLI (bb contract)
  4. Attempt to verify the bb.js proof against the bb CLI verifier on-chain
  5. Verification reverts with ProofLengthWrongWithLogN

Root Cause Analysis

There is a PAIRING_POINTS_SIZE mismatch between bb.js and the Solidity contracts:

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions