Testnet MVP — No security audit yet

Security Model

How Fluppy protects user identity and prevents payment replay — from browser credential storage through to on-chain nullifier protection.

⚠
Fluppy is a Testnet MVP. No external security audit has been completed. No real funds should be used until a full audit, multi-party trusted setup ceremony, and native BN254 on-chain verification are in place.

Security Overview

🔐Browser-side proof generation

Groth16 ZK proof computed entirely in the browser. No raw identity data reaches any server.

✓Local verification before submit

snarkjs.groth16.verify() runs locally before every transaction submission. Invalid proofs are rejected client-side.

🌳Poseidon Merkle membership

Membership is proven via a Poseidon-hashed Merkle path. Only the commitment hash reaches the backend.

⛓Nullifier replay protection

The contract stores nullifiers after each payment. Duplicate nullifiers are rejected — same proof cannot be reused.

🔗ChainId binding

Every proof embeds a chain-specific chainId derived from the network passphrase. Testnet proofs are invalid on Mainnet.

⚛Atomic 95/5 split

The contract atomically splits every payment. No single party controls the split logic after deployment.

What Is Private vs Public

DataDescriptionVisibility
raw secret64-char hex credential — browser memory onlyprivate
passwordPBKDF2 input — never stored or transmittedprivate
ZK witnessMerkle path + circuit inputs — local computation onlyprivate
commitmentPoseidon(LEAF_TAG, secret) — sent to Merkle backend onlyprivate
nullifierPoseidon(NULLIFIER_TAG, secret, nonce) — stored on-chainon-chain
merkleRootPoseidon tree root — stored on-chainon-chain
recipientHashBN254-safe Stellar address hash — public signalon-chain
chainIdNetwork passphrase hash — public signalon-chain
txHashStellar transaction hash — public ledgerpublic
merchant addressStellar G-address of merchant — publicpublic
payment amountAmount in stroops — visible in contract eventpublic

Credential Storage

// Browser credential storage stack
secret → never stored in plaintext anywhere
password + salt → PBKDF2-SHA256 (100k iter dev / 600k prod) → AES-256-GCM key
AES-256-GCM(secret, key, iv) → ciphertext in IndexedDB
// IndexedDB schema — nothing sensitive in plaintext
DB: fluppy-identity-v1 | store: credentials | key: zk-credential
{ version, kdf, iterations, salt(hex), iv(hex), ciphertext(hex) }
ℹ
The iteration count is stored inside each credential blob. This allows safe migration of iteration parameters in future SDK versions without breaking existing credentials.

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:

chainId = SHA256("Test SDF Network ; September 2015")[MSB=0]
// Testnet and Mainnet produce different values
contract validates: proof.chainId === expected_chain_id(env)
ℹ
A proof generated on Testnet will always fail on Mainnet (and vice versa) because the chainId differs. This prevents cross-network proof replay attacks.

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

LimitationMitigationPlanned Resolution
Single-contributor trusted setupTestnet only — no real fundsMulti-party ceremony before mainnet
Demo-mode on-chain verifierClient-side snarkjs.verify() enforcedNative BN254 when SDK supports it
No external security auditComprehensive internal test coverageSCF Soroban Audit Bank after MVP
No production relayerUser-signed Freighter (transparent)Optional future relayer layer
Testnet deployment onlyNo real value at riskAfter audit + ceremony + native verifier