Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnonPay

Privacy-Preserving Payment Links on Aleo

Get paid in crypto without revealing your wallet address. Share a simple link, protect your privacy.


The Problem

Traditional crypto payments expose everything:

  • Recipient wallet addresses are publicly visible
  • Transaction history is permanently on-chain
  • Financial privacy is non-existent for payees

Payment links on other platforms (PayPal, Venmo, Cash App) work because they use centralized servers to hide addresses. On transparent blockchains, this privacy doesn't exist — creating a payment link means doxxing your wallet.

AnonPay solves this using zero-knowledge cryptography.


How It Works

AnonPay uses cryptographic commitments to break the public link between usernames and wallet addresses:

1. Link Creation (Privacy-First)

When a user creates a payment link:

  • Generate a random secret
  • Compute commitment = Hash(recipient_address + secret)
  • Store the commitment on-chain (not the address)
  • Link becomes shareable: anonpay.com/pay/alice

Result: The blockchain only knows a commitment hash — the actual wallet address stays private.

2. Payment Processing (Zero-Knowledge Verification)

When someone pays through the link:

  • Sender provides the recipient's address + secret (off-chain)
  • Contract verifies: Hash(address + secret) == stored_commitment
  • Payment executes only if the commitment matches
  • Transaction completes without exposing recipient to the public

Result: Sender knows who they're paying, but blockchain observers see only hashes.

3. Privacy Guarantees

  • ✅ Recipient address never appears on-chain in plaintext
  • ✅ Only payment amounts and stats are publicly visible
  • ✅ Link owners can deactivate/reactivate links at will
  • ✅ Sender privacy protected via address hashing

Privacy Architecture

On-Chain (Public)

  • Link commitments: Hash(address + secret)
  • Payment statistics: total volume, payment count
  • Link active status: boolean flag

Off-Chain (Private)

  • Actual wallet addresses (encrypted in database)
  • User-to-username mappings
  • Payment metadata and history

Records (Private State)

record PaymentReceived {
    owner: address,        // Only recipient can decrypt
    amount: u64,
    sender_hash: field,    // Hashed for privacy
    payment_id: field,
    link_id: field,
    timestamp: u32,
}

Recipients receive private records that only they can decrypt — completely invisible to the network.


Key Features

🔐 True Privacy

  • Recipient addresses hidden using cryptographic commitments
  • Zero-knowledge proof verification ensures payments reach correct recipient
  • On-chain data reveals nothing about user identities

🔗 Dead Simple UX

  • Share one link for all payments: anonpay.com/pay/yourname
  • No need to share wallet address for each payment
  • Works like PayPal/Venmo but fully decentralized

💎 Practical & Usable

  • Content creators can accept tips without doxxing wallets
  • Freelancers can share payment links on profiles
  • Merchants can use human-readable payment pages
  • Users maintain financial privacy by default

Production-Ready

  • Full monorepo with smart contracts, API, and UI
  • Wallet integration via Leo Wallet Adapter
  • Encrypted data storage with AES-256-GCM
  • Responsive Next.js frontend with modern UX

Technical Implementation

Smart Contract (anonpay_v1.aleo)

Language: Leo (Aleo's zkSNARK programming language)

Core Functions:

  • create_link() - Registers payment link with commitment
  • send_payment() - Executes payment with ZK verification
  • deactivate_link() / reactivate_link() - Link management

Privacy Mechanism:

// Commitment generation
let addr_as_field: field = BHP256::hash_to_field(self.caller);
let commitment: field = BHP256::hash_to_field(addr_as_field + secret);

// Payment verification
assert_eq(stored_commitment, expected_commitment);

Backend (apps/api)

  • Framework: Express.js + TypeScript
  • Database: Prisma ORM (SQLite dev / PostgreSQL prod)
  • Security: Wallet-based authentication, encrypted address storage
  • Services: Aleo blockchain integration, payment tracking

Frontend (apps/web)

  • Framework: Next.js 14 (App Router)
  • Styling: Tailwind CSS + shadcn/ui
  • State: Zustand for wallet management
  • Integration: Leo Wallet Adapter for transactions

Shared Packages

  • SDK: Core Aleo helpers, transaction builders, type converters
  • UI: Reusable React components with consistent theming

Real-World Use Cases

💸 Content Creators

Streamers, YouTubers, and artists can share one permanent payment link without revealing their wallet across platforms.

💼 Freelancers & Professionals

Add anonpay.com/pay/yourname to email signatures, portfolios, and social profiles for private payment collection.

🏪 E-Commerce & Merchants

Accept payments with human-readable links while protecting customer privacy and business wallet security.

🎁 Tipping & Donations

Enable anonymous tipping for online communities, forums, and social platforms without tracking individual wallets.


Project Structure

anonpay/
├── contracts/          # Leo smart contracts
│   └── src/
│       └── main.leo   # Core privacy logic
├── apps/
│   ├── api/           # Express.js backend
│   │   ├── src/
│   │   │   ├── controllers/
│   │   │   ├── services/
│   │   │   └── middleware/
│   │   └── prisma/
│   └── web/           # Next.js frontend
│       └── src/
│           ├── app/
│           ├── components/
│           └── lib/
└── packages/
    ├── sdk/           # Aleo SDK & helpers
    └── ui/            # Shared UI components

Getting Started

Prerequisites

  • Node.js 18+
  • Leo CLI (for contract development)
  • Leo Wallet browser extension

Installation

  1. Clone and install dependencies:
npm install
  1. Set up environment variables:
cp apps/api/.env.example apps/api/.env
cp apps/web/.env.example apps/web/.env
  1. Run development servers:
# API (port 3001)
npm run dev:api

# Web (port 3002)
npm run dev:web
  1. Open the app:
http://localhost:3002

Building Contracts

cd contracts
leo build

Why This Matters

Privacy is a fundamental right, not a luxury.

On transparent blockchains, payment recipients have no choice but to expose their financial activity. Every payment link becomes a permanent record of their identity and transaction history.

AnonPay proves that privacy and usability aren't trade-offs — they can coexist through zero-knowledge cryptography.

This isn't just a demo. It's a blueprint for how payments should work when privacy is the default.


Technical Highlights

Privacy-First Design

  • Uses BHP256 hash commitments for address hiding
  • Implements Leo 3.4+ async/await model
  • Private records ensure recipient-only decryption
  • Sender hashing protects payer identities

Security Features

  • Wallet-based challenge-response authentication
  • AES-256-GCM encryption for sensitive data at rest
  • Input validation and sanitization across all APIs
  • Secure secret generation using crypto libraries

Production Considerations

  • Scalable monorepo architecture
  • Type-safe TypeScript throughout
  • Database schema designed for privacy compliance
  • Error handling and graceful degradation

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages