@fluxpointstudios/orynq-sdk-midnight-prover 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/dist/linking/cardano-anchor-link.d.ts +250 -0
- package/dist/linking/cardano-anchor-link.d.ts.map +1 -0
- package/dist/linking/cardano-anchor-link.js +447 -0
- package/dist/linking/cardano-anchor-link.js.map +1 -0
- package/dist/linking/index.d.ts +33 -0
- package/dist/linking/index.d.ts.map +1 -0
- package/dist/linking/index.js +31 -0
- package/dist/linking/index.js.map +1 -0
- package/dist/linking/proof-publication.d.ts +217 -0
- package/dist/linking/proof-publication.d.ts.map +1 -0
- package/dist/linking/proof-publication.js +385 -0
- package/dist/linking/proof-publication.js.map +1 -0
- package/dist/midnight/index.d.ts +30 -0
- package/dist/midnight/index.d.ts.map +1 -0
- package/dist/midnight/index.js +27 -0
- package/dist/midnight/index.js.map +1 -0
- package/dist/midnight/proof-server-client.d.ts +236 -0
- package/dist/midnight/proof-server-client.d.ts.map +1 -0
- package/dist/midnight/proof-server-client.js +422 -0
- package/dist/midnight/proof-server-client.js.map +1 -0
- package/dist/midnight/public-inputs.d.ts +134 -0
- package/dist/midnight/public-inputs.d.ts.map +1 -0
- package/dist/midnight/public-inputs.js +338 -0
- package/dist/midnight/public-inputs.js.map +1 -0
- package/dist/midnight/witness-builder.d.ts +119 -0
- package/dist/midnight/witness-builder.d.ts.map +1 -0
- package/dist/midnight/witness-builder.js +238 -0
- package/dist/midnight/witness-builder.js.map +1 -0
- package/dist/proofs/hash-chain-proof.d.ts +171 -0
- package/dist/proofs/hash-chain-proof.d.ts.map +1 -0
- package/dist/proofs/hash-chain-proof.js +437 -0
- package/dist/proofs/hash-chain-proof.js.map +1 -0
- package/dist/proofs/index.d.ts +35 -0
- package/dist/proofs/index.d.ts.map +1 -0
- package/dist/proofs/index.js +34 -0
- package/dist/proofs/index.js.map +1 -0
- package/dist/proofs/policy-compliance-proof.d.ts +165 -0
- package/dist/proofs/policy-compliance-proof.d.ts.map +1 -0
- package/dist/proofs/policy-compliance-proof.js +514 -0
- package/dist/proofs/policy-compliance-proof.js.map +1 -0
- package/dist/proofs/selective-disclosure.d.ts +213 -0
- package/dist/proofs/selective-disclosure.d.ts.map +1 -0
- package/dist/proofs/selective-disclosure.js +629 -0
- package/dist/proofs/selective-disclosure.js.map +1 -0
- package/dist/prover-interface.d.ts +288 -0
- package/dist/prover-interface.d.ts.map +1 -0
- package/dist/prover-interface.js +114 -0
- package/dist/prover-interface.js.map +1 -0
- package/dist/prover.d.ts +163 -0
- package/dist/prover.d.ts.map +1 -0
- package/dist/prover.js +417 -0
- package/dist/prover.js.map +1 -0
- package/dist/types.d.ts +410 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +128 -0
- package/dist/types.js.map +1 -0
- package/package.json +59 -0
- package/src/__tests__/hash-chain-proof.test.ts +709 -0
- package/src/__tests__/midnight-prover.test.ts +716 -0
- package/src/__tests__/policy-compliance.test.ts +567 -0
- package/src/__tests__/proof-publication.test.ts +644 -0
- package/src/__tests__/selective-disclosure.test.ts +921 -0
- package/src/index.ts +260 -0
- package/src/linking/cardano-anchor-link.ts +682 -0
- package/src/linking/index.ts +58 -0
- package/src/linking/proof-publication.ts +557 -0
- package/src/midnight/index.ts +73 -0
- package/src/midnight/proof-server-client.ts +595 -0
- package/src/midnight/public-inputs.ts +590 -0
- package/src/midnight/witness-builder.ts +341 -0
- package/src/proofs/hash-chain-proof.ts +610 -0
- package/src/proofs/index.ts +77 -0
- package/src/proofs/policy-compliance-proof.ts +717 -0
- package/src/proofs/selective-disclosure.ts +839 -0
- package/src/prover-interface.ts +410 -0
- package/src/prover.ts +537 -0
- package/src/types.ts +551 -0
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Selective disclosure proof generation and verification.
|
|
3
|
+
*
|
|
4
|
+
* Location: packages/midnight-prover/src/proofs/selective-disclosure.ts
|
|
5
|
+
*
|
|
6
|
+
* Summary:
|
|
7
|
+
* This module implements the SelectiveDisclosureProver class which generates ZK proofs
|
|
8
|
+
* demonstrating that a specific span exists in a trace bundle without revealing other
|
|
9
|
+
* spans. It uses Merkle proofs for inclusion verification and supports optional
|
|
10
|
+
* disclosure of the span and event data.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* - Used by the MidnightProver to generate selective disclosure proofs
|
|
14
|
+
* - Integrates with process-trace Merkle tree utilities
|
|
15
|
+
* - Binds proofs to Cardano anchor transactions for cross-chain verification
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { SelectiveDisclosureProver } from './selective-disclosure.js';
|
|
20
|
+
*
|
|
21
|
+
* const prover = new SelectiveDisclosureProver();
|
|
22
|
+
*
|
|
23
|
+
* const proof = await prover.generateProof({
|
|
24
|
+
* bundle: traceBundle,
|
|
25
|
+
* spanId: 'span-123',
|
|
26
|
+
* merkleRoot: traceBundle.merkleRoot,
|
|
27
|
+
* cardanoAnchorTxHash: 'txhash...',
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const isValid = await prover.verifyProof(proof);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
import { sha256StringHex, canonicalize, } from "@fluxpointstudios/orynq-sdk-core/utils";
|
|
34
|
+
import { MidnightProverError, MidnightProverException, } from "../types.js";
|
|
35
|
+
/**
|
|
36
|
+
* Domain separation prefixes for selective disclosure proofs.
|
|
37
|
+
*/
|
|
38
|
+
const DISCLOSURE_DOMAIN_PREFIXES = {
|
|
39
|
+
proof: "poi-prover:disclosure:v1|",
|
|
40
|
+
witness: "poi-prover:disclosure-witness:v1|",
|
|
41
|
+
publicInput: "poi-prover:disclosure-input:v1|",
|
|
42
|
+
span: "poi-trace:span:v1|",
|
|
43
|
+
leaf: "poi-trace:leaf:v1|",
|
|
44
|
+
node: "poi-trace:node:v1|",
|
|
45
|
+
};
|
|
46
|
+
// =============================================================================
|
|
47
|
+
// MERKLE UTILITIES
|
|
48
|
+
// =============================================================================
|
|
49
|
+
/**
|
|
50
|
+
* Compute the hash for a span including its event hashes.
|
|
51
|
+
*
|
|
52
|
+
* The span hash is computed as:
|
|
53
|
+
* H("poi-trace:span:v1|" + canon(spanHeaderWithoutHash) + "|" + eventHashes joined by "|")
|
|
54
|
+
*
|
|
55
|
+
* @param span - The span to compute hash for
|
|
56
|
+
* @param eventHashes - Array of event hashes in sequence order
|
|
57
|
+
* @returns Promise resolving to the span hash as a hex string
|
|
58
|
+
*/
|
|
59
|
+
export async function computeSpanHash(span, eventHashes) {
|
|
60
|
+
// Extract span header (all fields except hash)
|
|
61
|
+
const spanHeader = {
|
|
62
|
+
id: span.id,
|
|
63
|
+
spanSeq: span.spanSeq,
|
|
64
|
+
name: span.name,
|
|
65
|
+
status: span.status,
|
|
66
|
+
visibility: span.visibility,
|
|
67
|
+
startedAt: span.startedAt,
|
|
68
|
+
eventIds: span.eventIds,
|
|
69
|
+
childSpanIds: span.childSpanIds,
|
|
70
|
+
};
|
|
71
|
+
// Include optional fields only if they exist
|
|
72
|
+
if (span.parentSpanId !== undefined) {
|
|
73
|
+
spanHeader.parentSpanId = span.parentSpanId;
|
|
74
|
+
}
|
|
75
|
+
if (span.endedAt !== undefined) {
|
|
76
|
+
spanHeader.endedAt = span.endedAt;
|
|
77
|
+
}
|
|
78
|
+
if (span.durationMs !== undefined) {
|
|
79
|
+
spanHeader.durationMs = span.durationMs;
|
|
80
|
+
}
|
|
81
|
+
if (span.metadata !== undefined) {
|
|
82
|
+
spanHeader.metadata = span.metadata;
|
|
83
|
+
}
|
|
84
|
+
// Canonicalize the span header
|
|
85
|
+
const canonicalHeader = canonicalize(spanHeader, { removeNulls: true });
|
|
86
|
+
// Build the hash input: prefix + canon(header) + "|" + eventHashes joined by "|"
|
|
87
|
+
let hashInput = DISCLOSURE_DOMAIN_PREFIXES.span + canonicalHeader;
|
|
88
|
+
// Append event hashes if any exist
|
|
89
|
+
if (eventHashes.length > 0) {
|
|
90
|
+
hashInput += "|" + eventHashes.join("|");
|
|
91
|
+
}
|
|
92
|
+
return sha256StringHex(hashInput);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Compute the leaf hash for a span.
|
|
96
|
+
*
|
|
97
|
+
* The leaf hash is computed as: H("poi-trace:leaf:v1|" + spanHash)
|
|
98
|
+
*
|
|
99
|
+
* @param spanHash - The span hash
|
|
100
|
+
* @returns Promise resolving to the leaf hash
|
|
101
|
+
*/
|
|
102
|
+
export async function computeLeafHash(spanHash) {
|
|
103
|
+
return sha256StringHex(DISCLOSURE_DOMAIN_PREFIXES.leaf + spanHash);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Compute the parent node hash from two children.
|
|
107
|
+
*
|
|
108
|
+
* The node hash is computed as: H("poi-trace:node:v1|" + left + "|" + right)
|
|
109
|
+
*
|
|
110
|
+
* @param left - Left child hash
|
|
111
|
+
* @param right - Right child hash
|
|
112
|
+
* @returns Promise resolving to the parent node hash
|
|
113
|
+
*/
|
|
114
|
+
export async function computeNodeHash(left, right) {
|
|
115
|
+
return sha256StringHex(DISCLOSURE_DOMAIN_PREFIXES.node + left + "|" + right);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Generate a Merkle inclusion proof for a span in a bundle.
|
|
119
|
+
*
|
|
120
|
+
* @param bundle - The trace bundle containing the span
|
|
121
|
+
* @param spanId - ID of the span to prove inclusion for
|
|
122
|
+
* @returns MerkleInclusionResult with proof and span data
|
|
123
|
+
* @throws MidnightProverException if span not found
|
|
124
|
+
*/
|
|
125
|
+
export async function generateMerkleInclusionProof(bundle, spanId) {
|
|
126
|
+
const { privateRun } = bundle;
|
|
127
|
+
const spans = privateRun.spans;
|
|
128
|
+
const events = privateRun.events;
|
|
129
|
+
// Find the span
|
|
130
|
+
const span = spans.find((s) => s.id === spanId);
|
|
131
|
+
if (!span) {
|
|
132
|
+
throw new MidnightProverException(MidnightProverError.SPAN_NOT_FOUND, `Span not found: ${spanId}`);
|
|
133
|
+
}
|
|
134
|
+
// Create event map for quick lookup
|
|
135
|
+
const eventMap = new Map();
|
|
136
|
+
for (const event of events) {
|
|
137
|
+
eventMap.set(event.id, event);
|
|
138
|
+
}
|
|
139
|
+
// Get events for this span in seq order
|
|
140
|
+
const spanEvents = span.eventIds
|
|
141
|
+
.map((id) => eventMap.get(id))
|
|
142
|
+
.filter((e) => e !== undefined)
|
|
143
|
+
.sort((a, b) => a.seq - b.seq);
|
|
144
|
+
const eventHashes = spanEvents.map((e) => e.hash ?? "");
|
|
145
|
+
// Compute span hash
|
|
146
|
+
const spanHash = await computeSpanHash(span, eventHashes);
|
|
147
|
+
// Sort spans by spanSeq for consistent ordering
|
|
148
|
+
const sortedSpans = [...spans].sort((a, b) => a.spanSeq - b.spanSeq);
|
|
149
|
+
const spanIndex = sortedSpans.findIndex((s) => s.id === spanId);
|
|
150
|
+
if (spanIndex === -1) {
|
|
151
|
+
throw new MidnightProverException(MidnightProverError.SPAN_NOT_FOUND, `Span not found in sorted spans: ${spanId}`);
|
|
152
|
+
}
|
|
153
|
+
// Build leaf hashes for all spans
|
|
154
|
+
const leafHashes = [];
|
|
155
|
+
for (const s of sortedSpans) {
|
|
156
|
+
const sEvents = s.eventIds
|
|
157
|
+
.map((id) => eventMap.get(id))
|
|
158
|
+
.filter((e) => e !== undefined)
|
|
159
|
+
.sort((a, b) => a.seq - b.seq);
|
|
160
|
+
const sEventHashes = sEvents.map((e) => e.hash ?? "");
|
|
161
|
+
const sSpanHash = await computeSpanHash(s, sEventHashes);
|
|
162
|
+
const sLeafHash = await computeLeafHash(sSpanHash);
|
|
163
|
+
leafHashes.push(sLeafHash);
|
|
164
|
+
}
|
|
165
|
+
// Compute the leaf hash for the target span
|
|
166
|
+
const leafHash = await computeLeafHash(spanHash);
|
|
167
|
+
// Generate Merkle proof (sibling path from leaf to root)
|
|
168
|
+
const siblings = [];
|
|
169
|
+
if (leafHashes.length > 1) {
|
|
170
|
+
let currentLevel = [...leafHashes];
|
|
171
|
+
let currentIndex = spanIndex;
|
|
172
|
+
while (currentLevel.length > 1) {
|
|
173
|
+
const isLeftChild = currentIndex % 2 === 0;
|
|
174
|
+
const siblingIndex = isLeftChild ? currentIndex + 1 : currentIndex - 1;
|
|
175
|
+
// Handle odd-leaf case: if no sibling exists, duplicate current
|
|
176
|
+
let siblingHash;
|
|
177
|
+
if (siblingIndex >= currentLevel.length) {
|
|
178
|
+
const currentHash = currentLevel[currentIndex];
|
|
179
|
+
if (!currentHash) {
|
|
180
|
+
throw new MidnightProverException(MidnightProverError.PROOF_GENERATION_FAILED, "Unexpected undefined hash at current index");
|
|
181
|
+
}
|
|
182
|
+
siblingHash = currentHash;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
const hash = currentLevel[siblingIndex];
|
|
186
|
+
if (!hash) {
|
|
187
|
+
throw new MidnightProverException(MidnightProverError.PROOF_GENERATION_FAILED, "Unexpected undefined hash at sibling index");
|
|
188
|
+
}
|
|
189
|
+
siblingHash = hash;
|
|
190
|
+
}
|
|
191
|
+
siblings.push({
|
|
192
|
+
hash: siblingHash,
|
|
193
|
+
position: isLeftChild ? "right" : "left",
|
|
194
|
+
});
|
|
195
|
+
// Build next level
|
|
196
|
+
const nextLevel = [];
|
|
197
|
+
for (let i = 0; i < currentLevel.length; i += 2) {
|
|
198
|
+
const left = currentLevel[i] ?? "";
|
|
199
|
+
const right = i + 1 < currentLevel.length ? (currentLevel[i + 1] ?? left) : left;
|
|
200
|
+
const parentHash = await computeNodeHash(left, right);
|
|
201
|
+
nextLevel.push(parentHash);
|
|
202
|
+
}
|
|
203
|
+
currentLevel = nextLevel;
|
|
204
|
+
currentIndex = Math.floor(currentIndex / 2);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// Compute root hash for verification
|
|
208
|
+
const rootHash = leafHashes.length === 1 ? leafHashes[0] : await computeMerkleRoot(leafHashes);
|
|
209
|
+
if (!rootHash) {
|
|
210
|
+
throw new MidnightProverException(MidnightProverError.PROOF_GENERATION_FAILED, "Failed to compute Merkle root");
|
|
211
|
+
}
|
|
212
|
+
const merkleProof = {
|
|
213
|
+
leafHash,
|
|
214
|
+
leafIndex: spanIndex,
|
|
215
|
+
siblings,
|
|
216
|
+
rootHash,
|
|
217
|
+
};
|
|
218
|
+
return {
|
|
219
|
+
spanHash,
|
|
220
|
+
leafHash,
|
|
221
|
+
merkleProof,
|
|
222
|
+
span,
|
|
223
|
+
events: spanEvents,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Compute the Merkle root from leaf hashes.
|
|
228
|
+
*
|
|
229
|
+
* @param leafHashes - Array of leaf hashes
|
|
230
|
+
* @returns Promise resolving to the Merkle root hash
|
|
231
|
+
*/
|
|
232
|
+
export async function computeMerkleRoot(leafHashes) {
|
|
233
|
+
if (leafHashes.length === 0) {
|
|
234
|
+
return "";
|
|
235
|
+
}
|
|
236
|
+
if (leafHashes.length === 1) {
|
|
237
|
+
return leafHashes[0] ?? "";
|
|
238
|
+
}
|
|
239
|
+
let currentLevel = [...leafHashes];
|
|
240
|
+
while (currentLevel.length > 1) {
|
|
241
|
+
const nextLevel = [];
|
|
242
|
+
for (let i = 0; i < currentLevel.length; i += 2) {
|
|
243
|
+
const left = currentLevel[i] ?? "";
|
|
244
|
+
const right = i + 1 < currentLevel.length ? (currentLevel[i + 1] ?? left) : left;
|
|
245
|
+
const parentHash = await computeNodeHash(left, right);
|
|
246
|
+
nextLevel.push(parentHash);
|
|
247
|
+
}
|
|
248
|
+
currentLevel = nextLevel;
|
|
249
|
+
}
|
|
250
|
+
return currentLevel[0] ?? "";
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Verify a Merkle inclusion proof.
|
|
254
|
+
*
|
|
255
|
+
* @param proof - The Merkle proof to verify
|
|
256
|
+
* @returns Promise resolving to true if valid
|
|
257
|
+
*/
|
|
258
|
+
export async function verifyMerkleProof(proof) {
|
|
259
|
+
let currentHash = proof.leafHash;
|
|
260
|
+
for (const sibling of proof.siblings) {
|
|
261
|
+
let left;
|
|
262
|
+
let right;
|
|
263
|
+
if (sibling.position === "left") {
|
|
264
|
+
left = sibling.hash;
|
|
265
|
+
right = currentHash;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
left = currentHash;
|
|
269
|
+
right = sibling.hash;
|
|
270
|
+
}
|
|
271
|
+
currentHash = await computeNodeHash(left, right);
|
|
272
|
+
}
|
|
273
|
+
return currentHash === proof.rootHash;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Verify span inclusion using the proof and span data.
|
|
277
|
+
*
|
|
278
|
+
* @param proof - The Merkle proof
|
|
279
|
+
* @param span - The span data
|
|
280
|
+
* @param events - The events belonging to the span
|
|
281
|
+
* @returns Promise resolving to true if span is validly included
|
|
282
|
+
*/
|
|
283
|
+
export async function verifySpanInclusion(proof, span, events) {
|
|
284
|
+
// Sort events by seq for deterministic order
|
|
285
|
+
const sortedEvents = [...events].sort((a, b) => a.seq - b.seq);
|
|
286
|
+
const eventHashes = sortedEvents.map((e) => e.hash ?? "");
|
|
287
|
+
// Recompute span hash
|
|
288
|
+
const spanHash = await computeSpanHash(span, eventHashes);
|
|
289
|
+
// Compute expected leaf hash
|
|
290
|
+
const computedLeafHash = await computeLeafHash(spanHash);
|
|
291
|
+
// Verify leaf hash matches
|
|
292
|
+
if (computedLeafHash !== proof.leafHash) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
// Verify Merkle proof
|
|
296
|
+
return verifyMerkleProof(proof);
|
|
297
|
+
}
|
|
298
|
+
// =============================================================================
|
|
299
|
+
// SELECTIVE DISCLOSURE PROVER
|
|
300
|
+
// =============================================================================
|
|
301
|
+
/**
|
|
302
|
+
* SelectiveDisclosureProver generates and verifies ZK proofs of span membership.
|
|
303
|
+
*
|
|
304
|
+
* This prover creates a proof that a specific span exists in a trace bundle
|
|
305
|
+
* without revealing other spans. The proof uses Merkle tree inclusion proofs
|
|
306
|
+
* and optionally includes the disclosed span and event data.
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```typescript
|
|
310
|
+
* const prover = new SelectiveDisclosureProver();
|
|
311
|
+
* const proof = await prover.generateProof(input);
|
|
312
|
+
*
|
|
313
|
+
* // Proof includes optional span data for verification
|
|
314
|
+
* console.log(proof.disclosedSpan?.name); // e.g., "inference"
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
export class SelectiveDisclosureProver {
|
|
318
|
+
debug;
|
|
319
|
+
includeSpanData;
|
|
320
|
+
includeEventData;
|
|
321
|
+
/**
|
|
322
|
+
* Create a new SelectiveDisclosureProver instance.
|
|
323
|
+
*
|
|
324
|
+
* @param options - Configuration options
|
|
325
|
+
*/
|
|
326
|
+
constructor(options = {}) {
|
|
327
|
+
this.debug = options.debug ?? false;
|
|
328
|
+
this.includeSpanData = options.includeSpanData ?? true;
|
|
329
|
+
this.includeEventData = options.includeEventData ?? true;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Generate a selective disclosure proof.
|
|
333
|
+
*
|
|
334
|
+
* This method creates a ZK proof that a specific span exists in the
|
|
335
|
+
* trace bundle's Merkle tree. The proof binds to the Cardano anchor
|
|
336
|
+
* transaction for cross-chain verification.
|
|
337
|
+
*
|
|
338
|
+
* @param input - Selective disclosure input
|
|
339
|
+
* @returns Promise resolving to the disclosure proof
|
|
340
|
+
* @throws MidnightProverException on validation or generation failure
|
|
341
|
+
*/
|
|
342
|
+
async generateProof(input) {
|
|
343
|
+
const startTime = performance.now();
|
|
344
|
+
// Validate input
|
|
345
|
+
this.validateInput(input);
|
|
346
|
+
if (this.debug) {
|
|
347
|
+
console.log("[SelectiveDisclosureProver] Generating proof for span:", input.spanId);
|
|
348
|
+
}
|
|
349
|
+
// Generate Merkle inclusion proof
|
|
350
|
+
const inclusionResult = await generateMerkleInclusionProof(input.bundle, input.spanId);
|
|
351
|
+
// Verify the computed root matches the expected root
|
|
352
|
+
if (inclusionResult.merkleProof.rootHash !== input.merkleRoot) {
|
|
353
|
+
throw new MidnightProverException(MidnightProverError.HASH_MISMATCH, `Computed Merkle root ${inclusionResult.merkleProof.rootHash} does not match expected ${input.merkleRoot}`);
|
|
354
|
+
}
|
|
355
|
+
// Generate proof bytes (mock implementation)
|
|
356
|
+
const proofBytes = await this.generateProofBytes(input, inclusionResult);
|
|
357
|
+
const endTime = performance.now();
|
|
358
|
+
const provingTimeMs = Math.round(endTime - startTime);
|
|
359
|
+
// Construct public inputs
|
|
360
|
+
const publicInputs = {
|
|
361
|
+
spanHash: inclusionResult.spanHash,
|
|
362
|
+
merkleRoot: input.merkleRoot,
|
|
363
|
+
cardanoAnchorTxHash: input.cardanoAnchorTxHash,
|
|
364
|
+
};
|
|
365
|
+
// Generate proof ID
|
|
366
|
+
const proofId = await this.generateProofId(publicInputs);
|
|
367
|
+
const proof = {
|
|
368
|
+
proofType: "selective-disclosure",
|
|
369
|
+
proofId,
|
|
370
|
+
proof: proofBytes,
|
|
371
|
+
createdAt: new Date().toISOString(),
|
|
372
|
+
provingTimeMs,
|
|
373
|
+
proofSizeBytes: proofBytes.length,
|
|
374
|
+
publicInputs,
|
|
375
|
+
disclosedSpan: this.includeSpanData ? inclusionResult.span : undefined,
|
|
376
|
+
disclosedEvents: this.includeEventData ? inclusionResult.events : undefined,
|
|
377
|
+
};
|
|
378
|
+
if (this.debug) {
|
|
379
|
+
console.log("[SelectiveDisclosureProver] Proof generated:", {
|
|
380
|
+
proofId,
|
|
381
|
+
spanHash: inclusionResult.spanHash,
|
|
382
|
+
leafIndex: inclusionResult.merkleProof.leafIndex,
|
|
383
|
+
siblingCount: inclusionResult.merkleProof.siblings.length,
|
|
384
|
+
provingTimeMs,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
return proof;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Verify a selective disclosure proof.
|
|
391
|
+
*
|
|
392
|
+
* This method verifies the cryptographic validity of the proof and
|
|
393
|
+
* optionally verifies that disclosed span data matches the proof.
|
|
394
|
+
*
|
|
395
|
+
* @param proof - The disclosure proof to verify
|
|
396
|
+
* @returns Promise resolving to true if valid
|
|
397
|
+
*/
|
|
398
|
+
async verifyProof(proof) {
|
|
399
|
+
try {
|
|
400
|
+
// Validate proof structure
|
|
401
|
+
if (proof.proofType !== "selective-disclosure") {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
if (!proof.proof || proof.proof.length === 0) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
// Validate public inputs
|
|
408
|
+
const { publicInputs } = proof;
|
|
409
|
+
if (!publicInputs.spanHash || publicInputs.spanHash.length !== 64) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
if (!publicInputs.merkleRoot || publicInputs.merkleRoot.length !== 64) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
if (!publicInputs.cardanoAnchorTxHash || publicInputs.cardanoAnchorTxHash.length === 0) {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
// Verify proof ID matches public inputs
|
|
419
|
+
const expectedProofId = await this.generateProofId(publicInputs);
|
|
420
|
+
if (proof.proofId !== expectedProofId) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
// Extract Merkle proof from proof bytes and verify
|
|
424
|
+
const merkleProofValid = await this.verifyProofBytes(proof.proof, publicInputs);
|
|
425
|
+
if (!merkleProofValid) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
// If disclosed span data is provided, verify it matches the span hash
|
|
429
|
+
if (proof.disclosedSpan && proof.disclosedEvents) {
|
|
430
|
+
// Note: This simplified verification doesn't check full Merkle path
|
|
431
|
+
// In production, we'd extract and verify the full Merkle proof
|
|
432
|
+
const sortedEvents = [...proof.disclosedEvents].sort((a, b) => a.seq - b.seq);
|
|
433
|
+
const eventHashes = sortedEvents.map((e) => e.hash ?? "");
|
|
434
|
+
const recomputedSpanHash = await computeSpanHash(proof.disclosedSpan, eventHashes);
|
|
435
|
+
if (recomputedSpanHash !== publicInputs.spanHash) {
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
catch (error) {
|
|
442
|
+
if (this.debug) {
|
|
443
|
+
console.error("[SelectiveDisclosureProver] Verification error:", error);
|
|
444
|
+
}
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Generate a proof without disclosure (membership proof only).
|
|
450
|
+
*
|
|
451
|
+
* This creates a proof that demonstrates span existence without
|
|
452
|
+
* revealing any span or event data.
|
|
453
|
+
*
|
|
454
|
+
* @param input - Selective disclosure input
|
|
455
|
+
* @returns Promise resolving to the disclosure proof without span data
|
|
456
|
+
*/
|
|
457
|
+
async generateMembershipProof(input) {
|
|
458
|
+
// Create a new prover instance with disclosure disabled
|
|
459
|
+
const membershipProver = new SelectiveDisclosureProver({
|
|
460
|
+
debug: this.debug,
|
|
461
|
+
includeSpanData: false,
|
|
462
|
+
includeEventData: false,
|
|
463
|
+
});
|
|
464
|
+
return membershipProver.generateProof(input);
|
|
465
|
+
}
|
|
466
|
+
// ===========================================================================
|
|
467
|
+
// PRIVATE METHODS
|
|
468
|
+
// ===========================================================================
|
|
469
|
+
/**
|
|
470
|
+
* Validate disclosure input.
|
|
471
|
+
*/
|
|
472
|
+
validateInput(input) {
|
|
473
|
+
if (!input.bundle) {
|
|
474
|
+
throw new MidnightProverException(MidnightProverError.MISSING_REQUIRED_FIELD, "Trace bundle is required");
|
|
475
|
+
}
|
|
476
|
+
if (!input.spanId || input.spanId.length === 0) {
|
|
477
|
+
throw new MidnightProverException(MidnightProverError.MISSING_REQUIRED_FIELD, "Span ID is required");
|
|
478
|
+
}
|
|
479
|
+
if (!input.merkleRoot || input.merkleRoot.length !== 64) {
|
|
480
|
+
throw new MidnightProverException(MidnightProverError.INVALID_INPUT, "Invalid Merkle root: must be 64-character hex string");
|
|
481
|
+
}
|
|
482
|
+
if (!input.cardanoAnchorTxHash || input.cardanoAnchorTxHash.length === 0) {
|
|
483
|
+
throw new MidnightProverException(MidnightProverError.MISSING_REQUIRED_FIELD, "Cardano anchor transaction hash is required");
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Generate mock proof bytes.
|
|
488
|
+
* In a real implementation, this would call the Midnight proof server.
|
|
489
|
+
*/
|
|
490
|
+
async generateProofBytes(input, inclusion) {
|
|
491
|
+
// Construct witness data (private inputs)
|
|
492
|
+
const witnessData = canonicalize({
|
|
493
|
+
spanId: input.spanId,
|
|
494
|
+
spanHash: inclusion.spanHash,
|
|
495
|
+
leafHash: inclusion.leafHash,
|
|
496
|
+
leafIndex: inclusion.merkleProof.leafIndex,
|
|
497
|
+
siblings: inclusion.merkleProof.siblings,
|
|
498
|
+
merkleRoot: input.merkleRoot,
|
|
499
|
+
cardanoAnchorTxHash: input.cardanoAnchorTxHash,
|
|
500
|
+
});
|
|
501
|
+
// Generate witness hash
|
|
502
|
+
const witnessHash = await sha256StringHex(DISCLOSURE_DOMAIN_PREFIXES.witness + witnessData);
|
|
503
|
+
// Construct public input commitment
|
|
504
|
+
const publicInputData = canonicalize({
|
|
505
|
+
spanHash: inclusion.spanHash,
|
|
506
|
+
merkleRoot: input.merkleRoot,
|
|
507
|
+
cardanoAnchorTxHash: input.cardanoAnchorTxHash,
|
|
508
|
+
});
|
|
509
|
+
const publicInputHash = await sha256StringHex(DISCLOSURE_DOMAIN_PREFIXES.publicInput + publicInputData);
|
|
510
|
+
// Generate mock proof: commitment to witness + public inputs
|
|
511
|
+
const proofCommitment = await sha256StringHex(DISCLOSURE_DOMAIN_PREFIXES.proof + witnessHash + "|" + publicInputHash);
|
|
512
|
+
// Encode Merkle proof siblings for inclusion in proof bytes
|
|
513
|
+
const siblingData = inclusion.merkleProof.siblings.map((s) => ({
|
|
514
|
+
hash: s.hash,
|
|
515
|
+
pos: s.position === "left" ? 0 : 1,
|
|
516
|
+
}));
|
|
517
|
+
const siblingJson = JSON.stringify(siblingData);
|
|
518
|
+
const siblingBytes = new TextEncoder().encode(siblingJson);
|
|
519
|
+
// Construct proof bytes:
|
|
520
|
+
// - version (1 byte)
|
|
521
|
+
// - commitment (32 bytes)
|
|
522
|
+
// - witness hash (32 bytes)
|
|
523
|
+
// - sibling count (2 bytes)
|
|
524
|
+
// - sibling data (variable)
|
|
525
|
+
const proofBytes = new Uint8Array(67 + siblingBytes.length);
|
|
526
|
+
proofBytes[0] = 0x01; // Version 1
|
|
527
|
+
// Copy commitment hash
|
|
528
|
+
const commitmentBytes = this.hexToBytes(proofCommitment);
|
|
529
|
+
proofBytes.set(commitmentBytes, 1);
|
|
530
|
+
// Copy witness hash
|
|
531
|
+
const witnessBytes = this.hexToBytes(witnessHash);
|
|
532
|
+
proofBytes.set(witnessBytes, 33);
|
|
533
|
+
// Write sibling count (big-endian)
|
|
534
|
+
const siblingCount = inclusion.merkleProof.siblings.length;
|
|
535
|
+
proofBytes[65] = (siblingCount >> 8) & 0xff;
|
|
536
|
+
proofBytes[66] = siblingCount & 0xff;
|
|
537
|
+
// Copy sibling data
|
|
538
|
+
proofBytes.set(siblingBytes, 67);
|
|
539
|
+
return proofBytes;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Verify mock proof bytes.
|
|
543
|
+
*/
|
|
544
|
+
async verifyProofBytes(proofBytes, publicInputs) {
|
|
545
|
+
// Check minimum proof size
|
|
546
|
+
if (proofBytes.length < 67) {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
// Check version byte
|
|
550
|
+
if (proofBytes[0] !== 0x01) {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
// Extract and verify commitment is non-zero
|
|
554
|
+
const commitmentBytes = proofBytes.slice(1, 33);
|
|
555
|
+
const witnessHashBytes = proofBytes.slice(33, 65);
|
|
556
|
+
const commitmentNonZero = commitmentBytes.some((b) => b !== 0);
|
|
557
|
+
const witnessNonZero = witnessHashBytes.some((b) => b !== 0);
|
|
558
|
+
if (!commitmentNonZero || !witnessNonZero) {
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
// Extract sibling count
|
|
562
|
+
const siblingCount = (proofBytes[65] << 8) | proofBytes[66];
|
|
563
|
+
// Extract and parse sibling data if present
|
|
564
|
+
if (siblingCount > 0 && proofBytes.length > 67) {
|
|
565
|
+
try {
|
|
566
|
+
const siblingJson = new TextDecoder().decode(proofBytes.slice(67));
|
|
567
|
+
const siblings = JSON.parse(siblingJson);
|
|
568
|
+
if (siblings.length !== siblingCount) {
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
// Reconstruct Merkle proof and verify
|
|
572
|
+
const merkleProof = {
|
|
573
|
+
leafHash: await computeLeafHash(publicInputs.spanHash),
|
|
574
|
+
leafIndex: 0, // Not needed for verification
|
|
575
|
+
siblings: siblings.map((s) => ({
|
|
576
|
+
hash: s.hash,
|
|
577
|
+
position: s.pos === 0 ? "left" : "right",
|
|
578
|
+
})),
|
|
579
|
+
rootHash: publicInputs.merkleRoot,
|
|
580
|
+
};
|
|
581
|
+
return verifyMerkleProof(merkleProof);
|
|
582
|
+
}
|
|
583
|
+
catch {
|
|
584
|
+
// JSON parse error or other issue
|
|
585
|
+
return false;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
// For single-leaf trees (no siblings), verify leaf hash equals root
|
|
589
|
+
if (siblingCount === 0) {
|
|
590
|
+
const leafHash = await computeLeafHash(publicInputs.spanHash);
|
|
591
|
+
return leafHash === publicInputs.merkleRoot;
|
|
592
|
+
}
|
|
593
|
+
return true;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Generate proof ID from public inputs.
|
|
597
|
+
*/
|
|
598
|
+
async generateProofId(publicInputs) {
|
|
599
|
+
const data = canonicalize({
|
|
600
|
+
type: "selective-disclosure",
|
|
601
|
+
...publicInputs,
|
|
602
|
+
});
|
|
603
|
+
const hash = await sha256StringHex(data);
|
|
604
|
+
return `disclosure-proof-${hash.slice(0, 16)}`;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Convert hex string to bytes.
|
|
608
|
+
*/
|
|
609
|
+
hexToBytes(hex) {
|
|
610
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
611
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
612
|
+
bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
|
|
613
|
+
}
|
|
614
|
+
return bytes;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
// =============================================================================
|
|
618
|
+
// FACTORY FUNCTION
|
|
619
|
+
// =============================================================================
|
|
620
|
+
/**
|
|
621
|
+
* Create a new SelectiveDisclosureProver instance.
|
|
622
|
+
*
|
|
623
|
+
* @param options - Configuration options
|
|
624
|
+
* @returns New prover instance
|
|
625
|
+
*/
|
|
626
|
+
export function createSelectiveDisclosureProver(options) {
|
|
627
|
+
return new SelectiveDisclosureProver(options);
|
|
628
|
+
}
|
|
629
|
+
//# sourceMappingURL=selective-disclosure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selective-disclosure.js","sourceRoot":"","sources":["../../src/proofs/selective-disclosure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EACL,eAAe,EACf,YAAY,GACb,MAAM,wCAAwC,CAAC;AAehD,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAuCrB;;GAEG;AACH,MAAM,0BAA0B,GAAG;IACjC,KAAK,EAAE,2BAA2B;IAClC,OAAO,EAAE,mCAAmC;IAC5C,WAAW,EAA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