refactor: use compute_vk_hash for vk hash#1379
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
📝 WalkthroughWalkthroughThe 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts (1)
116-117: Consider removing debug logging before merging.This
console.logstatement 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
📒 Files selected for processing (6)
examples/CRISP/circuits/bin/fold/Nargo.tomlexamples/CRISP/circuits/bin/fold/src/main.nrexamples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.solexamples/CRISP/packages/crisp-contracts/contracts/CRISPVerifier.solexamples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.tsexamples/CRISP/packages/crisp-sdk/src/vote.ts
Summary by CodeRabbit
Release Notes
Refactor
Tests