feat(contract-dev): add working examples of Groth16 verification#1964
Conversation
There was a problem hiding this comment.
Thanks for expanding the ZK docs; I’ve left several suggestions in contract-dev/privacy-zk/groth16-examples.mdx plus a couple of small navigation and cross-link tweaks—please apply the inline suggestions to align with the content and safety guidelines.
📝 WalkthroughWalkthroughThis PR introduces a comprehensive tutorial page for running and verifying upstream Groth16 verifier examples on TON, featuring step-by-step flows for four proving stacks (Circom, Noname, Gnark, Arkworks). The zero-knowledge guide is updated with a cross-reference, navigation is restructured to list the new page, and spell-check dictionary entries are added for technical terms. ChangesGroth16 Examples & ZK Documentation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
♻️ Duplicate comments (2)
contract-dev/privacy-zk/groth16-examples.mdx (2)
53-65:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd a safety warning about the test-only entropy in the trusted setup commands.
Lines 57 and 60 use hard-coded
"some random text"for entropy contributions. Readers who copy-paste these commands for production use will create an insecure trusted setup that allows proof forgery.Add a caution block before the commands
+<Aside type="caution" title="Test-only setup"> + The commands below use weak entropy (`"some random text"`) suitable only for local testing. + For production, use high-entropy sources and participate in a multi-party ceremony. +</Aside> + ```bash cd circuits/Multiplier🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@contract-dev/privacy-zk/groth16-examples.mdx` around lines 53 - 65, Add a clear caution block before the setup commands warning that the hard-coded entropy string "some random text" in the npx snarkjs powersoftau contribute and npx snarkjs zkey contribute commands is for tests only and must not be used in production; instruct readers to supply secure, high-entropy randomness (e.g., use a secure RNG, OS-provided entropy, or explicit interactive/random-file contribution) and never reuse weak or copy-pasted entropy for trusted-setup contributions, and mention that using test-only entropy makes the ceremony insecure and enables proof forgery.
44-46:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUse
type="caution"for environment warnings when examples involve fund transfers.Line 174 shows a
sendVerifycall withvalue: toNano('0.15'), which transfers TON. Environment separation is a safety concern, not a tip, when fund movement is involved.Suggested fix
-<Aside type="tip"> +<Aside type="caution" title="Run in sandbox or testnet"> This page follows the upstream Tolk verifier tests and runs locally in the Blueprint sandbox, not on TON mainnet. </Aside>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@contract-dev/privacy-zk/groth16-examples.mdx` around lines 44 - 46, The Aside currently uses type="tip" but the example includes a sendVerify call that transfers funds (sendVerify with value: toNano('0.15')), so change the Aside component's type from "tip" to "caution" and update its text to clearly flag the environment and fund-transfer risk; locate the Aside instance surrounding the verifier example and the sendVerify usage to make this change (search for Aside and the sendVerify / toNano('0.15') symbols).
🧹 Nitpick comments (1)
contract-dev/privacy-zk/groth16-examples.mdx (1)
82-83: ⚡ Quick winMove placeholder definitions before their first use.
Line 83 uses
<SOLUTION_JSON>and<GRID_JSON>, but their definitions don't appear until lines 96-99. Readers encounter undefined placeholders and must scroll down to understand what they mean.Reorder the content
Move lines 96-99 to appear immediately before line 82, or integrate them into an Aside above the command block:
<Aside> Before running `noname run`, prepare two JSON files: - `<SOLUTION_JSON>` — the private solved grid in the format expected by `circuits/Sudoku/src/main.no` - `<GRID_JSON>` — the public partially filled grid in the format expected by `circuits/Sudoku/src/main.no` </Aside> ```bash cd circuits/Sudoku noname check noname run --backend r1cs-bls12-381 --private-inputs '<SOLUTION_JSON>' --public-inputs '<GRID_JSON>'Also applies to: 96-99
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@contract-dev/privacy-zk/groth16-examples.mdx` around lines 82 - 83, Place the placeholder definitions for <SOLUTION_JSON> and <GRID_JSON> before they are used in the `noname run` example: move the existing descriptive lines about those placeholders (the definitions currently at lines 96-99) to immediately above the `noname check` / `noname run` block or wrap them as an Aside right above that command so readers see what `<SOLUTION_JSON>` and `<GRID_JSON>` mean before encountering `noname run --backend r1cs-bls12-381 --private-inputs '<SOLUTION_JSON>' --public-inputs '<GRID_JSON>'`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@contract-dev/privacy-zk/groth16-examples.mdx`:
- Around line 53-65: Add a clear caution block before the setup commands warning
that the hard-coded entropy string "some random text" in the npx snarkjs
powersoftau contribute and npx snarkjs zkey contribute commands is for tests
only and must not be used in production; instruct readers to supply secure,
high-entropy randomness (e.g., use a secure RNG, OS-provided entropy, or
explicit interactive/random-file contribution) and never reuse weak or
copy-pasted entropy for trusted-setup contributions, and mention that using
test-only entropy makes the ceremony insecure and enables proof forgery.
- Around line 44-46: The Aside currently uses type="tip" but the example
includes a sendVerify call that transfers funds (sendVerify with value:
toNano('0.15')), so change the Aside component's type from "tip" to "caution"
and update its text to clearly flag the environment and fund-transfer risk;
locate the Aside instance surrounding the verifier example and the sendVerify
usage to make this change (search for Aside and the sendVerify / toNano('0.15')
symbols).
---
Nitpick comments:
In `@contract-dev/privacy-zk/groth16-examples.mdx`:
- Around line 82-83: Place the placeholder definitions for <SOLUTION_JSON> and
<GRID_JSON> before they are used in the `noname run` example: move the existing
descriptive lines about those placeholders (the definitions currently at lines
96-99) to immediately above the `noname check` / `noname run` block or wrap them
as an Aside right above that command so readers see what `<SOLUTION_JSON>` and
`<GRID_JSON>` mean before encountering `noname run --backend r1cs-bls12-381
--private-inputs '<SOLUTION_JSON>' --public-inputs '<GRID_JSON>'`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 185007b0-9d2d-4299-8e53-497f68e588eb
📒 Files selected for processing (4)
contract-dev/privacy-zk/groth16-examples.mdxcontract-dev/zero-knowledge.mdxdocs.jsonresources/dictionaries/custom.txt
Closes #1840
Summary by CodeRabbit