Skip to content

Systems Architecture

Adam edited this page Sep 12, 2023 · 2 revisions

Systems Design Document (SDD) for Anonymous Uniswap Interactions

1. Introduction

1.1 Purpose

This document describes the system design for implementing anonymous interactions with Uniswap using zk-SNARK proofs and commitments. It aims to provide a clear overview of the components, architecture, and interactions for the system.

1.2 Scope

The system facilitates anonymous deposits, liquidity adjustments, and withdrawals on Uniswap, hiding the identity of liquidity providers and users.

2. System Architecture

2.1 High-level Architecture

The system comprises three primary layers:

  • User Client (Frontend)
  • Backend Intermediary
  • Ethereum Network (including Uniswap and the Proxy Contract)

2.2 Component Breakdown

  • User Client (Local Frontend App):

    • Interface for user interactions.
    • zk-SNARK proofs and commitments generator.
  • Backend Intermediary:

    • zk-SNARK Manager
    • Communication interface with Proxy Contract
    • Commitment Storage
  • Ethereum Network:

    • Proxy Contract for interacting with Uniswap.
    • Modified Uniswap with zk-SNARK Hook.

3. Component Design

3.1 User Client (Local Frontend App)

  • Built with modern frontend frameworks (e.g., React, Vue).
  • Secure connection to Backend Intermediary.
  • Local generation of zk-SNARK proofs and commitments to ensure user privacy.

3.2 zk-SNARK Manager (Within Backend)

  • Utilizes existing zk-SNARK libraries.
  • Generates and verifies zk-SNARK proofs as required.
  • Acts as a bridge between the frontend and the proxy contract.

3.3 Proxy Contract (On Ethereum Network)

  • Deployed on the Ethereum mainnet.
  • Accepts zk-SNARK proofs and commitments from users.
  • Interfaces with Uniswap on behalf of users.

3.4 Commitment Storage (Within Backend)

  • Database (e.g., PostgreSQL, MongoDB) for storing commitments.
  • Quick retrieval methods to fetch commitments during verification.
  • Regular backups and security checks.

3.5 Uniswap zk-SNARK Hook

  • Extends or modifies Uniswap's existing codebase.
  • Verifies zk-SNARK proofs using the beforeModifyPosition hook.
  • Ensures liquidity operations are authentic and anonymous.

4. Data Flow

  1. User decides to interact (e.g., deposit) on the frontend app.
  2. User Client generates the zk-SNARK proof and commitment.
  3. Backend Intermediary receives and validates the proof and commitment.
  4. Proxy Contract is instructed to interact with Uniswap.
  5. Uniswap, through the zk-SNARK Hook, verifies the operation.
  6. Operation is executed (e.g., liquidity added), and feedback is relayed back to the user.

5. Security Measures

  • Secure HTTPS connections for all server-client interactions.
  • Secure Ethereum transaction methods for proxy contract interactions.
  • Database encryption and regular backups.
  • Periodic security audits.

6. Future Enhancements

  • Integration with other DeFi platforms beyond Uniswap.
  • Improved zk-SNARK generation speed.
  • Enhanced database scaling solutions for commitment storage.

my-anonymous-uniswap-project/ │ ├── frontend/ │ ├── src/ │ ├── public/ │ ├── package.json │ └── ... │ ├── backend-intermediary/ │ ├── zk-snark-manager/ │ │ ├── lib/ │ │ └── ... │ │ │ ├── commitment-storage/ │ │ ├── models/ │ │ └── ... │ │ │ ├── package.json │ └── ... │ ├── smart-contracts/ │ ├── proxy-contract/ │ │ ├── contracts/ │ │ ├── migrations/ │ │ ├── test/ │ │ └── ... │ │ │ ├── uniswap-zk-snark-hook/ │ │ ├── contracts/ │ │ ├── migrations/ │ │ ├── test/ │ │ └── ... │ │ │ └── truffle-config.js │ ├── docs/ │ └── ... │ ├── README.md └── .gitignore