Skip to content

feat(common): add Goldilocks (Field64_3) field support — Phase 1#453

Open
BornPsych wants to merge 11 commits into
worldfnd:v2from
BornPsych:ys/goldilocks-field64-3-phase1
Open

feat(common): add Goldilocks (Field64_3) field support — Phase 1#453
BornPsych wants to merge 11 commits into
worldfnd:v2from
BornPsych:ys/goldilocks-field64-3-phase1

Conversation

@BornPsych

Copy link
Copy Markdown

Summary

  • Adds a goldilocks Cargo feature alongside the default bn254, running the entire proof
    system (witness, R1CS, challenges, sumcheck) in the ~192-bit Goldilocks cubic extension
    Field64_3. This is Phase 1 — the validation milestone — which keeps a single field
    type in play (Identity embedding, zero WHIR changes).
  • bn254 stays the default and is behaviorally unchanged (same transcripts/proofs).
    goldilocks is an opt-in, off-chain, crate-scoped build:
    --no-default-features --features goldilocks over common + prover + verifier only.
  • Field selection becomes a mutually-exclusive Cargo feature. BN254-only modules (Noir
    frontend, witness builders, Skyscraper/Poseidon2, EC/bigint, Mavros) are cfg-gated out;
    the goldilocks default hash is Sha256.
  • Relocates WhirR1CSSchemeBuilder from r1cs-compiler into common (the goldilocks build
    excludes r1cs-compiler).
  • Adds a Field64_3 x*y=z prove/verify roundtrip plus soundness negatives.

Commits

  • feat(build): add bn254/goldilocks field features across the workspace
  • feat(common): select FieldElement by field feature and relocate WhirR1CSSchemeBuilder
  • feat(common): gate BN254-only hashes and add Goldilocks byte bridges
  • feat(common): gate BN254-only witness builders and proof IO
  • feat(prover): gate Noir entry points and add the goldilocks roundtrip test

Verification

  • Default bn254 build + tests: green (regression gate).
  • Goldilocks build (--no-default-features --features goldilocks): green.
  • Goldilocks roundtrip test: 4 passed, 0 failed.

@BornPsych BornPsych changed the base branch from main to v2 June 15, 2026 06:16
BornPsych added 10 commits June 15, 2026 12:27
- `provekit-common` gains mutually-informed `bn254` (default) and
  `goldilocks` field features; `bn254` takes precedence when both are on
  so `--all-features` builds as BN254. `provekit_ntt` now implies `bn254`.
- `mavros-vm`/`mavros-artifacts` become optional deps tied to `bn254`.
- Root manifest sets `provekit-common`/`provekit-verifier` to
  `default-features = false`; every consumer crate re-enables `bn254`
  explicitly so the goldilocks build can opt out with
  `--no-default-features --features goldilocks`.
…1CSSchemeBuilder

- Split the `FieldElement` alias: `ark_bn254::Fr` under `bn254`,
  `whir::algebra::fields::Field64_3` under `goldilocks`. Gate the
  BN254-only modules (mavros, noir_proof_scheme, ntt, optimize, poseidon2,
  prover, skyscraper, verifier) and the Skyscraper/Poseidon2 engine
  registrations in `register_ntt`.
- Move `WhirR1CSSchemeBuilder` (and the `MIN_*` consts) from
  `r1cs-compiler` into `common`, re-exporting it from both crates. The
  move rides here because the crate-root re-export and the field split
  touch the same `lib.rs`. The Mavros constructor stays `bn254`-gated.
- Gate the Skyscraper/Poseidon2 `HashConfig` and `TranscriptSponge`
  variants behind `bn254`; the goldilocks default hash is `Sha256`.
- Add Goldilocks twins for the field<->byte bridges (`field_to_bytes_le`
  -> 24 bytes, digest-to-field via the base subfield) and switch the
  sumcheck `HALF` constant to a `LazyLock`.
- Gate the Noir/BN254-coupled witness modules (binops, digits, limbs,
  ram, scheduling, witness builders) and the `NoirProof`/scheme
  `FileFormat` impls behind `bn254`; the field-agnostic IO machinery and
  `PublicInputs` stay shared.
- Add the goldilocks `PublicInputs::hash_bytes` twin (24 -> 32 pad).
… test

- Gate the `Prove`/`Verify` traits, Noir/Mavros prover paths, and EC/
  bigint gadgets behind `bn254`; expose `whir_r1cs` publicly under
  goldilocks (and in the verifier) so hand-built R1CS instances can be
  proved/verified directly.
- Add `roundtrip_tests.rs`: a `Field64_3` `x*y=z` prove/verify roundtrip
  plus soundness negatives, the Phase-1 milestone.
…mitment

The Mavros builder was relocated from r1cs-compiler into common before v2's
fix landing, so new_from_dimensions still derived m from next_power_of_two(
num_witnesses). v2 (PR worldfnd#443) changed it to max(npot(w1_size), npot(w2_size)),
since w1 and w2 are committed separately. Carry that split (already present in
new_for_r1cs) into new_from_dimensions, the Mavros path, and port v2's four
dimension tests, adapted for the now-fallible constructors.
@BornPsych BornPsych force-pushed the ys/goldilocks-field64-3-phase1 branch from 5715493 to d9cd553 Compare June 15, 2026 08:27
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

@BornPsych is attempting to deploy a commit to the World Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@BornPsych BornPsych marked this pull request as ready for review June 16, 2026 07:43
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.

1 participant