Harry Rook
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • Create new note
      • Create a note from template
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Write
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Save as template
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Umbra: Private UTXO Payment System ## Technical Overview ### Table of Contents 1. [Architecture Overview](#architecture-overview) 2. [System Components](#system-components) 3. [Privacy Model](#privacy-model) 4. [Cryptographic Primitives](#cryptographic-primitives) 5. [Zero-Knowledge Proofs](#zero-knowledge-proofs) 6. [Encrypted Storage](#encrypted-storage) 7. [Security Model](#security-model) --- ## Architecture Overview Umbra is a privacy-preserving payment system built on Ethereum (Sepolia) using a UTXO model with zero-knowledge proofs. It enables private transfers of USDC where transaction amounts and relationships between sender/receiver are hidden from observers. ### High-Level Architecture ``` ┌──────────────────────────────────────────────────────────┐ │ ETHEREUM (Sepolia) - Source of Truth │ │ ┌────────────────────────────────────────────────────┐ │ │ │ PrivateUTXOLedger Contract │ │ │ │ - SP1 Groth16 Verifier (on-chain proof verify) │ │ │ │ - UTXO Merkle Tree State │ │ │ │ - Nullifier Registry (double-spend prevention) │ │ │ │ - USDC Custody │ │ │ └────────────────────────────────────────────────────┘ │ │ ┌─────────────────────┐ ┌────────────────────────────┐ │ │ │EncryptedContacts │ │PrivatePaymentRequests │ │ │ │- Tag-based lookup │ │- Encrypted payment reqs │ │ │ │- ECIES encryption │ │- Tag-based recipient IDs │ │ │ └─────────────────────┘ └────────────────────────────┘ │ └──────────────────────────────────────────────────────────┘ ▲ │ Submit proven transactions │ (Gasless via Account Abstraction) ┌─────────────────────────┴─────────────────────────────┐ │ │ ▼ │ ┌──────────────────┐ │ │ Relayer Server │ │ │ - Alchemy Smart │ │ │ Account (AA) │ │ │ - Gas Sponsored │ │ │ │ │ └──────────────────┘ │ ▲ │ │ Proof + encrypted notes │ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ Wallet UI (Next.js) │ │ │ - Key derivation from MetaMask signature │─────────┘ │ - UTXO scanning and decryption (client-side) │ Read state │ - Transaction construction │ (events, roots) │ - Dual signature model (NullifierSig + TxSig) │ │ - All cryptography happens client-side │ └─────────────────────────────────────────────────────────────────┘ │ │ Witness data (notes, signatures, indices) ▼ ┌──────────────────┐ │ Prover Server │ │ - Express.js │ │ - Spawns Rust │ │ prover-host │ └──────────────────┘ │ │ Proof request via SP1 SDK ▼ ┌──────────────────┐ │ Succinct Prover │ │ Network │ │ - zkVM Execution │ │ - Groth16 Proof │ │ (~30-60 seconds) │ └──────────────────┘ ``` ### Data Flow 1. **Login**: User signs a fixed message with MetaMask → signature hashed → secp256k1 keypair derived 2. **Scan**: Wallet reads `OutputCommitted` events from contract, attempts ECIES decryption with private key 3. **Send**: User constructs transaction, signs commitments (NullifierSig + TxSig), sends witness to Prover Server 4. **Prove**: Prover Server precomputes values, submits to Succinct Network for Groth16 proof generation 5. **Submit**: Wallet receives proof, sends to Relayer (gasless) 6. **Verify**: Contract verifies SP1 proof on-chain, checks nullifiers unused, updates Merkle state --- ## System Components | Component | Role | Trust Level | |-----------|------|-------------| | **PrivateUTXOLedger** | On-chain source of truth. Verifies SP1 proofs, manages UTXO state, prevents double-spends | Trustless (code is law) | | **EncryptedContacts** | On-chain encrypted address book storage | Trustless (encryption is client-side) | | **PaymentRequests** | On-chain encrypted payment request storage | Trustless (encryption is client-side) | | **Wallet UI** | All client-side cryptography: key derivation, UTXO scanning, encryption, signing | Self-custody (keys never leave browser) | | **Prover Server** | Orchestrates proof generation via Succinct Network | Not trusted - proofs verified on-chain | | **Relayer** | Submits transactions via Alchemy Smart Account, pays gas | Cannot steal funds or modify proofs | | **Succinct Network** | Generates Groth16 proofs from SP1 zkVM execution | Not trusted - proofs verified on-chain | ### Contract Addresses (Sepolia) | Contract | Address | |----------|---------| | PrivateUTXOLedger | `0x42ae920DFD0d25Ac014DFd751bd2ff2D2fBa0443` | | EncryptedContacts | `0x813e453D13dE769922aFc40780FADeF3AC6d939D` | | PaymentRequests | `0x3c4d73f028d99eC10eB15fED99AC5080C99A4a4d` | --- ## Privacy Model ### What's Hidden vs. Public | Data | On-Chain Visibility | Who Can Decrypt | |------|---------------------|-----------------| | Note commitment | Public | No one (hash) | | Encrypted note data | Public (in events) | Only recipient | | Nullifier | Public (when spent) | No one (hash of signature) | | Transaction amount | Hidden | Sender & Recipient | | Sender identity | Hidden | Recipient only (via contact name in note) | | Recipient identity | Hidden | Sender only | | Contacts | Encrypted on-chain | Only owner | | Payment requests | Encrypted on-chain | Only recipient | ### Key Privacy Properties - **Amount Privacy**: Transaction values are never revealed on-chain - **Sender Privacy**: Cannot determine who sent a payment from on-chain data - **Recipient Privacy**: Cannot determine who received a payment - **Unlinkability**: Cannot link inputs to outputs in a transaction (nullifiers hide source notes) --- ## Cryptographic Primitives ### Key Derivation Users derive a deterministic keypair from their Ethereum wallet signature: ``` User signs fixed message → SHA-256(domain + signature) → secp256k1 Private Key → Public Key ``` ```typescript const domain = 'utxo-prototype-v1-key-derivation:' const privateKey = sha256(domain + signature) const publicKey = secp256k1.getPublicKey(privateKey, true) // compressed const address = '0x' + hex(publicKey) // "Private Address" ``` - Keys exist only in browser memory - never transmitted - Same MetaMask signature always produces same keypair (deterministic) ### Note Structure A note represents a private UTXO: ```rust Note { amount: u64, // Value in USDC micro-units (6 decimals) owner_pubkey: [u8; 32], // Recipient's X-coordinate (from compressed pubkey) blinding: [u8; 32] // Random factor for commitment uniqueness } ``` ### Note Commitment Domain-separated Blake3 hash ensuring collision resistance: ``` Commitment = Blake3(DOMAIN_NOTE_COMMITMENT || amount_le(8) || owner_pubkey(32) || blinding(32)) ``` Where: - `DOMAIN_NOTE_COMMITMENT = b"NOTE_COMMITMENT_v1"` - `amount_le` = 8-byte little-endian encoding - Commitment is stored on-chain in Merkle tree - Blinding factor ensures two notes with same amount/owner have different commitments ### Nullifier Construction Prevents double-spending while hiding which note is being spent: ``` Nullifier = Blake3(DOMAIN_NULLIFIER || NullifierSignature) ``` Where: - `DOMAIN_NULLIFIER = b"NULLIFIER_v1"` - `NullifierSignature` = ECDSA signature over `ethSignedMessage(keccak256(commitment))` **Security Properties:** - Only the owner can compute the nullifier (requires private key to sign) - Cannot be computed from commitment alone - Published on-chain when note is spent → prevents double-spend - Deterministic: same note + same key always produces same nullifier ### Dual Signature Model Each input note requires TWO signatures for security: 1. **NullifierSig**: Used to derive the nullifier (privacy) - Signs: `keccak256(commitment)` with Ethereum prefix - Purpose: Deterministic nullifier derivation 2. **TxSig**: Proves ownership for the ZK circuit (anti-theft) - Signs: `keccak256(commitment)` with Ethereum prefix - Purpose: Recovered pubkey must match note's `owner_pubkey` Both signatures use the same message but serve different purposes in the security model. ### ECIES Encryption (Notes) Notes are encrypted to the recipient's public key using ECIES: ``` 1. Generate ephemeral keypair (r, R = r*G) 2. Compute shared secret: S = ECDH(r, recipient_pubkey) 3. Derive AES key: K = HKDF-SHA256(S, info="utxo-prototype-v1-encryption") 4. Encrypt: AES-256-GCM(K, nonce, plaintext) 5. Output: (R || nonce || ciphertext) ``` - Ephemeral pubkey (R) is stored on-chain in `OutputCommitted` events - Only recipient can decrypt using their private key - Forward secrecy via ephemeral keys ### ECIES Encryption (Contacts & Payment Requests) Contacts and payment requests use a similar ECIES scheme: ``` 1. Generate ephemeral keypair 2. ECDH shared secret with owner/recipient pubkey 3. HKDF-SHA256 key derivation (domain: "utxo-contacts-v1" or "utxo-requests-v1") 4. AES-256-GCM encryption 5. Store: ephemeralPub(33) || nonce(12) || ciphertext ``` --- ## Zero-Knowledge Proofs ### SP1 zkVM We use Succinct's SP1 zkVM which allows writing ZK circuits in Rust. The circuit is compiled to a RISC-V ELF binary and executed in a zkVM that generates Groth16 proofs verifiable on Ethereum. ### Optimized Proving Path The system uses an **optimized path** where expensive ECDSA operations are performed on the host (prover server) rather than inside the zkVM: ``` Host (Rust): - Verify signatures via k256 library - Compute nullifiers from signatures - Compute commitments from note data - Pass precomputed values to zkVM zkVM (SP1): - Verify precomputed commitments match note data (Blake3) - Use precomputed nullifiers (no ECDSA in circuit) - Verify value conservation - Output ABI-encoded public values ``` This reduces proving time by 40-60% compared to in-circuit ECDSA. ### What the Circuit Proves | Statement | What It Proves | Why It Matters | |-----------|----------------|----------------| | Commitment Validity | Input commitments match `Hash(note)` | Cannot spend notes that don't exist | | Nullifier Correctness | Nullifiers derived from valid signatures | Deterministic spend tracking | | Output Validity | Output commitments properly formed | New notes are correctly structured | | Value Conservation | `sum(inputs) >= sum(outputs)` | Cannot create money from nothing | ### Circuit Logic (Simplified) ```rust // VERIFY precomputed values match note data for (note, precomputed_commitment) in inputs { assert!(commit(note) == precomputed_commitment); } // VERIFY value conservation assert!(sum(input_amounts) >= sum(output_amounts)); // OUTPUT (public, ABI-encoded): // - old_root (contract verifies this matches current state) // - new_root (new Merkle root after adding outputs) // - nullifiers (marks inputs as spent) // - output_commitments (new notes added to tree) ``` ### Security Note The standard path (in-circuit ECDSA) is **disabled** for security. The system requires precomputed values where: - Host verifies signatures before proving - zkVM verifies precomputed values via hash matching - Contract verifies the proof and checks nullifiers haven't been used --- ## Encrypted Storage ### EncryptedContacts Contract Stores encrypted address book entries on-chain: ```solidity mapping(bytes8 => uint256[]) public contactsByOwner; // ownerTag => contactIds mapping(uint256 => Contact) public contacts; struct Contact { bytes8 ownerTag; // First 8 bytes of keccak256(owner_pubkey) bytes encryptedData; // ECIES-encrypted contact data uint256 timestamp; } ``` **Owner Tag Computation:** ```typescript ownerTag = keccak256(publicKeyHex).slice(0, 8) // First 8 bytes ``` ### PaymentRequests Contract Stores encrypted payment requests: ```solidity mapping(bytes8 => uint256[]) public requestsByRecipient; // recipientTag => requestIds mapping(uint256 => Request) public requests; struct Request { bytes8 recipientTag; bytes encryptedPayload; // ECIES-encrypted: {requesterName, requesterAddress, amount, reference, message} uint256 timestamp; RequestStatus status; // Pending, Approved, Rejected, Expired } ``` --- ## Security Model ### Threat Model | Threat | Mitigation | |--------|------------| | Double-spend | Nullifier registry on-chain - each nullifier used once | | Forged ownership | ECDSA signature verification (host + zkVM hash check) | | Invalid amounts | Value conservation check in ZK circuit | | Malicious prover | All proofs verified on-chain by SP1 Verifier | | Front-running | Nullifiers hide which specific note is being spent | | Key theft | Keys derived from wallet signature, exist only in browser | | Replay attacks | Nullifiers are one-time use, nonces in Permit2 | | Proof-binding bypass | Contract decodes outputs from `publicValues` (not separate params) | ### Trust Assumptions | Component | Security Trust | Liveness Trust | |-----------|----------------|----------------| | Smart Contract | Full (verified on-chain) | Ethereum availability | | Succinct Network | None (proofs verified on-chain) | Required for proof generation | | Relayer | None (cannot modify proofs) | Required for gasless tx submission | | Wallet UI | Self-custody | User's device | ### Cryptographic Assumptions - **secp256k1 ECDSA**: Discrete log hardness - **Blake3**: Collision resistance, preimage resistance - **Groth16**: Knowledge-of-exponent assumption, q-PKE - **AES-256-GCM**: Standard symmetric encryption security - **HKDF-SHA256**: PRF security of HMAC-SHA256 ### Key Security Properties - **Soundness**: Cannot create valid proof without knowing private keys - **Zero-Knowledge**: Proof reveals nothing about transaction details - **Unlinkability**: Cannot link sender to recipient from on-chain data - **Non-Malleability**: Proofs cannot be modified without invalidation --- ## Gasless Transactions All user-facing transactions are gasless via Alchemy Account Abstraction: ### Relayer Architecture ```javascript // Alchemy Smart Account with Gas Policy const smartAccountClient = await createLightAccountAlchemyClient({ chain: sepolia, signer: LocalAccountSigner.privateKeyToAccountSigner(RELAYER_PRIVATE_KEY), policyId: GAS_POLICY_ID, // Alchemy gas sponsorship }); ``` ### Supported Gasless Operations | Endpoint | Operation | |----------|-----------| | `/api/deposit-with-permit` | Deposit USDC (Permit2 signature) | | `/api/submit-tx` | Private transfer (proof required) | | `/api/withdraw` | Withdraw to public address (proof required) | | `/api/save-contact` | Save encrypted contact | | `/api/create-payment-request` | Create encrypted payment request | --- ## References - [SP1 Documentation](https://docs.succinct.xyz/) - [Groth16 Paper](https://eprint.iacr.org/2016/260) - [ECIES Specification](https://cryptopp.com/wiki/Elliptic_Curve_Integrated_Encryption_Scheme) - [Blake3 Specification](https://github.com/BLAKE3-team/BLAKE3-specs) - [Alchemy Account Kit](https://accountkit.alchemy.com/) - [Permit2](https://github.com/Uniswap/permit2)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully