Skip to content

Add g16.verify Groth16 verifier builtin#138

Draft
elldeeone wants to merge 2 commits into
kaspanet:masterfrom
elldeeone:g16verify
Draft

Add g16.verify Groth16 verifier builtin#138
elldeeone wants to merge 2 commits into
kaspanet:masterfrom
elldeeone:g16verify

Conversation

@elldeeone

Copy link
Copy Markdown
Collaborator

Summary

Adds g16.verify(...) as a SilverScript builtin for verifying Groth16 proofs via the Rusty Kaspa ZK precompile.

The builtin signature is:

g16.verify(byte[] verifyingKey, byte[] proof, byte[32] ...publicInputs): bool

This PR includes:

  • parser/AST/formatter support for qualified builtin call targets such as g16.verify
  • compiler lowering to OpZkPrecompile with ZkTag::Groth16
  • static validation for byte[] verifying key/proof arguments and byte[32] public inputs
  • bool return typing so g16.verify(...) can be assigned/required like other boolean builtins
  • docs, syntax highlighting, and generated tree-sitter parser updates
  • runtime coverage using a valid Groth16 fixture plus a tampered-input failure case
  • debugger shadow-script support for post-Toccata-sized runtime params, so large byte[] values such as verifying keys/proofs can be inspected during expression evaluation

Notes

The debugger CLI still has pre-existing v2.0.1 migration debt around v1 transaction compute_commit construction (SigopCount vs ComputeBudget). I left that transaction-building path unchanged here because it predates this feature and is separate from the compiler builtin, but I can include it in this PR if maintainers would prefer to handle that post-Toccata debugger cleanup together.

Tests

cargo test -p silverscript-lang --test compiler_tests g16_verify
cargo test -p debugger-session
cargo test -p silverscript-lang --test examples_tests g16_verify
cargo test -p silverscript-lang --test parser_tests
cargo test -p silverscript-lang --test ast_format_tests
git diff --check upstream/master...HEAD

@elldeeone
elldeeone marked this pull request as draft June 29, 2026 05:30
@elldeeone

Copy link
Copy Markdown
Collaborator Author

I missed that #137 was already the ZK base.

I’m going to move this to draft for now and restack it on top of #137 once that lands, so g16.verify can reuse the qualified builtin/parser/compiler shape from the R0 support work instead of duplicating that machinery.

@michaelsutton michaelsutton mentioned this pull request Jun 29, 2026
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