@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/midnight/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAWH,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAe9B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAY5B,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,236 @@
1
+ /**
2
+ * @fileoverview Midnight proof server client for ZK proof generation.
3
+ *
4
+ * Location: packages/midnight-prover/src/midnight/proof-server-client.ts
5
+ *
6
+ * Summary:
7
+ * This module implements the ProofServerClient class which handles communication
8
+ * with the Midnight proof server for ZK proof generation. It manages connection
9
+ * lifecycle, proof submission, and result retrieval.
10
+ *
11
+ * Usage:
12
+ * - Used by the DefaultMidnightProver to generate proofs
13
+ * - Handles connection management and request/response serialization
14
+ * - Current implementation is a mock for testing; real Midnight integration TBD
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { ProofServerClient } from './proof-server-client.js';
19
+ *
20
+ * const client = new ProofServerClient();
21
+ * await client.connect(config);
22
+ *
23
+ * const result = await client.submitProof('hash-chain', witness, publicInputs);
24
+ * console.log('Proof generated:', result.proofId);
25
+ *
26
+ * await client.disconnect();
27
+ * ```
28
+ */
29
+ import type { ProofServerConfig } from "../types.js";
30
+ /**
31
+ * Result of proof generation from the server.
32
+ */
33
+ export interface ProofResult {
34
+ /**
35
+ * Unique proof identifier.
36
+ */
37
+ proofId: string;
38
+ /**
39
+ * The generated proof bytes.
40
+ */
41
+ proof: Uint8Array;
42
+ /**
43
+ * Time taken to generate the proof in milliseconds.
44
+ */
45
+ provingTimeMs: number;
46
+ /**
47
+ * Size of the proof in bytes.
48
+ */
49
+ proofSizeBytes: number;
50
+ /**
51
+ * Circuit name used for proof generation.
52
+ */
53
+ circuit: string;
54
+ /**
55
+ * Server-side metadata.
56
+ */
57
+ serverMetadata: {
58
+ serverId: string;
59
+ circuitVersion: string;
60
+ computeTimeMs: number;
61
+ };
62
+ }
63
+ /**
64
+ * Circuit information from the server.
65
+ */
66
+ export interface CircuitInfo {
67
+ name: string;
68
+ version: string;
69
+ constraintCount: number;
70
+ publicInputCount: number;
71
+ available: boolean;
72
+ }
73
+ /**
74
+ * Options for the ProofServerClient.
75
+ */
76
+ export interface ProofServerClientOptions {
77
+ /**
78
+ * Enable debug logging.
79
+ */
80
+ debug?: boolean;
81
+ /**
82
+ * Simulated proof generation time in milliseconds.
83
+ * Default: 50ms for fast testing.
84
+ */
85
+ simulatedProvingTimeMs?: number;
86
+ }
87
+ /**
88
+ * ProofServerClient handles communication with the Midnight proof server.
89
+ *
90
+ * This class provides:
91
+ * - Connection management to the proof server
92
+ * - Proof submission with witness and public inputs
93
+ * - Circuit information queries
94
+ *
95
+ * Current implementation is a mock that simulates proof server behavior.
96
+ * Real Midnight integration will be added when the Compact runtime is available.
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const client = new ProofServerClient({ debug: true });
101
+ *
102
+ * await client.connect({
103
+ * proofServerUrl: 'https://proof.midnight.network',
104
+ * timeout: 300000,
105
+ * retries: 3,
106
+ * });
107
+ *
108
+ * const result = await client.submitProof('hash-chain', witness, publicInputs);
109
+ * console.log('Generated proof:', result.proofId);
110
+ *
111
+ * await client.disconnect();
112
+ * ```
113
+ */
114
+ export declare class ProofServerClient {
115
+ private readonly options;
116
+ private config;
117
+ private connected;
118
+ private serverId;
119
+ /**
120
+ * Create a new ProofServerClient instance.
121
+ *
122
+ * @param options - Configuration options
123
+ */
124
+ constructor(options?: ProofServerClientOptions);
125
+ /**
126
+ * Connect to the Midnight proof server.
127
+ *
128
+ * @param config - Proof server configuration
129
+ * @throws MidnightProverException on connection failure
130
+ */
131
+ connect(config: ProofServerConfig): Promise<void>;
132
+ /**
133
+ * Disconnect from the proof server.
134
+ */
135
+ disconnect(): Promise<void>;
136
+ /**
137
+ * Check if connected to the proof server.
138
+ */
139
+ isConnected(): boolean;
140
+ /**
141
+ * Get the current configuration.
142
+ */
143
+ getConfig(): ProofServerConfig | undefined;
144
+ /**
145
+ * Submit a proof request to the server.
146
+ *
147
+ * This method:
148
+ * 1. Validates the circuit and inputs
149
+ * 2. Serializes the witness and public inputs
150
+ * 3. Submits to the proof server
151
+ * 4. Returns the generated proof
152
+ *
153
+ * @param circuit - Circuit name (e.g., "hash-chain", "policy-compliance")
154
+ * @param witness - Private witness data for the proof
155
+ * @param publicInputs - Public inputs for the proof
156
+ * @returns Promise resolving to the proof result
157
+ * @throws MidnightProverException on failure
158
+ */
159
+ submitProof(circuit: string, witness: unknown, publicInputs: unknown): Promise<ProofResult>;
160
+ /**
161
+ * Get information about a circuit.
162
+ *
163
+ * @param circuitName - Name of the circuit
164
+ * @returns Circuit information
165
+ */
166
+ getCircuitInfo(circuitName: string): Promise<CircuitInfo>;
167
+ /**
168
+ * List all available circuits.
169
+ *
170
+ * @returns Array of circuit names
171
+ */
172
+ listCircuits(): Promise<string[]>;
173
+ /**
174
+ * Check if a circuit is available.
175
+ *
176
+ * @param circuit - Circuit name or proof type
177
+ * @returns True if the circuit is available
178
+ */
179
+ isCircuitAvailable(circuit: string): Promise<boolean>;
180
+ /**
181
+ * Ensure connected before operations.
182
+ */
183
+ private ensureConnected;
184
+ /**
185
+ * Validate server configuration.
186
+ */
187
+ private validateConfig;
188
+ /**
189
+ * Resolve circuit name from proof type or direct name.
190
+ */
191
+ private resolveCircuitName;
192
+ /**
193
+ * Serialize input data for transmission.
194
+ */
195
+ private serializeInput;
196
+ /**
197
+ * Simulate proof generation delay.
198
+ */
199
+ private simulateProofGeneration;
200
+ /**
201
+ * Generate a mock proof.
202
+ */
203
+ private generateMockProof;
204
+ /**
205
+ * Generate a proof ID.
206
+ */
207
+ private generateProofId;
208
+ /**
209
+ * Hash bytes to hex string.
210
+ */
211
+ private hashBytes;
212
+ /**
213
+ * Convert hex string to bytes.
214
+ */
215
+ private hexToBytes;
216
+ /**
217
+ * Simulate network delay.
218
+ */
219
+ private simulateNetworkDelay;
220
+ /**
221
+ * Delay helper.
222
+ */
223
+ private delay;
224
+ /**
225
+ * Debug logging helper.
226
+ */
227
+ private debug;
228
+ }
229
+ /**
230
+ * Create a new ProofServerClient instance.
231
+ *
232
+ * @param options - Configuration options
233
+ * @returns New ProofServerClient instance
234
+ */
235
+ export declare function createProofServerClient(options?: ProofServerClientOptions): ProofServerClient;
236
+ //# sourceMappingURL=proof-server-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof-server-client.d.ts","sourceRoot":"","sources":["../../src/midnight/proof-server-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAa,MAAM,aAAa,CAAC;AAahE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,EAAE,UAAU,CAAC;IAElB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB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CAAC,cAAc;IAKtB;;OAEG;YACW,uBAAuB;IAOrC;;OAEG;YACW,iBAAiB;IA0C/B;;OAEG;YACW,eAAe;IAK7B;;OAEG;YACW,SAAS;IAWvB;;OAEG;IACH,OAAO,CAAC,UAAU;IAQlB;;OAEG;YACW,oBAAoB;IAKlC;;OAEG;IACH,OAAO,CAAC,KAAK;IAIb;;OAEG;IACH,OAAO,CAAC,KAAK;CAKd;AAMD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,wBAAwB,GACjC,iBAAiB,CAEnB"}
@@ -0,0 +1,422 @@
1
+ /**
2
+ * @fileoverview Midnight proof server client for ZK proof generation.
3
+ *
4
+ * Location: packages/midnight-prover/src/midnight/proof-server-client.ts
5
+ *
6
+ * Summary:
7
+ * This module implements the ProofServerClient class which handles communication
8
+ * with the Midnight proof server for ZK proof generation. It manages connection
9
+ * lifecycle, proof submission, and result retrieval.
10
+ *
11
+ * Usage:
12
+ * - Used by the DefaultMidnightProver to generate proofs
13
+ * - Handles connection management and request/response serialization
14
+ * - Current implementation is a mock for testing; real Midnight integration TBD
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { ProofServerClient } from './proof-server-client.js';
19
+ *
20
+ * const client = new ProofServerClient();
21
+ * await client.connect(config);
22
+ *
23
+ * const result = await client.submitProof('hash-chain', witness, publicInputs);
24
+ * console.log('Proof generated:', result.proofId);
25
+ *
26
+ * await client.disconnect();
27
+ * ```
28
+ */
29
+ import { MidnightProverError, MidnightProverException, } from "../types.js";
30
+ import { sha256StringHex, canonicalize } from "@fluxpointstudios/orynq-sdk-core/utils";
31
+ /**
32
+ * Circuit names for different proof types.
33
+ */
34
+ const CIRCUIT_NAMES = {
35
+ "hash-chain": "poi_hash_chain_v1",
36
+ "policy-compliance": "poi_policy_compliance_v1",
37
+ "attestation-valid": "poi_attestation_v1",
38
+ "selective-disclosure": "poi_disclosure_v1",
39
+ "zkml-inference": "poi_inference_v1",
40
+ };
41
+ // =============================================================================
42
+ // PROOF SERVER CLIENT
43
+ // =============================================================================
44
+ /**
45
+ * ProofServerClient handles communication with the Midnight proof server.
46
+ *
47
+ * This class provides:
48
+ * - Connection management to the proof server
49
+ * - Proof submission with witness and public inputs
50
+ * - Circuit information queries
51
+ *
52
+ * Current implementation is a mock that simulates proof server behavior.
53
+ * Real Midnight integration will be added when the Compact runtime is available.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const client = new ProofServerClient({ debug: true });
58
+ *
59
+ * await client.connect({
60
+ * proofServerUrl: 'https://proof.midnight.network',
61
+ * timeout: 300000,
62
+ * retries: 3,
63
+ * });
64
+ *
65
+ * const result = await client.submitProof('hash-chain', witness, publicInputs);
66
+ * console.log('Generated proof:', result.proofId);
67
+ *
68
+ * await client.disconnect();
69
+ * ```
70
+ */
71
+ export class ProofServerClient {
72
+ options;
73
+ config;
74
+ connected = false;
75
+ serverId;
76
+ /**
77
+ * Create a new ProofServerClient instance.
78
+ *
79
+ * @param options - Configuration options
80
+ */
81
+ constructor(options = {}) {
82
+ this.options = {
83
+ debug: options.debug ?? false,
84
+ simulatedProvingTimeMs: options.simulatedProvingTimeMs ?? 50,
85
+ };
86
+ }
87
+ /**
88
+ * Connect to the Midnight proof server.
89
+ *
90
+ * @param config - Proof server configuration
91
+ * @throws MidnightProverException on connection failure
92
+ */
93
+ async connect(config) {
94
+ this.debug(`Connecting to proof server at ${config.proofServerUrl}...`);
95
+ try {
96
+ // Validate configuration
97
+ this.validateConfig(config);
98
+ // Simulate connection establishment
99
+ await this.simulateNetworkDelay(30);
100
+ // In production, this would establish a WebSocket or HTTP connection
101
+ // and perform any necessary handshaking/authentication
102
+ if (config.apiKey) {
103
+ this.debug("Authenticating with API key...");
104
+ await this.simulateNetworkDelay(20);
105
+ }
106
+ // Generate a mock server ID
107
+ this.serverId = `server-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
108
+ this.config = config;
109
+ this.connected = true;
110
+ this.debug(`Connected to proof server (serverId: ${this.serverId})`);
111
+ }
112
+ catch (error) {
113
+ if (error instanceof MidnightProverException) {
114
+ throw error;
115
+ }
116
+ throw new MidnightProverException(MidnightProverError.CONNECTION_FAILED, `Failed to connect to proof server: ${String(error)}`, error instanceof Error ? error : undefined);
117
+ }
118
+ }
119
+ /**
120
+ * Disconnect from the proof server.
121
+ */
122
+ async disconnect() {
123
+ if (this.connected) {
124
+ this.debug("Disconnecting from proof server...");
125
+ await this.simulateNetworkDelay(10);
126
+ this.connected = false;
127
+ this.config = undefined;
128
+ this.serverId = undefined;
129
+ this.debug("Disconnected");
130
+ }
131
+ }
132
+ /**
133
+ * Check if connected to the proof server.
134
+ */
135
+ isConnected() {
136
+ return this.connected;
137
+ }
138
+ /**
139
+ * Get the current configuration.
140
+ */
141
+ getConfig() {
142
+ return this.config;
143
+ }
144
+ /**
145
+ * Submit a proof request to the server.
146
+ *
147
+ * This method:
148
+ * 1. Validates the circuit and inputs
149
+ * 2. Serializes the witness and public inputs
150
+ * 3. Submits to the proof server
151
+ * 4. Returns the generated proof
152
+ *
153
+ * @param circuit - Circuit name (e.g., "hash-chain", "policy-compliance")
154
+ * @param witness - Private witness data for the proof
155
+ * @param publicInputs - Public inputs for the proof
156
+ * @returns Promise resolving to the proof result
157
+ * @throws MidnightProverException on failure
158
+ */
159
+ async submitProof(circuit, witness, publicInputs) {
160
+ this.ensureConnected();
161
+ const circuitName = this.resolveCircuitName(circuit);
162
+ this.debug(`Submitting proof request for circuit: ${circuitName}`);
163
+ const startTime = Date.now();
164
+ try {
165
+ // Validate circuit exists
166
+ const circuitInfo = await this.getCircuitInfo(circuitName);
167
+ if (!circuitInfo.available) {
168
+ throw new MidnightProverException(MidnightProverError.CIRCUIT_NOT_FOUND, `Circuit '${circuitName}' is not available`);
169
+ }
170
+ // Serialize inputs
171
+ const serializedWitness = this.serializeInput(witness);
172
+ const serializedPublicInputs = this.serializeInput(publicInputs);
173
+ this.debug(`Witness size: ${serializedWitness.length} bytes`);
174
+ this.debug(`Public inputs size: ${serializedPublicInputs.length} bytes`);
175
+ // Simulate proof generation
176
+ await this.simulateProofGeneration();
177
+ // Generate mock proof
178
+ const proof = await this.generateMockProof(circuitName, serializedWitness, serializedPublicInputs);
179
+ const provingTimeMs = Date.now() - startTime;
180
+ // Generate proof ID
181
+ const proofId = await this.generateProofId(proof);
182
+ const result = {
183
+ proofId,
184
+ proof,
185
+ provingTimeMs,
186
+ proofSizeBytes: proof.length,
187
+ circuit: circuitName,
188
+ serverMetadata: {
189
+ serverId: this.serverId ?? "unknown",
190
+ circuitVersion: circuitInfo.version,
191
+ computeTimeMs: this.options.simulatedProvingTimeMs,
192
+ },
193
+ };
194
+ this.debug(`Proof generated: ${proofId} (${provingTimeMs}ms)`);
195
+ return result;
196
+ }
197
+ catch (error) {
198
+ if (error instanceof MidnightProverException) {
199
+ throw error;
200
+ }
201
+ throw new MidnightProverException(MidnightProverError.PROOF_GENERATION_FAILED, `Proof generation failed: ${String(error)}`, error instanceof Error ? error : undefined);
202
+ }
203
+ }
204
+ /**
205
+ * Get information about a circuit.
206
+ *
207
+ * @param circuitName - Name of the circuit
208
+ * @returns Circuit information
209
+ */
210
+ async getCircuitInfo(circuitName) {
211
+ this.ensureConnected();
212
+ await this.simulateNetworkDelay(20);
213
+ // Mock circuit information
214
+ const baseCircuitInfo = {
215
+ version: "1.0.0",
216
+ constraintCount: 1000000,
217
+ publicInputCount: 10,
218
+ available: true,
219
+ };
220
+ // Circuit-specific information
221
+ const circuitConfigs = {
222
+ poi_hash_chain_v1: {
223
+ constraintCount: 500000,
224
+ publicInputCount: 3,
225
+ },
226
+ poi_policy_compliance_v1: {
227
+ constraintCount: 750000,
228
+ publicInputCount: 5,
229
+ },
230
+ poi_attestation_v1: {
231
+ constraintCount: 600000,
232
+ publicInputCount: 4,
233
+ },
234
+ poi_disclosure_v1: {
235
+ constraintCount: 400000,
236
+ publicInputCount: 3,
237
+ },
238
+ poi_inference_v1: {
239
+ constraintCount: 10000000, // Very large for zkML
240
+ publicInputCount: 5,
241
+ available: false, // Mark as unavailable by default
242
+ },
243
+ };
244
+ const specificConfig = circuitConfigs[circuitName] ?? {};
245
+ return {
246
+ name: circuitName,
247
+ ...baseCircuitInfo,
248
+ ...specificConfig,
249
+ };
250
+ }
251
+ /**
252
+ * List all available circuits.
253
+ *
254
+ * @returns Array of circuit names
255
+ */
256
+ async listCircuits() {
257
+ this.ensureConnected();
258
+ await this.simulateNetworkDelay(15);
259
+ return Object.values(CIRCUIT_NAMES);
260
+ }
261
+ /**
262
+ * Check if a circuit is available.
263
+ *
264
+ * @param circuit - Circuit name or proof type
265
+ * @returns True if the circuit is available
266
+ */
267
+ async isCircuitAvailable(circuit) {
268
+ const circuitName = this.resolveCircuitName(circuit);
269
+ const info = await this.getCircuitInfo(circuitName);
270
+ return info.available;
271
+ }
272
+ // ===========================================================================
273
+ // PRIVATE METHODS
274
+ // ===========================================================================
275
+ /**
276
+ * Ensure connected before operations.
277
+ */
278
+ ensureConnected() {
279
+ if (!this.connected) {
280
+ throw new MidnightProverException(MidnightProverError.CONNECTION_FAILED, "Not connected to proof server. Call connect() first.");
281
+ }
282
+ }
283
+ /**
284
+ * Validate server configuration.
285
+ */
286
+ validateConfig(config) {
287
+ if (!config.proofServerUrl) {
288
+ throw new MidnightProverException(MidnightProverError.INVALID_INPUT, "Proof server URL is required");
289
+ }
290
+ if (config.timeout !== undefined && config.timeout <= 0) {
291
+ throw new MidnightProverException(MidnightProverError.INVALID_INPUT, "Timeout must be positive");
292
+ }
293
+ if (config.retries !== undefined && config.retries < 0) {
294
+ throw new MidnightProverException(MidnightProverError.INVALID_INPUT, "Retries must be non-negative");
295
+ }
296
+ }
297
+ /**
298
+ * Resolve circuit name from proof type or direct name.
299
+ */
300
+ resolveCircuitName(circuit) {
301
+ // Check if it's a proof type
302
+ const proofType = circuit;
303
+ if (proofType in CIRCUIT_NAMES) {
304
+ return CIRCUIT_NAMES[proofType];
305
+ }
306
+ // Assume it's already a circuit name
307
+ return circuit;
308
+ }
309
+ /**
310
+ * Serialize input data for transmission.
311
+ */
312
+ serializeInput(input) {
313
+ const jsonString = canonicalize(input);
314
+ return new TextEncoder().encode(jsonString);
315
+ }
316
+ /**
317
+ * Simulate proof generation delay.
318
+ */
319
+ async simulateProofGeneration() {
320
+ // Add some variance to simulate real proof generation
321
+ const variance = Math.random() * 0.2 - 0.1; // +/- 10%
322
+ const delay = this.options.simulatedProvingTimeMs * (1 + variance);
323
+ await this.delay(delay);
324
+ }
325
+ /**
326
+ * Generate a mock proof.
327
+ */
328
+ async generateMockProof(circuitName, witness, publicInputs) {
329
+ // Create a deterministic mock proof based on inputs
330
+ const witnessHash = await this.hashBytes(witness);
331
+ const publicInputsHash = await this.hashBytes(publicInputs);
332
+ // Mock proof structure:
333
+ // - Magic header (16 bytes): "MOCK-MIDNIGHT-V1"
334
+ // - Circuit name hash (32 bytes)
335
+ // - Witness commitment (32 bytes)
336
+ // - Public inputs commitment (32 bytes)
337
+ // - Random padding (144 bytes)
338
+ // Total: 256 bytes
339
+ const proof = new Uint8Array(256);
340
+ const header = new TextEncoder().encode("MOCK-MIDNIGHT-V1");
341
+ proof.set(header, 0);
342
+ // Circuit name hash
343
+ const circuitHash = await sha256StringHex(circuitName);
344
+ const circuitHashBytes = this.hexToBytes(circuitHash);
345
+ proof.set(circuitHashBytes, 16);
346
+ // Witness commitment
347
+ const witnessBytes = this.hexToBytes(witnessHash);
348
+ proof.set(witnessBytes, 48);
349
+ // Public inputs commitment
350
+ const publicInputsBytes = this.hexToBytes(publicInputsHash);
351
+ proof.set(publicInputsBytes, 80);
352
+ // Random padding
353
+ const randomPadding = new Uint8Array(144);
354
+ crypto.getRandomValues(randomPadding);
355
+ proof.set(randomPadding, 112);
356
+ return proof;
357
+ }
358
+ /**
359
+ * Generate a proof ID.
360
+ */
361
+ async generateProofId(proof) {
362
+ const hash = await this.hashBytes(proof);
363
+ return `proof-${hash.slice(0, 16)}`;
364
+ }
365
+ /**
366
+ * Hash bytes to hex string.
367
+ */
368
+ async hashBytes(data) {
369
+ // Create a copy to ensure ArrayBuffer type compatibility
370
+ const buffer = new ArrayBuffer(data.length);
371
+ new Uint8Array(buffer).set(data);
372
+ const hashBuffer = await crypto.subtle.digest("SHA-256", buffer);
373
+ const hashArray = new Uint8Array(hashBuffer);
374
+ return Array.from(hashArray)
375
+ .map((b) => b.toString(16).padStart(2, "0"))
376
+ .join("");
377
+ }
378
+ /**
379
+ * Convert hex string to bytes.
380
+ */
381
+ hexToBytes(hex) {
382
+ const bytes = new Uint8Array(hex.length / 2);
383
+ for (let i = 0; i < hex.length; i += 2) {
384
+ bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
385
+ }
386
+ return bytes;
387
+ }
388
+ /**
389
+ * Simulate network delay.
390
+ */
391
+ async simulateNetworkDelay(baseMs) {
392
+ const jitter = Math.random() * baseMs * 0.2;
393
+ await this.delay(baseMs + jitter);
394
+ }
395
+ /**
396
+ * Delay helper.
397
+ */
398
+ delay(ms) {
399
+ return new Promise((resolve) => setTimeout(resolve, ms));
400
+ }
401
+ /**
402
+ * Debug logging helper.
403
+ */
404
+ debug(message) {
405
+ if (this.options.debug) {
406
+ console.log(`[ProofServerClient] ${message}`);
407
+ }
408
+ }
409
+ }
410
+ // =============================================================================
411
+ // FACTORY FUNCTION
412
+ // =============================================================================
413
+ /**
414
+ * Create a new ProofServerClient instance.
415
+ *
416
+ * @param options - Configuration options
417
+ * @returns New ProofServerClient instance
418
+ */
419
+ export function createProofServerClient(options) {
420
+ return new ProofServerClient(options);
421
+ }
422
+ //# sourceMappingURL=proof-server-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof-server-client.js","sourceRoot":"","sources":["../../src/midnight/proof-server-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,eAAe,EAAE,YAAY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