| ``` | |
| βββ βββββββββββββββ βββββββ ββββββββ | |
| βββ ββββββββββββββββββββββββ ββββββββ | |
| βββ ββββββ βββ ββββββ ββββββββββ | |
| βββ ββββββ βββ ββββββ βββββββββ | |
| βββββββββββββββββββββββββββββββββββββββββ | |
| βββββββββββββββββββββββ βββββββ ββββββββ | |
| Sovereign Audit Chain Β· Built in Rust Β· Open Protocol Β· MIT | |
| ``` | |
| **Every event sealed. Every tamper detected. No trust required.** | |
| [](LICENSE) | |
| [](https://crates.io/crates/ledge) | |
| [](https://www.npmjs.com/package/@snapkitty/ledge) | |
| [](https://github.com/SNAPKITTYWEST/ledge/actions) | |
| --- | |
| ## The problem | |
| AI systems are making decisions worth millions of dollars. Financial platforms are processing transactions at scale. Compliance teams are asking one question: | |
| > **"Can you prove what happened β and that no one changed it?"** | |
| Most audit logs are mutable. A database row can be edited. A log file can be overwritten. An S3 object can be replaced. **None of that is proof.** | |
| LEDGE is proof. | |
| --- | |
| ## How it works | |
| ``` | |
| Genesis: SHA256("LEDGE_GENESIS:SOVEREIGN_CHAIN_INIT") | |
| Event 0: SHA256( genesis β payload_json β timestamp_ms β 0 ) | |
| Event 1: SHA256( seal_0 β payload_json β timestamp_ms β 1 ) | |
| Event 2: SHA256( seal_1 β payload_json β timestamp_ms β 2 ) | |
| Β·Β·Β· | |
| Merkle: SHA256 binary tree over all seals β single root fingerprint | |
| ``` | |
| Change one byte in any event. Every subsequent seal breaks. The Merkle root changes. **Tamper is instant, total, and mathematically provable.** | |
| --- | |
| ## Market context (VAULT analysis) | |
| ``` | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β WHY THIS EXISTS NOW β | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ | |
| β AI audit trail search volume +340% since Q1 2026 β | |
| β GDPR fines (2025) β¬2.1B and rising β | |
| β MiCA enforcement begins Q1 2027 β | |
| β SOX compliance market $4.2B 12% YoY growth β | |
| β Avg cost of compliance audit fail $14.8M per incident β | |
| β Enterprise AI governance market $1.2B β $9.4B by 2030 β | |
| β Companies with AI audit solutions < 4% of Fortune 500 β | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| Every enterprise deploying AI has no answer to: | |
| "How do we audit what the AI decided?" | |
| LEDGE is that answer. | |
| ``` | |
| --- | |
| ## Install | |
| ```bash | |
| npm install @snapkitty/ledge | |
| ``` | |
| ```toml | |
| [dependencies] | |
| ledge = "0.1" | |
| ``` | |
| --- | |
| ## Usage | |
| ### TypeScript / JavaScript | |
| ```typescript | |
| import { initLedge } from '@snapkitty/ledge' | |
| const { createChain } = await initLedge() | |
| const chain = createChain() | |
| // Seal an AI decision | |
| chain.seal({ | |
| agent: 'VAULT', | |
| decision: 'APPROVE_PAYMENT', | |
| amount: 50000, | |
| vendor: 'Acme Corp', | |
| reason: 'Invoice verified, funds available', | |
| }) | |
| // Seal a follow-up action | |
| chain.seal({ | |
| agent: 'FORGE', | |
| action: 'DEPLOY', | |
| ref: 'abc1234', | |
| env: 'production', | |
| }) | |
| // Verify nothing was tampered with | |
| const result = chain.verify() | |
| // { valid: true, eventCount: 2, merkleRoot: '7f3a...', failures: [] } | |
| console.log('Chain root:', chain.merkleRoot()) | |
| // One hex string that fingerprints the entire history | |
| ``` | |
| ### Rust | |
| ```rust | |
| use ledge::LedgeChain; | |
| use serde_json::json; | |
| let mut chain = LedgeChain::new(); | |
| chain.seal(json!({ | |
| "agent": "VAULT", | |
| "decision": "APPROVE_PAYMENT", | |
| "amount": 50000, | |
| }), unix_ms()); | |
| chain.seal(json!({ | |
| "agent": "FORGE", | |
| "action": "DEPLOY", | |
| "ref": "abc1234", | |
| }), unix_ms()); | |
| let result = chain.verify(); | |
| assert!(result.valid); | |
| println!("Merkle root: {}", chain.merkle_root()); | |
| ``` | |
| ### Tamper detection | |
| ```rust | |
| chain.events[0].payload = json!({ "amount": 1 }); // tamper | |
| let result = chain.verify(); | |
| assert!(!result.valid); | |
| assert!(result.failures.contains(&0)); // reports every broken link | |
| ``` | |
| --- | |
| ## API | |
| ### Rust β `LedgeChain` | |
| | Method | Returns | Description | | |
| |--------|---------|-------------| | |
| | `LedgeChain::new()` | `Self` | New chain from genesis | | |
| | `.seal(payload, timestamp_ms)` | `SealedEvent` | Append and seal an event | | |
| | `.verify()` | `VerifyResult` | Verify all seals; reports all failures | | |
| | `.merkle_root()` | `String` | Hex Merkle root of the full chain | | |
| | `.genesis()` | `String` | Genesis hash (constant per protocol) | | |
| | `.events()` | `&[SealedEvent]` | Read-only event slice | | |
| | `.len()` | `usize` | Event count | | |
| ### WASM / JavaScript β stateless functions | |
| | Function | Description | | |
| |----------|-------------| | |
| | `ledge_genesis()` | Genesis hash hex | | |
| | `ledge_seal(prev, payload_json, ts, idx)` | Compute one seal hex | | |
| | `ledge_verify(events_json)` | JSON in β `{valid, failures, merkleRoot, eventCount}` | | |
| | `ledge_merkle_root(seals_json)` | Build Merkle root from seal array | | |
| ### `SealedEvent` shape | |
| ```typescript | |
| { | |
| index: number // position in chain | |
| seal: string // 64-char hex SHA-256 | |
| previousSeal: string // 64-char hex of prior seal (or genesis) | |
| payload: object // your data β anything JSON-serializable | |
| timestampMs: number // unix ms | |
| } | |
| ``` | |
| --- | |
| ## The seal algorithm | |
| ``` | |
| seal = SHA256( | |
| prev_seal_bytes // 32 bytes | |
| payload_json // UTF-8 bytes β canonical JSON.stringify | |
| timestamp_ms // u64 big-endian | |
| index // u64 big-endian | |
| ) | |
| ``` | |
| Genesis: `SHA256("LEDGE_GENESIS:SOVEREIGN_CHAIN_INIT")` | |
| Open protocol. No secrets. Any party can verify any chain independently. | |
| --- | |
| ## Security model | |
| ``` | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β WHY RUST β | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββ€ | |
| β Prototype pollution impossible β | |
| β Timing attacks constant-time sha2 β | |
| β Memory safety borrow checker β | |
| β Supply chain risk 3 deps (sha2/hex/ β | |
| β serde) β auditable β | |
| β V8 non-determinism eliminated β | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ``` | |
| TypeScript was rejected for this library. A cryptographic audit trail written in JavaScript is a liability, not an asset. | |
| --- | |
| ## Build from source | |
| ```bash | |
| # Rust library + tests | |
| cargo build --release | |
| cargo test | |
| # WASM + JS (requires wasm-pack) | |
| cargo install wasm-pack | |
| wasm-pack build --features wasm --target bundler --out-dir pkg | |
| npm run build:js | |
| ``` | |
| --- | |
| ## Use cases | |
| ``` | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β AI AGENT DECISIONS Seal every AI output. Prove it wasn't β | |
| β altered retroactively. SOC 2 ready. β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ | |
| β FINANCIAL TRANSACTIONS Immutable payment sequence. Approval β | |
| β chain proof. Audit on demand. β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ | |
| β DEPLOYMENT RECORDS Cryptographic record of what shipped, β | |
| β when, and who approved it. β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ | |
| β COMPLIANCE EVIDENCE SOX Β· GDPR Β· MiCA Β· ISO 27001 β | |
| β Tamper-evident log, Merkle verifiable. β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ``` | |
| --- | |
| ## Live demo | |
| **[collectivekitty.com/labs/ledge](https://collectivekitty.com/labs/ledge)** | |
| Seal events in the browser. Verify chain integrity. Explore the Merkle tree. No account required. | |
| --- | |
| ## Part of the SnapKitty Sovereign OS | |
| LEDGE is the open protocol layer of a larger sovereign AI operating system. The chain protocol, SDK, and verification tools are MIT-licensed and open forever. | |
| The intelligence behind it β the agent mesh, the orchestration layer, the sovereign OS β runs privately on bare metal. [collectivekitty.com](https://collectivekitty.com) | |
| --- | |
| ## License | |
| MIT β see [LICENSE](LICENSE) | |
| --- | |
| ``` | |
| Built by LOC β Rust kinetic agent | |
| SnapKitty Sovereign OS Β· 2026 | |
| "The borrow checker is the security model." | |
| ``` | |
|  | |