Rayls Hook introduces two complementary ZK-SNARK enabled features built on Uniswap v4 hooks:
-
π‘οΈ Suitability Verifier (click for more info) β A privacy-preserving investor suitability assessment system. It allows users to prove their investment suitability without revealing their specific questionnaire responses using Zero-Knowledge Proofs.
-
π Private Swaps (click for more info) β Private swaps that allow users to conceal their swap parameters until an execution timestamp is reached. Hidden swap values are committed on-chain via a unique commitment ID, then at execution time they are revealed and validated using zkSNARK proofs. Swap details are also encrypted using the Auditorβs public key and the generated ciphertext is stored on-chain, enabling independent verification at any time. The commitment Id is the result of running the cryptographic function keccak256 against the auditor ciphertext and the poseidon hash generated by the zk snark proof.
- More details about circom and zkSNARK implementation here
- There's no partner integration but although Private swap commitments and encrypted payloads are currently fully stored on-chain, they could be stored in EigenDA with only lightweight references on-chain to reduce gas costs and improve scalability without compromising verifiability.
- Only the beforeSwap hook is used, but the logic can be extended to beforeAddLiquidity as well.
- The two features β Suitability Verifier and Private Swap Commitments β are independent, though private swap execution could optionally require passing the suitability check.
- The frontend provides an example of a Suitability questionaire, but there's currently no FE->BE integration.
π‘οΈ Suitability Verifier Logic
- β Private Questionnaire: Users answer 5 suitability questions without revealing their responses
- π Zero-Knowledge Proofs: Prove investment suitability using Circom circuits
- πͺ Uniswap v4 Integration: Seamless integration with Uniswap v4 hooks
- π Risk Profiling: Calculate and verify risk profiles (0-10 scale)
- π‘οΈ Privacy-First: Never reveal private questionnaire data
- β‘ On-Chain Verification: Smart contract verification of ZK proofs
π Private Swap Logic
- β Encrypted Commitments: Users (or backend services) create encrypted swap commitments
- β³ Deferred Execution: Commitments become executable only after a timestamp
- π ZK Proof of Intent: Execution requires a zkSNARK proof proving knowledge of commitment id
- π‘ Auditor Access: Commitments include encrypted values for auditors to decrypt
- πͺ Uniswap v4 Integration: Hook contract executes swaps using permit + safe transfer logic
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Frontend β β ZK Circuits β β Smart Contracts β
β (NextJS) βββββΊβ (Circom) βββββΊβ (Solidity) β
β β β β β β
β β’ Questionnaire β β β’ Suitability β β β’ Verifiers β
β β’ Proof Gen β β β’ PrivateSwap β β β’ Uniswap Hooks β
β β’ UI Components β β β’ Poseidon Hash β β β’ Integration β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
-
Suitability Verifier Logic lives in circuits + verifier contracts
-
Private Swap Logic lives in the hook contracts + zk circuits + auditor encrypt/decrypt scripts.
| Layer | Technology | Purpose |
|---|---|---|
| ZK Layer | Circom + SnarkJS | Zero-knowledge proof generation |
| Smart Contracts | Solidity + Foundry | On-chain verification |
| Frontend | NextJS + Scaffold-ETH 2 | User interface |
| Integration | Uniswap v4 Hooks | DEX integration |
| Development | TypeScript + Wagmi | Type-safe development |
- Private Inputs: 5 questionnaire responses (0-3 scale)
- Public Inputs: Risk threshold and calculated profile
- Output: Suitability verification (0 or 1)
- Private Inputs: amountIn, zeroForOne, sender, timestamp
- Public Outputs: Commitment hash and verification data
- Purpose: Prove swap intent without revealing sensitive details
Before you begin, you need to install the following tools:
To better run circom you might need to add this to your PATH:
export PATH=$PATH:$HOME/.cargo/binTo get started with Rayls Hook, follow these steps:
# Clone the repository
git clone https://github.com/raylsnetwork/uniswap-incubator.git
cd uniswap-incubator
# Install all dependencies
yarn install# Start local Ethereum network (Scaffold-ETH 2)
yarn chainThis command starts a local Ethereum network using Foundry. The network runs on your local machine and can be used for testing and development.
# Or setup specific circuits
yarn workspace rayls-hook-circom setup-suitability # Suitability assessment circuit
yarn workspace rayls-hook-circom setup-private-swap # Private swap intent circuit# Deploy contracts to local network
yarn deployThis command deploys the Rayls Hook smart contracts to the local network, including the ZK verifiers and Uniswap v4 hooks.
# Start the NextJS frontend
yarn startVisit your app on: http://localhost:3000. You can interact with the suitability assessment and test the ZK proof verification.
yarn test(We focused on RaylsHook contract for full coverage)
yarn coverage| Command | Description |
|---|---|
yarn chain |
Start local blockchain |
yarn deploy |
Deploy smart contracts |
yarn start |
Start frontend |
yarn setup |
Setup ZK circuits (default: Suitability) |
yarn prove |
Generate new ZK proof |
yarn setup-suitability |
Setup Suitability circuit |
yarn prove-suitability |
Generate Suitability proof |
yarn setup-private-swap |
Setup PrivateSwapIntent circuit |
yarn prove-private-swap |
Generate PrivateSwapIntent proof |
yarn test |
Run tests |
packages/
βββ circom/ # Zero-Knowledge circuits
β βββ circuits/ # Circom circuit files
β βββ scripts/ # ZK pipeline and utilities
β βββ test/ # Circuit tests
β βββ artifacts/ # Generated ZK artifacts
βββ foundry/ # Smart contracts
β βββ contracts/ # Solidity contracts
β βββ script/ # Deployment scripts
β βββ test/ # Contract tests
βββ nextjs/ # Frontend application
β βββ app/ # NextJS app directory
β βββ components/ # React components
β βββ hooks/ # Custom hooks
βββ encryption/ # Encryption utilities
# Test with example inputs
cp packages/circom/scripts/Suitability_input.example.json packages/circom/scripts/Suitability_input.json
cp packages/circom/scripts/PrivateSwapIntent_input.example.json packages/circom/scripts/PrivateSwapIntent_input.json
# Modify the input files as needed, then generate proofs
yarn prove-suitability
yarn prove-private-swap- ZK circuits implementation (Suitability + PrivateSwapIntent)
- Smart contract verifiers
- Basic Uniswap v4 hook integration
- ZK proof generation and verification pipeline
- Auditor encryption feature
- Multiple tests
- Complete UI + BE implementation
- ZK proof generation interface
- Real-time proof verification
- User dashboard and profile management
- Integration with wallet providers
- Multi-circuit support and management
- Private Swap multi-auditors support and management
- Private Swap multi-executors support and management
- Advanced risk assessment algorithms
- Compliance and regulatory features
- Integration with external KYC providers
- Mobile-responsive design
- Security audits and testing
- Performance optimization
- Documentation and tutorials
- Community features and governance
- Mainnet deployment
We welcome contributions to Rayls Hook! This project is part of the Uniswap Hook Incubator 6 program.
- Fork the repository and create a feature branch
- Follow the coding standards established in the project
- Test your changes thoroughly, especially ZK circuits
- Update documentation for any new features
- Submit a pull request with a clear description
- Frontend Development: UI/UX improvements, new components
- ZK Circuit Optimization: Performance and security improvements
- Smart Contract Features: New functionality and integrations
- Documentation: Tutorials, guides, and examples
- Testing: Comprehensive test coverage and edge cases
- Check the documentation for ZK circuits
- Review Scaffold-ETH 2 docs for frontend development
- Open an issue for bugs or feature requests
- Join our community discussions
This project is licensed under the MIT License - see the LICENSE file for details.
- Scaffold-ETH 2 for the excellent development framework
- Uniswap for the Hook Incubator program
- Circom and SnarkJS for ZK proof technology
- Open source community for inspiration and support
Note: This project is part of the Uniswap Hook Incubator 6 program. For production use, consider security audits and additional compliance requirements.