<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Quantum Pulse]]></title><description><![CDATA[Quantum Pulse]]></description><link>https://quantum-pulse.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 11:05:48 GMT</lastBuildDate><atom:link href="https://quantum-pulse.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How I built a 39× compression pipeline with AES-256-GCM in Python (and why the dictionary is everything)]]></title><description><![CDATA[I store LLM training data. Every tool I found either compresses it or encrypts it — nothing did both. So I built QUANTUM-PULSE.

The pipeline
payload → MsgPack → Zstd-L22 + corpus dict → AES-256-GCM →]]></description><link>https://quantum-pulse.hashnode.dev/how-i-built-a-39-compression-pipeline-with-aes-256-gcm-in-python-and-why-the-dictionary-is-everything</link><guid isPermaLink="true">https://quantum-pulse.hashnode.dev/how-i-built-a-39-compression-pipeline-with-aes-256-gcm-in-python-and-why-the-dictionary-is-everything</guid><category><![CDATA[Python]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[Security]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[data-engineering]]></category><dc:creator><![CDATA[Naveen Badiger]]></dc:creator><pubDate>Sat, 07 Mar 2026 06:49:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69abc2190bca1a39767b95ad/76e06a8f-abb1-4c92-92ff-32aff0e0a0f4.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<pre><code class="language-markdown">I store LLM training data. Every tool I found either compresses it or encrypts it — nothing did both. So I built QUANTUM-PULSE.
</code></pre>
<h2>The pipeline</h2>
<pre><code class="language-plaintext">payload → MsgPack → Zstd-L22 + corpus dict → AES-256-GCM → SHA3-256 Merkle
</code></pre>
<h2>Step 1: MsgPack over JSON</h2>
<p>Before compression, MsgPack shrinks the payload by ~22%:</p>
<pre><code class="language-python">import msgpack
raw = msgpack.packb(payload, use_bin_type=True)
# 22% smaller than json.dumps().encode() — better input = better downstream ratio
</code></pre>
<h2>Step 2: The dictionary insight</h2>
<p>Standard Zstd builds a probability model from scratch every time. For training records sharing the same schema, this is wasted work.</p>
<p>Train once:</p>
<pre><code class="language-python">import zstandard as zstd

dict_data = zstd.train_dictionary(131072, corpus_samples[:200])
cctx = zstd.ZstdCompressor(level=22, dict_data=dict_data)
compressed = cctx.compress(raw)
</code></pre>
<p>Result: <strong>28.46× with dict vs 14.64× vanilla — +94.4% improvement, 29% faster.</strong> The dictionary retrains automatically every 24h via APScheduler as new data arrives.</p>
<h2>Step 3: AES-256-GCM with per-blob HKDF keys</h2>
<p>One passphrase → master key → unique key per blob:</p>
<pre><code class="language-python">from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
import os

# Unique key per blob — one compromise reveals nothing about others
blob_key = HKDF(
    algorithm=hashes.SHA256(), length=32,
    salt=blob_salt, info=pulse_id.encode()
).derive(master_key)

nonce = os.urandom(12)  # fresh per seal
ciphertext = AESGCM(blob_key).encrypt(nonce, compressed, None)
</code></pre>
<h2>Step 4: SHA3-256 Merkle tree</h2>
<p>Every unseal verifies a Merkle proof before returning any data. Silent corruption — bit rot, tampered storage, partial writes — is caught cryptographically, not by hoping checksums match.</p>
<h2>Benchmark results</h2>
<table>
<thead>
<tr>
<th>Algorithm</th>
<th>Ratio</th>
<th>Time</th>
<th>Enc</th>
<th>Integrity</th>
</tr>
</thead>
<tbody><tr>
<td>snappy</td>
<td>12×</td>
<td>1.3ms</td>
<td>✗</td>
<td>✗</td>
</tr>
<tr>
<td>gzip-9</td>
<td>62×</td>
<td>9.9ms</td>
<td>✗</td>
<td>✗</td>
</tr>
<tr>
<td>zstd-L3</td>
<td>76×</td>
<td>1.6ms</td>
<td>✗</td>
<td>✗</td>
</tr>
<tr>
<td><strong>QUANTUM-PULSE</strong></td>
<td><strong>95×</strong></td>
<td><strong>590ms</strong></td>
<td><strong>✓</strong></td>
<td><strong>✓</strong></td>
</tr>
<tr>
<td>zstd-L22</td>
<td>99×</td>
<td>1745ms</td>
<td>✗</td>
<td>✗</td>
</tr>
<tr>
<td>brotli-11</td>
<td>112×</td>
<td>1441ms</td>
<td>✗</td>
<td>✗</td>
</tr>
</tbody></table>
<p>QUANTUM-PULSE is the only option with both encryption and integrity — and it's 3× faster than vanilla zstd-L22.</p>
<h2>Honest limitations</h2>
<ul>
<li><p>No formal third-party crypto audit yet (private reporting in <a href="http://SECURITY.md">SECURITY.md</a>)</p>
</li>
<li><p>PBKDF2-SHA256 over Argon2 — Argon2 planned for v1.1</p>
</li>
<li><p>MongoDB-first — S3/GCS backends on the roadmap</p>
</li>
</ul>
<h2>Try it</h2>
<pre><code class="language-bash">git clone https://github.com/Naveenub/quantum-pulse
cp .env.example .env   # set QUANTUM_PASSPHRASE
docker-compose up -d

qp seal dataset.json --tag version=v1
qp unseal &lt;pulse-id&gt;

python scripts/benchmark_demo.py   # reproduce the numbers
</code></pre>
<p>MIT license. 277 tests.</p>
<p>Checkout → <a href="https://github.com/Naveenub/quantum-pulse">https://github.com/Naveenub/quantum-pulse</a></p>
]]></content:encoded></item></channel></rss>