File size: 10,624 Bytes
c404bdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
```

β–ˆβ–ˆβ•—     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—

β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β• β–ˆβ–ˆβ•”β•β•β•β•β•

β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—

β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•

β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—

β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•  β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β•



  Sovereign Audit Chain Β· Built in Rust Β· Open Protocol Β· MIT

```

**Every event sealed. Every tamper detected. No trust required.**

[![MIT License](https://img.shields.io/badge/license-MIT-00ff88?style=flat-square)](LICENSE)
[![Crates.io](https://img.shields.io/crates/v/ledge?style=flat-square&color=00ff88)](https://crates.io/crates/ledge)
[![npm](https://img.shields.io/npm/v/@snapkitty/ledge?style=flat-square&color=00ff88)](https://www.npmjs.com/package/@snapkitty/ledge)
[![CI](https://img.shields.io/github/actions/workflow/status/SNAPKITTYWEST/ledge/ci.yml?style=flat-square&label=tests)](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."

```

![](https://sovereign-analytics.snapkittywest.workers.dev/canary/ledge)