Quantum-secure entity state system on IPFS.
- Entities write encrypted state blobs stored on IPFS
- Per-entity encryption — only authorized subscribers can decrypt
- Full history — state forms a linked chain (
prev_cid), walkable from any point - Quantum-secure — CRYSTALS-Kyber (ML-KEM) for key encapsulation, CRYSTALS-Dilithium (ML-DSA) for signatures, AES-256-GCM for symmetric encryption
Entity writes state
→ generate random AES-256 key
→ encrypt blob with AES-GCM
→ for each authorized reader: encapsulate AES key with their Kyber public key
→ sign entire record with Dilithium
→ publish to IPFS → get CID
→ notify subscribers
Entity reads state (given CID)
→ fetch record from IPFS
→ verify Dilithium signature
→ find own encapsulated key
→ decapsulate with Kyber secret key → recover AES key
→ decrypt blob
Install liboqs (the C library):
# macOS
brew install liboqs
# Ubuntu/Debian
sudo apt install liboqs-devFor real IPFS storage (optional — LocalStore works for testing):
brew install ipfs # or https://docs.ipfs.tech/install/
ipfs init
ipfs daemonpip install -r requirements.txtfrom boostipfs import Entity, Network, LocalStore
store = LocalStore() # or IPFSStore("http://127.0.0.1:5001")
net = Network(store)
alice = Entity("alice", net)
bob = Entity("bob", net)
bob.authorize(alice)
alice.subscribe(bob, callback=lambda cid: print(f"new: {cid}"))
cid = bob.write(b"hello world")
print(alice.read(cid)) # b"hello world"
print(alice.read_history(cid)) # [b"hello world"]python demo.py