@longarc/mdash 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +278 -0
- package/dist/checkpoint/engine.d.ts +208 -0
- package/dist/checkpoint/engine.d.ts.map +1 -0
- package/dist/checkpoint/engine.js +369 -0
- package/dist/checkpoint/engine.js.map +1 -0
- package/dist/context/engine.d.ts +197 -0
- package/dist/context/engine.d.ts.map +1 -0
- package/dist/context/engine.js +392 -0
- package/dist/context/engine.js.map +1 -0
- package/dist/core/commitment.d.ts +154 -0
- package/dist/core/commitment.d.ts.map +1 -0
- package/dist/core/commitment.js +305 -0
- package/dist/core/commitment.js.map +1 -0
- package/dist/core/crypto.d.ts +100 -0
- package/dist/core/crypto.d.ts.map +1 -0
- package/dist/core/crypto.js +243 -0
- package/dist/core/crypto.js.map +1 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +234 -0
- package/dist/index.js.map +1 -0
- package/dist/mcca/engine.d.ts +260 -0
- package/dist/mcca/engine.d.ts.map +1 -0
- package/dist/mcca/engine.js +518 -0
- package/dist/mcca/engine.js.map +1 -0
- package/dist/physics/engine.d.ts +165 -0
- package/dist/physics/engine.d.ts.map +1 -0
- package/dist/physics/engine.js +371 -0
- package/dist/physics/engine.js.map +1 -0
- package/dist/tee/engine.d.ts +285 -0
- package/dist/tee/engine.d.ts.map +1 -0
- package/dist/tee/engine.js +505 -0
- package/dist/tee/engine.js.map +1 -0
- package/dist/warrant/engine.d.ts +195 -0
- package/dist/warrant/engine.d.ts.map +1 -0
- package/dist/warrant/engine.js +409 -0
- package/dist/warrant/engine.js.map +1 -0
- package/dist/zk/engine.d.ts +243 -0
- package/dist/zk/engine.d.ts.map +1 -0
- package/dist/zk/engine.js +489 -0
- package/dist/zk/engine.js.map +1 -0
- package/package.json +25 -0
- package/src/__tests__/phase1.test.ts +1120 -0
- package/src/__tests__/phase2-4.test.ts +898 -0
- package/src/checkpoint/engine.ts +532 -0
- package/src/context/engine.ts +598 -0
- package/src/core/commitment.ts +438 -0
- package/src/core/crypto.ts +304 -0
- package/src/index.ts +320 -0
- package/src/mcca/engine.ts +778 -0
- package/src/physics/engine.ts +563 -0
- package/src/tee/engine.ts +810 -0
- package/src/warrant/engine.ts +625 -0
- package/src/zk/engine.ts +730 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mdash v3.0 - Sealed Context Architecture (SCA)
|
|
3
|
+
*
|
|
4
|
+
* Incremental Merkle sealing with streaming support.
|
|
5
|
+
* O(log n) proof verification.
|
|
6
|
+
*
|
|
7
|
+
* Target Latency:
|
|
8
|
+
* - Context chunk seal: <2ms P50, <5ms P99
|
|
9
|
+
*/
|
|
10
|
+
import { generateFragmentId, generateTimestamp, sha256Object, hmacSeal, hmacVerify, deriveKey, deterministicStringify, } from '../core/crypto';
|
|
11
|
+
import { IncrementalMerkleTree } from '../core/commitment';
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// TRUST LEVELS
|
|
14
|
+
// ============================================================================
|
|
15
|
+
export const DEFAULT_TRUST_LEVELS = {
|
|
16
|
+
system: 100,
|
|
17
|
+
operator: 90,
|
|
18
|
+
user: 70,
|
|
19
|
+
derived: 60,
|
|
20
|
+
agent: 50,
|
|
21
|
+
external: 30,
|
|
22
|
+
};
|
|
23
|
+
export class ContextStream {
|
|
24
|
+
chunks = [];
|
|
25
|
+
tree;
|
|
26
|
+
key = null;
|
|
27
|
+
sourceClass;
|
|
28
|
+
source;
|
|
29
|
+
constructor(params) {
|
|
30
|
+
this.source = params.source;
|
|
31
|
+
this.sourceClass = params.sourceClass;
|
|
32
|
+
this.tree = new IncrementalMerkleTree(params.maxDepth || 16);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Initialize with seal key
|
|
36
|
+
*/
|
|
37
|
+
async initialize(sealKey) {
|
|
38
|
+
this.key = await deriveKey(sealKey);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Add a chunk to the stream
|
|
42
|
+
* Target: <2ms P50, <5ms P99
|
|
43
|
+
*/
|
|
44
|
+
async addChunk(content) {
|
|
45
|
+
const startTime = performance.now();
|
|
46
|
+
const index = this.chunks.length;
|
|
47
|
+
const hash = await sha256Object({ index, content });
|
|
48
|
+
const chunk = {
|
|
49
|
+
index,
|
|
50
|
+
content,
|
|
51
|
+
hash,
|
|
52
|
+
sealed: false,
|
|
53
|
+
};
|
|
54
|
+
// Add to Merkle tree
|
|
55
|
+
await this.tree.addLeaf(hash);
|
|
56
|
+
chunk.sealed = true;
|
|
57
|
+
this.chunks.push(chunk);
|
|
58
|
+
const elapsed = performance.now() - startTime;
|
|
59
|
+
if (elapsed > 5) {
|
|
60
|
+
console.warn(`Context chunk seal exceeded P99: ${elapsed.toFixed(2)}ms`);
|
|
61
|
+
}
|
|
62
|
+
return chunk;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get the current root hash
|
|
66
|
+
*/
|
|
67
|
+
async getRoot() {
|
|
68
|
+
return this.tree.getRoot();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get proof for a specific chunk
|
|
72
|
+
*/
|
|
73
|
+
async getProof(index) {
|
|
74
|
+
if (index < 0 || index >= this.chunks.length) {
|
|
75
|
+
throw new Error(`Invalid chunk index: ${index}`);
|
|
76
|
+
}
|
|
77
|
+
const chunk = this.chunks[index];
|
|
78
|
+
if (!chunk) {
|
|
79
|
+
throw new Error(`Chunk not found at index: ${index}`);
|
|
80
|
+
}
|
|
81
|
+
const path = await this.tree.getProof(index);
|
|
82
|
+
const root = await this.tree.getRoot();
|
|
83
|
+
return { chunk, path, root };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Finalize the stream into a single sealed fragment
|
|
87
|
+
*/
|
|
88
|
+
async finalize() {
|
|
89
|
+
if (!this.key) {
|
|
90
|
+
throw new Error('Stream not initialized. Call initialize() first.');
|
|
91
|
+
}
|
|
92
|
+
const id = generateFragmentId();
|
|
93
|
+
const now = generateTimestamp();
|
|
94
|
+
const root = await this.tree.getRoot();
|
|
95
|
+
// Collect all chunk data
|
|
96
|
+
const data = this.chunks.map(c => c.content);
|
|
97
|
+
const totalTokens = this.chunks.length * 100; // Approximate
|
|
98
|
+
const content = {
|
|
99
|
+
type: 'structured',
|
|
100
|
+
data,
|
|
101
|
+
tokens: totalTokens,
|
|
102
|
+
metadata: {
|
|
103
|
+
chunks: this.chunks.length,
|
|
104
|
+
merkle_root: root,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
const provenance = {
|
|
108
|
+
source: this.source,
|
|
109
|
+
attribution: this.sourceClass,
|
|
110
|
+
trust_level: DEFAULT_TRUST_LEVELS[this.sourceClass],
|
|
111
|
+
timestamp: now,
|
|
112
|
+
parent_hash: null,
|
|
113
|
+
};
|
|
114
|
+
const hash = await sha256Object({
|
|
115
|
+
content,
|
|
116
|
+
provenance,
|
|
117
|
+
sealed_at: now,
|
|
118
|
+
});
|
|
119
|
+
const sealData = {
|
|
120
|
+
_v: 1,
|
|
121
|
+
id,
|
|
122
|
+
hash,
|
|
123
|
+
content,
|
|
124
|
+
provenance,
|
|
125
|
+
sealed_at: now,
|
|
126
|
+
constraints: [],
|
|
127
|
+
};
|
|
128
|
+
const seal = await hmacSeal(sealData, this.key);
|
|
129
|
+
return {
|
|
130
|
+
id,
|
|
131
|
+
hash,
|
|
132
|
+
content,
|
|
133
|
+
provenance,
|
|
134
|
+
sealed_at: now,
|
|
135
|
+
seal,
|
|
136
|
+
constraints: [],
|
|
137
|
+
version: 'v3.0',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get stream statistics
|
|
142
|
+
*/
|
|
143
|
+
getStats() {
|
|
144
|
+
return {
|
|
145
|
+
chunks: this.chunks.length,
|
|
146
|
+
treeStats: this.tree.getStats(),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// ============================================================================
|
|
151
|
+
// SEALED CONTEXT ENGINE
|
|
152
|
+
// ============================================================================
|
|
153
|
+
export class SealedContextEngine {
|
|
154
|
+
key = null;
|
|
155
|
+
commitmentEngine;
|
|
156
|
+
fragments = new Map();
|
|
157
|
+
byHash = new Map();
|
|
158
|
+
constructor(commitmentEngine) {
|
|
159
|
+
this.commitmentEngine = commitmentEngine;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Initialize the engine with a seal key
|
|
163
|
+
*/
|
|
164
|
+
async initialize(sealKey) {
|
|
165
|
+
this.key = await deriveKey(sealKey);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Create a sealed context fragment
|
|
169
|
+
*/
|
|
170
|
+
async seal(params) {
|
|
171
|
+
if (!this.key) {
|
|
172
|
+
throw new Error('Engine not initialized. Call initialize() first.');
|
|
173
|
+
}
|
|
174
|
+
const startTime = performance.now();
|
|
175
|
+
const id = generateFragmentId();
|
|
176
|
+
const now = generateTimestamp();
|
|
177
|
+
const semanticUnit = {
|
|
178
|
+
type: params.contentType,
|
|
179
|
+
data: params.content,
|
|
180
|
+
tokens: params.tokens ?? this.estimateTokens(params.content),
|
|
181
|
+
};
|
|
182
|
+
const provenance = {
|
|
183
|
+
source: params.source,
|
|
184
|
+
attribution: params.sourceClass,
|
|
185
|
+
trust_level: DEFAULT_TRUST_LEVELS[params.sourceClass],
|
|
186
|
+
timestamp: now,
|
|
187
|
+
parent_hash: params.parentHash || null,
|
|
188
|
+
};
|
|
189
|
+
const hash = await sha256Object({
|
|
190
|
+
content: semanticUnit,
|
|
191
|
+
provenance,
|
|
192
|
+
sealed_at: now,
|
|
193
|
+
});
|
|
194
|
+
const sealData = {
|
|
195
|
+
_v: 1,
|
|
196
|
+
id,
|
|
197
|
+
hash,
|
|
198
|
+
content: semanticUnit,
|
|
199
|
+
provenance,
|
|
200
|
+
sealed_at: now,
|
|
201
|
+
constraints: params.constraints || [],
|
|
202
|
+
};
|
|
203
|
+
const seal = await hmacSeal(sealData, this.key);
|
|
204
|
+
const fragment = {
|
|
205
|
+
id,
|
|
206
|
+
hash,
|
|
207
|
+
content: semanticUnit,
|
|
208
|
+
provenance,
|
|
209
|
+
sealed_at: now,
|
|
210
|
+
seal,
|
|
211
|
+
constraints: params.constraints || [],
|
|
212
|
+
version: 'v3.0',
|
|
213
|
+
};
|
|
214
|
+
// Commit to L1
|
|
215
|
+
await this.commitmentEngine.commit(fragment, `context:${id}`);
|
|
216
|
+
// Store
|
|
217
|
+
this.fragments.set(id, fragment);
|
|
218
|
+
this.byHash.set(hash, id);
|
|
219
|
+
const elapsed = performance.now() - startTime;
|
|
220
|
+
if (elapsed > 5) {
|
|
221
|
+
console.warn(`Context seal exceeded P99: ${elapsed.toFixed(2)}ms`);
|
|
222
|
+
}
|
|
223
|
+
return fragment;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Derive a new fragment from an existing one
|
|
227
|
+
*/
|
|
228
|
+
async derive(params) {
|
|
229
|
+
const derived = params.transform(params.parent.content.data);
|
|
230
|
+
const sealParams = {
|
|
231
|
+
content: derived,
|
|
232
|
+
contentType: params.parent.content.type,
|
|
233
|
+
source: params.source,
|
|
234
|
+
sourceClass: 'derived',
|
|
235
|
+
parentHash: params.parent.hash,
|
|
236
|
+
};
|
|
237
|
+
if (params.constraints) {
|
|
238
|
+
sealParams.constraints = params.constraints;
|
|
239
|
+
}
|
|
240
|
+
return this.seal(sealParams);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Verify a fragment
|
|
244
|
+
*/
|
|
245
|
+
async verify(fragment) {
|
|
246
|
+
if (!this.key) {
|
|
247
|
+
throw new Error('Engine not initialized. Call initialize() first.');
|
|
248
|
+
}
|
|
249
|
+
// Verify hash
|
|
250
|
+
const expectedHash = await sha256Object({
|
|
251
|
+
content: fragment.content,
|
|
252
|
+
provenance: fragment.provenance,
|
|
253
|
+
sealed_at: fragment.sealed_at,
|
|
254
|
+
});
|
|
255
|
+
if (expectedHash !== fragment.hash) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
// Verify seal
|
|
259
|
+
const sealData = {
|
|
260
|
+
_v: 1,
|
|
261
|
+
id: fragment.id,
|
|
262
|
+
hash: fragment.hash,
|
|
263
|
+
content: fragment.content,
|
|
264
|
+
provenance: fragment.provenance,
|
|
265
|
+
sealed_at: fragment.sealed_at,
|
|
266
|
+
constraints: fragment.constraints,
|
|
267
|
+
};
|
|
268
|
+
return hmacVerify(sealData, fragment.seal, this.key);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Resolve a fragment (check constraints)
|
|
272
|
+
*/
|
|
273
|
+
async resolve(fragment, context) {
|
|
274
|
+
const violations = [];
|
|
275
|
+
const now = context.now || new Date();
|
|
276
|
+
for (const constraint of fragment.constraints) {
|
|
277
|
+
switch (constraint.kind) {
|
|
278
|
+
case 'time': {
|
|
279
|
+
if (constraint.type === 'max_age') {
|
|
280
|
+
const maxAgeMs = constraint.params.max_age_ms;
|
|
281
|
+
const sealedAt = new Date(fragment.sealed_at);
|
|
282
|
+
if (now.getTime() - sealedAt.getTime() > maxAgeMs) {
|
|
283
|
+
violations.push({
|
|
284
|
+
constraint,
|
|
285
|
+
reason: `Fragment age exceeds max_age_ms: ${maxAgeMs}`,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
case 'trust': {
|
|
292
|
+
if (constraint.type === 'minimum') {
|
|
293
|
+
const minTrust = constraint.params.minimum_trust;
|
|
294
|
+
if (fragment.provenance.trust_level < minTrust) {
|
|
295
|
+
violations.push({
|
|
296
|
+
constraint,
|
|
297
|
+
reason: `Trust ${fragment.provenance.trust_level} < required ${minTrust}`,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
case 'scope': {
|
|
304
|
+
if (constraint.type === 'domain' && context.domain) {
|
|
305
|
+
const allowed = constraint.params.allowed_domains;
|
|
306
|
+
if (!allowed.includes(context.domain)) {
|
|
307
|
+
violations.push({
|
|
308
|
+
constraint,
|
|
309
|
+
reason: `Domain ${context.domain} not in allowed list`,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
success: violations.length === 0,
|
|
319
|
+
violations,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Get fragment by ID
|
|
324
|
+
*/
|
|
325
|
+
get(id) {
|
|
326
|
+
return this.fragments.get(id) || null;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Get fragment by hash
|
|
330
|
+
*/
|
|
331
|
+
getByHash(hash) {
|
|
332
|
+
const id = this.byHash.get(hash);
|
|
333
|
+
if (!id)
|
|
334
|
+
return null;
|
|
335
|
+
return this.get(id);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Create a streaming context
|
|
339
|
+
*/
|
|
340
|
+
createStream(params) {
|
|
341
|
+
return new ContextStream(params);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Estimate tokens (rough: ~4 chars/token)
|
|
345
|
+
*/
|
|
346
|
+
estimateTokens(content) {
|
|
347
|
+
const str = typeof content === 'string'
|
|
348
|
+
? content
|
|
349
|
+
: deterministicStringify(content);
|
|
350
|
+
return Math.ceil(str.length / 4);
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Get statistics
|
|
354
|
+
*/
|
|
355
|
+
getStats() {
|
|
356
|
+
return {
|
|
357
|
+
fragments: this.fragments.size,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// ============================================================================
|
|
362
|
+
// CONSTRAINT BUILDERS
|
|
363
|
+
// ============================================================================
|
|
364
|
+
export function maxAge(ms) {
|
|
365
|
+
return {
|
|
366
|
+
kind: 'time',
|
|
367
|
+
type: 'max_age',
|
|
368
|
+
params: { max_age_ms: ms },
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
export function requireTrust(minimum) {
|
|
372
|
+
return {
|
|
373
|
+
kind: 'trust',
|
|
374
|
+
type: 'minimum',
|
|
375
|
+
params: { minimum_trust: minimum },
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
export function allowDomains(domains) {
|
|
379
|
+
return {
|
|
380
|
+
kind: 'scope',
|
|
381
|
+
type: 'domain',
|
|
382
|
+
params: { allowed_domains: domains },
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
export function requireSignature(signers) {
|
|
386
|
+
return {
|
|
387
|
+
kind: 'signature',
|
|
388
|
+
type: 'required',
|
|
389
|
+
params: { allowed_signers: signers },
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/context/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAKL,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,SAAS,EACT,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAoB,MAAM,oBAAoB,CAAC;AAwE7E,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E,MAAM,CAAC,MAAM,oBAAoB,GAAgC;IAC/D,MAAM,EAAE,GAAG;IACX,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,EAAE;CACb,CAAC;AAiBF,MAAM,OAAO,aAAa;IAChB,MAAM,GAAqB,EAAE,CAAC;IAC9B,IAAI,CAAwB;IAC5B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AM,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;KAC3B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,OAAO;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE;KACnC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAiB;IAC5C,OAAO;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE;KACrC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAiB;IAChD,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mdash v3.0 - Commitment Layer (L1)
|
|
3
|
+
*
|
|
4
|
+
* Sub-millisecond cryptographic commitments.
|
|
5
|
+
* "The seal races the attack."
|
|
6
|
+
*
|
|
7
|
+
* Target Latency:
|
|
8
|
+
* - Commitment seal: <0.5ms P50, <1ms P99
|
|
9
|
+
* - Merkle proof: <0.1ms
|
|
10
|
+
*/
|
|
11
|
+
import { Hash, Seal, Timestamp } from './crypto';
|
|
12
|
+
export interface Commitment {
|
|
13
|
+
/** Unique commitment identifier */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Operation ID this commitment is associated with */
|
|
16
|
+
operationId?: string;
|
|
17
|
+
/** SHA-256 hash of the committed content */
|
|
18
|
+
content_hash: Hash;
|
|
19
|
+
/** Timestamp of commitment creation */
|
|
20
|
+
committed_at: Timestamp;
|
|
21
|
+
/** HMAC seal binding id + hash + timestamp */
|
|
22
|
+
seal: Seal;
|
|
23
|
+
/** Protocol version for upgrade path */
|
|
24
|
+
version: 'v3.0';
|
|
25
|
+
}
|
|
26
|
+
export interface CommitmentProof {
|
|
27
|
+
/** The commitment being proven */
|
|
28
|
+
commitment: Commitment;
|
|
29
|
+
/** Merkle path from leaf to root */
|
|
30
|
+
merkle_path: MerklePathNode[];
|
|
31
|
+
/** Root hash at time of commitment */
|
|
32
|
+
root_hash: Hash;
|
|
33
|
+
/** Position in the tree (leaf index) */
|
|
34
|
+
leaf_index: number;
|
|
35
|
+
}
|
|
36
|
+
export interface MerklePathNode {
|
|
37
|
+
/** Hash value */
|
|
38
|
+
hash: Hash;
|
|
39
|
+
/** Position: 'left' or 'right' relative to current node */
|
|
40
|
+
position: 'left' | 'right';
|
|
41
|
+
}
|
|
42
|
+
export declare class IncrementalMerkleTree {
|
|
43
|
+
private leaves;
|
|
44
|
+
private levels;
|
|
45
|
+
private readonly maxDepth;
|
|
46
|
+
constructor(maxDepth?: number);
|
|
47
|
+
/**
|
|
48
|
+
* Add a leaf to the tree
|
|
49
|
+
* O(log n) operation
|
|
50
|
+
*/
|
|
51
|
+
addLeaf(hash: Hash): Promise<number>;
|
|
52
|
+
/**
|
|
53
|
+
* Update the Merkle path for a new leaf
|
|
54
|
+
* Incrementally updates only affected nodes
|
|
55
|
+
*/
|
|
56
|
+
private updatePath;
|
|
57
|
+
/**
|
|
58
|
+
* Get the current root hash
|
|
59
|
+
*/
|
|
60
|
+
getRoot(): Promise<Hash>;
|
|
61
|
+
/**
|
|
62
|
+
* Generate Merkle proof for a leaf
|
|
63
|
+
* O(log n) operation
|
|
64
|
+
*/
|
|
65
|
+
getProof(leafIndex: number): Promise<MerklePathNode[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Verify a Merkle proof
|
|
68
|
+
* O(log n) operation
|
|
69
|
+
*/
|
|
70
|
+
static verifyProof(leafHash: Hash, proof: MerklePathNode[], expectedRoot: Hash): Promise<boolean>;
|
|
71
|
+
/**
|
|
72
|
+
* Get tree statistics
|
|
73
|
+
*/
|
|
74
|
+
getStats(): {
|
|
75
|
+
leaves: number;
|
|
76
|
+
depth: number;
|
|
77
|
+
capacity: number;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export declare class CommitmentEngine {
|
|
81
|
+
private key;
|
|
82
|
+
private tree;
|
|
83
|
+
private commitments;
|
|
84
|
+
constructor(maxTreeDepth?: number);
|
|
85
|
+
/**
|
|
86
|
+
* Initialize the engine with a seal key
|
|
87
|
+
*/
|
|
88
|
+
initialize(sealKey: string): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Create a commitment for content
|
|
91
|
+
* Target: <0.5ms P50, <1ms P99
|
|
92
|
+
*/
|
|
93
|
+
commit<T>(content: T, id: string): Promise<Commitment>;
|
|
94
|
+
/**
|
|
95
|
+
* Get a commitment by ID
|
|
96
|
+
*/
|
|
97
|
+
getCommitment(id: string): Commitment | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Verify a commitment
|
|
100
|
+
*/
|
|
101
|
+
verify(commitment: Commitment): Promise<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* Generate a proof for a commitment
|
|
104
|
+
*/
|
|
105
|
+
generateProof(id: string): Promise<CommitmentProof>;
|
|
106
|
+
/**
|
|
107
|
+
* Verify a proof
|
|
108
|
+
*/
|
|
109
|
+
verifyProof(proof: CommitmentProof): Promise<boolean>;
|
|
110
|
+
/**
|
|
111
|
+
* Get the current Merkle root
|
|
112
|
+
*/
|
|
113
|
+
getRoot(): Promise<Hash>;
|
|
114
|
+
/**
|
|
115
|
+
* Get statistics
|
|
116
|
+
*/
|
|
117
|
+
getStats(): {
|
|
118
|
+
commitments: number;
|
|
119
|
+
treeStats: {
|
|
120
|
+
leaves: number;
|
|
121
|
+
depth: number;
|
|
122
|
+
capacity: number;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export interface LatencyMetrics {
|
|
127
|
+
operation: string;
|
|
128
|
+
p50_ms: number;
|
|
129
|
+
p99_ms: number;
|
|
130
|
+
count: number;
|
|
131
|
+
breaches: number;
|
|
132
|
+
}
|
|
133
|
+
export declare class LatencyMonitor {
|
|
134
|
+
private metrics;
|
|
135
|
+
private thresholds;
|
|
136
|
+
constructor();
|
|
137
|
+
/**
|
|
138
|
+
* Record a latency sample
|
|
139
|
+
*/
|
|
140
|
+
record(operation: string, latencyMs: number): void;
|
|
141
|
+
/**
|
|
142
|
+
* Get metrics for an operation
|
|
143
|
+
*/
|
|
144
|
+
getMetrics(operation: string): LatencyMetrics | null;
|
|
145
|
+
/**
|
|
146
|
+
* Check if operation is within SLA
|
|
147
|
+
*/
|
|
148
|
+
isWithinSLA(operation: string): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Clear metrics
|
|
151
|
+
*/
|
|
152
|
+
clear(): void;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=commitment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitment.d.ts","sourceRoot":"","sources":["../../src/core/commitment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,SAAS,EASV,MAAM,UAAU,CAAC;AAMlB,MAAM,WAAW,UAAU;IACzB,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,YAAY,EAAE,IAAI,CAAC;IACnB,uCAAuC;IACvC,YAAY,EAAE,SAAS,CAAC;IACxB,8CAA8C;IAC9C,IAAI,EAAE,IAAI,CAAC;IACX,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,UAAU,EAAE,UAAU,CAAC;IACvB,oCAAoC;IACpC,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,sCAAsC;IACtC,SAAS,EAAE,IAAI,CAAC;IAChB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED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