Skip to content

feat(verifier-ray) - implement stub Zig verifier#3115

Merged
ivokub merged 12 commits into
mainfrom
feat/ray-zig-verifier-stub
May 19, 2026
Merged

feat(verifier-ray) - implement stub Zig verifier#3115
ivokub merged 12 commits into
mainfrom
feat/ray-zig-verifier-stub

Conversation

@ivokub
Copy link
Copy Markdown
Contributor

@ivokub ivokub commented May 15, 2026

This PR adds an initial Ray verifier for verifying the proofs produced by Ray prover.

It already has Koalabear/extension support and arithmetic implemented. It currently performs computations natively in Zig instead of offloading to zkVM precompiles. Also adds testing between the Ray prover by generating test vectors and then verifying the computation results in Zig.

Also include some github actions for verifying that the sources compile and lint. I added two build targets -- debug version with all debug symbols etc. but also a release version with everything stripped, this leads to a quite small binary (4KB for now).

Resolves #3106 and #3107

@claude-review

Checklist

  • I wrote new tests for my new core changes.
  • I have successfully ran tests, style checker and build against my new changes locally.
  • If this change is deployed to any environment (including Devnet), E2E test coverage exists or is included in this
    PR.
  • I have informed the team of any breaking changes if there are any.

Note

Medium Risk
Introduces new cryptographic and field arithmetic code plus proof-verification scaffolding; subtle math/serialization mismatches could cause false accepts/rejects despite golden tests. Also adds a new CI workflow and generated testdata that may impact build reliability if toolchain versions drift.

Overview
Adds a new verifier-ray Zig package with a minimal verify entrypoint that delegates to a generated stub (VerifyError.Unsupported for now) plus runtime/transcript scaffolding.

Implements core Koalabear primitives in Zig (base/extension field ops, polynomial & Lagrange evaluation, Poseidon2 compression + Merkle–Damgård hasher, Fiat–Shamir transcript) and wires a simple precompile backend interface.

Adds Go-based tooling to generate prover-aligned golden vectors (testdata/generate), checks them in under testdata/generated, and adds Zig/Go unit tests to validate against those vectors. Introduces a dedicated GitHub Actions workflow (verifier-ray.yml) and updates .gitignore to allow committing generated verifier/testdata outputs.

Reviewed by Cursor Bugbot for commit 1f7c173. Bugbot is set up for automated code reviews on this repo. Configure here.

@ivokub ivokub requested review from arijitdutta67 and Copilot May 15, 2026 09:22
@ivokub ivokub self-assigned this May 15, 2026
@ivokub ivokub linked an issue May 15, 2026 that may be closed by this pull request
6 tasks
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 15, 2026

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgithub/​mlugg/​setup-zig@​d1434d08867e3ee9daa34448df10607b98908d2937100100100100

View full report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

coordinator Changelog Preview (informational)

[Unreleased] diff (commits touching coordinator/** since latest releases/coordinator/v* tag)

[unreleased]

Generated by git-cliff-action using cliff.toml. This comment is informational and does not gate the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

linea-besu Changelog Preview (informational)

[Unreleased] diff (commits touching linea-besu/** since latest releases/linea-besu/v* tag)

[unreleased]

🐛 Bug Fixes

Generated by git-cliff-action using cliff.toml. This comment is informational and does not gate the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

postman Changelog Preview (informational)

[Unreleased] diff (commits touching postman/** since latest releases/postman/v* tag)

[unreleased]

⚙️ Miscellaneous Tasks

Generated by git-cliff-action using cliff.toml. This comment is informational and does not gate the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

tx-exclusion-api Changelog Preview (informational)

[Unreleased] diff (commits touching tx-exclusion-api/** since latest releases/tx-exclusion-api/v* tag)

[unreleased]

⚙️ Miscellaneous Tasks

Generated by git-cliff-action using cliff.toml. This comment is informational and does not gate the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

prover Changelog Preview (informational)

[Unreleased] diff (commits touching prover/** since latest releases/prover/v* tag)

[unreleased]

🐛 Bug Fixes

⚙️ Miscellaneous Tasks

Generated by git-cliff-action using cliff.toml. This comment is informational and does not gate the PR.

Comment thread verifier-ray/src/crypto/poseidon2.zig
@ivokub ivokub added this to the RV recursion - M1 milestone May 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an initial verifier-ray/ Zig package intended to verify Ray proofs, including core Koalabear field/extension arithmetic, Poseidon2 + Fiat–Shamir transcript primitives, polynomial evaluation helpers, and a stubbed verifier/codegen pipeline. It also adds prover-ray–backed golden vector generation/consumption and a dedicated GitHub Actions workflow for formatting/building/testing this new package.

Changes:

  • Added Zig implementations for Koalabear base/extension fields, Poseidon2 (width-16) compression + Merkle–Damgård hashing, Fiat–Shamir transcript, and polynomial evaluation (canonical + Lagrange).
  • Added testdata generation (Go) that imports prover-ray to emit deterministic Zig golden vectors, plus Zig tests that validate the implementation against those vectors.
  • Added scaffolding for verifier runtime, generated verifier stub/codegen skeleton, vortex placeholders, and CI/Makefile/build wiring for verifier-ray.

Reviewed changes

Copilot reviewed 44 out of 50 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
verifier-ray/testdata/vortex/.gitkeep Keeps testdata/vortex/ tracked for future fixtures.
verifier-ray/testdata/transcript/.gitkeep Keeps testdata/transcript/ tracked for future fixtures.
verifier-ray/testdata/README.md Documents intended fixture layout and refresh/verification make targets.
verifier-ray/testdata/generated/vectors.zig Checked-in prover-ray-derived golden vectors consumed by Zig tests.
verifier-ray/testdata/generated/.gitkeep Ensures generated fixture directory exists in git.
verifier-ray/testdata/generate/main.go Go generator producing Zig golden vectors by calling prover-ray code.
verifier-ray/testdata/generate/go.sum Go module lockfile for testdata generator.
verifier-ray/testdata/generate/go.mod Go module for testdata generator with local replace to prover-ray.
verifier-ray/testdata/field/.gitkeep Keeps testdata/field/ tracked for future fixtures.
verifier-ray/test/vortex_test.zig Validates vortex verifier currently returns Unsupported.
verifier-ray/test/transcript_test.zig Basic determinism test for transcript absorption/challenge derivation.
verifier-ray/test/golden_test.zig Golden tests comparing Zig arithmetic/crypto/poly ops vs generated vectors.
verifier-ray/test/generated_stub_test.zig Ensures generated stub advances runtime and returns Unsupported.
verifier-ray/test/field_test.zig Unit tests for base field ops and extension lifting.
verifier-ray/test/all.zig Aggregates Zig test modules for zig build test.
verifier-ray/src/vortex/verifier.zig Vortex verifier placeholder returning Unsupported.
verifier-ray/src/vortex/smt.zig Sparse Merkle proof structure + placeholder verify.
verifier-ray/src/vortex/ringsis.zig RingSIS hash placeholder.
verifier-ray/src/vortex/reed_solomon.zig Reed–Solomon check placeholder.
verifier-ray/src/verifier.zig Top-level verifier entrypoint that routes to generated stub.
verifier-ray/src/runtime.zig Runtime state (Fiat–Shamir transcript + round counter).
verifier-ray/src/proof.zig Proof container types and Proof.empty().
verifier-ray/src/precompiles/riscv.zig Selects a precompile backend (currently native).
verifier-ray/src/precompiles/native.zig Native precompile backend wiring (currently Poseidon2 only).
verifier-ray/src/precompiles/interface.zig Defines precompile backend interface types.
verifier-ray/src/pcs/polynomial.zig Canonical Horner evaluation + batch evaluation helpers.
verifier-ray/src/pcs/lagrange.zig Lagrange evaluation routines + batch variants.
verifier-ray/src/main.zig Minimal executable entrypoint (currently a no-op verify call).
verifier-ray/src/lib.zig Public library surface/module exports for verifier-ray.
verifier-ray/src/generated/stub.zig Generated verifier stub placeholder advancing the runtime.
verifier-ray/src/field/vec.zig Slice aliases and batch invert helpers.
verifier-ray/src/field/koalabear.zig Koalabear base field implementation + serialization/utilities.
verifier-ray/src/field/koalabear_ext.zig Degree-4 extension field implementation + serialization.
verifier-ray/src/crypto/poseidon2.zig Poseidon2 permutation/compress + MD hasher implementation.
verifier-ray/src/crypto/poseidon2_constants.zig Poseidon2 round keys/constants for width-16 Koalabear parameters.
verifier-ray/src/crypto/fiat_shamir.zig Transcript built on Poseidon2 MD hashing.
verifier-ray/README.md Package overview, layout, and local check commands.
verifier-ray/Makefile Local developer targets for fmt/build/test/testdata verification.
verifier-ray/codegen/internal/generator/writer.go Helper for emitting indented Zig source.
verifier-ray/codegen/internal/generator/options.go Codegen option defaults placeholder.
verifier-ray/codegen/internal/generator/generator.go Minimal Zig verifier stub generator.
verifier-ray/codegen/internal/generator/generator_test.go Unit tests for codegen output structure/entrypoint naming.
verifier-ray/codegen/internal/generator/emitters.go Reserved placeholder for future action emitters.
verifier-ray/codegen/go.mod Go module for the codegen tool.
verifier-ray/codegen/cmd/ray-zig-codegen/main.go CLI wrapper for stub code generation.
verifier-ray/build.zig.zon Zig package manifest for verifier-ray.
verifier-ray/build.zig Zig build script wiring library, exe, and unit tests.
verifier-ray/.gitignore Ignores Zig build outputs for verifier-ray.
.gitignore Un-ignores verifier-ray generated directories under a global generated/ ignore.
.github/workflows/verifier-ray.yml CI workflow for formatting, regenerating vectors, building, and testing verifier-ray.
Files not reviewed (1)
  • verifier-ray/codegen/internal/generator/generator.go: Language not supported
Comments suppressed due to low confidence (3)

verifier-ray/src/pcs/lagrange.zig:41

  • Same domain-point edge case as evaluateBaseAtBase: inverting point - omega_i will crash when point equals omega_i (now in extension form). Add a check for denom.isZero() / equality with the lifted omega_i and return the matching values[i] lifted into Ext instead of inverting.
    var omega_i = field.Element.one();
    var sum = ext.Ext.zero();
    for (values) |value| {
        const weighted = omega_i.mul(inv_n).mul(value);
        const denom = point.sub(ext.Ext.lift(omega_i));
        sum = sum.add(denom.inverse().mulByBase(weighted));
        omega_i = omega_i.mul(omega);
    }

verifier-ray/src/pcs/lagrange.zig:61

  • Same domain-point edge case as evaluateBaseAtBase: if point == omega_i, inv_denom becomes an inverse of zero and inverse() will hit unreachable. Add a fast path to return the corresponding values[i] (as ext.Ext) when point.eql(omega_i) before performing any inversions.
    var omega_i = field.Element.one();
    var sum = ext.Ext.zero();
    for (values) |value| {
        const weighted = value.mulByBase(omega_i.mul(inv_n));
        const inv_denom = point.sub(omega_i).inverse();
        sum = sum.add(weighted.mulByBase(inv_denom));
        omega_i = omega_i.mul(omega);
    }

verifier-ray/src/pcs/lagrange.zig:81

  • Same domain-point edge case as the other Lagrange evaluators: denom.inverse() will crash when point equals a domain point (lift(omega_i)). Add an equality/zero-denominator check and return the matching values[i] directly in that case.
    var omega_i = field.Element.one();
    var sum = ext.Ext.zero();
    for (values) |value| {
        const weighted = value.mulByBase(omega_i.mul(inv_n));
        const denom = point.sub(ext.Ext.lift(omega_i));
        sum = sum.add(weighted.mul(denom.inverse()));
        omega_i = omega_i.mul(omega);
    }

Comment thread verifier-ray/src/precompiles/native.zig
Comment thread verifier-ray/src/pcs/lagrange.zig
@ivokub ivokub marked this pull request as draft May 15, 2026 09:28
@ivokub ivokub marked this pull request as ready for review May 15, 2026 11:02
@ivokub ivokub requested a review from Copilot May 15, 2026 11:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 44 out of 50 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • verifier-ray/codegen/internal/generator/generator.go: Language not supported

Comment thread verifier-ray/src/pcs/lagrange.zig Outdated
Comment thread verifier-ray/src/crypto/fiat_shamir.zig Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a1879f4. Configure here.

Comment thread verifier-ray/codegen/internal/generator/options.go
Copy link
Copy Markdown
Contributor

@arijitdutta67 arijitdutta67 left a comment

Choose a reason for hiding this comment

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

LGTM

@ivokub ivokub merged commit 8f72062 into main May 19, 2026
46 checks passed
@ivokub ivokub deleted the feat/ray-zig-verifier-stub branch May 19, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RV recursion] - cryptographic operations [RV recursion] - verifier structure in Zig

3 participants