Skip to main content

Cryptographic Primitives

Single source of truth for all crypto used in b1e55ed.

Current Implementation (v2)

PurposePrimitiveLibraryNotes
Identity signingEd25519cryptographyEvent signing, karma intents
Key derivationArgon2id (19 MiB, 2 iter)argon2-cffiMemory-hard, GPU-resistant
At-rest encryptionAES-256-GCMcryptographyAuthenticated encryption
Hash chainSHA-256hashlibEvent integrity
Canonical serializationJSON (sorted keys, compact)jsonDeterministic hashing
Vanity grindingsecp256k1 + Keccak-256eth-accountForge identity

Legacy Support (v1 — read-only)

Purposev1 PrimitiveStatus
KDFPBKDF2-HMAC-SHA256 (480K iter)Read-only (for loading old identity files)
EncryptionFernet (AES-128-CBC + HMAC-SHA256)Read-only (for loading old vaults)
New writes always use v2. Old files are automatically readable.

Migration

  • b1e55ed identity migrate (planned): loads v1 identity, re-saves as v2
  • For now: re-saving any identity automatically upgrades to v2

Threat Model

ThreatMitigation
Local file compromiseAt-rest encryption (Fernet/AES-256-GCM)
Password brute forcePBKDF2 480K iter → Argon2id (memory-hard)
GPU attacks on KDFArgon2id (v2 target)
Key in memoryPython heap — no mlock yet. Planned for SEC1.
Swap/core dumpNot mitigated. Planned for SEC1.
Backup compromiseEncrypted at rest + password
Supply chainPinned dependencies (uv.lock)
Hash chain tamperingSHA-256 chain + signed genesis (FIX1)

Files

FileCrypto Used
engine/security/identity.pyPBKDF2, Fernet, Ed25519, HKDF
engine/security/keystore.pyPBKDF2, Fernet
engine/core/database.pySHA-256 (hash chain)
engine/core/models.pySHA-256 (event hash)
engine/integrations/forge.pysecp256k1, Keccak-256