Skip to content

Cryptographic Reference

This page is a quick-reference table of every cryptographic algorithm, key size, and library used in Relay. It is intended for security auditors, contributors, and anyone who wants to verify the crypto stack at a glance.


Algorithm Table

OperationAlgorithmKey / Output SizeLibraryNotes
Seed generationBIP39128-bit entropy, 12 words@scure/bip39English wordlist, PBKDF2-SHA512 to seed
HD key derivationSLIP-0010 (Ed25519)256-bit keys@noble/hashes (HMAC-SHA512)Hardened derivation only
Auth signingEd25519256-bit private, 256-bit publictweetnacl (server), @noble/curves (client)Challenge-response login
Transaction signingEd25519256-bit private, 256-bit publictweetnacl (via @solana/web3.js)Solana transactions
DH key agreementX25519256-bit shared secret@noble/curvesSignal Protocol X3DH
Identity signingEd25519256-bit keys@noble/curvesSignal Protocol identity + pre-key signing
Ed25519 to X25519Birational map256-bit@noble/curvesedwardsToMontgomery / toMontgomerySecret
Key derivation (Signal)HKDF-SHA256Variable output@noble/hashesRoot key, chain key, message key derivation
Message encryptionAES-256-CBC + HMAC-SHA256256-bit AES, 256-bit HMAC@noble/ciphers + @noble/hashesSignal Protocol messages
Storage encryptionAES-256-GCM256-bit key, 96-bit IV@noble/ciphersEncryptedStorage wrapper
Backup encryptionAES-256-GCM256-bit key, 96-bit IV@noble/ciphersRelay backup files
Backup KDFArgon2id256-bit outputhash-wasm3 iterations, 64 MB memory, parallelism 1
PIN hashingPBKDF2-SHA256256-bit output@noble/hashes (HMAC-SHA256)10,000 iterations, 128-bit random salt
Password hashing (legacy)PBKDF2-SHA256256-bit output@noble/hashes600,000 iterations (v1, auto-migrated)
Random bytesCSPRNGVariable@noble/ciphers (randomBytes)OS-provided entropy

Library Versions

All cryptographic libraries are from the @noble and @scure families by Paul Miller. These are:

  • Pure JavaScript — no native C/Rust bindings, fully compatible with React Native and Hermes.
  • Audited — independently security-audited.
  • Widely used — trusted by Ethereum, Solana, and other blockchain ecosystems.
LibraryPurpose
@noble/curvesEd25519, X25519, birational map
@noble/hashesSHA-256, SHA-512, HMAC, HKDF, PBKDF2
@noble/ciphersAES-256-CBC, AES-256-GCM, randomBytes
@scure/bip39BIP39 mnemonic generation and validation
tweetnaclEd25519 signing (server-side)
hash-wasmArgon2id (backup encryption)

Key Sizes and Formats

Key TypeSizeEncodingStorage
BIP39 mnemonic12 words (128-bit entropy + 4-bit checksum)English wordsKeychain (biometric-gated)
Ed25519 private key32 bytes (256 bits)Base58 (Solana format)Keychain (biometric-gated)
Ed25519 public key32 bytes (256 bits)Base58 (Solana format)Keychain (no biometric)
X25519 private key32 bytes (256 bits)Base64EncryptedStorage
X25519 public key32 bytes (256 bits)Base64Server (pre-key bundles)
AES-256 key32 bytes (256 bits)Raw bytesDerived (HKDF), never stored directly
HMAC-SHA256 key32 bytes (256 bits)Raw bytesDerived (HKDF), never stored directly
AES-GCM IV12 bytes (96 bits)Raw bytesPrepended to ciphertext
AES-CBC IV16 bytes (128 bits)Raw bytesDerived from message key via HKDF
Argon2id salt16 bytes (128 bits)Raw bytesStored in backup file header
PBKDF2 salt16 bytes (128 bits)HexStored in PIN hash string

Security Properties

PropertyHow Relay Achieves It
Forward secrecyDouble Ratchet generates a new DH key pair per conversation turn. Compromising a current key cannot decrypt past messages.
Post-compromise securityNew DH ratchet steps re-establish security after a key compromise.
Replay protectionMessage counters in ratchet headers prevent replay.
Tampering detectionHMAC-SHA256 (Signal messages) and GCM auth tags (storage/backups) detect any modification.
Timing attack resistanceConstant-time comparison for PIN verification and HMAC verification.
Key separationWallet and auth keys derived from the same seed but at different SLIP-0010 paths — cryptographically independent.
Key erasurePrivate key bytes zeroed in memory immediately after use.
Brute-force resistanceArgon2id (backups) and PBKDF2 (PIN) impose computational cost on each guess.

Standards and Specifications

StandardWhere UsedReferenceNotes
BIP-39Mnemonic seed generationBIP-0039Industry-wide standard (not Bitcoin-specific)
BIP-44Derivation path formatBIP-0044Path convention adopted by all chains
SLIP-0010Ed25519 HD key derivationSLIP-0010Replaces BIP-32 for Ed25519 curves (Solana)
SLIP-0044Coin type 501 (Solana)SLIP-0044Chain identifier registry
X3DHKey agreement protocolSignal X3DH Spec
Double RatchetMessage encryption protocolSignal Double Ratchet Spec
RFC 5869HKDF key derivationRFC 5869
RFC 8439ChaCha20-Poly1305 / AES-GCMRFC 8439
RFC 9106Argon2 password hashingRFC 9106
NIST SP 800-132PBKDF2NIST SP 800-132

Built with conviction.