Skip to content

fix #6 bn254 encode - #9

Open
zz-sol wants to merge 34 commits into
solana-program:mainfrom
zz-sol:zz/bn254_encode
Open

zz-sol wants to merge 34 commits into
solana-program:mainfrom
zz-sol:zz/bn254_encode

Conversation

@zz-sol

@zz-sol zz-sol commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

… arkworks, registry and malformed-input tests
The syscall takes all-zero bytes as the identity and hands anything else
to arkworks' uncompressed decoding, which reads serialization flags from
the top two bits of `y` before looking at the coordinates: `0x40` yields
the identity whatever `x` holds, `0x80` is stripped and the point decodes
normally. So a key whose α (or −β, −γ, −δ) carries the infinity flag is
not all-zero, passes the identity test in `validate_for_publish`, and is
then accepted by the pairing syscall as the identity; and every point has
a second encoding, giving one key two bodies and two addresses. The
strict converter already rejected all of these, so converter-generated
test inputs never reached them.

Both flag bits put the coordinate above 2^254 > p, so requiring every
coordinate to be < p rejects both and leaves each point one encoding.
`Proof::from_bytes` now checks A, B and C (eight 32-byte compares, about
80 CU, with their own error code 9) and `validate_for_publish` checks the
whole body ahead of the identity tests. Regression tests at every layer:
the point module, proof construction, publish validation, the converter
agreeing with the verifier on canonicity, and the program's Publish and
Verify paths under Mollusk. CU tables re-measured.

Fixes solana-program#6
# Conflicts:
#	README.md
#	docs/cu-budget.md
#	docs/design.md
#	groth16-verify/src/constants.rs
#	groth16-verify/src/error.rs
#	groth16-verify/src/lib.rs
#	groth16-verify/src/proof.rs
#	groth16-verify/src/validation.rs
#	program/src/error.rs
#	program/tests/common/mod.rs
#	program/tests/malformed.rs
#	program/tests/registry.rs
#	tools/convert/src/wire.rs
@zz-sol zz-sol linked an issue Oct 19, 2026 that may be closed by this pull request
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.

Enforce canonical BN254 coordinates for proofs and verifying keys

1 participant