<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: DiaryVault</title>
    <description>The latest articles on DEV Community by DiaryVault (@diaryvault).</description>
    <link>https://dev.to/diaryvault</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3759172%2Fd5a83bd6-4446-4a60-a916-848159ed0e60.png</url>
      <title>DEV Community: DiaryVault</title>
      <link>https://dev.to/diaryvault</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/diaryvault"/>
    <language>en</language>
    <item>
      <title>I built a cryptographic memory layer for humans in Python tags: python, opensource, security, blockchain</title>
      <dc:creator>DiaryVault</dc:creator>
      <pubDate>Sat, 07 Feb 2026 22:43:51 +0000</pubDate>
      <link>https://dev.to/diaryvault/i-built-a-cryptographic-memory-layer-for-humans-in-python-tags-python-opensource-security-20jo</link>
      <guid>https://dev.to/diaryvault/i-built-a-cryptographic-memory-layer-for-humans-in-python-tags-python-opensource-security-20jo</guid>
      <description>&lt;p&gt;Planes have black boxes. Cars have dash cams. Companies have audit logs.&lt;br&gt;
Humans have... memory. And memory is terrible.&lt;br&gt;
You forget 70% of new information within 24 hours. Meanwhile, AI can now generate fake photos, voices, and text indistinguishable from reality. So I asked myself: what if there was a way to create a tamper-proof, encrypted, verifiable record of your life?&lt;br&gt;
I built it over a weekend and open sourced it. Here's how.&lt;br&gt;
What it does&lt;br&gt;
DiaryVault Memory Layer is a Python SDK that turns any text — journal entries, notes, decisions, thoughts — into cryptographically verified, encrypted, permanent memory records.&lt;br&gt;
You write → SHA-256 hashed → AES-256 encrypted → HMAC signed → optionally anchored on-chain&lt;br&gt;
Five lines to get started:&lt;br&gt;
pythonfrom diaryvault_memory import MemoryVault&lt;/p&gt;

&lt;p&gt;vault = MemoryVault(encryption_key="your-secret-key")&lt;br&gt;
memory = vault.create(&lt;br&gt;
    content="Today I decided to start a company.",&lt;br&gt;
    tags=["career", "milestone"]&lt;br&gt;
)&lt;br&gt;
print(memory.hash)      # a7f3b2c1d4e5...&lt;br&gt;
print(memory.verified)  # True&lt;br&gt;
That's it. Your memory is now hashed, encrypted, signed, and stored.&lt;br&gt;
The architecture&lt;br&gt;
The system has four layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Capture Layer — Gets data in. Manual entries now, AI agents later.&lt;/li&gt;
&lt;li&gt;Synthesis Layer — AI enrichment. Summarization, pattern detection, emotional analysis. (Coming in v0.2)&lt;/li&gt;
&lt;li&gt;Verification Layer — The cryptographic core. This is where it gets interesting.&lt;/li&gt;
&lt;li&gt;Permanence Layer — Where verified hashes get anchored. Local storage, Arweave, Ethereum L2, or IPFS.
The crypto decisions I made (and why)
This was the part I spent the most time thinking about. Every choice here matters because if the crypto is wrong, the whole project is meaningless.
Key derivation: HKDF, not raw SHA-256
My first implementation derived encryption and signing keys by doing SHA-256(master_key + purpose). It worked, but it's not how serious cryptographic systems do it.
I switched to HKDF (RFC 5869), which is the industry standard used by TLS 1.3 and the Signal Protocol:
pythonfrom cryptography.hazmat.primitives.kdf.hkdf import HKDF
from cryptography.hazmat.primitives import hashes&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;def _derive_key(self, purpose: bytes) -&amp;gt; bytes:&lt;br&gt;
    hkdf = HKDF(&lt;br&gt;
        algorithm=hashes.SHA256(),&lt;br&gt;
        length=32,&lt;br&gt;
        salt=None,&lt;br&gt;
        info=purpose,&lt;br&gt;
    )&lt;br&gt;
    return hkdf.derive(self._master_key)&lt;br&gt;
Why does this matter? HKDF properly separates the "extract" and "expand" phases of key derivation, making it resistant to related-key attacks. Raw SHA-256 concatenation can leak information about the master key if an attacker sees multiple derived keys.&lt;br&gt;
Encryption: AES-256-GCM&lt;br&gt;
I chose AES-256-GCM over alternatives like ChaCha20-Poly1305 for one reason: ubiquity. AES-GCM is hardware-accelerated on virtually every modern CPU, it's NIST-approved, and every security auditor on earth knows how to review it.&lt;br&gt;
GCM mode is critical — it provides both confidentiality (nobody can read it) AND authenticity (nobody can tamper with it without detection). A unique 96-bit nonce per encryption prevents pattern analysis:&lt;br&gt;
pythondef encrypt(self, plaintext: str) -&amp;gt; tuple[bytes, bytes]:&lt;br&gt;
    from cryptography.hazmat.primitives.ciphers.aead import AESGCM&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nonce = os.urandom(12)
aesgcm = AESGCM(self._enc_key)
ciphertext = aesgcm.encrypt(nonce, plaintext.encode("utf-8"), None)
return ciphertext, nonce
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Signing: HMAC-SHA256&lt;br&gt;
Every memory hash gets signed with HMAC-SHA256. This proves that the holder of the key created the hash — not just that the hash exists.&lt;br&gt;
Batch verification: Merkle trees&lt;br&gt;
If you have 1,000 memories, you don't want to anchor 1,000 hashes on-chain. Merkle trees let you compute a single root hash that verifies the entire batch:&lt;br&gt;
         [Root Hash]        ← Anchor this ONE hash&lt;br&gt;
          /        \&lt;br&gt;
    [Hash AB]    [Hash CD]&lt;br&gt;
     /    \       /    \&lt;br&gt;
   [A]   [B]   [C]   [D]   ← Individual memories&lt;br&gt;
One hash on-chain. Thousands of memories verified. Cost: one transaction.&lt;br&gt;
Tamper detection in action&lt;br&gt;
This is my favorite part. If someone changes even one character, the verification fails:&lt;br&gt;
pythonmemory = vault.create(content="I said this.")&lt;br&gt;
vault.verify(memory)  # True&lt;/p&gt;

&lt;p&gt;memory.content = "I NEVER said this."&lt;br&gt;
vault.verify(memory)  # False — hash mismatch detected&lt;br&gt;
The SHA-256 hash acts as a fingerprint. Any modification, no matter how small, produces a completely different hash. Combined with the HMAC signature, you get proof of both content and authorship.&lt;br&gt;
The .dvmem open format&lt;br&gt;
I didn't want to lock anyone into a proprietary format. The .dvmem format is a documented JSON structure that any tool can read:&lt;br&gt;
json{&lt;br&gt;
  "dvmem_version": "1.0",&lt;br&gt;
  "encoding": "utf-8",&lt;br&gt;
  "payload": {&lt;br&gt;
    "id": "550e8400-...",&lt;br&gt;
    "content": "...",&lt;br&gt;
    "hash": "a1b2c3d4...",&lt;br&gt;
    "encrypted_content": "...",&lt;br&gt;
    "signature": "...",&lt;br&gt;
    "created_at": "2025-02-07T14:32:01+00:00",&lt;br&gt;
    "metadata": {&lt;br&gt;
      "tags": ["daily", "career"],&lt;br&gt;
      "mood": "optimistic",&lt;br&gt;
      "source": "manual"&lt;br&gt;
    }&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
Export your data anytime. No lock-in. If this project disappears tomorrow, your memories survive.&lt;br&gt;
What I learned shipping my first open source project&lt;br&gt;
A few things surprised me:&lt;br&gt;
The README matters more than the code. I spent as much time on the README as on the SDK itself. If someone can't understand your project in 30 seconds, they leave.&lt;br&gt;
pip install has to work. Sounds obvious, but I almost launched without publishing to PyPI. A developer who can't install your package in 5 seconds will never try it.&lt;br&gt;
CI signals legitimacy. Adding GitHub Actions with a green badge took 10 minutes but immediately made the project look more real.&lt;br&gt;
Start small. The SDK does one thing: hash, encrypt, verify, store. I had grand visions of AI agents, blockchain anchoring, and a mobile SDK. All of that is on the roadmap, but none of it is in v0.1. Ship the core, see if anyone cares, then build what people ask for.&lt;br&gt;
What's next&lt;br&gt;
The roadmap is public, but honestly it depends on what the community wants:&lt;/p&gt;

&lt;p&gt;AI capture agents (v0.2)&lt;br&gt;
Arweave and Ethereum L2 anchoring (v0.3)&lt;br&gt;
Photo and voice capture (v0.4)&lt;br&gt;
Dead man's switch for digital legacy (v0.5)&lt;br&gt;
Personal AI training export (v0.6)&lt;/p&gt;

&lt;p&gt;Try it&lt;br&gt;
bashpip install diaryvault-memory&lt;/p&gt;

&lt;p&gt;GitHub: github.com/DiaryVault/diaryvault-memory-layer&lt;br&gt;
Landing page: memory.diaryvault.com&lt;br&gt;
PyPI: pypi.org/project/diaryvault-memory&lt;/p&gt;

&lt;p&gt;MIT licensed. 28 tests passing. No VC. No tokens. Just a thing I think should exist.&lt;br&gt;
Stars and feedback welcome. Especially on the crypto — I'd love eyes from security folks on the implementation.&lt;/p&gt;

&lt;p&gt;I'm Stephen — I build AI products including DiaryVault and Crene. This is my first open source project. You can find me on Twitter and GitHub.&lt;/p&gt;

</description>
      <category>python</category>
      <category>opensource</category>
      <category>security</category>
      <category>blockchain</category>
    </item>
  </channel>
</rss>
