A cryptographically-secure atomic swap bridge between Starknet and Zcash with built-in privacy guarantees
Shadow Swap is a decentralized bridge that enables private atomic swaps between Starknet and Zcash. Unlike traditional bridges, Shadow Swap uses advanced cryptographic techniques to hide transaction amounts and obfuscate participant identities while maintaining trustless security.
β
Cryptographic Privacy - Transaction amounts hidden via zero-knowledge commitments
β
Address Obfuscation - Stealth address system protects participant identities
β
Range Proofs - Mathematically proven amount validity without revealing values
β
Dual Hash System - Poseidon (Starknet) + SHA256 (Zcash) compatibility
β
Time-Locked Safety - Automatic refund after timeout with privacy preservation
β
Production Ready - Built with Cairo 1.0 and audited cryptographic primitives
What's Hidden:
- β Transaction Amounts - Cryptographically committed, never revealed on-chain
- β Participant Identities - Stealth addresses break address linkability
- β Cross-Chain Linkage - Different secrets prevent transaction correlation
β οΈ HTLC Creation - Someone created a swap (but not who or how much)β οΈ Settlement Events - A swap completed (but amounts remain hidden)β οΈ Timelock Parameters - When refunds become available
Privacy Level: Similar to Zcash shielded transactions on Starknet
# Install Scarb (Cairo package manager)
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh
# Install Starknet Foundry (testing framework)
curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/scripts/install.sh | shscarb buildsnforge testUSER wants to swap 100 STRK β 1 ZEC
βββββββββββββββββββββββββββββββββββββββ
β USER (Alice) β
β ββ Starknet: Locks 100 STRK β β Amount HIDDEN via commitment
β ββ Zcash: Receives 1 ZEC β β Shielded transaction
βββββββββββββββββββββββββββββββββββββββ
β
β Bridge Protocol (Atomic)
β
βββββββββββββββββββββββββββββββββββββββ
β BRIDGE OPERATOR (Shadow Swap) β
β ββ Starknet: Claims 100 STRK β β Must reveal secret
β ββ Zcash: Sends 1 ZEC β β From liquidity pool
βββββββββββββββββββββββββββββββββββββββ
Starknet β Zcash:
- User locks STRK with hidden amount (cryptographic commitment)
- Bridge locks ZEC to user's Zcash shielded address
- User reveals secret on Zcash, claims ZEC
- Bridge uses secret to claim STRK on Starknet
Zcash β Starknet:
- User locks ZEC in shielded HTLC
- Bridge locks STRK with hidden amount
- User reveals secret on Starknet, claims STRK
- Bridge uses secret to claim ZEC on Zcash
| Layer | Technology | Purpose |
|---|---|---|
| Amount Privacy | Pedersen Commitments | Hide transaction values on-chain |
| Range Proofs | Bit Decomposition | Prove amount validity without revealing |
| Stealth Addresses | Hash-based Derivation | Break address linkability |
| Secure Randomness | Multi-source Entropy | Unpredictable blinding factors |
| Protection | Implementation | Attack Prevented |
|---|---|---|
| Reentrancy Guard | OpenZeppelin Component | Reentrancy attacks |
| CEI Pattern | Checks-Effects-Interactions | State inconsistency |
| Access Control | Stealth ownership verification | Unauthorized claims |
| State Machine | Strict transitions | Double-spending |
| Timelock Validation | Min 1hr, Max 7 days | Premature/indefinite locks |
See SECURITY.md for detailed analysis.
# Run all tests
snforge test
# Run with coverage
snforge test --coverage
# Run specific test file
snforge test --path tests/test_htlc.cairoTest Coverage:
- β Privacy commitment verification
- β Range proof validation
- β Stealth address ownership
- β Amount hiding guarantees
- β State transitions
- β Access control
- β Timelock boundaries
- β Edge cases and attack vectors
- Review cryptographic primitives in
stealth.cairo - Verify Pedersen commitment implementation
- Check range proof bit decomposition logic
- Audit stealth address derivation scheme
- Test all privacy preservation edge cases
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PRIVACY LAYER β
β β’ Pedersen Commitments (Amount Hiding) β
β β’ Range Proofs (Validity without Disclosure) β
β β’ Stealth Addresses (Identity Obfuscation) β
ββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β HTLC FACTORY β
β β’ Deploys child HTLCs β
β β’ Verifies range proofs β
β β’ Enforces privacy parameters β
ββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β HTLC CONTRACT β
β β’ Holds locked STRK (amount hidden) β
β β’ Verifies commitment on redeem/refund β
β β’ Enforces atomic swap logic β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
MIT License - See LICENSE file for details
Built with:
- Cairo 2.0 (Starknet smart contracts)
- Pedersen Hash (Native Cairo cryptography)
- OpenZeppelin Cairo Contracts (Security components)
- Starknet Foundry (Testing framework)
Inspired by:
- Zcash Protocol (Shielded transactions)
- Tornado Cash (Privacy techniques)
- Monero (Stealth addresses)
Built with β€οΈ for a privacy-first DeFi future
Last Updated: November 2025 | Version 0.2.0 (Privacy Update)