<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Radrdotfun on Medium]]></title>
        <description><![CDATA[Stories by Radrdotfun on Medium]]></description>
        <link>https://medium.com/@radrdotfun?source=rss-79fe8f8fd332------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dzPIIFszKn1rLoRYReob2w.png</url>
            <title>Stories by Radrdotfun on Medium</title>
            <link>https://medium.com/@radrdotfun?source=rss-79fe8f8fd332------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 12:44:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@radrdotfun/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ShadowPay v1.01: How We Cut Costs by 64% While Hardening Security]]></title>
            <link>https://medium.com/@radrdotfun/shadowpay-v1-01-how-we-cut-costs-by-64-while-hardening-security-7c86b502a0be?source=rss-79fe8f8fd332------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c86b502a0be</guid>
            <category><![CDATA[solana-blockchain]]></category>
            <category><![CDATA[elgamal-encryption]]></category>
            <category><![CDATA[zksnark]]></category>
            <category><![CDATA[solana-network]]></category>
            <category><![CDATA[solana-ecosystem]]></category>
            <dc:creator><![CDATA[Radrdotfun]]></dc:creator>
            <pubDate>Thu, 06 Nov 2025 06:13:00 GMT</pubDate>
            <atom:updated>2025-11-06T06:29:04.848Z</atom:updated>
            <content:encoded><![CDATA[<h3>A deep dive into our security audit, cost optimization, and what it means for private payments on Solana</h3><p><em>6 November 2025 • 12 min read</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WEvEvkEPqHrklqss_aeQTg.png" /></figure><p>Two months ago, we started working on ShadowPay with a bold vision: enable truly private payments on Solana without compromising on security or usability.</p><p>Today, we’re releasing <strong>v1.01, </strong>the result of a comprehensive security audit and architectural optimization that makes frequent payments <strong>64% cheaper</strong> while fixing every critical vulnerability.</p><p>Here’s how we did it, what changed, and why it matters for the future of private commerce and x402 payments on Solana.</p><h3>🧩 The Problem: Security vs. Cost</h3><p>When we launched ShadowPay v1.0, we faced a fundamental tradeoff in blockchain architecture:<br><strong>how do you prevent double-spending without creating a new account for every transaction?</strong></p><p>Our initial solution was straightforward: create a unique <em>nullifier account</em> for each payment, think of it like issuing a unique receipt that lives on-chain forever.</p><p>If someone tries to reuse the same payment proof, the blockchain checks the receipt and rejects it.</p><p>✅ <strong>Perfect security but </strong>zero successful double-spend attacks, zero replay vulnerabilities, perfect privacy.<br> ❌ <strong>But it was expensive but </strong>each receipt cost ~$0.24 in rent to store on Solana.</p><p>For a one-time purchase, that’s fine. For 100 purchases, that’s <strong>$24 in overhead</strong>.<br>Something had to change.</p><h3>💡 The Breakthrough: Receipt Books, Not Receipts</h3><p>The solution came from an unexpected place: how physical stores handle receipts.</p><p>Instead of printing a new receipt book for every transaction, stores use one book with numbered pages. Each transaction gets a page number, once used, it can’t be reused.</p><p>We applied the same logic to blockchain:</p><p><strong>Old system </strong>Create a new nullifier account (receipt) for each payment</p><p><strong>New system </strong>Create one nullifier account (receipt book) per user, mark each payment as a “page number”</p><p>The technical term for this optimization is a <strong>bitmap, </strong>a structure that stores 8,192 “yes/no” flags in just <strong>1 KB</strong> of space.<br>Each flag represents whether a specific payment commitment has been used.</p><h3>⚙️ The Implementation Challenge</h3><p>Our first attempt was ambitious: a <strong>16 KB bitmap</strong> supporting 131,072 payments per user.<br> The math checked out. The model worked. The cost savings were incredible.</p><p>Then… the deployment failed.</p><blockquote><strong><em>Problem:</em></strong><em> Solana’s BPF runtime has a 4 KB stack limit.<br> Loading a 16 KB account into memory crashed the program every time.</em></blockquote><p>✅ <strong>Fix:</strong> Reduce the bitmap to 1 KB (8,192 payments per user).<br> This fits BPF limits and covers <strong>99% of real-world use cases.</strong></p><blockquote><strong><em>Quick math:</em></strong><em> Even at 5 payments/day, it’d take </em><strong><em>4.5 years</em></strong><em> to exhaust the account.</em></blockquote><h3>The Cost Transformation</h3><p>Let’s look at real-world numbers.</p><h3>Old System (Per-Payment Nullifiers)</h3><p>Each payment required a new account:</p><ul><li>$0.019 fee + $0.24 nullifier = <strong>$0.259</strong></li><li>20 payments = <strong>$5.18 total</strong></li></ul><h3>New System (Bitmap Nullifiers)</h3><ul><li>Payment 1: $0.019 + $0.84 setup = <strong>$0.859</strong></li><li>Payments 2–20: $0.019 × 19 = <strong>$0.38</strong></li><li><strong>Total: $1.24</strong></li></ul><p>➡️ <strong>Savings: $3.94 (76% reduction)</strong><br> ➡️ Break-even after <strong>4 payments</strong></p><p>At scale:</p><ul><li><strong>1,000 payments:</strong> $239.25 saved (92% reduction)</li></ul><h3>🔒 Security: The Audit Results</h3><h3>Security: The Audit Results</h3><p>Before the v1.01 launch, we commissioned a full independent security audit.<br> Eight issues were identified, from <strong>critical</strong> to <strong>low</strong> severity and <strong>all have been fixed. ✅</strong></p><h3>🔴 SP-001 — Double-Spend Prevention</h3><p><strong>Issue:</strong> No on-chain mechanism to prevent reusing the same payment proof.<br> <strong>Fix:</strong> Implemented bitmap-based nullifier tracking.<br> <strong>Result:</strong> 100% protection against replay attacks, each commitment can only be used once, ever.</p><h3>🔴 SP-002 — ZK Proof Verification</h3><p><strong>Issue:</strong> No on-chain proof verification (initial Groth16 approach exceeded compute limits).<br> <strong>Fix:</strong> Verification now handled by authorized off-chain relayers, sending lightweight settlement proofs on-chain.<br> <strong>Result:</strong> Compute cost reduced from 2.5M CU → 5 000 CU while retaining cryptographic integrity.</p><h3>🟡 SP-003 — Relayer Authorization</h3><p><strong>Issue:</strong> Any address could act as a relayer and set arbitrary fees.<br> <strong>Fix:</strong> Added a RelayerRegistry with an allowlist and fee caps.<br> <strong>Result:</strong> Only approved relayers can operate; fee manipulation eliminated.</p><h3>🟡 SP-004 — Account Ownership Validation</h3><p><strong>Issue:</strong> Merchant token account ownership was not enforced.<br> <strong>Fix:</strong> Added explicit ownership constraints.<br> <strong>Result:</strong> Prevents accidental or malicious payment redirection.</p><h3>🟡 SP-C001 — Re-Initialization Vulnerability</h3><p><strong>Issue:</strong> Accounts could be re-initialized, causing state conflicts.<br> <strong>Fix:</strong> Added version guards and strict initialization checks.<br> <strong>Result:</strong> Safe migrations and deterministic account states.</p><h3>🟢 SP-C002 — Missing State Versioning</h3><p><strong>Issue:</strong> No version fields in account structs.<br> <strong>Fix:</strong> Added version tracking to all key accounts.<br> <strong>Result:</strong> Future-proof upgrades and smoother migrations.</p><h3>🔴 SP-E001 — Privacy Leakage</h3><p><strong>Issue:</strong> Commitments were being logged on-chain.<br> <strong>Fix:</strong> Removed all sensitive logging; only generic “payment processed” events remain.<br> <strong>Result:</strong> No link between payments and goods/services — privacy fully preserved.</p><h3>🟢 SP-E002 — Owner Address Logging</h3><p><strong>Issue:</strong> User wallet addresses were logged unnecessarily.<br> <strong>Fix:</strong> Removed non-essential logs.<br> <strong>Result:</strong> Minimal metadata exposure; improved privacy posture.</p><p>✅ <strong>Outcome:</strong> Every critical and high-severity issue has been remediated, verified, and retested. ShadowPay v1.01 ships with hardened privacy, strong authorization guarantees, and a future-ready state model.</p><h3>🧠 The Smart Contract Evolution</h3><h3>Program Capacity</h3><ul><li>Current size: <strong>526 KB</strong></li><li>Allocated: <strong>1.2 MB</strong></li><li>Headroom: <strong>~700 KB</strong></li></ul><p>Enough room for:</p><ul><li>State compression (1M+ payments/user)</li><li>Token-2022 support</li><li>NFT &amp; DeFi composability</li><li>Advanced ZK circuits</li></ul><h3>Technical Debt Cleanup</h3><ul><li>Removed Arkworks deps (−400 KB)</li><li>Removed on-chain verifier (−300 KB)</li><li>Refactored SPL token interface</li><li>Modularized architecture</li></ul><p>Result: <strong>Binary 40% smaller</strong>, cleaner, faster.</p><h3>👥 What This Means for Users</h3><h3>One-Time Buyers</h3><ul><li>Slightly higher first payment ($0.86 vs $0.26)</li><li>Future payments: $0.019 each</li><li>✅ Privacy + enterprise-grade security</li></ul><h3>Regular Customers</h3><ul><li>Save 64–76% after 4 payments</li><li>Example: 5 coffees/week → $64 saved/year</li></ul><h3>Power Users</h3><ul><li>1,000 payments = 92% savings</li><li>Merchants processing 10K tx/month save <strong>$2,391/month</strong></li></ul><h3>Relayers</h3><ul><li>Breakeven after 44 payments</li><li>Profitable thereafter → sustainable economics</li></ul><h3>🧰 Developer Architecture</h3><p>Each user = 1 PDA (UserNullifierAccount):</p><ul><li>Size: <strong>1,070 bytes</strong></li><li>Bitmap: <strong>8,192 slots (1 KB)</strong></li><li>Rent: <strong>0.0076 SOL (~$0.84)</strong></li></ul><p><strong>Deterministic PDA derivation:</strong></p><ul><li>No collisions</li><li>Simple lookups</li><li>One account per user forever</li></ul><p><strong>Capacity Monitoring:</strong></p><ul><li>95% full → warning</li><li>100% → graceful rotation</li></ul><p><strong>Rotation Policy:</strong></p><ul><li>After 8,192 payments <strong>or</strong> 365 days</li><li>Old account closed (rent reclaimed)</li><li>New one auto-created</li><li>Net cost: <strong>$0</strong></li></ul><h3>🚀 Performance Benchmarks</h3><p><strong>First payment:</strong> $0.859 which includes setup<br> <strong>Subsequent payments:</strong> $0.0196 fee + relayer<br> <strong>Average (100 payments):</strong> $0.027 ~64% cheaper vs v1.0</p><h3>🛣 Roadmap</h3><h3>Q4 2025: State Compression</h3><ul><li>Support <strong>1M+ payments/user</strong></li><li>Using <strong>SPL Account Compression</strong></li><li>$1.50 setup → $0.0001 per payment</li><li>💸 <strong>99.99% cost reduction</strong></li></ul><h3>Q1 2026: Token-2022</h3><ul><li>Confidential transfers</li><li>Transfer memo hooks</li><li>Interest-bearing &amp; soulbound tokens</li></ul><h3>Q1 2026: SDK &amp; Composability</h3><ul><li>React Native &amp; Flutter SDKs</li><li>Direct wallet integration</li><li>DeFi composability hooks</li></ul><h3>🧭 Try It Yourself</h3><p><strong>For Users:</strong><br> 👉 <a href="https://registry.scalar.com/@radr/apis/shadowpay-api/latest#description/shadowpay-privacy-preserving-payment-rails-for-x402">ShadowPay API on Scalar</a><br>Test in our sandbox.</p><p><strong>For Merchants:</strong><br> 📘 <a href="https://registry.scalar.com/@radr/apis/shadowpay-api/latest#description/shadowpay-privacy-preserving-payment-rails-for-x402">Integration Guide</a><br> 📧 hello@radr.fun</p><p><strong>For Developers:</strong><br> 💻 <a href="https://github.com/radrdotfun">GitHub</a><br> 📖 <a href="https://registry.scalar.com/@radr/apis/shadowpay-api/latest#description/shadowpay-privacy-preserving-payment-rails-for-x402">Technical Docs</a><br> 💬 <a href="https://t.me/radrdotfun">Telegram</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c86b502a0be" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>