ETHGlobal New Delhi 2025 Project
- Intercepts email data requests from third-party apps
- Applies user policy and redaction
- Returns filtered payload with payment processing
- Express server within extension background script
- x402 middleware protecting email data endpoints
- Dynamic pricing through policy agent
- Payment processing via x402 facilitator
- Real-time payment verification
DataGuard: transforms your inbox into a privacy-preserving marketplace where you get paid for email data access via x402 protocol while maintaining complete control over your data.
- Build an end-to-end demo that proves the concept: extension negotiates payment via x402 protocol for email data access, applies user policy, returns filtered results with payment processing.
- Focus domain: email only with decentralized storage integration.
- Implement and demo 2 concrete predicates: subscription acknowledgement & package delivery with monetization.
- Provide AI agent negotiation for automated pricing and x402 payment processing on Polygon testnet.
- Clear UI flow that shows payment negotiation, data access approval, and user earnings.
- No production Gmail OAuth integration in MVP — use Dmail + IPFS for decentralized email storage. ✅ PLANNED: Integration with Dmail Network for IPFS-stored emails.
- No complex ZK circuits for MVP — focus on payment-for-data model with basic privacy proofs.
- No full support for multiple data domains (photos, calendar, files) — email only.
- No mobile development — browser extension + web interface only.
-
Subscription Acknowledgement 💰 $0.10-0.50 per proof
- Predicate: "There exists an email from a recognized newsletter sender OR containing keyword
unsubscribe/subscriptionin subject within the last X months." - Verifiable claim: boolean
has_subscription == trueorcount_subscriptions >= N. - Demo value: AI training data, marketing intelligence, research analytics.
- Predicate: "There exists an email from a recognized newsletter sender OR containing keyword
-
Package Delivery 💰 $0.25-1.00 per proof
- Predicate: "There exists a delivery confirmation email from recognized carriers or ecommerce senders (Amazon, Flipkart, DHL) within the last X weeks."
- Verifiable claim:
has_delivery == trueand optionallycount_deliveries >= N. - Demo value: logistics analytics, consumer behavior research, targeted advertising.
- Proof of Purchase (count) 💰 $0.50-2.00 per proof
- Predicate: "Number of purchase-confirmation emails in the last M days ≥ K."
- Verifiable claim:
count_purchases >= K. - Demo value: financial services verification, loyalty program analytics, market research.
[Third-Party App / AI] --x402 payment--> [Browser Extension / Express Server]
|
|--- x402 middleware validates payment
|--- reads local email store (mock)
|--- applies user policy & redaction
|--- runs predicate circuit -> generates ZK proof
|--- returns filtered payload + proof -> to App
[Third-Party App] --verifies proof--> [On-chain Verifier Contract OR local JS verifier]
Components:
- Browser extension: Express server with x402 middleware that handles paid API requests, presents UI prompt to user, forwards allowed queries to local agent.
- x402 Payment Layer: Express middleware protecting email data endpoints with dynamic pricing and payment verification.
- Policy Agent: Automated negotiation system for pricing and privacy policy enforcement.
- Local agent: small WASM or Node process (or BG script) that performs parsing, policy enforcement, and ZK proof generation.
- Mock email store: ✅ COMPLETED - JSON dataset with 21 realistic sample emails in
/mail-demo/src/data/sampleEmails.tswith labeled types (purchase, subscription, delivery, general) and filtering functions. - ZK circuit: simple circuit (e.g., count predicate) compiled with Circom/snarkjs or Noir; proof generated locally.
- Verifier: JS verifier for browser + optional on-chain verifier contract deployed on testnet (Holesky/Polygon testnet) to show on-chain verification.
- Extension: Chrome extension (MV3) using React for popup UI (or vanilla if time-constrained).
- x402 Integration: Express server with x402-express middleware for payment processing.
- Payment Processing: x402 facilitator on Base Sepolia testnet for development.
- Local agent: Node.js background process or extension background service worker. If proof generation needs it, run via WASM compiled circuits in-browser or call a local worker endpoint.
- ZK: Use Circom + SnarkJS or Noir depending on developer familiarity. (Question: which ZK stack are we most comfortable with?)
- On-chain verification: Solidity verifier from SnarkJS compiled for a testnet (Holesky or Polygon zk testnet). (Question: which testnet to deploy to for submission?)
- Mock email store: ✅ COMPLETED - TypeScript files in
/mail-demo/src/data/sampleEmails.tswith varied realistic senders/domains (Amazon, DHL, GitHub, Netflix, etc.). - Payments: ✅ COMPLETED - x402 integration with Base Sepolia testnet for development.
- Setup: show the mock inbox (in the extension dev UI) — ✅ COMPLETED: 21 labeled emails available in
/mail-demowith filtering by type (subscription, delivery, purchase, unread). - Third-party request: simulate an AI app requesting "Provide proof of package delivery in last 30 days."
- x402 Payment Flow: AI app receives 402 Payment Required response with payment instructions.
- Payment Processing: AI app completes payment through x402 facilitator using USDC on Base Sepolia.
- Agent prompt: extension popup shows request, explains privacy implications, displays policy (auto-allow filtered data & generate proof / deny full access).
- User approves: agent filters emails (returns subject + sender for matched emails but redacts bodies), generates ZK proof for
has_delivery == true. - Verification: the third-party app runs JS verifier or verifies via on-chain call; verifier confirms proof valid without seeing other emails.
- UI confirmation: extension shows what was revealed, shows proof verification status, and displays payment received.
- Input: hash commitments of email metadata (subject hashes, sender hashes, timestamp buckets) and a witness set describing which emails match predicate.
- Predicate:
count(matches) >= K. - Output / public signals:
K,count >= Kboolean (or exact count), root commitment or aggregator hash to bind proof to specific inbox snapshot. - Commitment strategy: Emails hashed and combined into a Merkle root or aggregated commitment to prevent changing data after proof.
-
Install x402 dependencies in extension:
cd extension yarn add x402-express @coinbase/x402 -
Configure Express server in background script:
- Create Express server within extension background service worker
- Apply x402 middleware to protect email data endpoints
- Integrate with existing policy agent for dynamic pricing
-
Set up payment endpoints:
/api/emails/subscription- Protected subscription data endpoint/api/emails/delivery- Protected delivery data endpoint/api/emails/purchase- Protected purchase data endpoint
-
Configure x402 middleware:
app.use(paymentMiddleware( "0xYourWalletAddress", // User's receiving wallet { "GET /api/emails/subscription": { price: "$0.05", // Dynamic pricing from policy agent network: "base-sepolia", }, "GET /api/emails/delivery": { price: "$0.10", network: "base-sepolia", }, "GET /api/emails/purchase": { price: "$0.25", network: "base-sepolia", } }, { url: "https://x402.org/facilitator", // Base Sepolia facilitator } ));
- Policy Agent: Provides dynamic pricing based on user preferences and demand
- Email Filtering: Applies user privacy policies after payment verification
- ZK Proof Generation: Generates proofs for verified email predicates
- Payment History: Tracks all successful payments and earnings
- Start the extension with x402 middleware enabled
- Make a request to protected endpoint without payment (should receive 402)
- Complete payment using x402 client with USDC on Base Sepolia
- Retry request with payment header (should receive filtered email data)
- Verify payment was processed and user received funds