Home Protocol Security Whitepaper API Reference ghostpaymesh.com

Security Model

A comprehensive overview of GhostPay Mesh’s security architecture, cryptographic foundations, and privacy guarantees.

1. Threat Model

GhostPay Mesh is designed to operate securely in adversarial environments where devices may be compromised, communication channels may be monitored, and parties may be malicious. The security model addresses the following threat categories:

🔒 Double Spending

An attacker attempts to redeem the same PLC multiple times, either through chain forking or parallel settlement requests.

🔒 Replay Attacks

An attacker captures a valid transfer and re-broadcasts it to steal funds or confuse the transaction history.

🔒 Man-in-the-Middle

An attacker intercepts BLE/NFC communication between devices during an offline transfer to modify or steal PLC data.

🔒 Key Extraction

An attacker with physical access to a device attempts to extract the private key from secure storage.

🔒 Forgery

An attacker attempts to create counterfeit PLCs or forge transfer signatures without possessing the correct private key.

🔒 Timing Attacks

An attacker manipulates device clocks to extend expired PLCs or bypass time-based security constraints.

Trust Assumptions

2. Cryptographic Primitives

GhostPay Mesh uses a carefully selected set of modern, well-audited cryptographic primitives. No custom or novel cryptography is employed.

Primitive Algorithm Purpose Security Level
Digital Signatures Ed25519 PLC signing, transfer authorization, identity verification ~128-bit
Symmetric Encryption XChaCha20-Poly1305 Encrypting PLC payloads during BLE/NFC transport 256-bit
Hashing SHA-256 Commitment hashes, transfer chain integrity 128-bit collision
Key Derivation Argon2id Deriving encryption keys from user PINs for local key protection Memory-hard
Random Generation CSPRNG Nonces, UUIDs, key generation OS-level entropy

Why Ed25519?

Ed25519 was chosen for digital signatures for several reasons critical to the offline-first use case:

Why XChaCha20-Poly1305?

XChaCha20-Poly1305 provides authenticated encryption for PLC payloads during transport:

3. Device-Bound Keys

Every GhostPay Mesh device generates a unique Ed25519 keypair during initial setup. This keypair is the device’s identity and is never transmitted, exported, or backed up.

Key Generation

Key Generation Flow
// 1. Generate 32 bytes of entropy from OS CSPRNG
seed = CSPRNG(32)

// 2. Derive Ed25519 keypair
(private_key, public_key) = Ed25519.generate(seed)

// 3. User sets a 6-digit PIN
pin_hash = Argon2id(pin, salt, t=3, m=65536, p=4)

// 4. Encrypt private key with PIN-derived key
encrypted_key = XChaCha20Poly1305.encrypt(
  key: pin_hash,
  nonce: CSPRNG(24),
  plaintext: private_key
)

// 5. Store encrypted_key in device Secure Enclave / Keystore
SecureStorage.store("ghostpay_key", encrypted_key)

Key Storage

Key Loss: If a device is lost or destroyed, the associated keys are irrecoverable. Any PLCs issued by or held by that device must be settled through the dispute resolution process. This is by design — key recovery mechanisms would introduce an attack vector.

4. Transfer Security

Offline PLC transfers are protected by a multi-layer security architecture that ensures integrity, authenticity, and confidentiality during transmission.

Transport Encryption

All PLC data transmitted via BLE or NFC is encrypted using XChaCha20-Poly1305 with an ephemeral shared key established through X25519 Diffie-Hellman key exchange.

Ephemeral Key Exchange
// Sender and Receiver perform X25519 ECDH
sender_ephemeral = X25519.generate()
receiver_ephemeral = X25519.generate()

shared_secret = X25519.exchange(
  sender_ephemeral.private,
  receiver_ephemeral.public
)

// Derive transport key via HKDF
transport_key = HKDF-SHA256(
  ikm: shared_secret,
  salt: "ghostpay-transfer-v2",
  info: sender_pubkey || receiver_pubkey,
  len: 32
)

Signature Chain Verification

Each transfer in the chain is cryptographically linked to the previous transfer, creating an auditable, tamper-proof history:

  1. The sender creates a transfer record containing: to_pubkey, timestamp, nonce, and previous_hash.
  2. The sender signs this record with their private key.
  3. The receiver verifies the signature using the sender’s public key.
  4. The receiver verifies previous_hash matches the hash of the last entry in transfer_chain.
  5. If verification passes, the new transfer record is appended to the chain.

5. Anti-Fraud

While the protocol provides strong cryptographic guarantees, the settlement layer adds behavioral analysis and heuristic checks to detect fraud patterns that cryptography alone cannot prevent.

Backend Monitoring

Velocity Checks

Check Limit Window
Max PLC value R$ 1,000.00 Per PLC
Max daily issuance R$ 5,000.00 24 hours
Max daily settlements R$ 10,000.00 24 hours
Max transfer hops 10 Per PLC
Max concurrent PLCs 50 Per device

Amount Limits

PLC amounts are bounded to reduce systemic risk. Limits are tiered based on device reputation:

6. Privacy by Design

GhostPay Mesh is architected with privacy as a foundational principle, not an afterthought. The protocol minimizes data collection to the absolute minimum required for operation.

Zero Personal Data

Data Minimization

The settlement backend stores only the minimum data required to prevent double-spending:

The backend does not store:

Right to Erasure: Since the backend stores only cryptographic hashes and transaction IDs, there is no personal data to erase. The protocol is GDPR-compatible by architecture.

7. Compliance

GhostPay Mesh is designed to be compatible with existing financial regulations while preserving privacy and decentralization.

BACEN Compatibility

The protocol is compatible with the Brazilian Central Bank (BACEN) regulatory framework:

AML Integration

Anti-Money Laundering (AML) measures are integrated at the settlement layer:

Regulatory Approach

GhostPay Mesh follows a “compliance at the edges” approach: the core protocol remains privacy-preserving and decentralized, while settlement providers (the “edges” where value enters and exits the system) implement regulatory requirements. This allows the protocol to adapt to different jurisdictions without modifying the core PLC specification.