@vorionsys/atsf-core 0.1.0 → 0.2.1
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 +12 -12
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +463 -35
- package/dist/api/server.js.map +1 -1
- package/dist/arbitration/index.d.ts.map +1 -1
- package/dist/arbitration/index.js +8 -6
- package/dist/arbitration/index.js.map +1 -1
- package/dist/audit/key-manager.d.ts +118 -0
- package/dist/audit/key-manager.d.ts.map +1 -0
- package/dist/audit/key-manager.js +565 -0
- package/dist/audit/key-manager.js.map +1 -0
- package/dist/basis/evaluator.d.ts +31 -0
- package/dist/basis/evaluator.d.ts.map +1 -1
- package/dist/basis/evaluator.js +205 -10
- package/dist/basis/evaluator.js.map +1 -1
- package/dist/basis/parser.d.ts +210 -210
- package/dist/basis/parser.js.map +1 -1
- package/dist/carbon-aware/carbon-metrics.d.ts +151 -0
- package/dist/carbon-aware/carbon-metrics.d.ts.map +1 -0
- package/dist/carbon-aware/carbon-metrics.js +370 -0
- package/dist/carbon-aware/carbon-metrics.js.map +1 -0
- package/dist/carbon-aware/carbon-router.d.ts +101 -0
- package/dist/carbon-aware/carbon-router.d.ts.map +1 -0
- package/dist/carbon-aware/carbon-router.js +400 -0
- package/dist/carbon-aware/carbon-router.js.map +1 -0
- package/dist/chain/index.d.ts +147 -0
- package/dist/chain/index.d.ts.map +1 -0
- package/dist/chain/index.js +219 -0
- package/dist/chain/index.js.map +1 -0
- package/dist/cognigate/index.d.ts +33 -4
- package/dist/cognigate/index.d.ts.map +1 -1
- package/dist/cognigate/index.js +199 -24
- package/dist/cognigate/index.js.map +1 -1
- package/dist/common/adapters.d.ts +172 -0
- package/dist/common/adapters.d.ts.map +1 -0
- package/dist/common/adapters.js +329 -0
- package/dist/common/adapters.js.map +1 -0
- package/dist/common/config.d.ts +168 -163
- package/dist/common/config.d.ts.map +1 -1
- package/dist/common/config.js +2 -0
- package/dist/common/config.js.map +1 -1
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +1 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/types.d.ts +67 -16
- package/dist/common/types.d.ts.map +1 -1
- package/dist/common/types.js +4 -0
- package/dist/common/types.js.map +1 -1
- package/dist/enforce/index.d.ts +226 -16
- package/dist/enforce/index.d.ts.map +1 -1
- package/dist/enforce/index.js +196 -49
- package/dist/enforce/index.js.map +1 -1
- package/dist/governance/fluid-workflow.d.ts +217 -0
- package/dist/governance/fluid-workflow.d.ts.map +1 -0
- package/dist/governance/fluid-workflow.js +491 -0
- package/dist/governance/fluid-workflow.js.map +1 -0
- package/dist/governance/index.d.ts +1 -0
- package/dist/governance/index.d.ts.map +1 -1
- package/dist/governance/index.js +1 -0
- package/dist/governance/index.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/intent/index.d.ts +127 -10
- package/dist/intent/index.d.ts.map +1 -1
- package/dist/intent/index.js +121 -16
- package/dist/intent/index.js.map +1 -1
- package/dist/langchain/executor.d.ts +19 -5
- package/dist/langchain/executor.d.ts.map +1 -1
- package/dist/langchain/executor.js +287 -36
- package/dist/langchain/executor.js.map +1 -1
- package/dist/langchain/index.d.ts +2 -1
- package/dist/langchain/index.d.ts.map +1 -1
- package/dist/langchain/index.js +3 -1
- package/dist/langchain/index.js.map +1 -1
- package/dist/langchain/tools.d.ts.map +1 -1
- package/dist/langchain/tools.js +2 -1
- package/dist/langchain/tools.js.map +1 -1
- package/dist/langchain/types.d.ts +41 -0
- package/dist/langchain/types.d.ts.map +1 -1
- package/dist/layers/index.d.ts +1 -1
- package/dist/layers/index.d.ts.map +1 -1
- package/dist/persistence/file.d.ts +35 -3
- package/dist/persistence/file.d.ts.map +1 -1
- package/dist/persistence/file.js +138 -11
- package/dist/persistence/file.js.map +1 -1
- package/dist/persistence/index.d.ts +11 -1
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +25 -1
- package/dist/persistence/index.js.map +1 -1
- package/dist/persistence/sqlite.d.ts +135 -0
- package/dist/persistence/sqlite.d.ts.map +1 -0
- package/dist/persistence/sqlite.js +372 -0
- package/dist/persistence/sqlite.js.map +1 -0
- package/dist/persistence/supabase.d.ts +93 -0
- package/dist/persistence/supabase.d.ts.map +1 -0
- package/dist/persistence/supabase.js +219 -0
- package/dist/persistence/supabase.js.map +1 -0
- package/dist/persistence/types.d.ts +5 -1
- package/dist/persistence/types.d.ts.map +1 -1
- package/dist/phase6/ceiling.d.ts +177 -0
- package/dist/phase6/ceiling.d.ts.map +1 -0
- package/dist/phase6/ceiling.js +463 -0
- package/dist/phase6/ceiling.js.map +1 -0
- package/dist/phase6/context.d.ts +207 -0
- package/dist/phase6/context.d.ts.map +1 -0
- package/dist/phase6/context.js +603 -0
- package/dist/phase6/context.js.map +1 -0
- package/dist/phase6/index.d.ts +79 -0
- package/dist/phase6/index.d.ts.map +1 -0
- package/dist/phase6/index.js +152 -0
- package/dist/phase6/index.js.map +1 -0
- package/dist/phase6/presets.d.ts +148 -0
- package/dist/phase6/presets.d.ts.map +1 -0
- package/dist/phase6/presets.js +467 -0
- package/dist/phase6/presets.js.map +1 -0
- package/dist/phase6/provenance.d.ts +148 -0
- package/dist/phase6/provenance.d.ts.map +1 -0
- package/dist/phase6/provenance.js +545 -0
- package/dist/phase6/provenance.js.map +1 -0
- package/dist/phase6/role-gates/index.d.ts +7 -0
- package/dist/phase6/role-gates/index.d.ts.map +1 -0
- package/dist/phase6/role-gates/index.js +7 -0
- package/dist/phase6/role-gates/index.js.map +1 -0
- package/dist/phase6/role-gates/kernel.d.ts +84 -0
- package/dist/phase6/role-gates/kernel.d.ts.map +1 -0
- package/dist/phase6/role-gates/kernel.js +258 -0
- package/dist/phase6/role-gates/kernel.js.map +1 -0
- package/dist/phase6/role-gates/policy.d.ts +110 -0
- package/dist/phase6/role-gates/policy.d.ts.map +1 -0
- package/dist/phase6/role-gates/policy.js +157 -0
- package/dist/phase6/role-gates/policy.js.map +1 -0
- package/dist/phase6/role-gates.d.ts +164 -0
- package/dist/phase6/role-gates.d.ts.map +1 -0
- package/dist/phase6/role-gates.js +536 -0
- package/dist/phase6/role-gates.js.map +1 -0
- package/dist/phase6/types.d.ts +1827 -0
- package/dist/phase6/types.d.ts.map +1 -0
- package/dist/phase6/types.js +450 -0
- package/dist/phase6/types.js.map +1 -0
- package/dist/phase6/weight-presets/canonical.d.ts +93 -0
- package/dist/phase6/weight-presets/canonical.d.ts.map +1 -0
- package/dist/phase6/weight-presets/canonical.js +122 -0
- package/dist/phase6/weight-presets/canonical.js.map +1 -0
- package/dist/phase6/weight-presets/deltas.d.ts +144 -0
- package/dist/phase6/weight-presets/deltas.d.ts.map +1 -0
- package/dist/phase6/weight-presets/deltas.js +184 -0
- package/dist/phase6/weight-presets/deltas.js.map +1 -0
- package/dist/phase6/weight-presets/index.d.ts +8 -0
- package/dist/phase6/weight-presets/index.d.ts.map +1 -0
- package/dist/phase6/weight-presets/index.js +8 -0
- package/dist/phase6/weight-presets/index.js.map +1 -0
- package/dist/phase6/weight-presets/merger.d.ts +79 -0
- package/dist/phase6/weight-presets/merger.d.ts.map +1 -0
- package/dist/phase6/weight-presets/merger.js +161 -0
- package/dist/phase6/weight-presets/merger.js.map +1 -0
- package/dist/proof/index.d.ts +50 -1
- package/dist/proof/index.d.ts.map +1 -1
- package/dist/proof/index.js +122 -3
- package/dist/proof/index.js.map +1 -1
- package/dist/proof/merkle.d.ts +195 -0
- package/dist/proof/merkle.d.ts.map +1 -0
- package/dist/proof/merkle.js +412 -0
- package/dist/proof/merkle.js.map +1 -0
- package/dist/proof/zk-proofs.d.ts +218 -0
- package/dist/proof/zk-proofs.d.ts.map +1 -0
- package/dist/proof/zk-proofs.js +531 -0
- package/dist/proof/zk-proofs.js.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/audit.d.ts +98 -0
- package/dist/trust-engine/ceiling-enforcement/audit.d.ts.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/audit.js +160 -0
- package/dist/trust-engine/ceiling-enforcement/audit.js.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/index.d.ts +6 -0
- package/dist/trust-engine/ceiling-enforcement/index.d.ts.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/index.js +6 -0
- package/dist/trust-engine/ceiling-enforcement/index.js.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.d.ts +112 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.d.ts.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.js +158 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.js.map +1 -0
- package/dist/trust-engine/context-policy/enforcement.d.ts +62 -0
- package/dist/trust-engine/context-policy/enforcement.d.ts.map +1 -0
- package/dist/trust-engine/context-policy/enforcement.js +104 -0
- package/dist/trust-engine/context-policy/enforcement.js.map +1 -0
- package/dist/trust-engine/context-policy/factory.d.ts +75 -0
- package/dist/trust-engine/context-policy/factory.d.ts.map +1 -0
- package/dist/trust-engine/context-policy/factory.js +130 -0
- package/dist/trust-engine/context-policy/factory.js.map +1 -0
- package/dist/trust-engine/context-policy/index.d.ts +6 -0
- package/dist/trust-engine/context-policy/index.d.ts.map +1 -0
- package/dist/trust-engine/context-policy/index.js +6 -0
- package/dist/trust-engine/context-policy/index.js.map +1 -0
- package/dist/trust-engine/creation-modifiers/index.d.ts +5 -0
- package/dist/trust-engine/creation-modifiers/index.d.ts.map +1 -0
- package/dist/trust-engine/creation-modifiers/index.js +5 -0
- package/dist/trust-engine/creation-modifiers/index.js.map +1 -0
- package/dist/trust-engine/creation-modifiers/types.d.ts +112 -0
- package/dist/trust-engine/creation-modifiers/types.d.ts.map +1 -0
- package/dist/trust-engine/creation-modifiers/types.js +166 -0
- package/dist/trust-engine/creation-modifiers/types.js.map +1 -0
- package/dist/trust-engine/decay-profiles.d.ts +159 -0
- package/dist/trust-engine/decay-profiles.d.ts.map +1 -0
- package/dist/trust-engine/decay-profiles.js +210 -0
- package/dist/trust-engine/decay-profiles.js.map +1 -0
- package/dist/trust-engine/index.d.ts +144 -5
- package/dist/trust-engine/index.d.ts.map +1 -1
- package/dist/trust-engine/index.js +320 -15
- package/dist/trust-engine/index.js.map +1 -1
- package/dist/trust-engine/phase6-types.d.ts +123 -0
- package/dist/trust-engine/phase6-types.d.ts.map +1 -0
- package/dist/trust-engine/phase6-types.js +88 -0
- package/dist/trust-engine/phase6-types.js.map +1 -0
- package/package.json +26 -10
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merkle Tree Aggregation Service
|
|
3
|
+
*
|
|
4
|
+
* Implements batch proof aggregation using Merkle trees for:
|
|
5
|
+
* - Efficient batch verification
|
|
6
|
+
* - External anchoring (blockchain, timestamping services)
|
|
7
|
+
* - Privacy-preserving proof disclosure
|
|
8
|
+
*
|
|
9
|
+
* Key Features:
|
|
10
|
+
* - SHA-256 based Merkle tree construction
|
|
11
|
+
* - Incremental tree building
|
|
12
|
+
* - Compact inclusion proofs
|
|
13
|
+
* - Anchor commitments for external verification
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
import * as nodeCrypto from 'node:crypto';
|
|
18
|
+
import { createLogger } from '../common/logger.js';
|
|
19
|
+
const logger = createLogger({ component: 'proof:merkle' });
|
|
20
|
+
// =============================================================================
|
|
21
|
+
// MERKLE TREE CONSTRUCTION
|
|
22
|
+
// =============================================================================
|
|
23
|
+
/**
|
|
24
|
+
* Compute SHA-256 hash
|
|
25
|
+
*/
|
|
26
|
+
function sha256(data) {
|
|
27
|
+
return nodeCrypto.createHash('sha256').update(data).digest('hex');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Hash two nodes together (sorted for consistency)
|
|
31
|
+
*/
|
|
32
|
+
function hashNodes(left, right) {
|
|
33
|
+
// Sort to ensure consistent ordering regardless of sibling position
|
|
34
|
+
const [first, second] = left < right ? [left, right] : [right, left];
|
|
35
|
+
return sha256(first + second);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build Merkle tree from leaf hashes
|
|
39
|
+
*/
|
|
40
|
+
export function buildMerkleTree(leafHashes) {
|
|
41
|
+
if (leafHashes.length === 0) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
// Create leaf nodes
|
|
45
|
+
let currentLevel = leafHashes.map((hash) => ({
|
|
46
|
+
hash,
|
|
47
|
+
data: hash,
|
|
48
|
+
}));
|
|
49
|
+
// Build tree bottom-up
|
|
50
|
+
while (currentLevel.length > 1) {
|
|
51
|
+
const nextLevel = [];
|
|
52
|
+
for (let i = 0; i < currentLevel.length; i += 2) {
|
|
53
|
+
const left = currentLevel[i];
|
|
54
|
+
const right = currentLevel[i + 1] ?? left; // Duplicate last if odd
|
|
55
|
+
nextLevel.push({
|
|
56
|
+
hash: hashNodes(left.hash, right.hash),
|
|
57
|
+
left,
|
|
58
|
+
right: currentLevel[i + 1] ? right : undefined,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
currentLevel = nextLevel;
|
|
62
|
+
}
|
|
63
|
+
return currentLevel[0] ?? null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Generate Merkle proof for a leaf
|
|
67
|
+
*/
|
|
68
|
+
export function generateMerkleProof(leafHashes, leafIndex) {
|
|
69
|
+
if (leafIndex < 0 || leafIndex >= leafHashes.length) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const tree = buildMerkleTree(leafHashes);
|
|
73
|
+
if (!tree) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const path = [];
|
|
77
|
+
let currentIndex = leafIndex;
|
|
78
|
+
let levelSize = leafHashes.length;
|
|
79
|
+
// Build path from leaf to root
|
|
80
|
+
let currentLevel = leafHashes;
|
|
81
|
+
while (currentLevel.length > 1) {
|
|
82
|
+
const siblingIndex = currentIndex % 2 === 0 ? currentIndex + 1 : currentIndex - 1;
|
|
83
|
+
const siblingHash = currentLevel[siblingIndex] ?? currentLevel[currentIndex];
|
|
84
|
+
if (siblingIndex !== currentIndex) {
|
|
85
|
+
path.push({
|
|
86
|
+
hash: siblingHash,
|
|
87
|
+
position: currentIndex % 2 === 0 ? 'right' : 'left',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Move to next level
|
|
91
|
+
const nextLevel = [];
|
|
92
|
+
for (let i = 0; i < currentLevel.length; i += 2) {
|
|
93
|
+
const left = currentLevel[i];
|
|
94
|
+
const right = currentLevel[i + 1] ?? left;
|
|
95
|
+
nextLevel.push(hashNodes(left, right));
|
|
96
|
+
}
|
|
97
|
+
currentIndex = Math.floor(currentIndex / 2);
|
|
98
|
+
currentLevel = nextLevel;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
leafHash: leafHashes[leafIndex],
|
|
102
|
+
path,
|
|
103
|
+
root: tree.hash,
|
|
104
|
+
leafIndex,
|
|
105
|
+
treeSize: leafHashes.length,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Verify a Merkle proof
|
|
110
|
+
*/
|
|
111
|
+
export function verifyMerkleProof(proof) {
|
|
112
|
+
let currentHash = proof.leafHash;
|
|
113
|
+
for (const step of proof.path) {
|
|
114
|
+
if (step.position === 'left') {
|
|
115
|
+
currentHash = hashNodes(step.hash, currentHash);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
currentHash = hashNodes(currentHash, step.hash);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return currentHash === proof.root;
|
|
122
|
+
}
|
|
123
|
+
const DEFAULT_CONFIG = {
|
|
124
|
+
minBatchSize: 10,
|
|
125
|
+
maxBatchSize: 1000,
|
|
126
|
+
maxBatchAgeMs: 60000, // 1 minute
|
|
127
|
+
enableExternalAnchoring: false,
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Merkle Aggregation Service
|
|
131
|
+
*
|
|
132
|
+
* Aggregates proofs into Merkle trees for efficient batch verification
|
|
133
|
+
* and external anchoring.
|
|
134
|
+
*/
|
|
135
|
+
export class MerkleAggregationService {
|
|
136
|
+
config;
|
|
137
|
+
pending = [];
|
|
138
|
+
anchors = new Map();
|
|
139
|
+
proofsByAnchor = new Map();
|
|
140
|
+
anchorTimer = null;
|
|
141
|
+
signingKey = null;
|
|
142
|
+
constructor(config = {}) {
|
|
143
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
144
|
+
if (config.signingKey) {
|
|
145
|
+
try {
|
|
146
|
+
this.signingKey = nodeCrypto.createPrivateKey({
|
|
147
|
+
key: Buffer.from(config.signingKey, 'base64'),
|
|
148
|
+
format: 'der',
|
|
149
|
+
type: 'pkcs8',
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
logger.warn({ error }, 'Failed to load signing key');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
logger.info({
|
|
157
|
+
minBatchSize: this.config.minBatchSize,
|
|
158
|
+
maxBatchSize: this.config.maxBatchSize,
|
|
159
|
+
maxBatchAgeMs: this.config.maxBatchAgeMs,
|
|
160
|
+
}, 'Merkle aggregation service initialized');
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Add an item for aggregation
|
|
164
|
+
*/
|
|
165
|
+
async addItem(id, data) {
|
|
166
|
+
const hash = sha256(data);
|
|
167
|
+
this.pending.push({
|
|
168
|
+
id,
|
|
169
|
+
hash,
|
|
170
|
+
addedAt: new Date(),
|
|
171
|
+
});
|
|
172
|
+
logger.debug({ id, hash: hash.substring(0, 16) }, 'Item added to aggregation queue');
|
|
173
|
+
// Check if we should auto-anchor
|
|
174
|
+
if (this.pending.length >= this.config.maxBatchSize) {
|
|
175
|
+
await this.anchor();
|
|
176
|
+
}
|
|
177
|
+
else if (this.pending.length >= this.config.minBatchSize && !this.anchorTimer) {
|
|
178
|
+
// Start timer for auto-anchor
|
|
179
|
+
this.anchorTimer = setTimeout(async () => {
|
|
180
|
+
await this.anchor();
|
|
181
|
+
}, this.config.maxBatchAgeMs);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Add a proof for aggregation
|
|
186
|
+
*/
|
|
187
|
+
async addProof(proof) {
|
|
188
|
+
const proofData = JSON.stringify({
|
|
189
|
+
proofId: proof.id,
|
|
190
|
+
chainHash: proof.hash,
|
|
191
|
+
timestamp: proof.createdAt,
|
|
192
|
+
});
|
|
193
|
+
await this.addItem(proof.id, proofData);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Force anchor current batch
|
|
197
|
+
*/
|
|
198
|
+
async anchor() {
|
|
199
|
+
if (this.anchorTimer) {
|
|
200
|
+
clearTimeout(this.anchorTimer);
|
|
201
|
+
this.anchorTimer = null;
|
|
202
|
+
}
|
|
203
|
+
if (this.pending.length === 0) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
const startTime = Date.now();
|
|
207
|
+
const items = [...this.pending];
|
|
208
|
+
this.pending = [];
|
|
209
|
+
// Build Merkle tree
|
|
210
|
+
const leafHashes = items.map((item) => item.hash);
|
|
211
|
+
const tree = buildMerkleTree(leafHashes);
|
|
212
|
+
if (!tree) {
|
|
213
|
+
logger.error('Failed to build Merkle tree');
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
// Generate proofs for each item
|
|
217
|
+
const proofs = new Map();
|
|
218
|
+
for (let i = 0; i < items.length; i++) {
|
|
219
|
+
const proof = generateMerkleProof(leafHashes, i);
|
|
220
|
+
if (proof) {
|
|
221
|
+
proofs.set(items[i].id, proof);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// Create anchor
|
|
225
|
+
const anchorId = nodeCrypto.randomUUID();
|
|
226
|
+
const anchor = {
|
|
227
|
+
anchorId,
|
|
228
|
+
rootHash: tree.hash,
|
|
229
|
+
leafCount: items.length,
|
|
230
|
+
timestamp: new Date(),
|
|
231
|
+
externalAnchors: [],
|
|
232
|
+
};
|
|
233
|
+
// Sign anchor if key available
|
|
234
|
+
if (this.signingKey) {
|
|
235
|
+
const dataToSign = JSON.stringify({
|
|
236
|
+
anchorId: anchor.anchorId,
|
|
237
|
+
rootHash: anchor.rootHash,
|
|
238
|
+
leafCount: anchor.leafCount,
|
|
239
|
+
timestamp: anchor.timestamp.toISOString(),
|
|
240
|
+
});
|
|
241
|
+
const signature = nodeCrypto.sign(null, Buffer.from(dataToSign), this.signingKey);
|
|
242
|
+
anchor.signature = signature.toString('base64');
|
|
243
|
+
}
|
|
244
|
+
// External anchoring
|
|
245
|
+
if (this.config.enableExternalAnchoring) {
|
|
246
|
+
const externalAnchors = await this.submitExternalAnchors(tree.hash);
|
|
247
|
+
anchor.externalAnchors = externalAnchors;
|
|
248
|
+
}
|
|
249
|
+
// Store anchor and proofs
|
|
250
|
+
this.anchors.set(anchorId, anchor);
|
|
251
|
+
this.proofsByAnchor.set(anchorId, proofs);
|
|
252
|
+
const durationMs = Date.now() - startTime;
|
|
253
|
+
logger.info({
|
|
254
|
+
anchorId,
|
|
255
|
+
rootHash: tree.hash.substring(0, 16),
|
|
256
|
+
leafCount: items.length,
|
|
257
|
+
externalAnchors: anchor.externalAnchors.length,
|
|
258
|
+
durationMs,
|
|
259
|
+
}, 'Merkle anchor created');
|
|
260
|
+
return { anchor, proofs, durationMs };
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Submit to external anchoring services
|
|
264
|
+
*/
|
|
265
|
+
async submitExternalAnchors(rootHash) {
|
|
266
|
+
const anchors = [];
|
|
267
|
+
// RFC 3161 timestamp
|
|
268
|
+
if (this.config.externalAnchorServices?.rfc3161) {
|
|
269
|
+
try {
|
|
270
|
+
const result = await this.submitRFC3161Timestamp(rootHash, this.config.externalAnchorServices.rfc3161);
|
|
271
|
+
if (result) {
|
|
272
|
+
anchors.push(result);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
logger.warn({ error }, 'RFC 3161 anchoring failed');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// Ethereum (placeholder)
|
|
280
|
+
if (this.config.externalAnchorServices?.ethereum) {
|
|
281
|
+
try {
|
|
282
|
+
const result = await this.submitEthereumAnchor(rootHash, this.config.externalAnchorServices.ethereum);
|
|
283
|
+
if (result) {
|
|
284
|
+
anchors.push(result);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
logger.warn({ error }, 'Ethereum anchoring failed');
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return anchors;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Submit RFC 3161 timestamp request
|
|
295
|
+
*/
|
|
296
|
+
async submitRFC3161Timestamp(rootHash, tsaUrl) {
|
|
297
|
+
try {
|
|
298
|
+
// Create timestamp request
|
|
299
|
+
// In a full implementation, this would create a proper ASN.1 TSP request
|
|
300
|
+
const response = await fetch(tsaUrl, {
|
|
301
|
+
method: 'POST',
|
|
302
|
+
headers: {
|
|
303
|
+
'Content-Type': 'application/timestamp-query',
|
|
304
|
+
},
|
|
305
|
+
body: Buffer.from(rootHash, 'hex'),
|
|
306
|
+
});
|
|
307
|
+
if (!response.ok) {
|
|
308
|
+
logger.warn({ status: response.status }, 'TSA request failed');
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
const responseData = await response.arrayBuffer();
|
|
312
|
+
const reference = sha256(Buffer.from(responseData)).substring(0, 32);
|
|
313
|
+
return {
|
|
314
|
+
type: 'rfc3161',
|
|
315
|
+
reference,
|
|
316
|
+
timestamp: new Date(),
|
|
317
|
+
confirmed: true,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
logger.error({ error }, 'RFC 3161 timestamp failed');
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Submit Ethereum anchor
|
|
327
|
+
*/
|
|
328
|
+
async submitEthereumAnchor(rootHash, rpcUrl) {
|
|
329
|
+
// Placeholder for Ethereum anchoring
|
|
330
|
+
// In production, this would:
|
|
331
|
+
// 1. Create a transaction with rootHash in data field
|
|
332
|
+
// 2. Sign and submit transaction
|
|
333
|
+
// 3. Wait for confirmation
|
|
334
|
+
logger.debug({ rpcUrl }, 'Ethereum anchoring not fully implemented');
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Get anchor by ID
|
|
339
|
+
*/
|
|
340
|
+
getAnchor(anchorId) {
|
|
341
|
+
return this.anchors.get(anchorId);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Get proof for an item
|
|
345
|
+
*/
|
|
346
|
+
getProof(anchorId, itemId) {
|
|
347
|
+
return this.proofsByAnchor.get(anchorId)?.get(itemId);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Verify item inclusion in an anchor
|
|
351
|
+
*/
|
|
352
|
+
verifyInclusion(anchorId, itemId, data) {
|
|
353
|
+
const proof = this.getProof(anchorId, itemId);
|
|
354
|
+
if (!proof) {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
// Verify data hash matches leaf
|
|
358
|
+
const dataHash = sha256(data);
|
|
359
|
+
if (dataHash !== proof.leafHash) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
// Verify Merkle proof
|
|
363
|
+
return verifyMerkleProof(proof);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Get all anchors
|
|
367
|
+
*/
|
|
368
|
+
getAllAnchors() {
|
|
369
|
+
return Array.from(this.anchors.values());
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Get pending count
|
|
373
|
+
*/
|
|
374
|
+
getPendingCount() {
|
|
375
|
+
return this.pending.length;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Get statistics
|
|
379
|
+
*/
|
|
380
|
+
getStats() {
|
|
381
|
+
let totalProofs = 0;
|
|
382
|
+
let externalAnchors = 0;
|
|
383
|
+
for (const [, proofs] of this.proofsByAnchor) {
|
|
384
|
+
totalProofs += proofs.size;
|
|
385
|
+
}
|
|
386
|
+
for (const anchor of this.anchors.values()) {
|
|
387
|
+
externalAnchors += anchor.externalAnchors.length;
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
totalAnchors: this.anchors.size,
|
|
391
|
+
totalProofs,
|
|
392
|
+
pendingItems: this.pending.length,
|
|
393
|
+
externalAnchors,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Cleanup resources
|
|
398
|
+
*/
|
|
399
|
+
destroy() {
|
|
400
|
+
if (this.anchorTimer) {
|
|
401
|
+
clearTimeout(this.anchorTimer);
|
|
402
|
+
this.anchorTimer = null;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Create a Merkle aggregation service
|
|
408
|
+
*/
|
|
409
|
+
export function createMerkleAggregationService(config) {
|
|
410
|
+
return new MerkleAggregationService(config);
|
|
411
|
+
}
|
|
412
|
+
//# sourceMappingURL=merkle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merkle.js","sourceRoot":"","sources":["../../src/proof/merkle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;AA+E3D,gFAAgF;AAChF,2BAA2B;AAC3B,gFAAgF;AAEhF;;GAEG;AACH,SAAS,MAAM,CAAC,IAAqB;IACnC,OAAO,UAAU,CAAC,UAAU,CA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C/B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAC5C,MAAyC;IAEzC,OAAO,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-Knowledge Proof Service for Privacy-Preserving Trust Verification
|
|
3
|
+
*
|
|
4
|
+
* Implements ZK proofs to enable:
|
|
5
|
+
* - Trust tier verification without revealing exact score
|
|
6
|
+
* - Action authorization without exposing full context
|
|
7
|
+
* - Compliance attestation without disclosing sensitive data
|
|
8
|
+
*
|
|
9
|
+
* Proof Types:
|
|
10
|
+
* - Range proofs (score in tier range)
|
|
11
|
+
* - Membership proofs (role in allowed set)
|
|
12
|
+
* - Threshold proofs (score >= minimum)
|
|
13
|
+
*
|
|
14
|
+
* Implementation uses Bulletproofs-style commitments for range proofs.
|
|
15
|
+
* For production deployment, integrate with full ZK library (snarkjs, circom).
|
|
16
|
+
*
|
|
17
|
+
* @packageDocumentation
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Pedersen commitment (hiding + binding)
|
|
21
|
+
*/
|
|
22
|
+
export interface PedersenCommitment {
|
|
23
|
+
/** Commitment value C = value*G + blinding*H */
|
|
24
|
+
commitment: string;
|
|
25
|
+
/** Blinding factor (kept secret) */
|
|
26
|
+
blinding: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Range proof (proves value in [min, max])
|
|
30
|
+
*/
|
|
31
|
+
export interface RangeProof {
|
|
32
|
+
proofId: string;
|
|
33
|
+
proofType: 'range';
|
|
34
|
+
commitment: string;
|
|
35
|
+
rangeMin: number;
|
|
36
|
+
rangeMax: number;
|
|
37
|
+
proof: string;
|
|
38
|
+
createdAt: Date;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Threshold proof (proves value >= threshold)
|
|
42
|
+
*/
|
|
43
|
+
export interface ThresholdProof {
|
|
44
|
+
proofId: string;
|
|
45
|
+
proofType: 'threshold';
|
|
46
|
+
commitment: string;
|
|
47
|
+
threshold: number;
|
|
48
|
+
proof: string;
|
|
49
|
+
createdAt: Date;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Membership proof (proves value in set)
|
|
53
|
+
*/
|
|
54
|
+
export interface MembershipProof {
|
|
55
|
+
proofId: string;
|
|
56
|
+
proofType: 'membership';
|
|
57
|
+
commitment: string;
|
|
58
|
+
setHash: string;
|
|
59
|
+
proof: string;
|
|
60
|
+
createdAt: Date;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Trust tier proof (proves agent is in a specific tier)
|
|
64
|
+
*/
|
|
65
|
+
export interface TrustTierProof {
|
|
66
|
+
proofId: string;
|
|
67
|
+
proofType: 'trust-tier';
|
|
68
|
+
agentId: string;
|
|
69
|
+
tierCommitment: string;
|
|
70
|
+
tier: string;
|
|
71
|
+
proof: string;
|
|
72
|
+
validUntil: Date;
|
|
73
|
+
createdAt: Date;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Composite proof combining multiple statements
|
|
77
|
+
*/
|
|
78
|
+
export interface CompositeProof {
|
|
79
|
+
proofId: string;
|
|
80
|
+
proofType: 'composite';
|
|
81
|
+
statements: Array<{
|
|
82
|
+
type: 'range' | 'threshold' | 'membership';
|
|
83
|
+
commitment: string;
|
|
84
|
+
parameters: Record<string, unknown>;
|
|
85
|
+
}>;
|
|
86
|
+
proof: string;
|
|
87
|
+
createdAt: Date;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Verification result
|
|
91
|
+
*/
|
|
92
|
+
export interface ZKVerificationResult {
|
|
93
|
+
valid: boolean;
|
|
94
|
+
proofId: string;
|
|
95
|
+
verifiedAt: Date;
|
|
96
|
+
reason?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create Pedersen commitment
|
|
100
|
+
*
|
|
101
|
+
* In a real implementation, this would use elliptic curve operations.
|
|
102
|
+
* This is a simplified hash-based commitment for demonstration.
|
|
103
|
+
*/
|
|
104
|
+
export declare function createCommitment(value: number): PedersenCommitment;
|
|
105
|
+
/**
|
|
106
|
+
* Verify a commitment matches a value
|
|
107
|
+
*/
|
|
108
|
+
export declare function verifyCommitment(commitment: string, value: number, blinding: string): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Generate a simplified range proof
|
|
111
|
+
*
|
|
112
|
+
* Uses a commit-and-prove approach where:
|
|
113
|
+
* 1. Commit to the value
|
|
114
|
+
* 2. Prove value is in range using bit decomposition
|
|
115
|
+
*
|
|
116
|
+
* For production, use Bulletproofs library.
|
|
117
|
+
*/
|
|
118
|
+
export declare function generateRangeProof(value: number, min: number, max: number): {
|
|
119
|
+
proof: RangeProof;
|
|
120
|
+
secret: PedersenCommitment;
|
|
121
|
+
} | null;
|
|
122
|
+
/**
|
|
123
|
+
* Verify a range proof
|
|
124
|
+
*
|
|
125
|
+
* Verifies that the committed value is in [rangeMin, rangeMax]
|
|
126
|
+
*/
|
|
127
|
+
export declare function verifyRangeProof(proof: RangeProof): ZKVerificationResult;
|
|
128
|
+
/**
|
|
129
|
+
* Generate a threshold proof (value >= threshold)
|
|
130
|
+
*/
|
|
131
|
+
export declare function generateThresholdProof(value: number, threshold: number): {
|
|
132
|
+
proof: ThresholdProof;
|
|
133
|
+
secret: PedersenCommitment;
|
|
134
|
+
} | null;
|
|
135
|
+
/**
|
|
136
|
+
* Verify a threshold proof
|
|
137
|
+
*/
|
|
138
|
+
export declare function verifyThresholdProof(proof: ThresholdProof): ZKVerificationResult;
|
|
139
|
+
/**
|
|
140
|
+
* Generate a membership proof (value in set)
|
|
141
|
+
*
|
|
142
|
+
* Proves that committed value is in the allowed set without revealing which one.
|
|
143
|
+
* Uses ring signature-style construction.
|
|
144
|
+
*/
|
|
145
|
+
export declare function generateMembershipProof(value: string, allowedSet: string[]): {
|
|
146
|
+
proof: MembershipProof;
|
|
147
|
+
secret: string;
|
|
148
|
+
} | null;
|
|
149
|
+
/**
|
|
150
|
+
* Verify a membership proof
|
|
151
|
+
*/
|
|
152
|
+
export declare function verifyMembershipProof(proof: MembershipProof, allowedSet: string[]): ZKVerificationResult;
|
|
153
|
+
/**
|
|
154
|
+
* Generate a trust tier proof
|
|
155
|
+
*
|
|
156
|
+
* Proves agent is in a specific tier without revealing exact score.
|
|
157
|
+
*/
|
|
158
|
+
export declare function generateTrustTierProof(agentId: string, score: number, tier: string, validityDurationMs?: number): {
|
|
159
|
+
proof: TrustTierProof;
|
|
160
|
+
secret: PedersenCommitment;
|
|
161
|
+
} | null;
|
|
162
|
+
/**
|
|
163
|
+
* Verify a trust tier proof
|
|
164
|
+
*/
|
|
165
|
+
export declare function verifyTrustTierProof(proof: TrustTierProof): ZKVerificationResult;
|
|
166
|
+
/**
|
|
167
|
+
* ZK Proof Service configuration
|
|
168
|
+
*/
|
|
169
|
+
export interface ZKProofConfig {
|
|
170
|
+
/** Default proof validity duration in ms */
|
|
171
|
+
defaultValidityMs: number;
|
|
172
|
+
/** Enable proof caching */
|
|
173
|
+
enableCaching: boolean;
|
|
174
|
+
/** Maximum cached proofs */
|
|
175
|
+
maxCacheSize: number;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Zero-Knowledge Proof Service
|
|
179
|
+
*/
|
|
180
|
+
export declare class ZKProofService {
|
|
181
|
+
private config;
|
|
182
|
+
private proofCache;
|
|
183
|
+
constructor(config?: Partial<ZKProofConfig>);
|
|
184
|
+
/**
|
|
185
|
+
* Generate trust tier proof for an agent
|
|
186
|
+
*/
|
|
187
|
+
generateTierProof(agentId: string, score: number, tier: string): TrustTierProof | null;
|
|
188
|
+
/**
|
|
189
|
+
* Verify any ZK proof
|
|
190
|
+
*/
|
|
191
|
+
verify(proof: RangeProof | ThresholdProof | MembershipProof | TrustTierProof, context?: {
|
|
192
|
+
allowedSet?: string[];
|
|
193
|
+
}): ZKVerificationResult;
|
|
194
|
+
/**
|
|
195
|
+
* Get cached proof for agent
|
|
196
|
+
*/
|
|
197
|
+
getCachedProof(agentId: string, tier: string): TrustTierProof | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* Cache a proof
|
|
200
|
+
*/
|
|
201
|
+
private cacheProof;
|
|
202
|
+
/**
|
|
203
|
+
* Clear expired proofs from cache
|
|
204
|
+
*/
|
|
205
|
+
cleanupCache(): number;
|
|
206
|
+
/**
|
|
207
|
+
* Get statistics
|
|
208
|
+
*/
|
|
209
|
+
getStats(): {
|
|
210
|
+
cachedProofs: number;
|
|
211
|
+
cacheHitRate: number;
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Create a ZK proof service
|
|
216
|
+
*/
|
|
217
|
+
export declare function createZKProofService(config?: Partial<ZKProofConfig>): ZKProofService;
|
|
218
|
+
//# sourceMappingURL=zk-proofs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zk-proofs.d.ts","sourceRoot":"","sources":["../../src/proof/zk-proofs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAWH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,EAAE,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