Skip to content

refactor: use compute_vk_hash for vk hash#1379

Merged
cedoor merged 2 commits into
mainfrom
refactor/crisp-vk-hash
Mar 4, 2026
Merged

refactor: use compute_vk_hash for vk hash#1379
cedoor merged 2 commits into
mainfrom
refactor/crisp-vk-hash

Conversation

@cedoor

@cedoor cedoor commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

Release Notes

  • Refactor

    • Verification key hash computation has been updated to use a new approach
    • Proof structure has been simplified, reducing the number of public input components
    • Verification constants and parameters have been adjusted to align with the updated system
  • Tests

    • Enhanced test output with additional debugging information

@cedoor cedoor requested review from 0xjei and ctrlc03 March 4, 2026 10:41
@vercel

vercel Bot commented Mar 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
crisp Skipped Skipped Mar 4, 2026 10:57am
enclave-docs Skipped Skipped Mar 4, 2026 10:57am

Request Review

@coderabbitai

coderabbitai Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes update the CRISP verification system's public input layout and VK hash computation mechanism across the circuit, contracts, and SDK. The circuit's main function now returns a single Field-based hash instead of a byte array, verification contract constants are reduced to reflect fewer public inputs (55 to 24), and the SDK extraction logic is simplified to retrieve the hash from a single public input value.

Changes

Cohort / File(s) Summary
Circuit Dependencies & Implementation
examples/CRISP/circuits/bin/fold/Nargo.toml, examples/CRISP/circuits/bin/fold/src/main.nr
Dependency migrated from remote git-based keccak256 to local enclave_lib path. Circuit's VK hash computation switched from keccak256-based approach to compute_vk_hash-based aggregation of entire VK chain; main function return type changed from (Field, [u8; 32]) to (Field, Field).
Verification Contracts
examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol, examples/CRISP/packages/crisp-contracts/contracts/CRISPVerifier.sol
ZK_VK_HASH constants updated to reflect new hash values. Public input array structure simplified from 39 to 8 bytes32 entries in CRISPProgram; NUMBER_OF_PUBLIC_INPUTS reduced from 55 to 24 in CRISPVerifier. All verification key G1Point data recomputed and updated in loadVerificationKey.
SDK & Testing
examples/CRISP/packages/crisp-sdk/src/vote.ts, examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts
VK hash extraction in encodeSolidityProof simplified from slicing publicInputs indices 7–38 to direct access of publicInputs[7]. Debug logging added to test file for proof inspection.

Sequence Diagram(s)

sequenceDiagram
    participant Circuit as Noir Circuit<br/>(main.nr)
    participant SDK as SDK<br/>(vote.ts)
    participant Contract as Smart Contract<br/>(CRISPVerifier.sol)

    Circuit->>Circuit: Compute VK hash via<br/>compute_vk_hash(vk_chain)
    Circuit->>Circuit: Return (pk_commitment, vk_hash_field)
    Circuit->>SDK: Proof with 8 public inputs<br/>(publicInputs[7] = vk_hash)
    
    SDK->>SDK: Extract vk_hash from<br/>publicInputs[7] directly
    SDK->>SDK: Encode Solidity proof<br/>with simplified hash
    SDK->>Contract: Submit encoded proof<br/>(24 public inputs)
    
    Contract->>Contract: Load verification key<br/>(publicInputsSize = 24)
    Contract->>Contract: Verify proof with<br/>updated VK constants
    Contract->>Contract: Validate zkKeyHash<br/>against VK_HASH
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

noir

Suggested reviewers

  • 0xjei
  • ctrlc03

Poem

🐰 A hash hops into new clothes,
One field where thirty-two bytes once prose,
The circuit chirps its streamlined song,
Twenty-four inputs move along,
Verification now runs light and long!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly and accurately describes the main change across all modified files—replacing keccak256-based VK hash computation with compute_vk_hash approach.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/crisp-vk-hash

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts (1)

116-117: Consider removing debug logging before merging.

This console.log statement is useful for development debugging but may clutter test output in CI. Consider removing it or wrapping it in a debug flag if it's intended to be temporary.

🧹 Remove debug logging
-      console.log('voteProof.publicInputs', voteProof.publicInputs)
-
       const encodedProof = encodeSolidityProof(voteProof)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts` around
lines 116 - 117, Remove or guard the debug console.log call that prints
voteProof.publicInputs in the tests: locate the statement
console.log('voteProof.publicInputs', voteProof.publicInputs) in
crisp.contracts.test.ts and either delete it or wrap it behind a test/debug flag
(e.g., check an environment variable like DEBUG_TESTS or a specific test helper
logger) so CI output is not cluttered while preserving the ability to enable the
log when needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts`:
- Around line 116-117: Remove or guard the debug console.log call that prints
voteProof.publicInputs in the tests: locate the statement
console.log('voteProof.publicInputs', voteProof.publicInputs) in
crisp.contracts.test.ts and either delete it or wrap it behind a test/debug flag
(e.g., check an environment variable like DEBUG_TESTS or a specific test helper
logger) so CI output is not cluttered while preserving the ability to enable the
log when needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: df13b12d-5ef2-472d-a2bd-ac0ef21b204c

📥 Commits

Reviewing files that changed from the base of the PR and between e06363a and 7b4ffd4.

📒 Files selected for processing (6)
  • examples/CRISP/circuits/bin/fold/Nargo.toml
  • examples/CRISP/circuits/bin/fold/src/main.nr
  • examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol
  • examples/CRISP/packages/crisp-contracts/contracts/CRISPVerifier.sol
  • examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts
  • examples/CRISP/packages/crisp-sdk/src/vote.ts

@vercel vercel Bot temporarily deployed to Preview – crisp March 4, 2026 10:57 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs March 4, 2026 10:57 Inactive
@cedoor cedoor merged commit c7167ec into main Mar 4, 2026
26 checks passed
@github-actions github-actions Bot deleted the refactor/crisp-vk-hash branch March 12, 2026 03:13
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