AlgoChat Protocol

End-to-end encrypted messaging protocol for Algorand


Project maintained by CorvidLabs Hosted on GitHub Pages — Theme by mattgraham

Security Considerations

Threat Model

What AlgoChat Protects Against

  1. Message Content Disclosure - Only sender and recipient can decrypt messages
  2. Message Tampering - Authenticated encryption detects modifications
  3. Replay Attacks - Blockchain transaction uniqueness prevents replays

What AlgoChat Does NOT Protect Against

  1. Metadata Analysis - Sender/recipient addresses, timing, and message sizes are visible
  2. Endpoint Compromise - Malware on user devices can access decrypted messages
  3. Key Compromise - Past and future messages to a compromised key are readable; exposure is retroactive and permanent (PSK mode additionally requires the PSK)
  4. Past Message Exposure - No forward secrecy: compromise of a long-term private key (or the recovery phrase that derives it) retroactively exposes that account’s base-mode history; PSK-mode decryption additionally requires the PSK (see Forward Secrecy – Not Provided)
  5. Traffic Analysis - Transaction patterns may reveal communication patterns
  6. Algorand Network Attacks - Protocol relies on blockchain security
  7. Quantum Attacks on Key Exchange - X25519 is vulnerable to quantum computers. With PSK mode (0x02), an attacker must also compromise the pre-shared key, providing defense-in-depth. See PSK Security Properties below. A Falcon-1024 account does not close this gap: it protects who can authorize the payment, not the X25519 handshake inside the note.
  8. Quantum Attacks on Ed25519 Identity - A sufficiently large quantum computer can recover an Ed25519 private key from the public key encoded in a classical Algorand address. Native Falcon-1024 accounts (pqsig) resist that attack. They are optional in v1.2. Importing a 25-word phrase without an explicit Falcon scheme MUST keep the Ed25519 address so existing wallets do not silently move.

Cryptographic Guarantees

Confidentiality

Integrity

Forward Secrecy Not Provided

AlgoChat does not provide forward secrecy. Each message uses a fresh ephemeral key pair, which separates per-message symmetric keys, but:

Ephemeral private keys are never stored, which limits endpoint exposure, but this is not forward secrecy. In PSK mode (0x02) an attacker needs the PSK as well – a meaningful additional barrier, but the PSK is static and every position key is a deterministic function of it.

Implication for users: a recovery phrase exposes the complete, permanent base-mode message history of that account; PSK-mode history additionally requires the PSK. It must be protected accordingly.

See PROTOCOL.md §11.1 for the full analysis.

Key Management

Key Derivation

Key Storage

Implementations should:

Memory Clearing

Sensitive data (private keys, symmetric keys, plaintext, PSK material, derived session/position PSKs) must be cleared from memory after use. Standard deallocation does not guarantee memory is zeroed.

Language-specific guidance:

Language Recommended Approach
C/C++ sodium_memzero() (libsodium) or explicit_bzero()
Rust zeroize crate with Zeroizing<T> wrapper
Swift Data.resetBytes(in:) or SecureBytes patterns
TypeScript/JS Overwrite buffer contents, then discard reference
Python ctypes.memset() or secrets module patterns
Kotlin/Java Overwrite ByteArray contents before GC
Go crypto/subtle.ConstantTimeCopy to zero, or memguard

Important: Garbage-collected languages cannot guarantee immediate clearing. Use native bindings (e.g., libsodium wrappers) for maximum security.

Key Discovery

PSK Key Management

When using PSK mode (0x02):

PSK Security Properties

Hybrid Key Derivation

PSK mode (0x02) derives symmetric keys from the concatenation of the X25519 shared secret and the ratcheted PSK: IKM = shared_secret || current_psk. This means:

This is a defense-in-depth strategy, not a replacement for post-quantum cryptography. When standardized PQ algorithms become available, they should replace X25519 directly.

Session Key Separation

The ratchet mechanism bounds exposure within sessions, but provides no forward secrecy:

Note: The PSK ratchet adds breadth limitation only. Every position key is a deterministic function of the initial_psk – nothing is advanced-and-destroyed – so this is a key schedule, not a ratchet in the Signal sense, and it does not provide forward secrecy.

PSK Threat Matrix

Threat No PSK (0x01) Ratcheting PSK (0x02)
Classical key exchange attack Vulnerable Protected (requires PSK)
Quantum key exchange attack Vulnerable Protected (requires PSK)
Long-term key compromise (future msgs) Vulnerable Protected (requires PSK)
Long-term key compromise (past msgs) Vulnerable (retroactive, permanent) Protected (requires PSK as well)
PSK compromise only N/A Protected (X25519 still required)
Both X25519 + PSK compromised N/A Vulnerable
Endpoint compromise Vulnerable Vulnerable
Metadata analysis Visible Visible

PSK Known Limitations

Known Limitations

Message Size

Deniability

Group Messaging

Recommendations

For Implementers

  1. Use audited cryptographic libraries (libsodium, @noble/ciphers, CryptoKit, etc.)
  2. Implement constant-time operations where applicable:
    • Authentication tag comparison (use crypto_verify_* or timingSafeEqual)
    • Key comparison operations
    • Any branching on secret data
  3. Validate all inputs before processing
  4. Handle errors without leaking information (same error response for all auth failures)
  5. Clear sensitive data from memory (see Memory Clearing section above)
  6. Use secure random number generators (/dev/urandom, SecRandomCopyBytes, crypto.getRandomValues)
  7. (PSK) Validate ratchet counters against the acceptance window before attempting decryption
  8. (PSK) Persist counter state reliably – loss of counter state degrades replay protection
  9. (PSK) Set a reasonable counter window (recommended: 200) to balance out-of-order tolerance with replay resistance
  10. (PSK) Provide clear UI indicators distinguishing PSK-protected conversations from standard ones

For Users

  1. Protect your Algorand mnemonic
  2. Use devices you trust
  3. Verify recipient addresses carefully
  4. Be aware of metadata exposure
  5. Report suspicious behavior
  6. (PSK) Exchange PSKs in person when possible – the security of PSK mode depends entirely on the secrecy of the initial PSK
  7. (PSK) Verify the PSK fingerprint (e.g., first 8 hex characters) with your contact after exchange
  8. (PSK) Understand that PSK mode is defense-in-depth – it strengthens security but does not replace the need for device security and mnemonic protection

Reporting Vulnerabilities

Do NOT report security vulnerabilities as public GitHub issues.

GitHub Security Advisory (preferred): Report a vulnerability

Include:

We aim to acknowledge reports within 48 hours and provide an initial assessment within 7 days. We will coordinate disclosure timing with you.