ft: extend rsk-rust-cli for zk-proofs#28
Open
michojekunle wants to merge 16 commits into
Open
Conversation
- Integrate `risc0` ZKVM and implement Transfer/Vote circuits. - Add CLI commands `zk generate/verify` and `demo_voting` binary. - Resolve cross-compilation target issues in `zk-circuits` build system. - Ensure ABI compatibility between Rust guest and Solidity contract. - Add comprehensive documentation and end-to-end testing support.
Author
|
My PR is now ready for review. Thank you. |
- Simplified the main function in `src/main.rs` to conditionally run the wallet setup only for non-ZK commands. - Enhanced error handling in `zk_generate_proof` to include pre-flight validation for transfer and vote inputs. - Updated `zk_verify_proof` to ensure receipt verification is handled correctly. - Moved ZK circuit types to a shared `types.rs` file for consistency across host and guest code. - Added comprehensive integration tests for transfer and vote circuits, covering both happy and error paths. - Introduced a mock verifier contract for local development and testing. - Improved build scripts to ensure the RISC Zero toolchain is installed and configured correctly. - Updated guest binaries to include nonce in transfer inputs for replay protection. - Enhanced documentation and comments throughout the codebase for clarity.
- Add proposal existence checks in smart contract - Fix race condition by reading proposalCount directly - Replace thread_rng with OsRng for better security - Enforce non-zero randomness in ElGamal encryption - Zeroize sensitive secrets after proof generation - Implement gas limit bounds checking
- Add zeroize to clear sensitive data like passwords and private keys from memory - Directly pass credentials without exposing them in CLI struct types - Add explicit warning about plaintext API key storage - Prioritize reading API keys from environment variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces Zero-Knowledge (ZK) capabilities to the Rootstock Rust SDK.
It includes a complete ZK framework based on RISC Zero (risc0), a proof-of-concept private voting system, and full CLI tooling for rapid prototyping and verification.
Major Features Added
ZK-SNARK Framework (zk-circuits crate)
transfer: Validates balance checks without revealing user details.vote: Validates voting logic (choice 0/1) with nullifier derivation for privacy.Robust Cross-Compilation
build.rsto reliably compile RISC-V guest code (riscv32im-risc0-zkvm-elf) from host environment.SDK Extensions & CLI
zkmodule torootstock-walletfor proof orchestration.cargo run -- zk generate ...→ Generate proofs and journals.cargo run -- zk verify ...→ Verify proofs locally.types.rsstructs (VoteInputs,VotePublicOutput) for host/guest consistency.Private Voting Demo (demo_voting)
Smart Contract (PrivateVoting.sol)
Technical Challenges Resolved
[u8; 32]).Documentation Updates
README.mdwith:How Has This Been Tested?
Unit Tests
cargo testpasses for ZK proof generation/verification logic.Integration
demo_votingbinary successfully.Checklist
Feel free to review, test the demo, or suggest improvements — especially around production proof verification, circuit optimizations, or additional circuits! 🚀