@veridid/poe 0.0.0-stage → 1.0.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 (183) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +39 -2
  3. package/build/PoeApi.d.mts +150 -0
  4. package/build/PoeApi.d.mts.map +1 -0
  5. package/build/PoeApi.mjs +262 -0
  6. package/build/PoeApi.mjs.map +1 -0
  7. package/build/PoeEvents.d.mts +187 -0
  8. package/build/PoeEvents.d.mts.map +1 -0
  9. package/build/PoeEvents.mjs +28 -0
  10. package/build/PoeEvents.mjs.map +1 -0
  11. package/build/PoeModule.d.mts +61 -0
  12. package/build/PoeModule.d.mts.map +1 -0
  13. package/build/PoeModule.mjs +139 -0
  14. package/build/PoeModule.mjs.map +1 -0
  15. package/build/PoeModuleConfig.d.mts +71 -0
  16. package/build/PoeModuleConfig.d.mts.map +1 -0
  17. package/build/PoeRole.d.mts +21 -0
  18. package/build/PoeRole.d.mts.map +1 -0
  19. package/build/PoeRole.mjs +23 -0
  20. package/build/PoeRole.mjs.map +1 -0
  21. package/build/PoeState.d.mts +76 -0
  22. package/build/PoeState.d.mts.map +1 -0
  23. package/build/PoeState.mjs +78 -0
  24. package/build/PoeState.mjs.map +1 -0
  25. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +10 -0
  26. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +7 -0
  27. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs +9 -0
  28. package/build/_virtual/_rolldown/runtime.mjs +8 -0
  29. package/build/errors/PoeError.d.mts +173 -0
  30. package/build/errors/PoeError.d.mts.map +1 -0
  31. package/build/errors/PoeError.mjs +147 -0
  32. package/build/errors/PoeError.mjs.map +1 -0
  33. package/build/errors/index.d.mts +1 -0
  34. package/build/errors/index.mjs +1 -0
  35. package/build/executor/ProgramExecutor.d.mts +148 -0
  36. package/build/executor/ProgramExecutor.d.mts.map +1 -0
  37. package/build/executor/ProgramExecutorRegistry.d.mts +111 -0
  38. package/build/executor/ProgramExecutorRegistry.d.mts.map +1 -0
  39. package/build/executor/ProgramExecutorRegistry.mjs +145 -0
  40. package/build/executor/ProgramExecutorRegistry.mjs.map +1 -0
  41. package/build/executor/__mocks__/MockProgramExecutor.d.mts +118 -0
  42. package/build/executor/__mocks__/MockProgramExecutor.d.mts.map +1 -0
  43. package/build/executor/__mocks__/MockProgramExecutor.mjs +96 -0
  44. package/build/executor/__mocks__/MockProgramExecutor.mjs.map +1 -0
  45. package/build/executor/__mocks__/MockProofVerifier.d.mts +97 -0
  46. package/build/executor/__mocks__/MockProofVerifier.d.mts.map +1 -0
  47. package/build/executor/__mocks__/MockProofVerifier.mjs +79 -0
  48. package/build/executor/__mocks__/MockProofVerifier.mjs.map +1 -0
  49. package/build/executor/__mocks__/index.d.mts +2 -0
  50. package/build/executor/index.d.mts +5 -0
  51. package/build/executor/index.mjs +3 -0
  52. package/build/handlers/AcceptPoeMessageHandler.mjs +24 -0
  53. package/build/handlers/AcceptPoeMessageHandler.mjs.map +1 -0
  54. package/build/handlers/ChallengeMessageHandler.mjs +24 -0
  55. package/build/handlers/ChallengeMessageHandler.mjs.map +1 -0
  56. package/build/handlers/CompleteMessageHandler.mjs +24 -0
  57. package/build/handlers/CompleteMessageHandler.mjs.map +1 -0
  58. package/build/handlers/DeclinePoeMessageHandler.mjs +24 -0
  59. package/build/handlers/DeclinePoeMessageHandler.mjs.map +1 -0
  60. package/build/handlers/PoeProblemReportMessageHandler.mjs +18 -0
  61. package/build/handlers/PoeProblemReportMessageHandler.mjs.map +1 -0
  62. package/build/handlers/ProposePoeMessageHandler.mjs +18 -0
  63. package/build/handlers/ProposePoeMessageHandler.mjs.map +1 -0
  64. package/build/handlers/RequestPoeMessageHandler.mjs +18 -0
  65. package/build/handlers/RequestPoeMessageHandler.mjs.map +1 -0
  66. package/build/handlers/SubmitPoeMessageHandler.mjs +18 -0
  67. package/build/handlers/SubmitPoeMessageHandler.mjs.map +1 -0
  68. package/build/handlers/index.mjs +8 -0
  69. package/build/index.d.mts +38 -0
  70. package/build/index.mjs +33 -0
  71. package/build/messages/AcceptPoeMessage.d.mts +48 -0
  72. package/build/messages/AcceptPoeMessage.d.mts.map +1 -0
  73. package/build/messages/AcceptPoeMessage.mjs +61 -0
  74. package/build/messages/AcceptPoeMessage.mjs.map +1 -0
  75. package/build/messages/ChallengeMessage.d.mts +46 -0
  76. package/build/messages/ChallengeMessage.d.mts.map +1 -0
  77. package/build/messages/ChallengeMessage.mjs +57 -0
  78. package/build/messages/ChallengeMessage.mjs.map +1 -0
  79. package/build/messages/CompleteMessage.d.mts +56 -0
  80. package/build/messages/CompleteMessage.d.mts.map +1 -0
  81. package/build/messages/CompleteMessage.mjs +69 -0
  82. package/build/messages/CompleteMessage.mjs.map +1 -0
  83. package/build/messages/DeclinePoeMessage.d.mts +36 -0
  84. package/build/messages/DeclinePoeMessage.d.mts.map +1 -0
  85. package/build/messages/DeclinePoeMessage.mjs +45 -0
  86. package/build/messages/DeclinePoeMessage.mjs.map +1 -0
  87. package/build/messages/PoeProblemReportMessage.d.mts +51 -0
  88. package/build/messages/PoeProblemReportMessage.d.mts.map +1 -0
  89. package/build/messages/PoeProblemReportMessage.mjs +64 -0
  90. package/build/messages/PoeProblemReportMessage.mjs.map +1 -0
  91. package/build/messages/ProposePoeMessage.d.mts +51 -0
  92. package/build/messages/ProposePoeMessage.d.mts.map +1 -0
  93. package/build/messages/ProposePoeMessage.mjs +69 -0
  94. package/build/messages/ProposePoeMessage.mjs.map +1 -0
  95. package/build/messages/RequestPoeMessage.d.mts +64 -0
  96. package/build/messages/RequestPoeMessage.d.mts.map +1 -0
  97. package/build/messages/RequestPoeMessage.mjs +82 -0
  98. package/build/messages/RequestPoeMessage.mjs.map +1 -0
  99. package/build/messages/SubmitPoeMessage.d.mts +58 -0
  100. package/build/messages/SubmitPoeMessage.d.mts.map +1 -0
  101. package/build/messages/SubmitPoeMessage.mjs +75 -0
  102. package/build/messages/SubmitPoeMessage.mjs.map +1 -0
  103. package/build/messages/index.d.mts +9 -0
  104. package/build/messages/index.mjs +11 -0
  105. package/build/models/BindingContext.d.mts +36 -0
  106. package/build/models/BindingContext.d.mts.map +1 -0
  107. package/build/models/BindingContext.mjs +42 -0
  108. package/build/models/BindingContext.mjs.map +1 -0
  109. package/build/models/ProgramExecution.d.mts +142 -0
  110. package/build/models/ProgramExecution.d.mts.map +1 -0
  111. package/build/models/ProofArtifact.d.mts +260 -0
  112. package/build/models/ProofArtifact.d.mts.map +1 -0
  113. package/build/programs/AppAttestationProgram.d.mts +179 -0
  114. package/build/programs/AppAttestationProgram.d.mts.map +1 -0
  115. package/build/programs/AppAttestationProgram.mjs +296 -0
  116. package/build/programs/AppAttestationProgram.mjs.map +1 -0
  117. package/build/programs/PoeProgram.d.mts +204 -0
  118. package/build/programs/PoeProgram.d.mts.map +1 -0
  119. package/build/programs/PoeProgram.mjs +155 -0
  120. package/build/programs/PoeProgram.mjs.map +1 -0
  121. package/build/programs/examples/MockProgram.d.mts +98 -0
  122. package/build/programs/examples/MockProgram.d.mts.map +1 -0
  123. package/build/programs/examples/MockProgram.mjs +117 -0
  124. package/build/programs/examples/MockProgram.mjs.map +1 -0
  125. package/build/programs/examples/index.d.mts +1 -0
  126. package/build/programs/index.d.mts +4 -0
  127. package/build/programs/index.mjs +3 -0
  128. package/build/programs/vkeys/app_attestation_vkey.mjs +136 -0
  129. package/build/programs/vkeys/app_attestation_vkey.mjs.map +1 -0
  130. package/build/registry/ProgramRegistry.d.mts +108 -0
  131. package/build/registry/ProgramRegistry.d.mts.map +1 -0
  132. package/build/registry/ProgramRegistry.mjs +87 -0
  133. package/build/registry/ProgramRegistry.mjs.map +1 -0
  134. package/build/registry/ProofSystemRegistry.d.mts +111 -0
  135. package/build/registry/ProofSystemRegistry.d.mts.map +1 -0
  136. package/build/registry/ProofSystemRegistry.mjs +87 -0
  137. package/build/registry/ProofSystemRegistry.mjs.map +1 -0
  138. package/build/registry/index.d.mts +2 -0
  139. package/build/registry/index.mjs +2 -0
  140. package/build/repository/NonceRecord.d.mts +45 -0
  141. package/build/repository/NonceRecord.d.mts.map +1 -0
  142. package/build/repository/NonceRecord.mjs +34 -0
  143. package/build/repository/NonceRecord.mjs.map +1 -0
  144. package/build/repository/NonceRepository.d.mts +41 -0
  145. package/build/repository/NonceRepository.d.mts.map +1 -0
  146. package/build/repository/NonceRepository.mjs +63 -0
  147. package/build/repository/NonceRepository.mjs.map +1 -0
  148. package/build/repository/PoeSessionRecord.d.mts +107 -0
  149. package/build/repository/PoeSessionRecord.d.mts.map +1 -0
  150. package/build/repository/PoeSessionRecord.mjs +100 -0
  151. package/build/repository/PoeSessionRecord.mjs.map +1 -0
  152. package/build/repository/PoeSessionRepository.d.mts +29 -0
  153. package/build/repository/PoeSessionRepository.d.mts.map +1 -0
  154. package/build/repository/PoeSessionRepository.mjs +46 -0
  155. package/build/repository/PoeSessionRepository.mjs.map +1 -0
  156. package/build/repository/index.d.mts +4 -0
  157. package/build/repository/index.mjs +6 -0
  158. package/build/services/AutoProofExecutionService.d.mts +2 -0
  159. package/build/services/AutoProofExecutionService.mjs +144 -0
  160. package/build/services/AutoProofExecutionService.mjs.map +1 -0
  161. package/build/services/ContextBindingService.d.mts +51 -0
  162. package/build/services/ContextBindingService.d.mts.map +1 -0
  163. package/build/services/ContextBindingService.mjs +92 -0
  164. package/build/services/ContextBindingService.mjs.map +1 -0
  165. package/build/services/NonceService.d.mts +74 -0
  166. package/build/services/NonceService.d.mts.map +1 -0
  167. package/build/services/NonceService.mjs +126 -0
  168. package/build/services/NonceService.mjs.map +1 -0
  169. package/build/services/PoeService.d.mts +163 -0
  170. package/build/services/PoeService.d.mts.map +1 -0
  171. package/build/services/PoeService.mjs +487 -0
  172. package/build/services/PoeService.mjs.map +1 -0
  173. package/build/services/ProofVerificationService.d.mts +87 -0
  174. package/build/services/ProofVerificationService.d.mts.map +1 -0
  175. package/build/services/ProofVerificationService.mjs +164 -0
  176. package/build/services/ProofVerificationService.mjs.map +1 -0
  177. package/build/services/index.d.mts +5 -0
  178. package/build/services/index.mjs +5 -0
  179. package/build/workflow/PoeV1Actions.d.mts +149 -0
  180. package/build/workflow/PoeV1Actions.d.mts.map +1 -0
  181. package/build/workflow/PoeV1Actions.mjs +190 -0
  182. package/build/workflow/PoeV1Actions.mjs.map +1 -0
  183. package/package.json +44 -3
@@ -0,0 +1,148 @@
1
+ import { BindingContext } from "../models/BindingContext.mjs";
2
+ import { ProgramExecution } from "../models/ProgramExecution.mjs";
3
+ import { ProofArtifact } from "../models/ProofArtifact.mjs";
4
+ import { AgentContext } from "@credo-ts/core";
5
+
6
+ //#region src/executor/ProgramExecutor.d.ts
7
+ /**
8
+ * Interface that all ZK program executors must implement.
9
+ *
10
+ * Executors are responsible for:
11
+ * 1. Retrieving necessary data (from Askar DB, HTTP, files, etc.)
12
+ * 2. Generating the ZK proof
13
+ * 3. Returning a properly formatted ProofArtifact
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * export class MyExecutor implements ProgramExecutor {
18
+ * programId = 'my.program.v1'
19
+ *
20
+ * async execute(context, execution, bindingContext) {
21
+ * // 1. Get data
22
+ * const data = await getData(context, execution.inputs)
23
+ *
24
+ * // 2. Generate proof
25
+ * const proof = await generateProof(data, bindingContext)
26
+ *
27
+ * // 3. Return artifact
28
+ * return {
29
+ * program_id: this.programId,
30
+ * result: 'pass',
31
+ * public: { ... },
32
+ * zk: { ... }
33
+ * }
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ interface ProgramExecutor {
39
+ /**
40
+ * Unique program identifier this executor handles
41
+ * Must match the program_id in ProgramMetadata
42
+ */
43
+ readonly programId: string;
44
+ /**
45
+ * Execute the ZK program and generate proof
46
+ *
47
+ * This method is called automatically when a proof request is received
48
+ * if autoExecuteProofs is enabled in PoeModuleConfig.
49
+ *
50
+ * @param context - Agent context for accessing storage, DID resolver, etc.
51
+ * @param execution - Program execution parameters from requester
52
+ * @param bindingContext - Context binding for anti-replay protection
53
+ * @returns Complete proof artifact ready to submit
54
+ * @throws Error if execution fails (will result in problem report)
55
+ */
56
+ execute(context: AgentContext, execution: ProgramExecution, bindingContext: BindingContext): Promise<ProofArtifact>;
57
+ /**
58
+ * Optional: Validate that this executor can handle the request
59
+ *
60
+ * Called before execute() to check if prerequisites are met.
61
+ * Useful for checking if required data exists, parameters are valid, etc.
62
+ *
63
+ * @param context - Agent context
64
+ * @param execution - Program execution parameters
65
+ * @returns Error message if cannot execute, undefined if can execute
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * async canExecute(context, execution) {
70
+ * const dataId = execution.inputs?.by_reference?.data_id
71
+ * if (!dataId) return 'Missing required data_id'
72
+ *
73
+ * const exists = await checkDataExists(context, dataId)
74
+ * if (!exists) return `Data not found: ${dataId}`
75
+ *
76
+ * return undefined // Can execute
77
+ * }
78
+ * ```
79
+ */
80
+ canExecute?(context: AgentContext, execution: ProgramExecution): Promise<string | undefined>;
81
+ }
82
+ /**
83
+ * Interface for ZK proof verifiers.
84
+ *
85
+ * Verifiers provide custom verification logic beyond the generic
86
+ * verification performed by ProofVerificationService.
87
+ *
88
+ * If a custom verifier is registered, it takes precedence over
89
+ * the generic verification logic.
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * export class MyVerifier implements ProofVerifier {
94
+ * programId = 'my.program.v1'
95
+ *
96
+ * async verify(context, artifact, expectedContext) {
97
+ * // 1. Check binding context
98
+ * if (artifact.public.nonce !== expectedContext.nonce) {
99
+ * return { verified: false, errors: ['Nonce mismatch'] }
100
+ * }
101
+ *
102
+ * // 2. Custom verification logic
103
+ * const valid = await myCustomVerification(artifact)
104
+ *
105
+ * return { verified: valid }
106
+ * }
107
+ * }
108
+ * ```
109
+ */
110
+ interface ProofVerifier {
111
+ /**
112
+ * Unique program identifier this verifier handles
113
+ * Must match the program_id in ProgramMetadata
114
+ */
115
+ readonly programId: string;
116
+ /**
117
+ * Verify a proof artifact with custom logic
118
+ *
119
+ * This method is called instead of generic verification if registered.
120
+ * Should perform all necessary verification including:
121
+ * - Binding context validation
122
+ * - ZK proof cryptographic verification
123
+ * - Program-specific constraints
124
+ *
125
+ * @param context - Agent context
126
+ * @param artifact - The proof artifact to verify
127
+ * @param expectedContext - The expected binding context
128
+ * @returns Verification result
129
+ */
130
+ verify(context: AgentContext, artifact: ProofArtifact, expectedContext: BindingContext): Promise<{
131
+ verified: boolean;
132
+ errors?: string[];
133
+ warnings?: string[];
134
+ }>;
135
+ }
136
+ /**
137
+ * Factory function type for creating executors
138
+ * Useful when executors need agent-specific initialization
139
+ */
140
+ type ExecutorFactory = (context: AgentContext) => ProgramExecutor | Promise<ProgramExecutor>;
141
+ /**
142
+ * Factory function type for creating verifiers
143
+ * Useful when verifiers need agent-specific initialization
144
+ */
145
+ type VerifierFactory = (context: AgentContext) => ProofVerifier | Promise<ProofVerifier>;
146
+ //#endregion
147
+ export { ExecutorFactory, ProgramExecutor, ProofVerifier, VerifierFactory };
148
+ //# sourceMappingURL=ProgramExecutor.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProgramExecutor.d.mts","names":[],"sources":["../../src/executor/ProgramExecutor.ts"],"mappings":";;;;;;;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;;;;;;;UAAiB,eAAA;EAmDZ;;;AA+BL;EA/BK,SA9CM,SAAA;;;;;;;;;;;;;EAcT,OAAA,CACE,OAAA,EAAS,YAAA,EACT,SAAA,EAAW,gBAAA,EACX,cAAA,EAAgB,cAAA,GACf,OAAA,CAAQ,aAAA;EAmFQ;;;;;;;;AAYrB;;;;;;;;;;;;;;;EAtEE,UAAA,EACE,OAAA,EAAS,YAAA,EACT,SAAA,EAAW,gBAAA,GACV,OAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+BY,aAAA;;;;;WAKN,SAAA;;;;;;;;;;;;;;;EAgBT,MAAA,CACE,OAAA,EAAS,YAAA,EACT,QAAA,EAAU,aAAA,EACV,eAAA,EAAiB,cAAA,GAChB,OAAA;IACD,QAAA;IACA,MAAA;IACA,QAAA;EAAA;AAAA;;;;;KAQQ,eAAA,IAAmB,OAAA,EAAS,YAAA,KAAiB,eAAA,GAAkB,OAAA,CAAQ,eAAA;;;;;KAMvE,eAAA,IAAmB,OAAA,EAAS,YAAA,KAAiB,aAAA,GAAgB,OAAA,CAAQ,aAAA"}
@@ -0,0 +1,111 @@
1
+ import { ProgramExecutor, ProofVerifier } from "./ProgramExecutor.mjs";
2
+
3
+ //#region src/executor/ProgramExecutorRegistry.d.ts
4
+ /**
5
+ * Registry for managing program executors and verifiers.
6
+ *
7
+ * This is a core service in the PoE module that maintains mappings
8
+ * between program IDs and their executor/verifier implementations.
9
+ *
10
+ * Executors are registered during module initialization via PoeModuleConfig.
11
+ */
12
+ declare class ProgramExecutorRegistry {
13
+ private executors;
14
+ private verifiers;
15
+ /**
16
+ * Register a program executor (prover side)
17
+ *
18
+ * @param executor - The executor implementation
19
+ * @throws PoeError if executor for this program already registered
20
+ */
21
+ registerExecutor(executor: ProgramExecutor): void;
22
+ /**
23
+ * Register a proof verifier (verifier side)
24
+ *
25
+ * @param verifier - The verifier implementation
26
+ * @throws PoeError if verifier for this program already registered
27
+ */
28
+ registerVerifier(verifier: ProofVerifier): void;
29
+ /**
30
+ * Get executor for a program
31
+ *
32
+ * @param programId - The program identifier
33
+ * @returns Executor if registered, undefined otherwise
34
+ */
35
+ getExecutor(programId: string): ProgramExecutor | undefined;
36
+ /**
37
+ * Get verifier for a program
38
+ *
39
+ * @param programId - The program identifier
40
+ * @returns Verifier if registered, undefined otherwise
41
+ */
42
+ getVerifier(programId: string): ProofVerifier | undefined;
43
+ /**
44
+ * Check if executor is registered for a program
45
+ *
46
+ * @param programId - The program identifier
47
+ * @returns True if executor registered, false otherwise
48
+ */
49
+ hasExecutor(programId: string): boolean;
50
+ /**
51
+ * Check if verifier is registered for a program
52
+ *
53
+ * @param programId - The program identifier
54
+ * @returns True if verifier registered, false otherwise
55
+ */
56
+ hasVerifier(programId: string): boolean;
57
+ /**
58
+ * Get all registered executor program IDs
59
+ *
60
+ * @returns Array of program IDs with executors
61
+ */
62
+ getAllExecutorIds(): string[];
63
+ /**
64
+ * Get all registered verifier program IDs
65
+ *
66
+ * @returns Array of program IDs with verifiers
67
+ */
68
+ getAllVerifierIds(): string[];
69
+ /**
70
+ * Unregister an executor
71
+ *
72
+ * @param programId - The program identifier
73
+ * @returns True if executor was removed, false if not found
74
+ */
75
+ unregisterExecutor(programId: string): boolean;
76
+ /**
77
+ * Unregister a verifier
78
+ *
79
+ * @param programId - The program identifier
80
+ * @returns True if verifier was removed, false if not found
81
+ */
82
+ unregisterVerifier(programId: string): boolean;
83
+ /**
84
+ * Get all registered executors (for debugging/introspection)
85
+ *
86
+ * @returns Map of program IDs to executors
87
+ */
88
+ getAllExecutors(): Map<string, ProgramExecutor>;
89
+ /**
90
+ * Get all registered verifiers (for debugging/introspection)
91
+ *
92
+ * @returns Map of program IDs to verifiers
93
+ */
94
+ getAllVerifiers(): Map<string, ProofVerifier>;
95
+ /**
96
+ * Clear all registered executors and verifiers
97
+ * Useful for testing
98
+ */
99
+ clear(): void;
100
+ /**
101
+ * Get count of registered executors
102
+ */
103
+ get executorCount(): number;
104
+ /**
105
+ * Get count of registered verifiers
106
+ */
107
+ get verifierCount(): number;
108
+ }
109
+ //#endregion
110
+ export { ProgramExecutorRegistry };
111
+ //# sourceMappingURL=ProgramExecutorRegistry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProgramExecutorRegistry.d.mts","names":[],"sources":["../../src/executor/ProgramExecutorRegistry.ts"],"mappings":";;;;;AAYA;;;;;;cACa,uBAAA;EAAA,QACH,SAAA;EAAA,QACA,SAAA;EAoI8B;;;;;;EA5H/B,gBAAA,CAAiB,QAAA,EAAU,eAAA;EAAA;;;;;;EAmB3B,gBAAA,CAAiB,QAAA,EAAU,aAAA;EAmBK;;;;;;EAAhC,WAAA,CAAY,SAAA,WAAoB,eAAA;EA8BpB;;;;;;EApBZ,WAAA,CAAY,SAAA,WAAoB,aAAA;EAmEhC;;;;;;EAzDA,WAAA,CAAY,SAAA;EAkFR;;;;;;EAxEJ,WAAA,CAAY,SAAA;;;;;;EASZ,iBAAA,CAAA;;;;;;EASA,iBAAA,CAAA;;;;;;;EAUA,kBAAA,CAAmB,SAAA;;;;;;;EAUnB,kBAAA,CAAmB,SAAA;;;;;;EASnB,eAAA,CAAA,GAAmB,GAAA,SAAY,eAAA;;;;;;EAS/B,eAAA,CAAA,GAAmB,GAAA,SAAY,aAAA;;;;;EAQ/B,KAAA,CAAA;;;;MAQI,aAAA,CAAA;;;;MAOA,aAAA,CAAA;AAAA"}
@@ -0,0 +1,145 @@
1
+ import { PoeError } from "../errors/PoeError.mjs";
2
+ import "../errors/index.mjs";
3
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
4
+ import { injectable } from "tsyringe";
5
+
6
+ //#region src/executor/ProgramExecutorRegistry.ts
7
+ let ProgramExecutorRegistry = class ProgramExecutorRegistry {
8
+ constructor() {
9
+ this.executors = /* @__PURE__ */ new Map();
10
+ this.verifiers = /* @__PURE__ */ new Map();
11
+ }
12
+ /**
13
+ * Register a program executor (prover side)
14
+ *
15
+ * @param executor - The executor implementation
16
+ * @throws PoeError if executor for this program already registered
17
+ */
18
+ registerExecutor(executor) {
19
+ const programId = executor.programId;
20
+ if (this.executors.has(programId)) throw new PoeError(`Executor for program ${programId} already registered. Use unregisterExecutor() first if you need to replace it.`);
21
+ this.executors.set(programId, executor);
22
+ }
23
+ /**
24
+ * Register a proof verifier (verifier side)
25
+ *
26
+ * @param verifier - The verifier implementation
27
+ * @throws PoeError if verifier for this program already registered
28
+ */
29
+ registerVerifier(verifier) {
30
+ const programId = verifier.programId;
31
+ if (this.verifiers.has(programId)) throw new PoeError(`Verifier for program ${programId} already registered. Use unregisterVerifier() first if you need to replace it.`);
32
+ this.verifiers.set(programId, verifier);
33
+ }
34
+ /**
35
+ * Get executor for a program
36
+ *
37
+ * @param programId - The program identifier
38
+ * @returns Executor if registered, undefined otherwise
39
+ */
40
+ getExecutor(programId) {
41
+ return this.executors.get(programId);
42
+ }
43
+ /**
44
+ * Get verifier for a program
45
+ *
46
+ * @param programId - The program identifier
47
+ * @returns Verifier if registered, undefined otherwise
48
+ */
49
+ getVerifier(programId) {
50
+ return this.verifiers.get(programId);
51
+ }
52
+ /**
53
+ * Check if executor is registered for a program
54
+ *
55
+ * @param programId - The program identifier
56
+ * @returns True if executor registered, false otherwise
57
+ */
58
+ hasExecutor(programId) {
59
+ return this.executors.has(programId);
60
+ }
61
+ /**
62
+ * Check if verifier is registered for a program
63
+ *
64
+ * @param programId - The program identifier
65
+ * @returns True if verifier registered, false otherwise
66
+ */
67
+ hasVerifier(programId) {
68
+ return this.verifiers.has(programId);
69
+ }
70
+ /**
71
+ * Get all registered executor program IDs
72
+ *
73
+ * @returns Array of program IDs with executors
74
+ */
75
+ getAllExecutorIds() {
76
+ return Array.from(this.executors.keys());
77
+ }
78
+ /**
79
+ * Get all registered verifier program IDs
80
+ *
81
+ * @returns Array of program IDs with verifiers
82
+ */
83
+ getAllVerifierIds() {
84
+ return Array.from(this.verifiers.keys());
85
+ }
86
+ /**
87
+ * Unregister an executor
88
+ *
89
+ * @param programId - The program identifier
90
+ * @returns True if executor was removed, false if not found
91
+ */
92
+ unregisterExecutor(programId) {
93
+ return this.executors.delete(programId);
94
+ }
95
+ /**
96
+ * Unregister a verifier
97
+ *
98
+ * @param programId - The program identifier
99
+ * @returns True if verifier was removed, false if not found
100
+ */
101
+ unregisterVerifier(programId) {
102
+ return this.verifiers.delete(programId);
103
+ }
104
+ /**
105
+ * Get all registered executors (for debugging/introspection)
106
+ *
107
+ * @returns Map of program IDs to executors
108
+ */
109
+ getAllExecutors() {
110
+ return new Map(this.executors);
111
+ }
112
+ /**
113
+ * Get all registered verifiers (for debugging/introspection)
114
+ *
115
+ * @returns Map of program IDs to verifiers
116
+ */
117
+ getAllVerifiers() {
118
+ return new Map(this.verifiers);
119
+ }
120
+ /**
121
+ * Clear all registered executors and verifiers
122
+ * Useful for testing
123
+ */
124
+ clear() {
125
+ this.executors.clear();
126
+ this.verifiers.clear();
127
+ }
128
+ /**
129
+ * Get count of registered executors
130
+ */
131
+ get executorCount() {
132
+ return this.executors.size;
133
+ }
134
+ /**
135
+ * Get count of registered verifiers
136
+ */
137
+ get verifierCount() {
138
+ return this.verifiers.size;
139
+ }
140
+ };
141
+ ProgramExecutorRegistry = __decorate([injectable()], ProgramExecutorRegistry);
142
+
143
+ //#endregion
144
+ export { ProgramExecutorRegistry };
145
+ //# sourceMappingURL=ProgramExecutorRegistry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProgramExecutorRegistry.mjs","names":[],"sources":["../../src/executor/ProgramExecutorRegistry.ts"],"sourcesContent":["import { injectable } from 'tsyringe'\nimport type { ProgramExecutor, ProofVerifier } from './ProgramExecutor'\nimport { PoeError } from '../errors'\n\n/**\n * Registry for managing program executors and verifiers.\n *\n * This is a core service in the PoE module that maintains mappings\n * between program IDs and their executor/verifier implementations.\n *\n * Executors are registered during module initialization via PoeModuleConfig.\n */\n@injectable()\nexport class ProgramExecutorRegistry {\n private executors = new Map<string, ProgramExecutor>()\n private verifiers = new Map<string, ProofVerifier>()\n\n /**\n * Register a program executor (prover side)\n *\n * @param executor - The executor implementation\n * @throws PoeError if executor for this program already registered\n */\n public registerExecutor(executor: ProgramExecutor): void {\n const programId = executor.programId\n\n if (this.executors.has(programId)) {\n throw new PoeError(\n `Executor for program ${programId} already registered. ` +\n `Use unregisterExecutor() first if you need to replace it.`\n )\n }\n\n this.executors.set(programId, executor)\n }\n\n /**\n * Register a proof verifier (verifier side)\n *\n * @param verifier - The verifier implementation\n * @throws PoeError if verifier for this program already registered\n */\n public registerVerifier(verifier: ProofVerifier): void {\n const programId = verifier.programId\n\n if (this.verifiers.has(programId)) {\n throw new PoeError(\n `Verifier for program ${programId} already registered. ` +\n `Use unregisterVerifier() first if you need to replace it.`\n )\n }\n\n this.verifiers.set(programId, verifier)\n }\n\n /**\n * Get executor for a program\n *\n * @param programId - The program identifier\n * @returns Executor if registered, undefined otherwise\n */\n public getExecutor(programId: string): ProgramExecutor | undefined {\n return this.executors.get(programId)\n }\n\n /**\n * Get verifier for a program\n *\n * @param programId - The program identifier\n * @returns Verifier if registered, undefined otherwise\n */\n public getVerifier(programId: string): ProofVerifier | undefined {\n return this.verifiers.get(programId)\n }\n\n /**\n * Check if executor is registered for a program\n *\n * @param programId - The program identifier\n * @returns True if executor registered, false otherwise\n */\n public hasExecutor(programId: string): boolean {\n return this.executors.has(programId)\n }\n\n /**\n * Check if verifier is registered for a program\n *\n * @param programId - The program identifier\n * @returns True if verifier registered, false otherwise\n */\n public hasVerifier(programId: string): boolean {\n return this.verifiers.has(programId)\n }\n\n /**\n * Get all registered executor program IDs\n *\n * @returns Array of program IDs with executors\n */\n public getAllExecutorIds(): string[] {\n return Array.from(this.executors.keys())\n }\n\n /**\n * Get all registered verifier program IDs\n *\n * @returns Array of program IDs with verifiers\n */\n public getAllVerifierIds(): string[] {\n return Array.from(this.verifiers.keys())\n }\n\n /**\n * Unregister an executor\n *\n * @param programId - The program identifier\n * @returns True if executor was removed, false if not found\n */\n public unregisterExecutor(programId: string): boolean {\n return this.executors.delete(programId)\n }\n\n /**\n * Unregister a verifier\n *\n * @param programId - The program identifier\n * @returns True if verifier was removed, false if not found\n */\n public unregisterVerifier(programId: string): boolean {\n return this.verifiers.delete(programId)\n }\n\n /**\n * Get all registered executors (for debugging/introspection)\n *\n * @returns Map of program IDs to executors\n */\n public getAllExecutors(): Map<string, ProgramExecutor> {\n return new Map(this.executors)\n }\n\n /**\n * Get all registered verifiers (for debugging/introspection)\n *\n * @returns Map of program IDs to verifiers\n */\n public getAllVerifiers(): Map<string, ProofVerifier> {\n return new Map(this.verifiers)\n }\n\n /**\n * Clear all registered executors and verifiers\n * Useful for testing\n */\n public clear(): void {\n this.executors.clear()\n this.verifiers.clear()\n }\n\n /**\n * Get count of registered executors\n */\n public get executorCount(): number {\n return this.executors.size\n }\n\n /**\n * Get count of registered verifiers\n */\n public get verifierCount(): number {\n return this.verifiers.size\n }\n}\n"],"mappings":";;;;;;AAaO,oCAAM,wBAAwB;;OAC3B,4BAAY,IAAI,KAA8B;OAC9C,4BAAY,IAAI,KAA4B;;;;;;;;CAQpD,AAAO,iBAAiB,UAAiC;EACvD,MAAM,YAAY,SAAS;AAE3B,MAAI,KAAK,UAAU,IAAI,UAAU,CAC/B,OAAM,IAAI,SACR,wBAAwB,UAAU,gFAEnC;AAGH,OAAK,UAAU,IAAI,WAAW,SAAS;;;;;;;;CASzC,AAAO,iBAAiB,UAA+B;EACrD,MAAM,YAAY,SAAS;AAE3B,MAAI,KAAK,UAAU,IAAI,UAAU,CAC/B,OAAM,IAAI,SACR,wBAAwB,UAAU,gFAEnC;AAGH,OAAK,UAAU,IAAI,WAAW,SAAS;;;;;;;;CASzC,AAAO,YAAY,WAAgD;AACjE,SAAO,KAAK,UAAU,IAAI,UAAU;;;;;;;;CAStC,AAAO,YAAY,WAA8C;AAC/D,SAAO,KAAK,UAAU,IAAI,UAAU;;;;;;;;CAStC,AAAO,YAAY,WAA4B;AAC7C,SAAO,KAAK,UAAU,IAAI,UAAU;;;;;;;;CAStC,AAAO,YAAY,WAA4B;AAC7C,SAAO,KAAK,UAAU,IAAI,UAAU;;;;;;;CAQtC,AAAO,oBAA8B;AACnC,SAAO,MAAM,KAAK,KAAK,UAAU,MAAM,CAAC;;;;;;;CAQ1C,AAAO,oBAA8B;AACnC,SAAO,MAAM,KAAK,KAAK,UAAU,MAAM,CAAC;;;;;;;;CAS1C,AAAO,mBAAmB,WAA4B;AACpD,SAAO,KAAK,UAAU,OAAO,UAAU;;;;;;;;CASzC,AAAO,mBAAmB,WAA4B;AACpD,SAAO,KAAK,UAAU,OAAO,UAAU;;;;;;;CAQzC,AAAO,kBAAgD;AACrD,SAAO,IAAI,IAAI,KAAK,UAAU;;;;;;;CAQhC,AAAO,kBAA8C;AACnD,SAAO,IAAI,IAAI,KAAK,UAAU;;;;;;CAOhC,AAAO,QAAc;AACnB,OAAK,UAAU,OAAO;AACtB,OAAK,UAAU,OAAO;;;;;CAMxB,IAAW,gBAAwB;AACjC,SAAO,KAAK,UAAU;;;;;CAMxB,IAAW,gBAAwB;AACjC,SAAO,KAAK,UAAU;;;sCA/JzB,YAAY"}
@@ -0,0 +1,118 @@
1
+ import { BindingContext } from "../../models/BindingContext.mjs";
2
+ import { ProgramExecution } from "../../models/ProgramExecution.mjs";
3
+ import { ProofArtifact } from "../../models/ProofArtifact.mjs";
4
+ import { ProgramExecutor } from "../ProgramExecutor.mjs";
5
+ import { AgentContext } from "@credo-ts/core";
6
+
7
+ //#region src/executor/__mocks__/MockProgramExecutor.d.ts
8
+ /**
9
+ * Mock ZK program executor for testing.
10
+ *
11
+ * Simulates proof generation without actual cryptographic computation.
12
+ * Useful for integration tests and development.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const mockExecutor = new MockProgramExecutor('mock-age-check', {
17
+ * executionDelayMs: 100, // Simulate processing time
18
+ * shouldFail: false,
19
+ * result: { age_over_18: true }
20
+ * })
21
+ *
22
+ * const agent = new Agent({
23
+ * modules: {
24
+ * poe: new PoeModule({
25
+ * executors: [mockExecutor],
26
+ * autoExecuteProofs: true
27
+ * })
28
+ * }
29
+ * })
30
+ * ```
31
+ */
32
+ declare class MockProgramExecutor implements ProgramExecutor {
33
+ readonly programId: string;
34
+ private options;
35
+ /**
36
+ * Create a new mock executor
37
+ *
38
+ * @param programId - Program identifier (e.g., 'mock-age-check')
39
+ * @param options - Mock behavior options
40
+ */
41
+ constructor(programId: string, options?: MockExecutorOptions);
42
+ /**
43
+ * Validate if this executor can handle the request
44
+ *
45
+ * Returns an error message if validation fails, undefined otherwise.
46
+ */
47
+ canExecute(context: AgentContext, execution: ProgramExecution): Promise<string | undefined>;
48
+ /**
49
+ * Execute the mock proof generation
50
+ *
51
+ * Returns a simulated proof artifact with mock cryptographic data.
52
+ */
53
+ execute(context: AgentContext, execution: ProgramExecution, bindingContext: BindingContext): Promise<ProofArtifact>;
54
+ /**
55
+ * Helper to introduce async delay
56
+ */
57
+ private delay;
58
+ }
59
+ /**
60
+ * Configuration options for MockProgramExecutor
61
+ */
62
+ interface MockExecutorOptions {
63
+ /**
64
+ * Delay in milliseconds to simulate proof generation time
65
+ * @default 0
66
+ */
67
+ executionDelayMs?: number;
68
+ /**
69
+ * Whether execution should fail with an error
70
+ * @default false
71
+ */
72
+ shouldFail?: boolean;
73
+ /**
74
+ * Error message if shouldFail is true
75
+ */
76
+ errorMessage?: string;
77
+ /**
78
+ * Whether validation (canExecute) should fail
79
+ * @default false
80
+ */
81
+ shouldFailValidation?: boolean;
82
+ /**
83
+ * Validation error message if shouldFailValidation is true
84
+ */
85
+ validationError?: string;
86
+ /**
87
+ * Mock result (pass/fail/partial)
88
+ * @default 'pass'
89
+ */
90
+ result?: 'pass' | 'fail' | 'partial';
91
+ /**
92
+ * Mock verifying key hash
93
+ * @default '0x' + '1'.repeat(64)
94
+ */
95
+ mockVkHash?: string;
96
+ /**
97
+ * Mock proof data (base64 encoded)
98
+ * @default Buffer.from('mock-proof-data').toString('base64')
99
+ */
100
+ mockProofB64?: string;
101
+ /**
102
+ * Mock proof scheme name
103
+ * @default 'mock-plonk'
104
+ */
105
+ mockScheme?: string;
106
+ /**
107
+ * Public schema identifier
108
+ * @default 'mock-schema-1.0'
109
+ */
110
+ publicSchema?: string;
111
+ /**
112
+ * Additional public outputs to include in proof artifact
113
+ */
114
+ publicOutputs?: Record<string, unknown>;
115
+ }
116
+ //#endregion
117
+ export { MockExecutorOptions, MockProgramExecutor };
118
+ //# sourceMappingURL=MockProgramExecutor.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockProgramExecutor.d.mts","names":[],"sources":["../../../src/executor/__mocks__/MockProgramExecutor.ts"],"mappings":";;;;;;;;;;;AA4BA;;;;;;;;;;;;;;;;;;;;cAAa,mBAAA,YAA+B,eAAA;EAAA,SAC1B,SAAA;EAAA,QAER,OAAA;EA4BG;;;;;;cApBQ,SAAA,UAAmB,OAAA,GAAS,mBAAA;EAyC7C;;;;;EAtBW,UAAA,CACX,OAAA,EAAS,YAAA,EACT,SAAA,EAAW,gBAAA,GACV,OAAA;EAsBQ;;;;AAmDb;EAvDe,OAAA,CACX,OAAA,EAAS,YAAA,EACT,SAAA,EAAW,gBAAA,EACX,cAAA,EAAgB,cAAA,GACf,OAAA,CAAQ,aAAA;;;;UA2CH,KAAA;AAAA;;;;UAQO,mBAAA;EA6Cf;;;;EAxCA,gBAAA;EAyDsB;;;;EAnDtB,UAAA;;;;EAKA,YAAA;;;;;EAMA,oBAAA;;;;EAKA,eAAA;;;;;EAMA,MAAA;;;;;EAMA,UAAA;;;;;EAMA,YAAA;;;;;EAMA,UAAA;;;;;EAMA,YAAA;;;;EAKA,aAAA,GAAgB,MAAA;AAAA"}
@@ -0,0 +1,96 @@
1
+ //#region src/executor/__mocks__/MockProgramExecutor.ts
2
+ /**
3
+ * Mock ZK program executor for testing.
4
+ *
5
+ * Simulates proof generation without actual cryptographic computation.
6
+ * Useful for integration tests and development.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const mockExecutor = new MockProgramExecutor('mock-age-check', {
11
+ * executionDelayMs: 100, // Simulate processing time
12
+ * shouldFail: false,
13
+ * result: { age_over_18: true }
14
+ * })
15
+ *
16
+ * const agent = new Agent({
17
+ * modules: {
18
+ * poe: new PoeModule({
19
+ * executors: [mockExecutor],
20
+ * autoExecuteProofs: true
21
+ * })
22
+ * }
23
+ * })
24
+ * ```
25
+ */
26
+ var MockProgramExecutor = class {
27
+ /**
28
+ * Create a new mock executor
29
+ *
30
+ * @param programId - Program identifier (e.g., 'mock-age-check')
31
+ * @param options - Mock behavior options
32
+ */
33
+ constructor(programId, options = {}) {
34
+ this.programId = programId;
35
+ this.options = {
36
+ executionDelayMs: 0,
37
+ shouldFail: false,
38
+ shouldFailValidation: false,
39
+ validationError: "Mock validation failed",
40
+ mockVkHash: "0x" + "1".repeat(64),
41
+ mockProofB64: Buffer.from("mock-proof-data").toString("base64"),
42
+ publicSchema: "mock-schema-1.0",
43
+ ...options
44
+ };
45
+ }
46
+ /**
47
+ * Validate if this executor can handle the request
48
+ *
49
+ * Returns an error message if validation fails, undefined otherwise.
50
+ */
51
+ async canExecute(context, execution) {
52
+ if (this.options.shouldFailValidation) return this.options.validationError;
53
+ if (execution.program_id !== this.programId) return `Program ID mismatch: expected ${this.programId}, got ${execution.program_id}`;
54
+ }
55
+ /**
56
+ * Execute the mock proof generation
57
+ *
58
+ * Returns a simulated proof artifact with mock cryptographic data.
59
+ */
60
+ async execute(context, execution, bindingContext) {
61
+ if (this.options.executionDelayMs && this.options.executionDelayMs > 0) await this.delay(this.options.executionDelayMs);
62
+ if (this.options.shouldFail) throw new Error(this.options.errorMessage || "Mock executor failed");
63
+ const result = this.options.result || "pass";
64
+ const vkHash = this.options.mockVkHash;
65
+ const proofB64 = this.options.mockProofB64;
66
+ return {
67
+ program_id: this.programId,
68
+ result,
69
+ zk: {
70
+ scheme: this.options.mockScheme || "mock-plonk",
71
+ circuit_id: execution.program_id,
72
+ vk_hash: vkHash,
73
+ proof_b64: proofB64
74
+ },
75
+ public: {
76
+ schema: this.options.publicSchema || "mock-schema-1.0",
77
+ nonce: bindingContext.nonce,
78
+ context_hash: bindingContext.context_hash,
79
+ session_id: bindingContext.session_id,
80
+ vk_hash: vkHash,
81
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
82
+ ...this.options.publicOutputs
83
+ }
84
+ };
85
+ }
86
+ /**
87
+ * Helper to introduce async delay
88
+ */
89
+ delay(ms) {
90
+ return new Promise((resolve) => setTimeout(resolve, ms));
91
+ }
92
+ };
93
+
94
+ //#endregion
95
+ export { MockProgramExecutor };
96
+ //# sourceMappingURL=MockProgramExecutor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockProgramExecutor.mjs","names":[],"sources":["../../../src/executor/__mocks__/MockProgramExecutor.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport type { ProgramExecutor } from '../ProgramExecutor'\nimport type { ProgramExecution, BindingContext, ProofArtifact } from '../../models'\n\n/**\n * Mock ZK program executor for testing.\n *\n * Simulates proof generation without actual cryptographic computation.\n * Useful for integration tests and development.\n *\n * @example\n * ```typescript\n * const mockExecutor = new MockProgramExecutor('mock-age-check', {\n * executionDelayMs: 100, // Simulate processing time\n * shouldFail: false,\n * result: { age_over_18: true }\n * })\n *\n * const agent = new Agent({\n * modules: {\n * poe: new PoeModule({\n * executors: [mockExecutor],\n * autoExecuteProofs: true\n * })\n * }\n * })\n * ```\n */\nexport class MockProgramExecutor implements ProgramExecutor {\n public readonly programId: string\n\n private options: MockExecutorOptions\n\n /**\n * Create a new mock executor\n *\n * @param programId - Program identifier (e.g., 'mock-age-check')\n * @param options - Mock behavior options\n */\n public constructor(programId: string, options: MockExecutorOptions = {}) {\n this.programId = programId\n this.options = {\n executionDelayMs: 0,\n shouldFail: false,\n shouldFailValidation: false,\n validationError: 'Mock validation failed',\n mockVkHash: '0x' + '1'.repeat(64),\n mockProofB64: Buffer.from('mock-proof-data').toString('base64'),\n publicSchema: 'mock-schema-1.0',\n ...options,\n }\n }\n\n /**\n * Validate if this executor can handle the request\n *\n * Returns an error message if validation fails, undefined otherwise.\n */\n public async canExecute(\n context: AgentContext,\n execution: ProgramExecution\n ): Promise<string | undefined> {\n if (this.options.shouldFailValidation) {\n return this.options.validationError\n }\n\n // Validate program ID matches\n if (execution.program_id !== this.programId) {\n return `Program ID mismatch: expected ${this.programId}, got ${execution.program_id}`\n }\n\n return undefined\n }\n\n /**\n * Execute the mock proof generation\n *\n * Returns a simulated proof artifact with mock cryptographic data.\n */\n public async execute(\n context: AgentContext,\n execution: ProgramExecution,\n bindingContext: BindingContext\n ): Promise<ProofArtifact> {\n // Simulate processing delay\n if (this.options.executionDelayMs && this.options.executionDelayMs > 0) {\n await this.delay(this.options.executionDelayMs)\n }\n\n // Simulate execution failure\n if (this.options.shouldFail) {\n throw new Error(this.options.errorMessage || 'Mock executor failed')\n }\n\n // Generate mock proof artifact\n const result = this.options.result || 'pass'\n const vkHash = this.options.mockVkHash!\n const proofB64 = this.options.mockProofB64!\n\n const proofArtifact: ProofArtifact = {\n program_id: this.programId,\n result,\n zk: {\n scheme: this.options.mockScheme || 'mock-plonk',\n circuit_id: execution.program_id, // Use program_id as circuit_id\n vk_hash: vkHash,\n proof_b64: proofB64,\n },\n public: {\n schema: this.options.publicSchema || 'mock-schema-1.0',\n nonce: bindingContext.nonce,\n context_hash: bindingContext.context_hash,\n session_id: bindingContext.session_id,\n vk_hash: vkHash,\n timestamp: new Date().toISOString(),\n // Include any public outputs from execution\n ...this.options.publicOutputs,\n },\n }\n\n return proofArtifact\n }\n\n /**\n * Helper to introduce async delay\n */\n private delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n }\n}\n\n/**\n * Configuration options for MockProgramExecutor\n */\nexport interface MockExecutorOptions {\n /**\n * Delay in milliseconds to simulate proof generation time\n * @default 0\n */\n executionDelayMs?: number\n\n /**\n * Whether execution should fail with an error\n * @default false\n */\n shouldFail?: boolean\n\n /**\n * Error message if shouldFail is true\n */\n errorMessage?: string\n\n /**\n * Whether validation (canExecute) should fail\n * @default false\n */\n shouldFailValidation?: boolean\n\n /**\n * Validation error message if shouldFailValidation is true\n */\n validationError?: string\n\n /**\n * Mock result (pass/fail/partial)\n * @default 'pass'\n */\n result?: 'pass' | 'fail' | 'partial'\n\n /**\n * Mock verifying key hash\n * @default '0x' + '1'.repeat(64)\n */\n mockVkHash?: string\n\n /**\n * Mock proof data (base64 encoded)\n * @default Buffer.from('mock-proof-data').toString('base64')\n */\n mockProofB64?: string\n\n /**\n * Mock proof scheme name\n * @default 'mock-plonk'\n */\n mockScheme?: string\n\n /**\n * Public schema identifier\n * @default 'mock-schema-1.0'\n */\n publicSchema?: string\n\n /**\n * Additional public outputs to include in proof artifact\n */\n publicOutputs?: Record<string, unknown>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,sBAAb,MAA4D;;;;;;;CAW1D,AAAO,YAAY,WAAmB,UAA+B,EAAE,EAAE;AACvE,OAAK,YAAY;AACjB,OAAK,UAAU;GACb,kBAAkB;GAClB,YAAY;GACZ,sBAAsB;GACtB,iBAAiB;GACjB,YAAY,OAAO,IAAI,OAAO,GAAG;GACjC,cAAc,OAAO,KAAK,kBAAkB,CAAC,SAAS,SAAS;GAC/D,cAAc;GACd,GAAG;GACJ;;;;;;;CAQH,MAAa,WACX,SACA,WAC6B;AAC7B,MAAI,KAAK,QAAQ,qBACf,QAAO,KAAK,QAAQ;AAItB,MAAI,UAAU,eAAe,KAAK,UAChC,QAAO,iCAAiC,KAAK,UAAU,QAAQ,UAAU;;;;;;;CAW7E,MAAa,QACX,SACA,WACA,gBACwB;AAExB,MAAI,KAAK,QAAQ,oBAAoB,KAAK,QAAQ,mBAAmB,EACnE,OAAM,KAAK,MAAM,KAAK,QAAQ,iBAAiB;AAIjD,MAAI,KAAK,QAAQ,WACf,OAAM,IAAI,MAAM,KAAK,QAAQ,gBAAgB,uBAAuB;EAItE,MAAM,SAAS,KAAK,QAAQ,UAAU;EACtC,MAAM,SAAS,KAAK,QAAQ;EAC5B,MAAM,WAAW,KAAK,QAAQ;AAuB9B,SArBqC;GACnC,YAAY,KAAK;GACjB;GACA,IAAI;IACF,QAAQ,KAAK,QAAQ,cAAc;IACnC,YAAY,UAAU;IACtB,SAAS;IACT,WAAW;IACZ;GACD,QAAQ;IACN,QAAQ,KAAK,QAAQ,gBAAgB;IACrC,OAAO,eAAe;IACtB,cAAc,eAAe;IAC7B,YAAY,eAAe;IAC3B,SAAS;IACT,4BAAW,IAAI,MAAM,EAAC,aAAa;IAEnC,GAAG,KAAK,QAAQ;IACjB;GACF;;;;;CAQH,AAAQ,MAAM,IAA2B;AACvC,SAAO,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC"}