Enterprise-Grade Encrypted Memory for AI Agents
If your agent memory leaks, you're going to OpenShart yourself.
OpenShart is a zero-dependency encrypted memory framework for AI agents. It fragments, encrypts, and distributes agent context using Shamir's Secret Sharing, AES-256-GCM, and HMAC-based searchable encryption โ with enterprise hierarchical access control, government classification levels, and ChainLock temporal sequence locks.
No single storage location holds a complete memory. No database breach reveals usable data. No admin can read agent context without the agent's key.
The name is intentional. The security is not a joke.
- ๐ AES-256-GCM authenticated encryption with per-fragment derived keys
- ๐งฉ Shamir's Secret Sharing โ K-of-N threshold reconstruction
- ๐ Searchable encryption โ HMAC-SHA256 tokens, zero content exposure during search
- ๐๏ธ Government classification โ UNCLASSIFIED โ CUI โ CONFIDENTIAL โ SECRET โ TOP SECRET โ TS/SCI
- โ๏ธ ChainLock โ temporal sequence locks with breach detection
- ๐ก๏ธ Bell-LaPadula MAC โ mandatory access control (no read up, no write down)
- ๐ข Enterprise RBAC โ role hierarchy, department isolation, delegated keys
- ๐ Tamper-evident audit โ SHA-256 hash chain, compliance export
- ๐๏ธ GDPR Article 17 โ DoD 5220.22-M 3-pass cryptographic erasure
- ๐ FIPS-ready โ approved algorithms, key entropy validation, self-tests
- ๐ฅ HIPAA PHI detection โ Safe Harbor patterns, minimum necessary enforcement
- ๐ฆ Zero runtime dependencies โ Node.js
cryptoonly
| Preset | What You Get |
|---|---|
standard |
AES-256-GCM, Shamir fragmentation, PII detection, audit log |
enterprise |
+ RBAC, department isolation, key rotation, SOC2 controls |
government |
+ ChainLock, FIPS mode, classification levels, Bell-LaPadula, compartments |
classified |
+ TS/SCI compartments, two-person integrity, air-gap ready, canary tokens |
npm install openshartimport { OpenShart, MemoryBackend, Classification } from 'openshart';
import { randomBytes } from 'node:crypto';
const shart = await OpenShart.init({
storage: new MemoryBackend(),
encryptionKey: randomBytes(32),
securityLevel: 'government',
});
// Store โ PII auto-detected, fragmented, encrypted, ChainLock-secured
const { id } = await shart.store(
"Patient John Doe, SSN 123-45-6789, diagnosed with hypertension",
{
classification: Classification.SECRET,
compartments: ['MEDICAL'],
tags: ['patient', 'diagnosis'],
}
);
// Search โ HMAC tokens only, content never decrypted
const results = await shart.search('patient diagnosis');
// Recall โ ChainLock sequence enforced, access control verified
const memory = await shart.recall(id);
console.log(memory.content);
// Forget โ DoD 5220.22-M 3-pass overwrite + cryptographic erasure
await shart.forget(id);
await shart.close();ChainLock is OpenShart's novel security primitive. Fragments must be decrypted in a cryptographically random sequence, within strict time windows, with chain tokens linking each step.
Recall Request
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 1. Generate session nonce โ
โ 2. Decrypt sequence order โ
โ 3. Start temporal clock โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโผโโโโโโโโโโ
โ Step 1 (โค2000ms) โโโโ chain_token_1
โโโโโโโโโโโฌโโโโโโโโโโ
โ
โโโโโโโโโโโผโโโโโโโโโโ
โ Step 2 (โค2000ms) โโโโ chain_token_2
โโโโโโโโโโโฌโโโโโโโโโโ
โ
โโโโโโโโโโโผโโโโโโโโโโ
โ Step N (โค2000ms) โโโโ chain_token_N
โโโโโโโโโโโฌโโโโโโโโโโ
โ
โโโโโโโโโโโผโโโโโโโโโโ
โ โ
Reconstruct โ
โ ๐ Rotate sequence โ
โ ๐งน Wipe ephemeral โ
โโโโโโโโโโโโโโโโโโโโโ
Why it matters:
- Stolen fragments are useless without the sequence, timing, and chain tokens
- Automated attacks detected via timing analysis (uniform step durations = bot)
- Replay attacks prevented โ sequence rotates after every successful recall
- Breach lockdown โ configurable failure threshold triggers lockdown
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AGENT APPLICATION โ
โ (OpenClaw, LangChain, CrewAI, custom) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ OPENSHART SDK โ
โ โ
โ โโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โ
โ โ STORE โ โ SEARCH โ โ RECALL โ โ FORGET โ โ
โ โโโโโโฌโโโโโ โโโโโฌโโโโโ โโโโโฌโโโโโ โโโโโฌโโโโโ โ
โ โ โ โ โ โ
โ โโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโ โ
โ โ ACCESS CONTROL ยท BELL-LAPADULA ยท CLASSIFICATION โ โ
โ โ FIPS Crypto ยท Key Rotation ยท Need-to-Know โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ PII DETECTION + AUTO-CLASSIFICATION โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ FRAGMENT ENGINE (Shamir SSS) + CHAINLOCK โ โ
โ โ K-of-N shares โ AES-256-GCM โ Temporal Lock โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโผโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โ
โ โ SEARCH INDEX โ โ AUDIT LOG โ โ KEY MANAGEMENT โ โ
โ โ(HMAC-SHA256) โ โ (hash chain) โ โ(HSM ยท rotation) โ โ
โ โโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโโโ โโโโโโโโฌโโโโโโโโโโโโ โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ STORAGE BACKEND โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ SQLite โ โ PostgreSQL โ โ Memory โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
OpenShart supports the full US government classification hierarchy with cryptographic enforcement:
import { Classification, checkClassifiedAccess } from 'openshart';
// Classification levels:
// UNCLASSIFIED โ CUI โ CONFIDENTIAL โ SECRET โ TOP_SECRET โ TS_SCI
// SCI Compartments: GAMMA, HCS, SI, TK
// Dissemination controls: NOFORN, ORCON, REL TO
// Bell-LaPadula enforced at the cryptographic level:
// - No Read Up: agents cannot read above their clearance
// - No Write Down: agents cannot write below their clearance| Classification | Clearance Required | Fragmentation | ChainLock |
|---|---|---|---|
| UNCLASSIFIED | None | 2-of-3 | Off |
| CUI | CONTRIBUTOR+ | 3-of-5 | Off |
| CONFIDENTIAL | MANAGER+ | 3-of-5 | Off |
| SECRET | DIRECTOR+ | 5-of-8 | โ |
| TOP SECRET | EXECUTIVE | 5-of-8 | โ |
| TS/SCI | EXECUTIVE + compartment | 5-of-8 | โ + TPI |
import { OpenShart, ContextFlowManager, DepartmentManager, Role } from 'openshart';
const departments = new DepartmentManager();
departments.registerDepartment({
id: 'engineering',
name: 'Engineering',
encryptionNamespace: 'eng-ns-2026',
});
const flow = new ContextFlowManager(departments);
// Context flows DOWN with automatic PII redaction
const pushed = flow.pushDown(
'Q3 target: $2M ARR. Contact jane@corp.com for details.',
Role.EXECUTIVE,
Role.CONTRIBUTOR,
);
// pushed.content: 'Q3 target: [FINANCIAL_REDACTED]. Contact [EMAIL_REDACTED] for details.'import { KeyRotationManager, createEscrow, SecureBuffer } from 'openshart';
// Secure key wrapper โ auto-zeros on destroy
const key = new SecureBuffer(masterKeyBuffer);
// Key escrow โ Shamir split of master key for M-of-N recovery
const shares = createEscrow(masterKey, custodianKeys, {
threshold: 3,
totalShares: 5,
});
// Key rotation โ re-encrypts all fragments
const rotator = new KeyRotationManager(storage);
await rotator.rotateAll(oldKey, newKey);| Threat | Mitigation |
|---|---|
| Database breach | Shamir's SSS + AES-256-GCM + ChainLock |
| Automated extraction | ChainLock timing analysis detects bots |
| Replay attacks | Sequence rotates after every recall |
| Brute force | Exponential backoff + lockdown |
| Insider threat | Bell-LaPadula MAC + compartmentalization |
| Key compromise | Key rotation + HSM-ready + Shamir escrow |
| Quantum (future) | Architecture ready for ML-KEM-1024 hybrid |
| Framework | Status |
|---|---|
| SOC2 Type II | โ Compliant |
| HIPAA | โ Compliant |
| GDPR | โ Compliant โ Article 17 cryptographic erasure |
| FIPS 140-2 | ๐ก Ready โ approved algorithms, awaiting validated module |
| FedRAMP | ๐ก Ready โ NIST 800-53 controls implemented |
| NIST 800-53 | ๐ก Partial โ AC, AU, SC, SI families |
| Backend | Use Case | Peer Dependency |
|---|---|---|
MemoryBackend |
Testing | None |
SQLiteBackend |
Development / single-agent | better-sqlite3 |
PostgresBackend |
Production | pg |
| Option | Type | Default | Description |
|---|---|---|---|
storage |
StorageBackend |
required | Storage backend |
encryptionKey |
Buffer |
required | 32-byte master key |
securityLevel |
SecurityLevel |
'standard' |
Security preset |
agentId |
string |
'system' |
Agent identifier |
role |
Role |
โ | Agent's hierarchy role |
department |
string |
โ | Agent's department |
clearance |
ClearanceProfile |
โ | Government clearance |
chainLock |
ChainLockConfig |
โ | ChainLock overrides |
| Method | Description |
|---|---|
store(content, options?) |
Store with PII detection, fragmentation, encryption, classification |
recall(memoryId) |
Reconstruct with ChainLock + access control |
search(query, options?) |
HMAC token search, zero content exposure |
forget(memoryId) |
DoD 5220.22-M 3-pass + cryptographic erasure |
list(filters?) |
List metadata (never content) |
export(filters?) |
Compliance audit export |
verifyAuditChain() |
Verify tamper-evident hash chain |
Q: Is the name a joke? A: Yes, the name is intentional. The security is not a joke. OpenShart implements AES-256-GCM, Shamir's Secret Sharing, Bell-LaPadula mandatory access control, FIPS-ready cryptography, and government classification with compartmentalization. The absurdity of the name is inversely proportional to the seriousness of the security.
Q: Can I use this in production? A: Yes. OpenShart is designed for production use in environments ranging from standard SaaS to classified government systems. SOC2, HIPAA, and GDPR compliant by design.
Q: Why not just use a normal database with encryption? A: Because a database breach exposes everything. OpenShart fragments data using Shamir's Secret Sharing โ no single storage location holds a complete memory. Even with full database access, an attacker gets meaningless encrypted shards.
Q: Does it really support TS/SCI? A: The classification model, access control, and compartmentalization are architecturally complete. Formal certification (FedRAMP, Common Criteria) requires third-party assessment. The crypto is real. The access control is real. The name is... what it is.
Q: My CISO asked about the name. A: Tell them it stands for Open Secure Hierarchical Agent Recall & Tokenization. That's not true, but it works in a slide deck.
Q: What happens if there's a security breach? A: The attacker gets useless encrypted fragments and you get to say "good thing we used OpenShart" in the incident report.
Q: How do I explain this to my board of directors? A: "We've implemented enterprise-grade cryptographic memory fragmentation with temporal sequence locking." Then hope nobody Googles the npm package name.
Q: Can I put this on my resume? A: "Led implementation of OpenShart across the organization" is technically accurate and a great conversation starter.
Q: Our compliance team flagged the package name. A: Show them the Shamir's Secret Sharing implementation, the FIPS compliance mode, and the Bell-LaPadula access control. Then watch them slowly nod and pretend the name doesn't bother them.
Q: Is there an enterprise version with a different name? A: No. The security is the same whether you call it OpenShart or "Open Secure Hierarchical Agent Recall & Tokenization." We just prefer honesty.
Q: My PR adding OpenShart as a dependency was rejected.
A: npm install openshart hits different in a code review. We recommend adding it on a Friday afternoon.
Q: I ran npm install openshart and my coworker saw my screen.
A: You're welcome. That's a core memory now.
git clone https://github.com/bcharleson/openshart.git
cd openshart
npm install
npm testSecurity vulnerabilities: Do not open a public issue. Email security@openshart.dev.
MIT โ see LICENSE.
OpenShart โ because agent memory should be as secure as the name is unfortunate.