@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
package/src/index.ts
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PoI Midnight Prover Package
|
|
3
|
+
*
|
|
4
|
+
* ZK proof generation for PoI using the Midnight network.
|
|
5
|
+
* Enables privacy-preserving verification of trace properties.
|
|
6
|
+
*
|
|
7
|
+
* Location: packages/midnight-prover/src/index.ts
|
|
8
|
+
*
|
|
9
|
+
* Summary:
|
|
10
|
+
* This is the main entry point for the poi-midnight-prover package. It re-exports
|
|
11
|
+
* all public types, interfaces, and utilities for ZK proof generation.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* The package integrates with:
|
|
15
|
+
* - poi-process-trace: Provides TraceEvent and TraceBundle data for proofs
|
|
16
|
+
* - poi-attestor: Provides AttestationBundle for attestation proofs
|
|
17
|
+
* - poi-anchors-cardano: Provides Cardano anchor transaction binding
|
|
18
|
+
*
|
|
19
|
+
* All proofs are bound to a Cardano anchor transaction, creating a cross-chain
|
|
20
|
+
* link between the PoI trace on Cardano L1 and the ZK proof on Midnight.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import {
|
|
25
|
+
* MidnightProver,
|
|
26
|
+
* proverRegistry,
|
|
27
|
+
* HashChainInput,
|
|
28
|
+
* MidnightProverException,
|
|
29
|
+
* } from '@fluxpointstudios/orynq-sdk-midnight-prover';
|
|
30
|
+
*
|
|
31
|
+
* // Get the default prover
|
|
32
|
+
* const prover = proverRegistry.getDefault();
|
|
33
|
+
*
|
|
34
|
+
* // Connect to proof server
|
|
35
|
+
* await prover.connect({
|
|
36
|
+
* proofServerUrl: 'https://proof.midnight.network',
|
|
37
|
+
* apiKey: process.env.MIDNIGHT_API_KEY,
|
|
38
|
+
* timeout: 300000,
|
|
39
|
+
* retries: 3,
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* try {
|
|
43
|
+
* // Generate a hash chain proof
|
|
44
|
+
* const proof = await prover.proveHashChain({
|
|
45
|
+
* events: bundle.privateRun.events,
|
|
46
|
+
* genesisHash: '0x' + '0'.repeat(64),
|
|
47
|
+
* expectedRootHash: bundle.rootHash,
|
|
48
|
+
* cardanoAnchorTxHash: anchorTxHash,
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Publish to Midnight
|
|
52
|
+
* const result = await prover.publish(proof);
|
|
53
|
+
* console.log('Proof published:', result.midnightTxHash);
|
|
54
|
+
* } catch (e) {
|
|
55
|
+
* if (e instanceof MidnightProverException) {
|
|
56
|
+
* console.error('Prover error:', e.code, e.message);
|
|
57
|
+
* }
|
|
58
|
+
* throw e;
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @packageDocumentation
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
// =============================================================================
|
|
66
|
+
// CORE TYPES
|
|
67
|
+
// =============================================================================
|
|
68
|
+
|
|
69
|
+
export type {
|
|
70
|
+
// Proof type discriminator
|
|
71
|
+
ProofType,
|
|
72
|
+
|
|
73
|
+
// Base proof interface
|
|
74
|
+
Proof,
|
|
75
|
+
|
|
76
|
+
// Hash chain proof
|
|
77
|
+
HashChainInput,
|
|
78
|
+
HashChainProof,
|
|
79
|
+
HashChainPublicInputs,
|
|
80
|
+
|
|
81
|
+
// Policy compliance proof
|
|
82
|
+
PolicyInput,
|
|
83
|
+
PolicyProof,
|
|
84
|
+
PolicyPublicInputs,
|
|
85
|
+
ContentPolicy,
|
|
86
|
+
PolicyRule,
|
|
87
|
+
|
|
88
|
+
// Attestation validity proof
|
|
89
|
+
AttestationInput,
|
|
90
|
+
AttestationProof,
|
|
91
|
+
AttestationPublicInputs,
|
|
92
|
+
|
|
93
|
+
// Selective disclosure proof
|
|
94
|
+
DisclosureInput,
|
|
95
|
+
DisclosureProof,
|
|
96
|
+
DisclosurePublicInputs,
|
|
97
|
+
|
|
98
|
+
// zkML inference proof
|
|
99
|
+
InferenceInput,
|
|
100
|
+
InferenceProof,
|
|
101
|
+
InferencePublicInputs,
|
|
102
|
+
InferenceParams,
|
|
103
|
+
InferenceProofMetrics,
|
|
104
|
+
|
|
105
|
+
// Configuration
|
|
106
|
+
ProofServerConfig,
|
|
107
|
+
|
|
108
|
+
// Publication
|
|
109
|
+
PublicationResult,
|
|
110
|
+
|
|
111
|
+
// Verification
|
|
112
|
+
ProofVerificationResult,
|
|
113
|
+
|
|
114
|
+
// Union types
|
|
115
|
+
AnyProof,
|
|
116
|
+
AnyProofInput,
|
|
117
|
+
AnyPublicInputs,
|
|
118
|
+
} from "./types.js";
|
|
119
|
+
|
|
120
|
+
// =============================================================================
|
|
121
|
+
// ERROR HANDLING
|
|
122
|
+
// =============================================================================
|
|
123
|
+
|
|
124
|
+
export {
|
|
125
|
+
MidnightProverError,
|
|
126
|
+
MidnightProverException,
|
|
127
|
+
DEFAULT_PROOF_SERVER_CONFIG,
|
|
128
|
+
} from "./types.js";
|
|
129
|
+
|
|
130
|
+
// =============================================================================
|
|
131
|
+
// TYPE GUARDS
|
|
132
|
+
// =============================================================================
|
|
133
|
+
|
|
134
|
+
export {
|
|
135
|
+
isHashChainProof,
|
|
136
|
+
isPolicyProof,
|
|
137
|
+
isAttestationProof,
|
|
138
|
+
isDisclosureProof,
|
|
139
|
+
isInferenceProof,
|
|
140
|
+
} from "./types.js";
|
|
141
|
+
|
|
142
|
+
// =============================================================================
|
|
143
|
+
// PROVER INTERFACE
|
|
144
|
+
// =============================================================================
|
|
145
|
+
|
|
146
|
+
export type {
|
|
147
|
+
MidnightProver,
|
|
148
|
+
MidnightProverFactory,
|
|
149
|
+
CreateMidnightProverOptions,
|
|
150
|
+
MidnightProverRegistry,
|
|
151
|
+
} from "./prover-interface.js";
|
|
152
|
+
|
|
153
|
+
export {
|
|
154
|
+
AbstractMidnightProver,
|
|
155
|
+
DefaultMidnightProverRegistry,
|
|
156
|
+
proverRegistry,
|
|
157
|
+
} from "./prover-interface.js";
|
|
158
|
+
|
|
159
|
+
// =============================================================================
|
|
160
|
+
// PROOF GENERATORS
|
|
161
|
+
// =============================================================================
|
|
162
|
+
|
|
163
|
+
export type {
|
|
164
|
+
HashChainProverOptions,
|
|
165
|
+
PolicyComplianceProverOptions,
|
|
166
|
+
RuleEvaluationResult,
|
|
167
|
+
PolicyEvaluationResult,
|
|
168
|
+
RuleEvaluator,
|
|
169
|
+
SelectiveDisclosureProverOptions,
|
|
170
|
+
MerkleInclusionResult,
|
|
171
|
+
} from "./proofs/index.js";
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
// Hash chain prover
|
|
175
|
+
HashChainProver,
|
|
176
|
+
createHashChainProver,
|
|
177
|
+
// Policy compliance prover
|
|
178
|
+
PolicyComplianceProver,
|
|
179
|
+
createPolicyComplianceProver,
|
|
180
|
+
// Selective disclosure prover
|
|
181
|
+
SelectiveDisclosureProver,
|
|
182
|
+
createSelectiveDisclosureProver,
|
|
183
|
+
// Merkle utilities
|
|
184
|
+
computeSpanHash,
|
|
185
|
+
computeLeafHash,
|
|
186
|
+
computeNodeHash,
|
|
187
|
+
computeMerkleRoot,
|
|
188
|
+
generateMerkleInclusionProof,
|
|
189
|
+
verifyMerkleProof,
|
|
190
|
+
verifySpanInclusion,
|
|
191
|
+
} from "./proofs/index.js";
|
|
192
|
+
|
|
193
|
+
// =============================================================================
|
|
194
|
+
// MIDNIGHT UTILITIES
|
|
195
|
+
// =============================================================================
|
|
196
|
+
|
|
197
|
+
export type {
|
|
198
|
+
EventWitness,
|
|
199
|
+
HashChainWitness,
|
|
200
|
+
HashChainPublicInputData,
|
|
201
|
+
PolicyPublicInputData,
|
|
202
|
+
AttestationPublicInputData,
|
|
203
|
+
DisclosurePublicInputData,
|
|
204
|
+
InferencePublicInputData,
|
|
205
|
+
AnyPublicInputData,
|
|
206
|
+
} from "./midnight/index.js";
|
|
207
|
+
|
|
208
|
+
export {
|
|
209
|
+
buildHashChainWitness,
|
|
210
|
+
serializeWitness,
|
|
211
|
+
computeWitnessSize,
|
|
212
|
+
validateWitness,
|
|
213
|
+
buildPublicInputs,
|
|
214
|
+
serializePublicInputs,
|
|
215
|
+
hashPublicInputs,
|
|
216
|
+
} from "./midnight/index.js";
|
|
217
|
+
|
|
218
|
+
// =============================================================================
|
|
219
|
+
// PROOF SERVER CLIENT
|
|
220
|
+
// =============================================================================
|
|
221
|
+
|
|
222
|
+
export type {
|
|
223
|
+
ProofResult,
|
|
224
|
+
CircuitInfo,
|
|
225
|
+
ProofServerClientOptions,
|
|
226
|
+
} from "./midnight/index.js";
|
|
227
|
+
|
|
228
|
+
export {
|
|
229
|
+
ProofServerClient,
|
|
230
|
+
createProofServerClient,
|
|
231
|
+
} from "./midnight/index.js";
|
|
232
|
+
|
|
233
|
+
// =============================================================================
|
|
234
|
+
// LINKING (Publication & Cross-Chain)
|
|
235
|
+
// =============================================================================
|
|
236
|
+
|
|
237
|
+
export type {
|
|
238
|
+
ProofStatus,
|
|
239
|
+
ProofStatusInfo,
|
|
240
|
+
ProofPublisherOptions,
|
|
241
|
+
CrossChainLink,
|
|
242
|
+
LinkVerificationResult,
|
|
243
|
+
CardanoAnchorLinkerOptions,
|
|
244
|
+
} from "./linking/index.js";
|
|
245
|
+
|
|
246
|
+
export {
|
|
247
|
+
ProofPublisher,
|
|
248
|
+
createProofPublisher,
|
|
249
|
+
CardanoAnchorLinker,
|
|
250
|
+
createCardanoAnchorLinker,
|
|
251
|
+
} from "./linking/index.js";
|
|
252
|
+
|
|
253
|
+
// =============================================================================
|
|
254
|
+
// DEFAULT PROVER IMPLEMENTATION
|
|
255
|
+
// =============================================================================
|
|
256
|
+
|
|
257
|
+
export {
|
|
258
|
+
DefaultMidnightProver,
|
|
259
|
+
createMidnightProver,
|
|
260
|
+
} from "./prover.js";
|