@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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +78 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +89 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/linking/cardano-anchor-link.d.ts +250 -0
  7. package/dist/linking/cardano-anchor-link.d.ts.map +1 -0
  8. package/dist/linking/cardano-anchor-link.js +447 -0
  9. package/dist/linking/cardano-anchor-link.js.map +1 -0
  10. package/dist/linking/index.d.ts +33 -0
  11. package/dist/linking/index.d.ts.map +1 -0
  12. package/dist/linking/index.js +31 -0
  13. package/dist/linking/index.js.map +1 -0
  14. package/dist/linking/proof-publication.d.ts +217 -0
  15. package/dist/linking/proof-publication.d.ts.map +1 -0
  16. package/dist/linking/proof-publication.js +385 -0
  17. package/dist/linking/proof-publication.js.map +1 -0
  18. package/dist/midnight/index.d.ts +30 -0
  19. package/dist/midnight/index.d.ts.map +1 -0
  20. package/dist/midnight/index.js +27 -0
  21. package/dist/midnight/index.js.map +1 -0
  22. package/dist/midnight/proof-server-client.d.ts +236 -0
  23. package/dist/midnight/proof-server-client.d.ts.map +1 -0
  24. package/dist/midnight/proof-server-client.js +422 -0
  25. package/dist/midnight/proof-server-client.js.map +1 -0
  26. package/dist/midnight/public-inputs.d.ts +134 -0
  27. package/dist/midnight/public-inputs.d.ts.map +1 -0
  28. package/dist/midnight/public-inputs.js +338 -0
  29. package/dist/midnight/public-inputs.js.map +1 -0
  30. package/dist/midnight/witness-builder.d.ts +119 -0
  31. package/dist/midnight/witness-builder.d.ts.map +1 -0
  32. package/dist/midnight/witness-builder.js +238 -0
  33. package/dist/midnight/witness-builder.js.map +1 -0
  34. package/dist/proofs/hash-chain-proof.d.ts +171 -0
  35. package/dist/proofs/hash-chain-proof.d.ts.map +1 -0
  36. package/dist/proofs/hash-chain-proof.js +437 -0
  37. package/dist/proofs/hash-chain-proof.js.map +1 -0
  38. package/dist/proofs/index.d.ts +35 -0
  39. package/dist/proofs/index.d.ts.map +1 -0
  40. package/dist/proofs/index.js +34 -0
  41. package/dist/proofs/index.js.map +1 -0
  42. package/dist/proofs/policy-compliance-proof.d.ts +165 -0
  43. package/dist/proofs/policy-compliance-proof.d.ts.map +1 -0
  44. package/dist/proofs/policy-compliance-proof.js +514 -0
  45. package/dist/proofs/policy-compliance-proof.js.map +1 -0
  46. package/dist/proofs/selective-disclosure.d.ts +213 -0
  47. package/dist/proofs/selective-disclosure.d.ts.map +1 -0
  48. package/dist/proofs/selective-disclosure.js +629 -0
  49. package/dist/proofs/selective-disclosure.js.map +1 -0
  50. package/dist/prover-interface.d.ts +288 -0
  51. package/dist/prover-interface.d.ts.map +1 -0
  52. package/dist/prover-interface.js +114 -0
  53. package/dist/prover-interface.js.map +1 -0
  54. package/dist/prover.d.ts +163 -0
  55. package/dist/prover.d.ts.map +1 -0
  56. package/dist/prover.js +417 -0
  57. package/dist/prover.js.map +1 -0
  58. package/dist/types.d.ts +410 -0
  59. package/dist/types.d.ts.map +1 -0
  60. package/dist/types.js +128 -0
  61. package/dist/types.js.map +1 -0
  62. package/package.json +59 -0
  63. package/src/__tests__/hash-chain-proof.test.ts +709 -0
  64. package/src/__tests__/midnight-prover.test.ts +716 -0
  65. package/src/__tests__/policy-compliance.test.ts +567 -0
  66. package/src/__tests__/proof-publication.test.ts +644 -0
  67. package/src/__tests__/selective-disclosure.test.ts +921 -0
  68. package/src/index.ts +260 -0
  69. package/src/linking/cardano-anchor-link.ts +682 -0
  70. package/src/linking/index.ts +58 -0
  71. package/src/linking/proof-publication.ts +557 -0
  72. package/src/midnight/index.ts +73 -0
  73. package/src/midnight/proof-server-client.ts +595 -0
  74. package/src/midnight/public-inputs.ts +590 -0
  75. package/src/midnight/witness-builder.ts +341 -0
  76. package/src/proofs/hash-chain-proof.ts +610 -0
  77. package/src/proofs/index.ts +77 -0
  78. package/src/proofs/policy-compliance-proof.ts +717 -0
  79. package/src/proofs/selective-disclosure.ts +839 -0
  80. package/src/prover-interface.ts +410 -0
  81. package/src/prover.ts +537 -0
  82. package/src/types.ts +551 -0
package/src/types.ts ADDED
@@ -0,0 +1,551 @@
1
+ /**
2
+ * @fileoverview Type definitions for the poi-midnight-prover package.
3
+ *
4
+ * Location: packages/midnight-prover/src/types.ts
5
+ *
6
+ * Summary:
7
+ * This file contains all type definitions for ZK proof generation using the Midnight network.
8
+ * It defines proof types, input/output structures for various proof circuits, configuration
9
+ * options, and error handling.
10
+ *
11
+ * Usage:
12
+ * Types are imported by the prover-interface.ts and will be used by proof generation
13
+ * implementations in the proofs/ directory. These types integrate with process-trace
14
+ * (TraceEvent, TraceBundle) and attestor (AttestationBundle, VerifierPolicy) packages.
15
+ *
16
+ * Key concepts:
17
+ * - ProofType: Discriminator for different ZK proof circuits
18
+ * - HashChainProof: Proves trace hash chain validity
19
+ * - PolicyProof: Proves content compliance without revealing content
20
+ * - AttestationProof: Proves valid TEE attestation
21
+ * - DisclosureProof: Selective disclosure of spans without revealing others
22
+ * - InferenceProof: Optional zkML proof for model inference correctness
23
+ */
24
+
25
+ import type { TraceEvent, TraceSpan, TraceBundle } from "@fluxpointstudios/orynq-sdk-process-trace";
26
+ import type { AttestationBundle, VerifierPolicy, TeeType } from "@fluxpointstudios/orynq-sdk-attestor";
27
+
28
+ // =============================================================================
29
+ // PROOF TYPES
30
+ // =============================================================================
31
+
32
+ /**
33
+ * Discriminator for different ZK proof types.
34
+ * Each type corresponds to a specific Compact circuit.
35
+ */
36
+ export type ProofType =
37
+ | "hash-chain" // Trace hash chain is valid
38
+ | "policy-compliance" // Content passed policy Y
39
+ | "attestation-valid" // TEE attestation is valid
40
+ | "selective-disclosure" // Span exists without reveal
41
+ | "zkml-inference"; // Output correct for input (expensive)
42
+
43
+ // =============================================================================
44
+ // BASE PROOF INTERFACE
45
+ // =============================================================================
46
+
47
+ /**
48
+ * Base interface for all ZK proofs.
49
+ * Contains common fields shared by all proof types.
50
+ *
51
+ * @property proofType - Discriminator for proof kind
52
+ * @property proofId - Unique identifier for this proof
53
+ * @property proof - Serialized proof bytes (Compact format)
54
+ * @property createdAt - ISO 8601 timestamp of proof generation
55
+ * @property provingTimeMs - Time taken to generate the proof
56
+ * @property proofSizeBytes - Size of the proof in bytes
57
+ */
58
+ export interface Proof {
59
+ proofType: ProofType;
60
+ proofId: string;
61
+ proof: Uint8Array;
62
+ createdAt: string;
63
+ provingTimeMs: number;
64
+ proofSizeBytes: number;
65
+ }
66
+
67
+ // =============================================================================
68
+ // HASH CHAIN PROOF
69
+ // =============================================================================
70
+
71
+ /**
72
+ * Input for hash chain validity proof.
73
+ * Proves that a sequence of events produces the expected rolling hash.
74
+ *
75
+ * @property events - The trace events (private witness)
76
+ * @property genesisHash - Initial hash state (usually zeros)
77
+ * @property expectedRootHash - Public commitment (from Cardano anchor)
78
+ * @property cardanoAnchorTxHash - Transaction hash on Cardano L1 for cross-chain binding
79
+ */
80
+ export interface HashChainInput {
81
+ events: TraceEvent[];
82
+ genesisHash: string;
83
+ expectedRootHash: string;
84
+ cardanoAnchorTxHash: string;
85
+ }
86
+
87
+ /**
88
+ * Hash chain validity proof.
89
+ * Demonstrates that a sequence of events produces the anchored root hash.
90
+ *
91
+ * @property publicInputs - Values visible to verifiers
92
+ * @property publicInputs.rootHash - The final rolling hash (matches anchor)
93
+ * @property publicInputs.eventCount - Number of events in the chain
94
+ * @property publicInputs.cardanoAnchorTxHash - Binding to Cardano anchor
95
+ */
96
+ export interface HashChainProof extends Proof {
97
+ proofType: "hash-chain";
98
+ publicInputs: HashChainPublicInputs;
99
+ }
100
+
101
+ export interface HashChainPublicInputs {
102
+ rootHash: string;
103
+ eventCount: number;
104
+ cardanoAnchorTxHash: string;
105
+ }
106
+
107
+ // =============================================================================
108
+ // POLICY COMPLIANCE PROOF
109
+ // =============================================================================
110
+
111
+ /**
112
+ * Input for policy compliance proof.
113
+ * Proves content passed a policy without revealing the content.
114
+ *
115
+ * @property promptHash - Hash of the prompt (private)
116
+ * @property outputHash - Hash of the output (private)
117
+ * @property policy - Policy definition to check against
118
+ * @property cardanoAnchorTxHash - Binding to Cardano anchor
119
+ */
120
+ export interface PolicyInput {
121
+ promptHash: string;
122
+ outputHash: string;
123
+ policy: ContentPolicy;
124
+ cardanoAnchorTxHash: string;
125
+ }
126
+
127
+ /**
128
+ * Content policy definition.
129
+ * Describes rules that content must comply with.
130
+ *
131
+ * @property id - Unique identifier for this policy
132
+ * @property version - Semantic version of the policy
133
+ * @property rules - Array of rules to evaluate
134
+ */
135
+ export interface ContentPolicy {
136
+ id: string;
137
+ version: string;
138
+ rules: PolicyRule[];
139
+ }
140
+
141
+ /**
142
+ * Individual policy rule.
143
+ *
144
+ * @property type - Rule type (blocklist, allowlist, regex, classifier)
145
+ * @property target - What to apply the rule to (prompt, output, or both)
146
+ * @property params - Rule-specific parameters
147
+ */
148
+ export interface PolicyRule {
149
+ type: "blocklist" | "allowlist" | "regex" | "classifier";
150
+ target: "prompt" | "output" | "both";
151
+ params: Record<string, unknown>;
152
+ }
153
+
154
+ /**
155
+ * Policy compliance proof.
156
+ * Demonstrates content compliance without revealing content.
157
+ *
158
+ * @property publicInputs - Values visible to verifiers
159
+ * @property publicInputs.promptHash - Reveals hash, not content
160
+ * @property publicInputs.policyId - Policy that was checked
161
+ * @property publicInputs.policyVersion - Version of the policy
162
+ * @property publicInputs.compliant - Whether content passed policy
163
+ * @property publicInputs.cardanoAnchorTxHash - Binding to Cardano anchor
164
+ */
165
+ export interface PolicyProof extends Proof {
166
+ proofType: "policy-compliance";
167
+ publicInputs: PolicyPublicInputs;
168
+ }
169
+
170
+ export interface PolicyPublicInputs {
171
+ promptHash: string;
172
+ policyId: string;
173
+ policyVersion: string;
174
+ compliant: boolean;
175
+ cardanoAnchorTxHash: string;
176
+ }
177
+
178
+ // =============================================================================
179
+ // ATTESTATION VALIDITY PROOF
180
+ // =============================================================================
181
+
182
+ /**
183
+ * Input for attestation validity proof.
184
+ * Proves a TEE attestation is valid without revealing full evidence.
185
+ *
186
+ * @property attestation - Full attestation bundle (private witness)
187
+ * @property policy - Expected verifier policy
188
+ * @property cardanoAnchorTxHash - Binding to Cardano anchor
189
+ */
190
+ export interface AttestationInput {
191
+ attestation: AttestationBundle;
192
+ policy: VerifierPolicy;
193
+ cardanoAnchorTxHash: string;
194
+ }
195
+
196
+ /**
197
+ * Attestation validity proof.
198
+ * Demonstrates TEE attestation validity without exposing full evidence.
199
+ *
200
+ * @property publicInputs - Values visible to verifiers
201
+ * @property publicInputs.teeType - Type of TEE that was attested
202
+ * @property publicInputs.measurementMatch - Whether measurements matched policy
203
+ * @property publicInputs.boundHash - The hash that was bound in attestation
204
+ * @property publicInputs.cardanoAnchorTxHash - Binding to Cardano anchor
205
+ */
206
+ export interface AttestationProof extends Proof {
207
+ proofType: "attestation-valid";
208
+ publicInputs: AttestationPublicInputs;
209
+ }
210
+
211
+ export interface AttestationPublicInputs {
212
+ teeType: TeeType;
213
+ measurementMatch: boolean;
214
+ boundHash: string;
215
+ cardanoAnchorTxHash: string;
216
+ }
217
+
218
+ // =============================================================================
219
+ // SELECTIVE DISCLOSURE PROOF
220
+ // =============================================================================
221
+
222
+ /**
223
+ * Input for selective disclosure proof.
224
+ * Proves a span exists in a bundle without revealing other spans.
225
+ *
226
+ * @property bundle - Full trace bundle (private witness)
227
+ * @property spanId - ID of span to disclose/prove membership
228
+ * @property merkleRoot - Expected Merkle root (from anchor)
229
+ * @property cardanoAnchorTxHash - Binding to Cardano anchor
230
+ */
231
+ export interface DisclosureInput {
232
+ bundle: TraceBundle;
233
+ spanId: string;
234
+ merkleRoot: string;
235
+ cardanoAnchorTxHash: string;
236
+ }
237
+
238
+ /**
239
+ * Selective disclosure proof.
240
+ * Proves span membership with optional span/event revelation.
241
+ *
242
+ * @property publicInputs - Values visible to verifiers
243
+ * @property publicInputs.spanHash - Hash of the disclosed span
244
+ * @property publicInputs.merkleRoot - Merkle root the span belongs to
245
+ * @property publicInputs.cardanoAnchorTxHash - Binding to Cardano anchor
246
+ * @property disclosedSpan - Optionally revealed span data
247
+ * @property disclosedEvents - Optionally revealed events in span
248
+ */
249
+ export interface DisclosureProof extends Proof {
250
+ proofType: "selective-disclosure";
251
+ publicInputs: DisclosurePublicInputs;
252
+ disclosedSpan: TraceSpan | undefined;
253
+ disclosedEvents: TraceEvent[] | undefined;
254
+ }
255
+
256
+ export interface DisclosurePublicInputs {
257
+ spanHash: string;
258
+ merkleRoot: string;
259
+ cardanoAnchorTxHash: string;
260
+ }
261
+
262
+ // =============================================================================
263
+ // ZKML INFERENCE PROOF (OPTIONAL, HIGH-STAKES)
264
+ // =============================================================================
265
+
266
+ /**
267
+ * Inference parameters for zkML proof.
268
+ * Captures model configuration at inference time.
269
+ */
270
+ export interface InferenceParams {
271
+ temperature: number | undefined;
272
+ topP: number | undefined;
273
+ topK: number | undefined;
274
+ maxTokens: number | undefined;
275
+ stopStrings: string[] | undefined;
276
+ frequencyPenalty: number | undefined;
277
+ presencePenalty: number | undefined;
278
+ }
279
+
280
+ /**
281
+ * Input for zkML inference proof.
282
+ * Proves model output is correct for given inputs.
283
+ *
284
+ * WARNING: zkML proofs are extremely expensive. Use only for high-stakes scenarios.
285
+ *
286
+ * @property modelId - Identifier of the model (e.g., "gpt-4", "claude-3")
287
+ * @property modelWeightDigest - Hash of model weights (for verification)
288
+ * @property inputTokens - Tokenized input (private)
289
+ * @property outputTokens - Tokenized output (private)
290
+ * @property params - Inference parameters used
291
+ * @property cardanoAnchorTxHash - Binding to Cardano anchor
292
+ */
293
+ export interface InferenceInput {
294
+ modelId: string;
295
+ modelWeightDigest: string;
296
+ inputTokens: number[];
297
+ outputTokens: number[];
298
+ params: InferenceParams;
299
+ cardanoAnchorTxHash: string;
300
+ }
301
+
302
+ /**
303
+ * zkML inference proof.
304
+ * Proves model inference correctness (extremely expensive).
305
+ *
306
+ * @property publicInputs - Values visible to verifiers
307
+ * @property publicInputs.modelWeightDigest - Proves which model was used
308
+ * @property publicInputs.inputHash - Hash of input tokens
309
+ * @property publicInputs.outputHash - Hash of output tokens
310
+ * @property publicInputs.paramsHash - Hash of inference parameters
311
+ * @property publicInputs.cardanoAnchorTxHash - Binding to Cardano anchor
312
+ * @property metrics - Cost/performance metrics for the proof
313
+ */
314
+ export interface InferenceProof extends Proof {
315
+ proofType: "zkml-inference";
316
+ publicInputs: InferencePublicInputs;
317
+ metrics: InferenceProofMetrics;
318
+ }
319
+
320
+ export interface InferencePublicInputs {
321
+ modelWeightDigest: string;
322
+ inputHash: string;
323
+ outputHash: string;
324
+ paramsHash: string;
325
+ cardanoAnchorTxHash: string;
326
+ }
327
+
328
+ /**
329
+ * Metrics for zkML proof generation.
330
+ * zkML proofs are expensive - these metrics help track costs.
331
+ */
332
+ export interface InferenceProofMetrics {
333
+ provingTimeMs: number;
334
+ proofSizeBytes: number;
335
+ circuitSize: number;
336
+ memoryUsageMB: number | undefined;
337
+ gpuUsed: boolean | undefined;
338
+ }
339
+
340
+ // =============================================================================
341
+ // PROOF SERVER CONFIGURATION
342
+ // =============================================================================
343
+
344
+ /**
345
+ * Configuration for connecting to a Midnight proof server.
346
+ *
347
+ * @property proofServerUrl - URL of the Midnight proof server
348
+ * @property apiKey - Optional API key for authentication
349
+ * @property timeout - Request timeout in milliseconds
350
+ * @property retries - Number of retries on failure
351
+ * @property circuitCacheDir - Optional local circuit cache directory
352
+ */
353
+ export interface ProofServerConfig {
354
+ proofServerUrl: string;
355
+ apiKey: string | undefined;
356
+ timeout: number;
357
+ retries: number;
358
+ circuitCacheDir: string | undefined;
359
+ }
360
+
361
+ /**
362
+ * Default proof server configuration.
363
+ */
364
+ export const DEFAULT_PROOF_SERVER_CONFIG: Partial<ProofServerConfig> = {
365
+ timeout: 300_000, // 5 minutes
366
+ retries: 3,
367
+ } as const;
368
+
369
+ // =============================================================================
370
+ // PUBLICATION
371
+ // =============================================================================
372
+
373
+ /**
374
+ * Result of publishing a proof to the Midnight network.
375
+ *
376
+ * @property midnightTxHash - Transaction hash on Midnight
377
+ * @property proofId - Unique identifier for the proof
378
+ * @property timestamp - When the proof was published
379
+ * @property cardanoAnchorTxHash - Cross-chain reference to Cardano
380
+ * @property blockNumber - Block number where proof was included
381
+ * @property fee - Fee paid for publication
382
+ */
383
+ export interface PublicationResult {
384
+ midnightTxHash: string;
385
+ proofId: string;
386
+ timestamp: string;
387
+ cardanoAnchorTxHash: string;
388
+ blockNumber: number | undefined;
389
+ fee: bigint | undefined;
390
+ }
391
+
392
+ // =============================================================================
393
+ // VERIFICATION
394
+ // =============================================================================
395
+
396
+ /**
397
+ * Result of verifying a proof.
398
+ */
399
+ export interface ProofVerificationResult {
400
+ valid: boolean;
401
+ proofType: ProofType;
402
+ publicInputs: Record<string, unknown>;
403
+ errors: string[];
404
+ warnings: string[];
405
+ verifiedAt: string;
406
+ }
407
+
408
+ // =============================================================================
409
+ // ERRORS
410
+ // =============================================================================
411
+
412
+ /**
413
+ * Error codes for midnight-prover operations.
414
+ * Uses 5xxx range as specified in architectural plan.
415
+ */
416
+ export enum MidnightProverError {
417
+ // Connection errors (5000-5019)
418
+ CONNECTION_FAILED = 5000,
419
+ CONNECTION_TIMEOUT = 5001,
420
+ CONNECTION_REFUSED = 5002,
421
+ AUTHENTICATION_FAILED = 5003,
422
+
423
+ // Proof generation errors (5020-5049)
424
+ PROOF_GENERATION_FAILED = 5020,
425
+ CIRCUIT_NOT_FOUND = 5021,
426
+ INVALID_WITNESS = 5022,
427
+ WITNESS_TOO_LARGE = 5023,
428
+ INSUFFICIENT_RESOURCES = 5024,
429
+ PROVING_TIMEOUT = 5025,
430
+
431
+ // Proof verification errors (5050-5079)
432
+ PROOF_VERIFICATION_FAILED = 5050,
433
+ INVALID_PROOF_FORMAT = 5051,
434
+ PUBLIC_INPUT_MISMATCH = 5052,
435
+ PROOF_EXPIRED = 5053,
436
+
437
+ // Publication errors (5080-5099)
438
+ PUBLICATION_FAILED = 5080,
439
+ INSUFFICIENT_FUNDS = 5081,
440
+ NETWORK_ERROR = 5082,
441
+ TRANSACTION_REJECTED = 5083,
442
+
443
+ // Input validation errors (5100-5119)
444
+ INVALID_INPUT = 5100,
445
+ MISSING_REQUIRED_FIELD = 5101,
446
+ HASH_MISMATCH = 5102,
447
+ ANCHOR_NOT_FOUND = 5103,
448
+ SPAN_NOT_FOUND = 5104,
449
+
450
+ // Circuit errors (5120-5139)
451
+ CIRCUIT_COMPILE_FAILED = 5120,
452
+ CIRCUIT_EXECUTION_FAILED = 5121,
453
+ CIRCUIT_CONSTRAINT_VIOLATED = 5122,
454
+ }
455
+
456
+ /**
457
+ * Exception class for midnight-prover errors.
458
+ * Provides structured error information with error codes.
459
+ */
460
+ export class MidnightProverException extends Error {
461
+ constructor(
462
+ public readonly code: MidnightProverError,
463
+ message: string,
464
+ public readonly cause?: Error
465
+ ) {
466
+ super(message);
467
+ this.name = "MidnightProverException";
468
+ }
469
+
470
+ /**
471
+ * Create a formatted error message including code.
472
+ */
473
+ toString(): string {
474
+ const codeStr = MidnightProverError[this.code] ?? this.code.toString();
475
+ const causeStr = this.cause ? ` (caused by: ${this.cause.message})` : "";
476
+ return `[${codeStr}] ${this.message}${causeStr}`;
477
+ }
478
+ }
479
+
480
+ // =============================================================================
481
+ // UNION TYPES
482
+ // =============================================================================
483
+
484
+ /**
485
+ * Union of all proof types for type guards and discriminated unions.
486
+ */
487
+ export type AnyProof =
488
+ | HashChainProof
489
+ | PolicyProof
490
+ | AttestationProof
491
+ | DisclosureProof
492
+ | InferenceProof;
493
+
494
+ /**
495
+ * Union of all proof input types.
496
+ */
497
+ export type AnyProofInput =
498
+ | HashChainInput
499
+ | PolicyInput
500
+ | AttestationInput
501
+ | DisclosureInput
502
+ | InferenceInput;
503
+
504
+ /**
505
+ * Union of all public input types.
506
+ */
507
+ export type AnyPublicInputs =
508
+ | HashChainPublicInputs
509
+ | PolicyPublicInputs
510
+ | AttestationPublicInputs
511
+ | DisclosurePublicInputs
512
+ | InferencePublicInputs;
513
+
514
+ // =============================================================================
515
+ // TYPE GUARDS
516
+ // =============================================================================
517
+
518
+ /**
519
+ * Type guard for HashChainProof.
520
+ */
521
+ export function isHashChainProof(proof: AnyProof): proof is HashChainProof {
522
+ return proof.proofType === "hash-chain";
523
+ }
524
+
525
+ /**
526
+ * Type guard for PolicyProof.
527
+ */
528
+ export function isPolicyProof(proof: AnyProof): proof is PolicyProof {
529
+ return proof.proofType === "policy-compliance";
530
+ }
531
+
532
+ /**
533
+ * Type guard for AttestationProof.
534
+ */
535
+ export function isAttestationProof(proof: AnyProof): proof is AttestationProof {
536
+ return proof.proofType === "attestation-valid";
537
+ }
538
+
539
+ /**
540
+ * Type guard for DisclosureProof.
541
+ */
542
+ export function isDisclosureProof(proof: AnyProof): proof is DisclosureProof {
543
+ return proof.proofType === "selective-disclosure";
544
+ }
545
+
546
+ /**
547
+ * Type guard for InferenceProof.
548
+ */
549
+ export function isInferenceProof(proof: AnyProof): proof is InferenceProof {
550
+ return proof.proofType === "zkml-inference";
551
+ }