OffPay
Tap Now, Chain Later — Offline USDC Payments
The problem OffPay solves
Digital payments fail without internet — UPI, mobile wallets, and crypto all need connectivity. In rural markets, crowded festivals, and underground transit, millions can't transact during outages.
OffPay enables fully offline USDC payments via NFC tap-to-pay. Lock USDC into an on-chain vault on Polygon, pre-sign bearer vouchers, and pay by tapping phones — no internet on either side. Settlement auto-triggers when connectivity returns.
How it works
- Lock funds — Deposit USDC into OfflineVault on Polygon
- Pre-sign vouchers — Android app signs bearer vouchers using device's secp256k1 key
- Tap to pay — NFC HCE transfers signed voucher instantly to receiver phone or ESP32 reader
- Verify locally — Receiver verifies ECDSA signature + nonce + digest offline
- Auto-settle — Pending vouchers batch-settle on-chain via
settleBearerBatch
Key features
- Unified Android wallet — sender + receiver in one app, NFC HCE tap-to-pay
- ESP32 POS terminal — RC522 NFC + Bluetooth bridge to merchant phone
- P2P mesh replication — Google Nearby Connections gossips vouchers for redundancy
- On-chain settlement — double-spend protection via
usedVouchersmapping - Sybil-resistant handshake — ECDSA challenge-response for mesh peer auth
- Key backup — PBKDF2 + AES-GCM encrypted backup with server-side pepper
Challenges we ran into
Voucher digest byte-identity across 5 platforms
The keccak256 hash must be identical in Solidity, JavaScript, Kotlin (sender), Kotlin (verifier), and C++ (ESP32). A single byte mismatch breaks signature recovery. We matched ABI encoding, EIP-191 prefix, and Keccak-256 (NOT NIST SHA3) across all five.
ESP32 Keccak-256 vs SHA3-256
mbedtls on ESP32 only provides NIST SHA3 (different padding from Ethereum's Keccak). We shipped a standalone Keccak-256 implementation — using the library's sha3 would silently break all signatures.
Offline double-spend prevention
Without a blockchain at tap-time, we combine:
- Per-payer monotonic nonces (client-side + on-chain)
- Pre-flight locked balance checks before settlement
- On-chain
usedVouchersmapping as safety net - Mesh
claimAndWaitso two backups don't settle the same voucher
Unified app architecture
Consolidated separate customer and merchant apps into one wallet handling NFC HCE send, NFC reader receive, ESP32 Bluetooth bridge, and mesh replication — single APK, single cryptographic identity.
NFC payload constraints
Android HCE APDU frames have strict size limits. Voucher JSON had to be carefully serialized to fit single-tap exchanges while preserving all cryptographic fields.
Tracks Applied (2)
