Skip to content

Add Poseidon2 Goldilocks inline#1570

Draft
jay-clarke wants to merge 3 commits into
a16z:mainfrom
jay-clarke:codex/poseidon2-goldilocks-inline
Draft

Add Poseidon2 Goldilocks inline#1570
jay-clarke wants to merge 3 commits into
a16z:mainfrom
jay-clarke:codex/poseidon2-goldilocks-inline

Conversation

@jay-clarke
Copy link
Copy Markdown

@jay-clarke jay-clarke commented May 24, 2026

Summary

Adds a new jolt-inlines-poseidon2-goldilocks crate implementing the canonical 8-wide Poseidon2 permutation over the Goldilocks field as a Jolt inline.

Spec: specs/1570-poseidon2-goldilocks-inline.md

The inline exposes a small guest API:

  • poseidon2_permute(&mut [u64; 8])
  • RISC-V guest builds emit one custom inline instruction.
  • Host builds use the standalone reference implementation.

The host side registers the inline with the Jolt tracer/prover through the existing register_inlines! path and adds a Poseidon2Goldilocks entry to InlineExtension.

Why

Poseidon2 over Goldilocks is commonly used inside proof systems for Merkle trees, commitments, and other ZK-native hashing paths. Running that permutation as ordinary guest Rust creates a much larger trace than an inline expansion. This adds a dedicated inline for the Plonky3-compatible Poseidon2-Goldilocks-8 instance.

Validation

  • cargo check -p jolt-inlines-poseidon2-goldilocks
  • cargo check -p jolt-inlines-poseidon2-goldilocks --features host
  • cargo test -p jolt-inlines-poseidon2-goldilocks --features host
  • cargo test -p jolt-riscv

The new tests cover:

  • Goldilocks multiplication reduction against u128 arithmetic.
  • Permutation parity with Plonky3's default Poseidon2Goldilocks<8>.
  • Permutation parity with an explicitly constructed generic Plonky3 Poseidon2 path.
  • Round-constant and internal-diagonal parity with Plonky3 constants.
  • Deterministic sequence emission.
  • Inline emulator execution against the host reference for fixed and randomized states.

Notes

The crate intentionally covers only the 8-wide Goldilocks instance. Other widths or fields can be added separately if they are useful.

@github-actions
Copy link
Copy Markdown
Contributor

Warning

This PR has more than 500 changed lines and does not include a spec.

Large features and architectural changes benefit from a spec-driven workflow.
See CONTRIBUTING.md for details on how to create a spec.

If this PR is a bug fix, refactor, or doesn't warrant a spec, feel free to ignore this message.

@github-actions github-actions Bot added the no-spec PR has no spec file label May 24, 2026
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 24, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​p3-field@​0.5.310010093100100
Addedcargo/​p3-goldilocks@​0.5.310010093100100
Addedcargo/​p3-symmetric@​0.5.310010093100100
Addedcargo/​rand@​0.10.110010093100100
Addedcargo/​rand_core@​0.10.110010093100100
Addedcargo/​p3-poseidon2@​0.5.3100100100100100

View full report

@github-actions github-actions Bot added spec Tracking issue for a feature spec implementation PR contains implementation of a spec and removed no-spec PR has no spec file labels May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

implementation PR contains implementation of a spec spec Tracking issue for a feature spec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants