🧱
🧱 Building with the Larz Stack · STK-101 · Session 4 of 8

Security & Identity — Crypto You Can Trust

Security code is where 'roll your own' is scariest — so this family sticks to standard, RFC-verified algorithms, tested against the official vectors, with no dependencies to compromise.

⏱ 9 min read📅 Updated 2026-07-26📊 Tables, charts & examples

Cryptography is the one place where writing your own is genuinely dangerous — subtle mistakes are invisible and catastrophic. The Larz Stack's security family doesn't invent algorithms; it implements the standard ones correctly and proves it against the official RFC test vectors. You get hashing, encryption, secrets management, two-factor auth and identity — all pure Python, all checkable.

The security family

Each library covers a distinct security job, and each is tested against published vectors.

LibraryWhat it does
larzcryptHashes/HMAC, KDFs (PBKDF2/scrypt/HKDF), ChaCha20-Poly1305, X25519, Ed25519, JWT
larzvaultEncrypted secrets store (scrypt master key + authenticated encryption)
larztotpTOTP/HOTP two-factor auth + provisioning URIs (RFC 6238/4226)
larzqrQR codes from scratch (Reed-Solomon ECC) — turn a 2FA URI into a scannable code
larzidSelf-certifying DIDs + verifiable credentials (Ed25519)

The theme: standard algorithms, verified. larzcrypt matches RFC 8439/7748/8032; larztotp matches RFC 6238; larzqr matches the QR spec's own test vectors.

Correctness you can verify

The reason to trust these isn't a promise — it's that they reproduce the official answers. For example, larztotp generates the exact codes from the RFC's test table, and pairs with larzqr for enrollment.

from larztotp import TOTP
from larzqr import QR

totp = TOTP("JBSWY3DPEHPK3PXP")
totp.now()                       # 6-digit code, matches any authenticator app

uri = totp.provisioning_uri("alice", issuer="MyApp")
QR(uri).to_svg("enroll.svg")     # scannable enrollment QR, no image library
⚠️
Standard, but not a silver bullet. These libraries are correct implementations of well-reviewed algorithms — but security is bigger than crypto. The libraries are honest that they aren't hardened against every side-channel like a C library such as libsodium. Use them for the right threat model: correct, portable crypto for ordinary applications, not nation-state-resistant hardening.

Identity without a central authority

larzid builds on larzcrypt to give each user a self-certifying identity — a DID whose public key is its name — and verifiable credentials that anyone can check offline.

ConceptWhat it means
DID (did:larz:...)An identity you control, no central registry
Sign / verifyProve a message came from that identity
Verifiable credentialA claim others can verify offline, with expiry
Tamper / forgery detectionAny change or fake fails verification

This is the toolkit behind decentralised identity — useful for signed tokens, offline-verifiable passes, and the identity layer of blockchain apps like LarzChain.

🎯 Key takeaways

  • The security family: larzcrypt (crypto toolkit), larzvault (secrets), larztotp (2FA), larzqr (QR), larzid (identity).
  • It implements standard, RFC-verified algorithms — not home-grown crypto — and proves it against official vectors.
  • larztotp + larzqr give you authenticator-app 2FA and scannable enrollment with no image library.
  • The libraries are honest about their threat model: correct portable crypto, not side-channel-hardened like libsodium.

Frequently asked

Isn't 'rolling your own crypto' the classic mistake?

Inventing your own algorithm is the mistake. Implementing a standard, well-reviewed algorithm — and verifying it against the official test vectors — is how every crypto library is built. larzcrypt does exactly the latter: it's AES, ChaCha20-Poly1305, Ed25519 and friends, matching the RFC answers exactly. It's also honest that it isn't side-channel-hardened, so you can match it to the right use.

What's a self-certifying identity (DID)?

It's an identity whose name is derived from its own public key, so no central authority is needed to vouch for it — the identity certifies itself. You can sign messages as that identity and issue credentials others verify offline. larzid implements this on Ed25519, which is the foundation for decentralised identity and for signed, verifiable tokens in blockchain systems.

Session 4 of 8 complete

Next up: Web, AI & Dev Tooling — the Everyday Kit

Continue to Session 5 →

Related lessons

More in this course

Course home → · Browse all courses →