Security Model
How Fluppy protects user identity and prevents payment replay — from browser credential storage through to on-chain nullifier protection.
Security Overview
Groth16 ZK proof computed entirely in the browser. No raw identity data reaches any server.
snarkjs.groth16.verify() runs locally before every transaction submission. Invalid proofs are rejected client-side.
Membership is proven via a Poseidon-hashed Merkle path. Only the commitment hash reaches the backend.
The contract stores nullifiers after each payment. Duplicate nullifiers are rejected — same proof cannot be reused.
Every proof embeds a chain-specific chainId derived from the network passphrase. Testnet proofs are invalid on Mainnet.
The contract atomically splits every payment. No single party controls the split logic after deployment.
What Is Private vs Public
| Data | Description | Visibility |
|---|---|---|
| raw secret | 64-char hex credential — browser memory only | private |
| password | PBKDF2 input — never stored or transmitted | private |
| ZK witness | Merkle path + circuit inputs — local computation only | private |
| commitment | Poseidon(LEAF_TAG, secret) — sent to Merkle backend only | private |
| nullifier | Poseidon(NULLIFIER_TAG, secret, nonce) — stored on-chain | on-chain |
| merkleRoot | Poseidon tree root — stored on-chain | on-chain |
| recipientHash | BN254-safe Stellar address hash — public signal | on-chain |
| chainId | Network passphrase hash — public signal | on-chain |
| txHash | Stellar transaction hash — public ledger | public |
| merchant address | Stellar G-address of merchant — public | public |
| payment amount | Amount in stroops — visible in contract event | public |
Credential Storage
Merkle Proof Security
Only the commitment reaches the backend
The SDK computes Poseidon(LEAF_TAG=2, secret) locally and sends only that hash to /api/merkle-proof. The raw secret never leaves the browser.
Sparse Merkle tree with domain separation
The server builds a sparse Poseidon Merkle tree using pre-computed zero hashes. Domain tags (LEAF=2, NODE=3) prevent cross-context hash collisions.
Root sync guard
executeFluppyPayment() compares the frontend Merkle root against the on-chain contract root before generating a proof. A mismatch throws RootSyncError before any computation begins.
Nullifier Replay Protection
Each ZK payment proof includes a nullifier: Poseidon(NULLIFIER_TAG=1, secret, nonce) — a random one-time value derived from the secret and a CSPRNG nonce.
First payment
Nullifier stored in contract temporary storage (TTL ~30 days)
Duplicate attempt
Contract rejects with NullifierSpent error (#4)
New payment
New CSPRNG nonce → new nullifier → new valid proof
ChainId Binding
Every ZK proof includes a chainId public signal derived from the Stellar network passphrase:
On-Chain Verifier Strategy
Demo-mode verifier (current)
The Soroban contract validates proof structure and public inputs but does not perform a full BN254 pairing check at the contract level. This demo-mode strategy was chosen to unblock frontend development while native BN254 host function exposure in the soroban-sdk stabilises.
Defense-in-depth: Client-side snarkjs.groth16.verify() is enforced before every transaction submission. Invalid proofs are caught client-side and never submitted to the contract.
Future: native BN254 pairing
When the soroban-sdk exposes stable BN254 host functions (bn254_g1_mul, bn254_g1_add, bn254_pairing_check), the verifier module can be upgraded by recompiling with --features bn254_native. The modular verifier architecture (types.rs, vk_constants.rs, bn254_demo.rs, bn254_native.rs) was designed for zero-impact migration. No changes to payment.rs or tests are required.
Current Limitations
| Limitation | Mitigation | Planned Resolution |
|---|---|---|
| Single-contributor trusted setup | Testnet only — no real funds | Multi-party ceremony before mainnet |
| Demo-mode on-chain verifier | Client-side snarkjs.verify() enforced | Native BN254 when SDK supports it |
| No external security audit | Comprehensive internal test coverage | SCF Soroban Audit Bank after MVP |
| No production relayer | User-signed Freighter (transparent) | Optional future relayer layer |
| Testnet deployment only | No real value at risk | After audit + ceremony + native verifier |