Version:

What is Keychain Core?

Ever tried to implement secure peer-to-peer communication only to get tangled in certificate management? Or built an offline-first app that falls apart when your auth server is unreachable? Maybe you’ve watched your elegantly designed system become a mess of OAuth flows, API keys, and trust assumptions.

Keychain Core solves these problems by giving you cryptographic superpowers through a simple API. Think of it as libsodium meets a distributed systems toolkit - except the hard parts are already solved.

Here’s What You Actually Get

Six capabilities that compose into something powerful:

1. Digital Identity That Actually Works

Forget managing certificates, keys, or identity providers. A persona in Keychain Core is a self-contained cryptographic identity:

# This creates an actual cryptographic identity, not just a database row
persona = gateway.create_persona("trading-bot", "prod", SecurityLevel.MAXIMUM)

# The keys are in hardware. Not in memory. Not in a file. Hardware.
# Even if someone dumps your process memory, they get nothing.

The twist? These identities work peer-to-peer. No phoning home to an auth server. No certificate chains to validate. Just pure cryptographic proof.

2. Data Security That Travels

Most encryption is transport-focused (TLS) or storage-focused (disk encryption). Keychain Core does something different:

# Encrypt data that remains secure everywhere
encrypted = persona.encrypt(sensitive_data, recipients=[alice, bob])

# This data is now secure:
# - In your Redis cache
# - In your message queue
# - In your database
# - On Bob's laptop
# - Even in your logs (if you're that careless)

The encryption travels with the data. Store it anywhere. Send it through any channel. It’s always protected.

3. Verifiable Everything

Digital signatures are old news. What’s new is making them so easy you’ll actually use them everywhere:

# Every operation can be verified
audit_entry = persona.sign({
    "action": "DELETE_USER",
    "target": user_id,
    "timestamp": time.now(),
    "reason": "GDPR request"
})

# Later, anyone can prove:
# - WHO performed this action
# - WHEN it happened
# - WHAT was done
# - That it hasn't been tampered with
verified = gateway.verify(audit_entry)  # No network calls

This isn’t just for audit logs. Sign API calls. Sign state transitions. Sign sensor readings. If it matters, sign it.

4. Consensus Without Servers

Here’s where it gets interesting. Keychain Core includes primitives for building distributed consensus:

# Multiple nodes agree on state without a central coordinator
proposal = persona.create_proposal(new_state)
signatures = []

for node in peer_nodes:
    if node.verify_proposal(proposal):
        signatures.append(node.sign_approval(proposal))

# With enough signatures, the state change is authoritative
# No Raft. No Paxos. Just cryptographic agreement.

This enables peer-to-peer coordination patterns that normally require complex distributed systems infrastructure.

5. Automatic Key Rotation (The "Keychain" Part)

Here’s why it’s called Keychain Core - it manages your keys like a keychain, automatically:

# You create a persona once
persona = gateway.create_persona("api-service", "prod", SecurityLevel.HIGH)

# Behind the scenes, Keychain Core:
# - Generates new keys periodically
# - Maintains a chain of valid keys
# - Transparently uses the right key for decryption
# - Retires old keys according to policy

# Years later, this still works:
old_encrypted_data = load_from_2021()
decrypted = persona.decrypt(old_encrypted_data)  # Just works

No manual key rotation. No "key rotation day" disasters. No expired keys breaking production at 3am. The keychain handles it all.

6. Composable Cryptographic Operations

Most crypto libraries make you choose: encrypt OR sign. Keychain Core lets you compose operations like LEGO blocks:

# Sign, then encrypt (hide who signed it)
classified_report = SerializedData(secret_data)
signed = analyst.sign(classified_report)
encrypted = analyst.encrypt(signed, recipients=[commander])

# Or encrypt, then sign (prove who sent the encrypted data)
encrypted = analyst.encrypt(classified_report, recipients=[commander])
signed_envelope = analyst.sign(encrypted)

# Or go wild - multi-party signatures with encryption
doc = SerializedData(contract_terms)
alice_signed = alice.sign(doc)
bob_signed = bob.sign(alice_signed)
encrypted = bob.encrypt(bob_signed, recipients=[alice, charlie])

# Embed it all in a verifiable credential
credential = gateway.create_credential(
    claims={"contract": encrypted, "parties": ["alice", "bob", "charlie"]},
    issuer=notary
)

Stack operations however your application needs. The cryptography composes cleanly without footguns.

The Magic: It Works Offline

Everything above works without network access. Let that sink in.

Your authentication works offline. Your encryption works offline. Your signatures work offline. Even your consensus mechanisms work offline (with eventual consistency when you reconnect).

This is possible because Keychain Core uses a decentralized PKI. There’s no central authority to check with. No certificates to validate online. No OCSP responders to timeout. The cryptographic proofs are self-contained.

Real Problems This Solves

Let’s get specific about when you’d reach for this:

Building for Unreliable Networks

Your app serves users in rural areas with spotty connectivity? Or maybe it’s for maritime/aviation where internet is expensive and slow? Traditional auth systems fail hard here. Keychain Core doesn’t even notice.

Regulatory Compliance Without the Pain

Need to prove who did what and when for compliance? Every operation in Keychain Core is cryptographically signed and timestamped. Your audit trail isn’t just tamper-evident - it’s cryptographically guaranteed.

# This is legally stronger than any database log
transaction = persona.sign({
    "type": "MEDICAL_RECORD_ACCESS",
    "patient_id": patient.id,
    "accessed_fields": ["diagnosis", "prescription"],
    "purpose": "treatment",
    "timestamp": datetime.utcnow()
}, approval=True)  # approval=True for non-repudiation

Multi-Party Computation

Building a system where multiple parties need to agree but don’t trust each other? (Think supply chain, financial settlements, or federated learning.) Traditional approaches require a trusted coordinator. With Keychain Core:

# Each party independently verifies and signs
if verify_business_rules(transaction):
    my_signature = persona.sign(transaction)
    broadcast_to_peers(my_signature)

# With threshold signatures, transaction proceeds
# No trusted third party needed

IoT and Edge Computing

Deploying to devices that can’t always phone home? Traditional PKI falls apart when devices can’t reach the CA. Keychain Core’s personas work from day one, no infrastructure required. Core fits on resource-constrained devices too with as little as 32 MB of RAM.

What About the Crypto?

You’re probably wondering what’s under the hood. Here’s the short version:

  • Symmetric Encryption: AES-GCM (128/192/256-bit) or Camellia-GCM for those who distrust NIST

  • Asymmetric Encryption: ECIES-ECP (up to P-521), RSA-OAEP-SHA (up to 4096-bit), or DLIES

  • Digital Signatures: ECDSA-ECP (P-256 default), ECGDSA for European compliance, DSA, or RSA-SS

  • Key Exchange: X25519 (Curve25519) for modern apps, or classic ECDH

  • Key Derivation: Argon2id (not PBKDF2, because it’s 2024)

  • Hardware Security: Platform-specific (Secure Enclave on iOS, Android Keystore, TPM on Windows, etc.)

But here’s the thing - you don’t have to care. The API is the same whether you’re using a YubiKey or Apple’s Secure Enclave. The cryptography is upgradeable without changing your code.

Compared to What You Know

vs. JWT/OAuth: JWTs are just signed JSON. OAuth is a protocol, not a security primitive. Keychain Core gives you the building blocks to implement these patterns and more including binary data, without the typical vulnerabilities.

vs. libsodium: libsodium gives you crypto primitives. Keychain Core gives you a distributed systems toolkit built on crypto primitives. It’s a higher level of abstraction.

vs. HSMs: Hardware Security Modules are powerful but painful. Keychain Core gives you the security benefits of HSMs through platform-native secure elements, with crypto agility.

vs. Blockchain: Blockchains are distributed ledgers. Keychain Core is distributed identity and security. You can build blockchain-like systems with it, but without the energy waste and performance penalties.

The Catch (There’s Always a Catch)

Keychain Core isn’t magic. Here’s what it doesn’t do:

  1. It’s not a database - You still need to store your application data somewhere

  2. It’s not a network protocol - You still need to move bytes between systems

  3. It’s not a silver bullet - Cryptography is hard. Keychain Core makes it easier, but you still need to understand your threat model.

Show Me the Code

Here’s a complete example that demonstrates the power - a secure document workflow that works offline:

from keychain_python import Gateway, SecurityLevel, SerializedData

# Initialize
gateway = Gateway(Gateway.init("~/.keychain/config.json"))

# Create identities for a law firm
lawyer = gateway.create_persona("counsel", "production", SecurityLevel.MAXIMUM)
client = gateway.create_persona("client", "production", SecurityLevel.HIGH)

# Client encrypts sensitive documents for lawyer
confidential_doc = SerializedData("Privileged attorney-client communication...")
encrypted_doc = client.encrypt(confidential_doc, recipients=[lawyer])

# Document can be stored anywhere - it's encrypted
save_to_untrusted_storage(encrypted_doc)

# Later, lawyer retrieves and signs
retrieved = load_from_storage(doc_id)
decrypted = lawyer.decrypt(retrieved)

# Lawyer signs their advice
legal_advice = SerializedData("Based on review, I recommend...")
signed_advice = lawyer.sign(legal_advice, approval=True)

# Client can verify the advice came from their lawyer
if gateway.verify(signed_advice):
    print("Verified: Advice is authentic and unmodified")

# This entire flow works offline. No auth servers, no CAs, no blockchain.

Why Engineers Choose Keychain Core

It’s not about the features. It’s about what those features enable:

You can build systems that don’t break

When AWS us-east-1 goes down, your auth still works. When your certificate expires at 3am, your system keeps running. When nation-state actors compromise a CA, your security isn’t affected.

You can sleep at night

Every sensitive operation is cryptographically logged. Every access is provable. Every action is attributable. When the auditors come knocking, you have mathematical proof, not just database logs.

You can innovate freely

Want to build peer-to-peer systems? Offline-first apps? Decentralized protocols? Systems that work across air gaps? Keychain Core gives you the primitives. You provide the imagination.

Getting Started

pip install keychain-python
# or: cargo add keychain-core
# or: npm install @keychain/core

Then:

from keychain_python import Gateway, SecurityLevel

gateway = Gateway(Gateway.init())
persona = gateway.create_persona("my-app", "dev", SecurityLevel.HIGH)

# You now have cryptographic superpowers. Use them wisely.

The future of software is distributed, offline-capable, and cryptographically secure. Keychain Core gets you there without a PhD in cryptography or distributed systems.

Ready to build something that actually works when the internet doesn’t?