Skip to content

Support LLZK fields that are not builtins - #20

Merged
0xddom merged 196 commits into
mainfrom
shankara/llzk-non-builtin-field
Oct 16, 2026
Merged

0xddom merged 196 commits into
mainfrom
shankara/llzk-non-builtin-field

Conversation

@shankarapailoor

Copy link
Copy Markdown
Contributor

Problem

The runner passed --llzk-field-name straight to LlzkParams::with_builtin_field, so:

  • circuits over a prime that isn't one of LLZK's builtins (e.g. BLS12-381's scalar field, used by midnight-proofs) could not be emitted;
  • a mislabeled field was silently accepted. The SHA3 demo config says bn254, but the circuit is over midnight_curves::Fq (BLS12-381 scalar, 524358…184513), so the LLZK output declared the wrong prime.

Change

  • Builtin names (bn128, bn254, grumpkin, babybear, goldilocks, mersenne31, koalabear, the set registered by LLZK's Field::initKnownFields) are checked against the circuit's prime (ResolvedIRCircuit::prime). A mismatch is an error.
  • Any other name defines a new field with the circuit's prime via the existing LlzkParams::with_prime_field.
  • --llzk-field-name now has help text describing this.

Testing

  • Unit tests for the builtin/custom decision, using halo2curves BN254 Fr and Fq (matching builtins, bn128 alias, Grumpkin as BN254's base field, mismatch, custom name).
  • cargo test -p haloumi-extractor-runner --all-features passes.
  • SHA3 extraction with --llzk-field-name bls12-381 produces #felt.field<"bls12-381", 52435875175126190479447740508185965837690552500527637822603658699938581184513>.

Notes

  • The builtin table duplicates LLZK's list, since the Rust bindings don't expose a lookup. It needs updating if LLZK adds fields.
  • The CLI config still calls the key backends.llzk.field.builtin, which reads oddly for non-builtin names. Renaming it is left for a follow-up.
  • This PR is independent of Skip lookup rows where every lookup is disabled #19.

🤖 Generated with Claude Code

0xddom
0xddom previously approved these changes Oct 2, 2026

@0xddom 0xddom left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@0xddom
0xddom force-pushed the shankara/llzk-non-builtin-field branch from 2536264 to 2eaad64 Compare October 13, 2026 16:37
@0xddom
0xddom force-pushed the shankara/llzk-non-builtin-field branch from 5e0beba to 39b9ce2 Compare October 13, 2026 17:05
@0xddom
0xddom force-pushed the shankara/llzk-non-builtin-field branch from 39b9ce2 to f19a753 Compare October 13, 2026 17:30
0xddom and others added 17 commits October 13, 2026 20:00
The runner always passed --llzk-field-name to LLZK as a builtin field, so
circuits over other primes could not be emitted and a mislabeled field was
silently accepted. For example, a circuit over BLS12-381's scalar field
labeled `bn254` produced LLZK over BN254's prime.

Builtin names are now checked against the circuit's prime and rejected on
a mismatch. Any other name defines a field with the circuit's prime.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@0xddom
0xddom force-pushed the shankara/llzk-non-builtin-field branch from f19a753 to f42ac56 Compare October 13, 2026 18:00
Base automatically changed from dani/cargo-haloumi to main October 16, 2026 11:34
@0xddom
0xddom dismissed their stale review October 16, 2026 11:34

The base branch was changed.

@0xddom
0xddom merged commit 6b34f8d into main Oct 16, 2026
6 checks passed
@0xddom
0xddom deleted the shankara/llzk-non-builtin-field branch October 16, 2026 11:52
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.

2 participants