@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.
- package/LICENSE +202 -0
- package/README.md +39 -2
- package/build/PoeApi.d.mts +150 -0
- package/build/PoeApi.d.mts.map +1 -0
- package/build/PoeApi.mjs +262 -0
- package/build/PoeApi.mjs.map +1 -0
- package/build/PoeEvents.d.mts +187 -0
- package/build/PoeEvents.d.mts.map +1 -0
- package/build/PoeEvents.mjs +28 -0
- package/build/PoeEvents.mjs.map +1 -0
- package/build/PoeModule.d.mts +61 -0
- package/build/PoeModule.d.mts.map +1 -0
- package/build/PoeModule.mjs +139 -0
- package/build/PoeModule.mjs.map +1 -0
- package/build/PoeModuleConfig.d.mts +71 -0
- package/build/PoeModuleConfig.d.mts.map +1 -0
- package/build/PoeRole.d.mts +21 -0
- package/build/PoeRole.d.mts.map +1 -0
- package/build/PoeRole.mjs +23 -0
- package/build/PoeRole.mjs.map +1 -0
- package/build/PoeState.d.mts +76 -0
- package/build/PoeState.d.mts.map +1 -0
- package/build/PoeState.mjs +78 -0
- package/build/PoeState.mjs.map +1 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +10 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +7 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs +9 -0
- package/build/_virtual/_rolldown/runtime.mjs +8 -0
- package/build/errors/PoeError.d.mts +173 -0
- package/build/errors/PoeError.d.mts.map +1 -0
- package/build/errors/PoeError.mjs +147 -0
- package/build/errors/PoeError.mjs.map +1 -0
- package/build/errors/index.d.mts +1 -0
- package/build/errors/index.mjs +1 -0
- package/build/executor/ProgramExecutor.d.mts +148 -0
- package/build/executor/ProgramExecutor.d.mts.map +1 -0
- package/build/executor/ProgramExecutorRegistry.d.mts +111 -0
- package/build/executor/ProgramExecutorRegistry.d.mts.map +1 -0
- package/build/executor/ProgramExecutorRegistry.mjs +145 -0
- package/build/executor/ProgramExecutorRegistry.mjs.map +1 -0
- package/build/executor/__mocks__/MockProgramExecutor.d.mts +118 -0
- package/build/executor/__mocks__/MockProgramExecutor.d.mts.map +1 -0
- package/build/executor/__mocks__/MockProgramExecutor.mjs +96 -0
- package/build/executor/__mocks__/MockProgramExecutor.mjs.map +1 -0
- package/build/executor/__mocks__/MockProofVerifier.d.mts +97 -0
- package/build/executor/__mocks__/MockProofVerifier.d.mts.map +1 -0
- package/build/executor/__mocks__/MockProofVerifier.mjs +79 -0
- package/build/executor/__mocks__/MockProofVerifier.mjs.map +1 -0
- package/build/executor/__mocks__/index.d.mts +2 -0
- package/build/executor/index.d.mts +5 -0
- package/build/executor/index.mjs +3 -0
- package/build/handlers/AcceptPoeMessageHandler.mjs +24 -0
- package/build/handlers/AcceptPoeMessageHandler.mjs.map +1 -0
- package/build/handlers/ChallengeMessageHandler.mjs +24 -0
- package/build/handlers/ChallengeMessageHandler.mjs.map +1 -0
- package/build/handlers/CompleteMessageHandler.mjs +24 -0
- package/build/handlers/CompleteMessageHandler.mjs.map +1 -0
- package/build/handlers/DeclinePoeMessageHandler.mjs +24 -0
- package/build/handlers/DeclinePoeMessageHandler.mjs.map +1 -0
- package/build/handlers/PoeProblemReportMessageHandler.mjs +18 -0
- package/build/handlers/PoeProblemReportMessageHandler.mjs.map +1 -0
- package/build/handlers/ProposePoeMessageHandler.mjs +18 -0
- package/build/handlers/ProposePoeMessageHandler.mjs.map +1 -0
- package/build/handlers/RequestPoeMessageHandler.mjs +18 -0
- package/build/handlers/RequestPoeMessageHandler.mjs.map +1 -0
- package/build/handlers/SubmitPoeMessageHandler.mjs +18 -0
- package/build/handlers/SubmitPoeMessageHandler.mjs.map +1 -0
- package/build/handlers/index.mjs +8 -0
- package/build/index.d.mts +38 -0
- package/build/index.mjs +33 -0
- package/build/messages/AcceptPoeMessage.d.mts +48 -0
- package/build/messages/AcceptPoeMessage.d.mts.map +1 -0
- package/build/messages/AcceptPoeMessage.mjs +61 -0
- package/build/messages/AcceptPoeMessage.mjs.map +1 -0
- package/build/messages/ChallengeMessage.d.mts +46 -0
- package/build/messages/ChallengeMessage.d.mts.map +1 -0
- package/build/messages/ChallengeMessage.mjs +57 -0
- package/build/messages/ChallengeMessage.mjs.map +1 -0
- package/build/messages/CompleteMessage.d.mts +56 -0
- package/build/messages/CompleteMessage.d.mts.map +1 -0
- package/build/messages/CompleteMessage.mjs +69 -0
- package/build/messages/CompleteMessage.mjs.map +1 -0
- package/build/messages/DeclinePoeMessage.d.mts +36 -0
- package/build/messages/DeclinePoeMessage.d.mts.map +1 -0
- package/build/messages/DeclinePoeMessage.mjs +45 -0
- package/build/messages/DeclinePoeMessage.mjs.map +1 -0
- package/build/messages/PoeProblemReportMessage.d.mts +51 -0
- package/build/messages/PoeProblemReportMessage.d.mts.map +1 -0
- package/build/messages/PoeProblemReportMessage.mjs +64 -0
- package/build/messages/PoeProblemReportMessage.mjs.map +1 -0
- package/build/messages/ProposePoeMessage.d.mts +51 -0
- package/build/messages/ProposePoeMessage.d.mts.map +1 -0
- package/build/messages/ProposePoeMessage.mjs +69 -0
- package/build/messages/ProposePoeMessage.mjs.map +1 -0
- package/build/messages/RequestPoeMessage.d.mts +64 -0
- package/build/messages/RequestPoeMessage.d.mts.map +1 -0
- package/build/messages/RequestPoeMessage.mjs +82 -0
- package/build/messages/RequestPoeMessage.mjs.map +1 -0
- package/build/messages/SubmitPoeMessage.d.mts +58 -0
- package/build/messages/SubmitPoeMessage.d.mts.map +1 -0
- package/build/messages/SubmitPoeMessage.mjs +75 -0
- package/build/messages/SubmitPoeMessage.mjs.map +1 -0
- package/build/messages/index.d.mts +9 -0
- package/build/messages/index.mjs +11 -0
- package/build/models/BindingContext.d.mts +36 -0
- package/build/models/BindingContext.d.mts.map +1 -0
- package/build/models/BindingContext.mjs +42 -0
- package/build/models/BindingContext.mjs.map +1 -0
- package/build/models/ProgramExecution.d.mts +142 -0
- package/build/models/ProgramExecution.d.mts.map +1 -0
- package/build/models/ProofArtifact.d.mts +260 -0
- package/build/models/ProofArtifact.d.mts.map +1 -0
- package/build/programs/AppAttestationProgram.d.mts +179 -0
- package/build/programs/AppAttestationProgram.d.mts.map +1 -0
- package/build/programs/AppAttestationProgram.mjs +296 -0
- package/build/programs/AppAttestationProgram.mjs.map +1 -0
- package/build/programs/PoeProgram.d.mts +204 -0
- package/build/programs/PoeProgram.d.mts.map +1 -0
- package/build/programs/PoeProgram.mjs +155 -0
- package/build/programs/PoeProgram.mjs.map +1 -0
- package/build/programs/examples/MockProgram.d.mts +98 -0
- package/build/programs/examples/MockProgram.d.mts.map +1 -0
- package/build/programs/examples/MockProgram.mjs +117 -0
- package/build/programs/examples/MockProgram.mjs.map +1 -0
- package/build/programs/examples/index.d.mts +1 -0
- package/build/programs/index.d.mts +4 -0
- package/build/programs/index.mjs +3 -0
- package/build/programs/vkeys/app_attestation_vkey.mjs +136 -0
- package/build/programs/vkeys/app_attestation_vkey.mjs.map +1 -0
- package/build/registry/ProgramRegistry.d.mts +108 -0
- package/build/registry/ProgramRegistry.d.mts.map +1 -0
- package/build/registry/ProgramRegistry.mjs +87 -0
- package/build/registry/ProgramRegistry.mjs.map +1 -0
- package/build/registry/ProofSystemRegistry.d.mts +111 -0
- package/build/registry/ProofSystemRegistry.d.mts.map +1 -0
- package/build/registry/ProofSystemRegistry.mjs +87 -0
- package/build/registry/ProofSystemRegistry.mjs.map +1 -0
- package/build/registry/index.d.mts +2 -0
- package/build/registry/index.mjs +2 -0
- package/build/repository/NonceRecord.d.mts +45 -0
- package/build/repository/NonceRecord.d.mts.map +1 -0
- package/build/repository/NonceRecord.mjs +34 -0
- package/build/repository/NonceRecord.mjs.map +1 -0
- package/build/repository/NonceRepository.d.mts +41 -0
- package/build/repository/NonceRepository.d.mts.map +1 -0
- package/build/repository/NonceRepository.mjs +63 -0
- package/build/repository/NonceRepository.mjs.map +1 -0
- package/build/repository/PoeSessionRecord.d.mts +107 -0
- package/build/repository/PoeSessionRecord.d.mts.map +1 -0
- package/build/repository/PoeSessionRecord.mjs +100 -0
- package/build/repository/PoeSessionRecord.mjs.map +1 -0
- package/build/repository/PoeSessionRepository.d.mts +29 -0
- package/build/repository/PoeSessionRepository.d.mts.map +1 -0
- package/build/repository/PoeSessionRepository.mjs +46 -0
- package/build/repository/PoeSessionRepository.mjs.map +1 -0
- package/build/repository/index.d.mts +4 -0
- package/build/repository/index.mjs +6 -0
- package/build/services/AutoProofExecutionService.d.mts +2 -0
- package/build/services/AutoProofExecutionService.mjs +144 -0
- package/build/services/AutoProofExecutionService.mjs.map +1 -0
- package/build/services/ContextBindingService.d.mts +51 -0
- package/build/services/ContextBindingService.d.mts.map +1 -0
- package/build/services/ContextBindingService.mjs +92 -0
- package/build/services/ContextBindingService.mjs.map +1 -0
- package/build/services/NonceService.d.mts +74 -0
- package/build/services/NonceService.d.mts.map +1 -0
- package/build/services/NonceService.mjs +126 -0
- package/build/services/NonceService.mjs.map +1 -0
- package/build/services/PoeService.d.mts +163 -0
- package/build/services/PoeService.d.mts.map +1 -0
- package/build/services/PoeService.mjs +487 -0
- package/build/services/PoeService.mjs.map +1 -0
- package/build/services/ProofVerificationService.d.mts +87 -0
- package/build/services/ProofVerificationService.d.mts.map +1 -0
- package/build/services/ProofVerificationService.mjs +164 -0
- package/build/services/ProofVerificationService.mjs.map +1 -0
- package/build/services/index.d.mts +5 -0
- package/build/services/index.mjs +5 -0
- package/build/workflow/PoeV1Actions.d.mts +149 -0
- package/build/workflow/PoeV1Actions.d.mts.map +1 -0
- package/build/workflow/PoeV1Actions.mjs +190 -0
- package/build/workflow/PoeV1Actions.mjs.map +1 -0
- package/package.json +44 -3
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
//#region src/programs/PoeProgram.ts
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for POE programs.
|
|
4
|
+
*
|
|
5
|
+
* Implement this class to create a new ZK program that can be
|
|
6
|
+
* registered with the POE module. The class bundles:
|
|
7
|
+
* - Program metadata (capabilities, allowed VK hashes, schemas)
|
|
8
|
+
* - Executor (prover side - generates proofs)
|
|
9
|
+
* - Verifier (verifier side - validates proofs)
|
|
10
|
+
* - Proof system (optional - cryptographic verification)
|
|
11
|
+
*
|
|
12
|
+
* This unified approach allows you to register a program with a single
|
|
13
|
+
* object instead of separately registering metadata, executor, and verifier.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* export class AadharAgeProgram extends PoeProgram {
|
|
18
|
+
* readonly programId = 'aadhaar.zk.age-threshold.v1'
|
|
19
|
+
* readonly version = '1.0.0'
|
|
20
|
+
*
|
|
21
|
+
* getMetadata(): ProgramMetadata {
|
|
22
|
+
* return {
|
|
23
|
+
* program_id: this.programId,
|
|
24
|
+
* version: this.version,
|
|
25
|
+
* name: 'Aadhar Age Verification',
|
|
26
|
+
* allowed_vk_hashes: ['0x...'],
|
|
27
|
+
* public_schema: 'aadhaar.zk.age-threshold.v1/public@1',
|
|
28
|
+
* supports_interactive: false,
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* createExecutor(context: AgentContext): ProgramExecutor {
|
|
33
|
+
* return {
|
|
34
|
+
* programId: this.programId,
|
|
35
|
+
* async execute(ctx, execution, bindingContext) {
|
|
36
|
+
* // Generate ZK proof
|
|
37
|
+
* return { ... }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* createVerifier(context: AgentContext): ProofVerifier {
|
|
43
|
+
* return {
|
|
44
|
+
* programId: this.programId,
|
|
45
|
+
* async verify(ctx, artifact, expectedContext) {
|
|
46
|
+
* // Verify ZK proof
|
|
47
|
+
* return { verified: true }
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* // Register with module
|
|
54
|
+
* new PoeModule({
|
|
55
|
+
* programs: [new AadharAgeProgram()],
|
|
56
|
+
* autoExecuteProofs: true,
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
var PoeProgram = class {
|
|
61
|
+
/**
|
|
62
|
+
* Get a custom proof system for this program (optional).
|
|
63
|
+
*
|
|
64
|
+
* Return `undefined` to use the default proof system from ProofSystemRegistry.
|
|
65
|
+
* Only override if this program uses a non-standard proof system.
|
|
66
|
+
*
|
|
67
|
+
* @returns Custom proof system, or undefined to use default
|
|
68
|
+
*/
|
|
69
|
+
getProofSystem() {}
|
|
70
|
+
/**
|
|
71
|
+
* Called during module initialization.
|
|
72
|
+
*
|
|
73
|
+
* Override to perform async setup tasks such as:
|
|
74
|
+
* - Loading cryptographic keys
|
|
75
|
+
* - Initializing circuit parameters
|
|
76
|
+
* - Connecting to external services
|
|
77
|
+
*
|
|
78
|
+
* @param context - Agent context
|
|
79
|
+
*/
|
|
80
|
+
async initialize(context) {}
|
|
81
|
+
/**
|
|
82
|
+
* Called during module shutdown.
|
|
83
|
+
*
|
|
84
|
+
* Override to cleanup resources such as:
|
|
85
|
+
* - Closing connections
|
|
86
|
+
* - Releasing memory
|
|
87
|
+
* - Flushing caches
|
|
88
|
+
*/
|
|
89
|
+
async shutdown() {}
|
|
90
|
+
/**
|
|
91
|
+
* Get a human-readable description of this program.
|
|
92
|
+
* Used for logging and debugging.
|
|
93
|
+
*/
|
|
94
|
+
toString() {
|
|
95
|
+
return `PoeProgram(${this.programId}@${this.version})`;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Convenience base class for programs that only prove (prover-only agent).
|
|
100
|
+
*
|
|
101
|
+
* Use this when the agent will only generate proofs, never verify them.
|
|
102
|
+
* This is common for mobile wallets or edge devices.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* export class MyProverProgram extends ProverOnlyProgram {
|
|
107
|
+
* readonly programId = 'my.program.v1'
|
|
108
|
+
* readonly version = '1.0.0'
|
|
109
|
+
*
|
|
110
|
+
* getMetadata() { ... }
|
|
111
|
+
* createExecutor(context) { ... }
|
|
112
|
+
* // No need to implement createVerifier - it returns undefined
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
var ProverOnlyProgram = class extends PoeProgram {
|
|
117
|
+
/**
|
|
118
|
+
* Always returns undefined - prover-only programs don't verify.
|
|
119
|
+
*/
|
|
120
|
+
createVerifier() {}
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Convenience base class for programs that only verify (verifier-only agent).
|
|
124
|
+
*
|
|
125
|
+
* Use this when the agent will only verify proofs, never generate them.
|
|
126
|
+
* This is common for backend services or verification nodes.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* export class MyVerifierProgram extends VerifierOnlyProgram {
|
|
131
|
+
* readonly programId = 'my.program.v1'
|
|
132
|
+
* readonly version = '1.0.0'
|
|
133
|
+
*
|
|
134
|
+
* getMetadata() { ... }
|
|
135
|
+
* createVerifier(context) { ... }
|
|
136
|
+
* // No need to implement createExecutor - it returns undefined
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
var VerifierOnlyProgram = class extends PoeProgram {
|
|
141
|
+
/**
|
|
142
|
+
* Always returns undefined - verifier-only programs don't execute.
|
|
143
|
+
*/
|
|
144
|
+
createExecutor() {}
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Type guard to check if an object is a PoeProgram
|
|
148
|
+
*/
|
|
149
|
+
function isPoeProgram(obj) {
|
|
150
|
+
return obj !== null && typeof obj === "object" && "programId" in obj && "version" in obj && "getMetadata" in obj && typeof obj.getMetadata === "function" && "createExecutor" in obj && typeof obj.createExecutor === "function" && "createVerifier" in obj && typeof obj.createVerifier === "function";
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
export { PoeProgram, ProverOnlyProgram, VerifierOnlyProgram, isPoeProgram };
|
|
155
|
+
//# sourceMappingURL=PoeProgram.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PoeProgram.mjs","names":[],"sources":["../../src/programs/PoeProgram.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport type { ProgramMetadata } from '../registry/ProgramRegistry'\nimport type { ProgramExecutor, ProofVerifier } from '../executor/ProgramExecutor'\nimport type { ProofSystem } from '../registry/ProofSystemRegistry'\n\n/**\n * Abstract base class for POE programs.\n *\n * Implement this class to create a new ZK program that can be\n * registered with the POE module. The class bundles:\n * - Program metadata (capabilities, allowed VK hashes, schemas)\n * - Executor (prover side - generates proofs)\n * - Verifier (verifier side - validates proofs)\n * - Proof system (optional - cryptographic verification)\n *\n * This unified approach allows you to register a program with a single\n * object instead of separately registering metadata, executor, and verifier.\n *\n * @example\n * ```typescript\n * export class AadharAgeProgram extends PoeProgram {\n * readonly programId = 'aadhaar.zk.age-threshold.v1'\n * readonly version = '1.0.0'\n *\n * getMetadata(): ProgramMetadata {\n * return {\n * program_id: this.programId,\n * version: this.version,\n * name: 'Aadhar Age Verification',\n * allowed_vk_hashes: ['0x...'],\n * public_schema: 'aadhaar.zk.age-threshold.v1/public@1',\n * supports_interactive: false,\n * }\n * }\n *\n * createExecutor(context: AgentContext): ProgramExecutor {\n * return {\n * programId: this.programId,\n * async execute(ctx, execution, bindingContext) {\n * // Generate ZK proof\n * return { ... }\n * }\n * }\n * }\n *\n * createVerifier(context: AgentContext): ProofVerifier {\n * return {\n * programId: this.programId,\n * async verify(ctx, artifact, expectedContext) {\n * // Verify ZK proof\n * return { verified: true }\n * }\n * }\n * }\n * }\n *\n * // Register with module\n * new PoeModule({\n * programs: [new AadharAgeProgram()],\n * autoExecuteProofs: true,\n * })\n * ```\n */\nexport abstract class PoeProgram {\n /**\n * Unique program identifier (e.g., 'aadhaar.zk.age-threshold.v1')\n * Must be globally unique and follow naming conventions.\n */\n abstract readonly programId: string\n\n /**\n * Program version (semver recommended, e.g., '1.0.0')\n */\n abstract readonly version: string\n\n /**\n * Get program metadata for registry registration.\n *\n * Defines the capabilities and constraints of this program:\n * - Allowed verifying key hashes\n * - Input/output schemas\n * - Performance limits\n * - Interactive support\n *\n * @returns Program metadata to register in ProgramRegistry\n */\n abstract getMetadata(): ProgramMetadata\n\n /**\n * Create an executor instance for this program (prover side).\n *\n * The executor is responsible for:\n * 1. Retrieving necessary data\n * 2. Generating the ZK proof\n * 3. Returning a ProofArtifact\n *\n * Return `undefined` if this agent should only verify, not prove.\n * This is useful for verifier-only deployments.\n *\n * @param context - Agent context for accessing storage, DID resolver, etc.\n * @returns Executor instance, or undefined if proving not supported\n */\n abstract createExecutor(context: AgentContext): ProgramExecutor | undefined\n\n /**\n * Create a verifier instance for this program (verifier side).\n *\n * The verifier provides custom verification logic beyond generic verification.\n * If registered, it takes precedence over ProofVerificationService's generic logic.\n *\n * Return `undefined` to use generic verification only.\n * This is useful for prover-only deployments or when generic verification suffices.\n *\n * @param context - Agent context\n * @returns Verifier instance, or undefined to use generic verification\n */\n abstract createVerifier(context: AgentContext): ProofVerifier | undefined\n\n /**\n * Get a custom proof system for this program (optional).\n *\n * Return `undefined` to use the default proof system from ProofSystemRegistry.\n * Only override if this program uses a non-standard proof system.\n *\n * @returns Custom proof system, or undefined to use default\n */\n getProofSystem(): ProofSystem | undefined {\n return undefined\n }\n\n /**\n * Called during module initialization.\n *\n * Override to perform async setup tasks such as:\n * - Loading cryptographic keys\n * - Initializing circuit parameters\n * - Connecting to external services\n *\n * @param context - Agent context\n */\n async initialize(context: AgentContext): Promise<void> {\n // Default: no-op\n }\n\n /**\n * Called during module shutdown.\n *\n * Override to cleanup resources such as:\n * - Closing connections\n * - Releasing memory\n * - Flushing caches\n */\n async shutdown(): Promise<void> {\n // Default: no-op\n }\n\n /**\n * Get a human-readable description of this program.\n * Used for logging and debugging.\n */\n toString(): string {\n return `PoeProgram(${this.programId}@${this.version})`\n }\n}\n\n/**\n * Convenience base class for programs that only prove (prover-only agent).\n *\n * Use this when the agent will only generate proofs, never verify them.\n * This is common for mobile wallets or edge devices.\n *\n * @example\n * ```typescript\n * export class MyProverProgram extends ProverOnlyProgram {\n * readonly programId = 'my.program.v1'\n * readonly version = '1.0.0'\n *\n * getMetadata() { ... }\n * createExecutor(context) { ... }\n * // No need to implement createVerifier - it returns undefined\n * }\n * ```\n */\nexport abstract class ProverOnlyProgram extends PoeProgram {\n /**\n * Always returns undefined - prover-only programs don't verify.\n */\n createVerifier(): undefined {\n return undefined\n }\n}\n\n/**\n * Convenience base class for programs that only verify (verifier-only agent).\n *\n * Use this when the agent will only verify proofs, never generate them.\n * This is common for backend services or verification nodes.\n *\n * @example\n * ```typescript\n * export class MyVerifierProgram extends VerifierOnlyProgram {\n * readonly programId = 'my.program.v1'\n * readonly version = '1.0.0'\n *\n * getMetadata() { ... }\n * createVerifier(context) { ... }\n * // No need to implement createExecutor - it returns undefined\n * }\n * ```\n */\nexport abstract class VerifierOnlyProgram extends PoeProgram {\n /**\n * Always returns undefined - verifier-only programs don't execute.\n */\n createExecutor(): undefined {\n return undefined\n }\n}\n\n/**\n * Type guard to check if an object is a PoeProgram\n */\nexport function isPoeProgram(obj: unknown): obj is PoeProgram {\n return (\n obj !== null &&\n typeof obj === 'object' &&\n 'programId' in obj &&\n 'version' in obj &&\n 'getMetadata' in obj &&\n typeof (obj as PoeProgram).getMetadata === 'function' &&\n 'createExecutor' in obj &&\n typeof (obj as PoeProgram).createExecutor === 'function' &&\n 'createVerifier' in obj &&\n typeof (obj as PoeProgram).createVerifier === 'function'\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,IAAsB,aAAtB,MAAiC;;;;;;;;;CA+D/B,iBAA0C;;;;;;;;;;;CAc1C,MAAM,WAAW,SAAsC;;;;;;;;;CAYvD,MAAM,WAA0B;;;;;CAQhC,WAAmB;AACjB,SAAO,cAAc,KAAK,UAAU,GAAG,KAAK,QAAQ;;;;;;;;;;;;;;;;;;;;;AAsBxD,IAAsB,oBAAtB,cAAgD,WAAW;;;;CAIzD,iBAA4B;;;;;;;;;;;;;;;;;;;;AAuB9B,IAAsB,sBAAtB,cAAkD,WAAW;;;;CAI3D,iBAA4B;;;;;AAQ9B,SAAgB,aAAa,KAAiC;AAC5D,QACE,QAAQ,QACR,OAAO,QAAQ,YACf,eAAe,OACf,aAAa,OACb,iBAAiB,OACjB,OAAQ,IAAmB,gBAAgB,cAC3C,oBAAoB,OACpB,OAAQ,IAAmB,mBAAmB,cAC9C,oBAAoB,OACpB,OAAQ,IAAmB,mBAAmB"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ProgramMetadata } from "../../registry/ProgramRegistry.mjs";
|
|
2
|
+
import { ProgramExecutor, ProofVerifier } from "../../executor/ProgramExecutor.mjs";
|
|
3
|
+
import { PoeProgram } from "../PoeProgram.mjs";
|
|
4
|
+
import { AgentContext } from "@credo-ts/core";
|
|
5
|
+
|
|
6
|
+
//#region src/programs/examples/MockProgram.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for MockProgram
|
|
9
|
+
*/
|
|
10
|
+
interface MockProgramOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Program identifier
|
|
13
|
+
* @default 'mock.program.v1'
|
|
14
|
+
*/
|
|
15
|
+
programId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Program version
|
|
18
|
+
* @default '1.0.0'
|
|
19
|
+
*/
|
|
20
|
+
version?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Human-readable name
|
|
23
|
+
* @default 'Mock Program'
|
|
24
|
+
*/
|
|
25
|
+
name?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Allowed verifying key hashes
|
|
28
|
+
* @default ['0x' + '1'.repeat(64)]
|
|
29
|
+
*/
|
|
30
|
+
vkHashes?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Execution delay in milliseconds (simulates proof generation time)
|
|
33
|
+
* @default 0
|
|
34
|
+
*/
|
|
35
|
+
executionDelayMs?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Whether executor should fail
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
shouldExecutorFail?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Error message when executor fails
|
|
43
|
+
*/
|
|
44
|
+
executorErrorMessage?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether verifier should return verified: false
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
shouldVerifierFail?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether this program supports interactive challenges
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
supportsInteractive?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Additional public outputs to include in proof artifact
|
|
57
|
+
*/
|
|
58
|
+
publicOutputs?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Mock POE program for testing and demonstration.
|
|
62
|
+
*
|
|
63
|
+
* This program provides a complete implementation that can be used for:
|
|
64
|
+
* - Unit and integration testing
|
|
65
|
+
* - Development and debugging
|
|
66
|
+
* - Learning the PoeProgram interface
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // Basic usage
|
|
71
|
+
* const mockProgram = new MockProgram()
|
|
72
|
+
*
|
|
73
|
+
* // Custom configuration
|
|
74
|
+
* const customMock = new MockProgram({
|
|
75
|
+
* programId: 'my.test.program.v1',
|
|
76
|
+
* vkHashes: ['0xabc...'],
|
|
77
|
+
* executionDelayMs: 100,
|
|
78
|
+
* })
|
|
79
|
+
*
|
|
80
|
+
* // Register with module
|
|
81
|
+
* new PoeModule({
|
|
82
|
+
* programs: [mockProgram],
|
|
83
|
+
* autoExecuteProofs: true,
|
|
84
|
+
* })
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare class MockProgram extends PoeProgram {
|
|
88
|
+
readonly programId: string;
|
|
89
|
+
readonly version: string;
|
|
90
|
+
private readonly options;
|
|
91
|
+
constructor(options?: MockProgramOptions);
|
|
92
|
+
getMetadata(): ProgramMetadata;
|
|
93
|
+
createExecutor(context: AgentContext): ProgramExecutor;
|
|
94
|
+
createVerifier(context: AgentContext): ProofVerifier;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { MockProgram, MockProgramOptions };
|
|
98
|
+
//# sourceMappingURL=MockProgram.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockProgram.d.mts","names":[],"sources":["../../../src/programs/examples/MockProgram.ts"],"mappings":";;;;;;;;AAUA;UAAiB,kBAAA;;;;;EAKf,SAAA;EAkBA;;;;EAZA,OAAA;EAyCA;;;;EAnCA,IAAA;EAsEW;;;;EAhEX,QAAA;EAoGwB;;;;EA9FxB,gBAAA;EA0DyC;;;;EApDzC,kBAAA;EAwDiB;;;EAnDjB,oBAAA;EAqEA;;;;EA/DA,kBAAA;EA6EuC;;;;EAvEvC,mBAAA;EAoIoD;;;EA/HpD,aAAA,GAAgB,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BL,WAAA,SAAoB,UAAA;EAAA,SACtB,SAAA;EAAA,SACA,OAAA;EAAA,iBAEQ,OAAA;cAKL,OAAA,GAAS,kBAAA;EAarB,WAAA,CAAA,GAAe,eAAA;EAcf,cAAA,CAAe,OAAA,EAAS,YAAA,GAAe,eAAA;EA6DvC,cAAA,CAAe,OAAA,EAAS,YAAA,GAAe,aAAA;AAAA"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { PoeProgram } from "../PoeProgram.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/programs/examples/MockProgram.ts
|
|
4
|
+
/**
|
|
5
|
+
* Mock POE program for testing and demonstration.
|
|
6
|
+
*
|
|
7
|
+
* This program provides a complete implementation that can be used for:
|
|
8
|
+
* - Unit and integration testing
|
|
9
|
+
* - Development and debugging
|
|
10
|
+
* - Learning the PoeProgram interface
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Basic usage
|
|
15
|
+
* const mockProgram = new MockProgram()
|
|
16
|
+
*
|
|
17
|
+
* // Custom configuration
|
|
18
|
+
* const customMock = new MockProgram({
|
|
19
|
+
* programId: 'my.test.program.v1',
|
|
20
|
+
* vkHashes: ['0xabc...'],
|
|
21
|
+
* executionDelayMs: 100,
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* // Register with module
|
|
25
|
+
* new PoeModule({
|
|
26
|
+
* programs: [mockProgram],
|
|
27
|
+
* autoExecuteProofs: true,
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
var MockProgram = class extends PoeProgram {
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
super();
|
|
34
|
+
this.programId = options.programId ?? "mock.program.v1";
|
|
35
|
+
this.version = options.version ?? "1.0.0";
|
|
36
|
+
this.options = {
|
|
37
|
+
name: options.name ?? "Mock Program",
|
|
38
|
+
vkHashes: options.vkHashes ?? ["0x" + "1".repeat(64)],
|
|
39
|
+
executionDelayMs: options.executionDelayMs ?? 0,
|
|
40
|
+
supportsInteractive: options.supportsInteractive ?? false,
|
|
41
|
+
...options
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
getMetadata() {
|
|
45
|
+
return {
|
|
46
|
+
program_id: this.programId,
|
|
47
|
+
version: this.version,
|
|
48
|
+
name: this.options.name,
|
|
49
|
+
description: "A mock program for testing POE protocol",
|
|
50
|
+
allowed_vk_hashes: this.options.vkHashes,
|
|
51
|
+
public_schema: `${this.programId}/public@1`,
|
|
52
|
+
supports_interactive: this.options.supportsInteractive,
|
|
53
|
+
max_runtime_s: 60,
|
|
54
|
+
max_artifact_mb: 8
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
createExecutor(context) {
|
|
58
|
+
const programId = this.programId;
|
|
59
|
+
const vkHash = this.options.vkHashes[0];
|
|
60
|
+
const delay = this.options.executionDelayMs;
|
|
61
|
+
const shouldFail = this.options.shouldExecutorFail;
|
|
62
|
+
const errorMessage = this.options.executorErrorMessage;
|
|
63
|
+
const publicOutputs = this.options.publicOutputs;
|
|
64
|
+
return {
|
|
65
|
+
programId,
|
|
66
|
+
async canExecute(ctx, execution) {
|
|
67
|
+
if (execution.program_id !== programId) return `Program ID mismatch: expected ${programId}, got ${execution.program_id}`;
|
|
68
|
+
},
|
|
69
|
+
async execute(ctx, execution, bindingContext) {
|
|
70
|
+
if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay));
|
|
71
|
+
if (shouldFail) throw new Error(errorMessage ?? "Mock executor failed");
|
|
72
|
+
return {
|
|
73
|
+
program_id: programId,
|
|
74
|
+
result: "pass",
|
|
75
|
+
public: {
|
|
76
|
+
schema: `${programId}/public@1`,
|
|
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
|
+
...publicOutputs
|
|
83
|
+
},
|
|
84
|
+
zk: {
|
|
85
|
+
scheme: "mock",
|
|
86
|
+
circuit_id: programId,
|
|
87
|
+
vk_hash: vkHash,
|
|
88
|
+
proof_b64: Buffer.from(`mock-proof-${Date.now()}`).toString("base64")
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
createVerifier(context) {
|
|
95
|
+
const programId = this.programId;
|
|
96
|
+
const shouldFail = this.options.shouldVerifierFail;
|
|
97
|
+
return {
|
|
98
|
+
programId,
|
|
99
|
+
async verify(ctx, artifact, expectedContext) {
|
|
100
|
+
const errors = [];
|
|
101
|
+
if (artifact.program_id !== programId) errors.push(`Program ID mismatch: expected ${programId}, got ${artifact.program_id}`);
|
|
102
|
+
if (artifact.public.nonce !== expectedContext.nonce) errors.push("Nonce mismatch in binding context");
|
|
103
|
+
if (artifact.public.context_hash !== expectedContext.context_hash) errors.push("Context hash mismatch in binding context");
|
|
104
|
+
if (artifact.public.session_id !== expectedContext.session_id) errors.push("Session ID mismatch in binding context");
|
|
105
|
+
if (shouldFail) errors.push("Mock verifier configured to fail");
|
|
106
|
+
return {
|
|
107
|
+
verified: errors.length === 0,
|
|
108
|
+
errors: errors.length > 0 ? errors : void 0
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
export { MockProgram };
|
|
117
|
+
//# sourceMappingURL=MockProgram.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockProgram.mjs","names":[],"sources":["../../../src/programs/examples/MockProgram.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport type { ProgramMetadata } from '../../registry/ProgramRegistry'\nimport type { ProgramExecutor, ProofVerifier } from '../../executor/ProgramExecutor'\nimport type { ProgramExecution, BindingContext, ProofArtifact } from '../../models'\n\nimport { PoeProgram } from '../PoeProgram'\n\n/**\n * Configuration options for MockProgram\n */\nexport interface MockProgramOptions {\n /**\n * Program identifier\n * @default 'mock.program.v1'\n */\n programId?: string\n\n /**\n * Program version\n * @default '1.0.0'\n */\n version?: string\n\n /**\n * Human-readable name\n * @default 'Mock Program'\n */\n name?: string\n\n /**\n * Allowed verifying key hashes\n * @default ['0x' + '1'.repeat(64)]\n */\n vkHashes?: string[]\n\n /**\n * Execution delay in milliseconds (simulates proof generation time)\n * @default 0\n */\n executionDelayMs?: number\n\n /**\n * Whether executor should fail\n * @default false\n */\n shouldExecutorFail?: boolean\n\n /**\n * Error message when executor fails\n */\n executorErrorMessage?: string\n\n /**\n * Whether verifier should return verified: false\n * @default false\n */\n shouldVerifierFail?: boolean\n\n /**\n * Whether this program supports interactive challenges\n * @default false\n */\n supportsInteractive?: boolean\n\n /**\n * Additional public outputs to include in proof artifact\n */\n publicOutputs?: Record<string, unknown>\n}\n\n/**\n * Mock POE program for testing and demonstration.\n *\n * This program provides a complete implementation that can be used for:\n * - Unit and integration testing\n * - Development and debugging\n * - Learning the PoeProgram interface\n *\n * @example\n * ```typescript\n * // Basic usage\n * const mockProgram = new MockProgram()\n *\n * // Custom configuration\n * const customMock = new MockProgram({\n * programId: 'my.test.program.v1',\n * vkHashes: ['0xabc...'],\n * executionDelayMs: 100,\n * })\n *\n * // Register with module\n * new PoeModule({\n * programs: [mockProgram],\n * autoExecuteProofs: true,\n * })\n * ```\n */\nexport class MockProgram extends PoeProgram {\n readonly programId: string\n readonly version: string\n\n private readonly options: Required<\n Pick<MockProgramOptions, 'name' | 'vkHashes' | 'executionDelayMs' | 'supportsInteractive'>\n > &\n MockProgramOptions\n\n constructor(options: MockProgramOptions = {}) {\n super()\n this.programId = options.programId ?? 'mock.program.v1'\n this.version = options.version ?? '1.0.0'\n this.options = {\n name: options.name ?? 'Mock Program',\n vkHashes: options.vkHashes ?? ['0x' + '1'.repeat(64)],\n executionDelayMs: options.executionDelayMs ?? 0,\n supportsInteractive: options.supportsInteractive ?? false,\n ...options,\n }\n }\n\n getMetadata(): ProgramMetadata {\n return {\n program_id: this.programId,\n version: this.version,\n name: this.options.name,\n description: 'A mock program for testing POE protocol',\n allowed_vk_hashes: this.options.vkHashes,\n public_schema: `${this.programId}/public@1`,\n supports_interactive: this.options.supportsInteractive,\n max_runtime_s: 60,\n max_artifact_mb: 8,\n }\n }\n\n createExecutor(context: AgentContext): ProgramExecutor {\n const programId = this.programId\n const vkHash = this.options.vkHashes[0]\n const delay = this.options.executionDelayMs\n const shouldFail = this.options.shouldExecutorFail\n const errorMessage = this.options.executorErrorMessage\n const publicOutputs = this.options.publicOutputs\n\n return {\n programId,\n\n async canExecute(\n ctx: AgentContext,\n execution: ProgramExecution\n ): Promise<string | undefined> {\n // Validate program ID matches\n if (execution.program_id !== programId) {\n return `Program ID mismatch: expected ${programId}, got ${execution.program_id}`\n }\n return undefined\n },\n\n async execute(\n ctx: AgentContext,\n execution: ProgramExecution,\n bindingContext: BindingContext\n ): Promise<ProofArtifact> {\n // Simulate processing delay\n if (delay > 0) {\n await new Promise((resolve) => setTimeout(resolve, delay))\n }\n\n // Simulate failure\n if (shouldFail) {\n throw new Error(errorMessage ?? 'Mock executor failed')\n }\n\n // Generate mock proof artifact\n return {\n program_id: programId,\n result: 'pass',\n public: {\n schema: `${programId}/public@1`,\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 ...publicOutputs,\n },\n zk: {\n scheme: 'mock',\n circuit_id: programId,\n vk_hash: vkHash,\n proof_b64: Buffer.from(`mock-proof-${Date.now()}`).toString('base64'),\n },\n }\n },\n }\n }\n\n createVerifier(context: AgentContext): ProofVerifier {\n const programId = this.programId\n const shouldFail = this.options.shouldVerifierFail\n\n return {\n programId,\n\n async verify(\n ctx: AgentContext,\n artifact: ProofArtifact,\n expectedContext: BindingContext\n ): Promise<{ verified: boolean; errors?: string[]; warnings?: string[] }> {\n const errors: string[] = []\n\n // Validate program ID\n if (artifact.program_id !== programId) {\n errors.push(`Program ID mismatch: expected ${programId}, got ${artifact.program_id}`)\n }\n\n // Validate binding context\n if (artifact.public.nonce !== expectedContext.nonce) {\n errors.push('Nonce mismatch in binding context')\n }\n if (artifact.public.context_hash !== expectedContext.context_hash) {\n errors.push('Context hash mismatch in binding context')\n }\n if (artifact.public.session_id !== expectedContext.session_id) {\n errors.push('Session ID mismatch in binding context')\n }\n\n // Check if configured to fail\n if (shouldFail) {\n errors.push('Mock verifier configured to fail')\n }\n\n return {\n verified: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n }\n },\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,IAAa,cAAb,cAAiC,WAAW;CAS1C,YAAY,UAA8B,EAAE,EAAE;AAC5C,SAAO;AACP,OAAK,YAAY,QAAQ,aAAa;AACtC,OAAK,UAAU,QAAQ,WAAW;AAClC,OAAK,UAAU;GACb,MAAM,QAAQ,QAAQ;GACtB,UAAU,QAAQ,YAAY,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC;GACrD,kBAAkB,QAAQ,oBAAoB;GAC9C,qBAAqB,QAAQ,uBAAuB;GACpD,GAAG;GACJ;;CAGH,cAA+B;AAC7B,SAAO;GACL,YAAY,KAAK;GACjB,SAAS,KAAK;GACd,MAAM,KAAK,QAAQ;GACnB,aAAa;GACb,mBAAmB,KAAK,QAAQ;GAChC,eAAe,GAAG,KAAK,UAAU;GACjC,sBAAsB,KAAK,QAAQ;GACnC,eAAe;GACf,iBAAiB;GAClB;;CAGH,eAAe,SAAwC;EACrD,MAAM,YAAY,KAAK;EACvB,MAAM,SAAS,KAAK,QAAQ,SAAS;EACrC,MAAM,QAAQ,KAAK,QAAQ;EAC3B,MAAM,aAAa,KAAK,QAAQ;EAChC,MAAM,eAAe,KAAK,QAAQ;EAClC,MAAM,gBAAgB,KAAK,QAAQ;AAEnC,SAAO;GACL;GAEA,MAAM,WACJ,KACA,WAC6B;AAE7B,QAAI,UAAU,eAAe,UAC3B,QAAO,iCAAiC,UAAU,QAAQ,UAAU;;GAKxE,MAAM,QACJ,KACA,WACA,gBACwB;AAExB,QAAI,QAAQ,EACV,OAAM,IAAI,SAAS,YAAY,WAAW,SAAS,MAAM,CAAC;AAI5D,QAAI,WACF,OAAM,IAAI,MAAM,gBAAgB,uBAAuB;AAIzD,WAAO;KACL,YAAY;KACZ,QAAQ;KACR,QAAQ;MACN,QAAQ,GAAG,UAAU;MACrB,OAAO,eAAe;MACtB,cAAc,eAAe;MAC7B,YAAY,eAAe;MAC3B,SAAS;MACT,4BAAW,IAAI,MAAM,EAAC,aAAa;MACnC,GAAG;MACJ;KACD,IAAI;MACF,QAAQ;MACR,YAAY;MACZ,SAAS;MACT,WAAW,OAAO,KAAK,cAAc,KAAK,KAAK,GAAG,CAAC,SAAS,SAAS;MACtE;KACF;;GAEJ;;CAGH,eAAe,SAAsC;EACnD,MAAM,YAAY,KAAK;EACvB,MAAM,aAAa,KAAK,QAAQ;AAEhC,SAAO;GACL;GAEA,MAAM,OACJ,KACA,UACA,iBACwE;IACxE,MAAM,SAAmB,EAAE;AAG3B,QAAI,SAAS,eAAe,UAC1B,QAAO,KAAK,iCAAiC,UAAU,QAAQ,SAAS,aAAa;AAIvF,QAAI,SAAS,OAAO,UAAU,gBAAgB,MAC5C,QAAO,KAAK,oCAAoC;AAElD,QAAI,SAAS,OAAO,iBAAiB,gBAAgB,aACnD,QAAO,KAAK,2CAA2C;AAEzD,QAAI,SAAS,OAAO,eAAe,gBAAgB,WACjD,QAAO,KAAK,yCAAyC;AAIvD,QAAI,WACF,QAAO,KAAK,mCAAmC;AAGjD,WAAO;KACL,UAAU,OAAO,WAAW;KAC5B,QAAQ,OAAO,SAAS,IAAI,SAAS;KACtC;;GAEJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { MockProgram, MockProgramOptions } from "./MockProgram.mjs";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PoeProgram, ProverOnlyProgram, VerifierOnlyProgram, isPoeProgram } from "./PoeProgram.mjs";
|
|
2
|
+
import { MockProgram, MockProgramOptions } from "./examples/MockProgram.mjs";
|
|
3
|
+
import "./examples/index.mjs";
|
|
4
|
+
import { AppAttestationExecuteArgs, AppAttestationProgram, AppAttestationProgramOptions, AppAttestationProofProvider, AppAttestationProverResult, PUBLIC_INPUT_INDEX, canonicalVkHash } from "./AppAttestationProgram.mjs";
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
//#region src/programs/vkeys/app_attestation_vkey.json
|
|
2
|
+
var app_attestation_vkey_default = {
|
|
3
|
+
protocol: "groth16",
|
|
4
|
+
curve: "bn128",
|
|
5
|
+
nPublic: 18,
|
|
6
|
+
vk_alpha_1: [
|
|
7
|
+
"20491192805390485299153009773594534940189261866228447918068658471970481763042",
|
|
8
|
+
"9383485363053290200918347156157836566562967994039712273449902621266178545958",
|
|
9
|
+
"1"
|
|
10
|
+
],
|
|
11
|
+
vk_beta_2: [
|
|
12
|
+
["6375614351688725206403948262868962793625744043794305715222011528459656738731", "4252822878758300859123897981450591353533073413197771768651442665752259397132"],
|
|
13
|
+
["10505242626370262277552901082094356697409835680220590971873171140371331206856", "21847035105528745403288232691147584728191162732299865338377159692350059136679"],
|
|
14
|
+
["1", "0"]
|
|
15
|
+
],
|
|
16
|
+
vk_gamma_2: [
|
|
17
|
+
["10857046999023057135944570762232829481370756359578518086990519993285655852781", "11559732032986387107991004021392285783925812861821192530917403151452391805634"],
|
|
18
|
+
["8495653923123431417604973247489272438418190587263600148770280649306958101930", "4082367875863433681332203403145435568316851327593401208105741076214120093531"],
|
|
19
|
+
["1", "0"]
|
|
20
|
+
],
|
|
21
|
+
vk_delta_2: [
|
|
22
|
+
["13485085826533796541626463117473461740463243134621317736989048015065133539250", "347746134210697306455231044446811259098398284069865143767629485052608122898"],
|
|
23
|
+
["1757073442389259667079720084766480338746978768361467960210043571714926409216", "14475920910563677282186876056426657843951855855485129604149000125414791695448"],
|
|
24
|
+
["1", "0"]
|
|
25
|
+
],
|
|
26
|
+
vk_alphabeta_12: [[
|
|
27
|
+
["2029413683389138792403550203267699914886160938906632433982220835551125967885", "21072700047562757817161031222997517981543347628379360635925549008442030252106"],
|
|
28
|
+
["5940354580057074848093997050200682056184807770593307860589430076672439820312", "12156638873931618554171829126792193045421052652279363021382169897324752428276"],
|
|
29
|
+
["7898200236362823042373859371574133993780991612861777490112507062703164551277", "7074218545237549455313236346927434013100842096812539264420499035217050630853"]
|
|
30
|
+
], [
|
|
31
|
+
["7077479683546002997211712695946002074877511277312570035766170199895071832130", "10093483419865920389913245021038182291233451549023025229112148274109565435465"],
|
|
32
|
+
["4595479056700221319381530156280926371456704509942304414423590385166031118820", "19831328484489333784475432780421641293929726139240675179672856274388269393268"],
|
|
33
|
+
["11934129596455521040620786944827826205713621633706285934057045369193958244500", "8037395052364110730298837004334506829870972346962140206007064471173334027475"]
|
|
34
|
+
]],
|
|
35
|
+
IC: [
|
|
36
|
+
[
|
|
37
|
+
"13035873448995504691088890647930435029258019878302124867872940791383089152609",
|
|
38
|
+
"5222305595818400405848461500969339923638268787463116298746029431071268024479",
|
|
39
|
+
"1"
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
"19225868885439906894489681875477019126612793434459884225246208148902581103082",
|
|
43
|
+
"19113487660934624719406810614302382278165178070172489580344887652400899995214",
|
|
44
|
+
"1"
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
"10681035559004875959482249334067861307922615892852353970144384916994724282920",
|
|
48
|
+
"2723853730785280440606190231122357123118031480322919602630084594802093024185",
|
|
49
|
+
"1"
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
"1890930883324773416697505417454643146353262212812965823056451477403746319719",
|
|
53
|
+
"10099585096772324566010845915906104497997015307271500369257145301667648799380",
|
|
54
|
+
"1"
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
"11726232846559553556724790868857957305257704832560084152508606410601708183396",
|
|
58
|
+
"14518305486003406667044746473829769325623804597539916188902337304168601223998",
|
|
59
|
+
"1"
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
"13458495156848662838466762349832913271714150809317786552084546014781958296310",
|
|
63
|
+
"15385178258102180007181799728108323555337593033727062820635057990941444376738",
|
|
64
|
+
"1"
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
"7229256456360203073434123129356937146121142342853228112646678213734840208636",
|
|
68
|
+
"4837308569035721199799248279335790030879940347174192612906197567702296158583",
|
|
69
|
+
"1"
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
"2352779582542226629380520678429688768072774196421514521749547826863226003101",
|
|
73
|
+
"678333822320900259279459670514600562333740274644058668664649549291221452071",
|
|
74
|
+
"1"
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
"9852293850251103089244683996885685582739650824505948338634920471590730351771",
|
|
78
|
+
"17500397582429099536836194406780441991138997505094093876684446729882172488696",
|
|
79
|
+
"1"
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
"7038201744386209847104898122918825989840284565492644758843844829903970147898",
|
|
83
|
+
"9202137029650632421980242047510508701475179244523652014166548761012674433160",
|
|
84
|
+
"1"
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
"21105679930810661301615503509510984053954027420663754154635257995497542849928",
|
|
88
|
+
"3546005756800814754044651168966718744015217680652032988495786216834620434244",
|
|
89
|
+
"1"
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
"11352389433574661844447192296596621170490139393908776124418158165715113507846",
|
|
93
|
+
"15448846056616531946289488543905241156833694452112945233209328677366880997858",
|
|
94
|
+
"1"
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
"7968927018976797361605616401107868329985324459177196095518214686495733421202",
|
|
98
|
+
"889394621765617913836244239447717692684813003613212534054765396845437728161",
|
|
99
|
+
"1"
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
"11094223961630168254308243680484381183975229425985886854953983658365383460012",
|
|
103
|
+
"16639978753777334845894045221855556950935162512528954505999570381306491245305",
|
|
104
|
+
"1"
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
"5944011873636907511120457455016671102765657812724597767630358442283340514909",
|
|
108
|
+
"10106393277283763750488570984796482900031759912494032057056507116175378344446",
|
|
109
|
+
"1"
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
"15792439126745897471268454991709248709214958686630684563617125851973984761818",
|
|
113
|
+
"21176079504964929129178760134959957302931940098092505250263982912345493536470",
|
|
114
|
+
"1"
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
"9074651167792690224757027308019990975793264007865905612768711292547728169084",
|
|
118
|
+
"11543000474536512945948721495218633018097021475714550397106762074124731964131",
|
|
119
|
+
"1"
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
"9476119949654041128156325488506946976323045269696997707846073602504353835276",
|
|
123
|
+
"17148451390224809377960112791549998439418191593768089386880246316585397583294",
|
|
124
|
+
"1"
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
"3429415440390554982450525309431735287348749723272493968380917265315315978172",
|
|
128
|
+
"15100285689818327808061269454276055635756581197048235310747280118486425518698",
|
|
129
|
+
"1"
|
|
130
|
+
]
|
|
131
|
+
]
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { app_attestation_vkey_default as default };
|
|
136
|
+
//# sourceMappingURL=app_attestation_vkey.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app_attestation_vkey.mjs","names":[],"sources":["../../../src/programs/vkeys/app_attestation_vkey.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
//#region src/registry/ProgramRegistry.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Metadata for a registered program
|
|
4
|
+
*/
|
|
5
|
+
interface ProgramMetadata {
|
|
6
|
+
/**
|
|
7
|
+
* Unique program identifier (e.g., "vendor.policy.eval.v1")
|
|
8
|
+
*/
|
|
9
|
+
program_id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Program version
|
|
12
|
+
*/
|
|
13
|
+
version: string;
|
|
14
|
+
/**
|
|
15
|
+
* Human-readable name
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* Description of what the program does
|
|
20
|
+
*/
|
|
21
|
+
description?: string;
|
|
22
|
+
/**
|
|
23
|
+
* List of allowed verifying key hashes
|
|
24
|
+
*/
|
|
25
|
+
allowed_vk_hashes: string[];
|
|
26
|
+
/**
|
|
27
|
+
* List of allowed program parameter hashes (optional)
|
|
28
|
+
*/
|
|
29
|
+
allowed_params_hashes?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* JSON Schema for public outputs validation
|
|
32
|
+
*/
|
|
33
|
+
public_schema: string;
|
|
34
|
+
/**
|
|
35
|
+
* JSON Schema for inputs validation (optional)
|
|
36
|
+
*/
|
|
37
|
+
inputs_schema?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the program supports interactive challenges
|
|
40
|
+
*/
|
|
41
|
+
supports_interactive: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Maximum execution time in seconds
|
|
44
|
+
*/
|
|
45
|
+
max_runtime_s?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Maximum artifact size in megabytes
|
|
48
|
+
*/
|
|
49
|
+
max_artifact_mb?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Additional metadata
|
|
52
|
+
*/
|
|
53
|
+
metadata?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Registry for managing supported programs and their constraints
|
|
57
|
+
*/
|
|
58
|
+
declare class ProgramRegistry {
|
|
59
|
+
private programs;
|
|
60
|
+
/**
|
|
61
|
+
* Register a new program
|
|
62
|
+
*/
|
|
63
|
+
register(metadata: ProgramMetadata): void;
|
|
64
|
+
/**
|
|
65
|
+
* Unregister a program
|
|
66
|
+
*/
|
|
67
|
+
unregister(programId: string): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Get program metadata by ID
|
|
70
|
+
* @throws {ProgramNotSupportedError} if program not found
|
|
71
|
+
*/
|
|
72
|
+
getById(programId: string): ProgramMetadata;
|
|
73
|
+
/**
|
|
74
|
+
* Find program metadata by ID (returns undefined if not found)
|
|
75
|
+
*/
|
|
76
|
+
findById(programId: string): ProgramMetadata | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Check if a program is supported
|
|
79
|
+
*/
|
|
80
|
+
isSupported(programId: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Get all registered programs
|
|
83
|
+
*/
|
|
84
|
+
getAllPrograms(): ProgramMetadata[];
|
|
85
|
+
/**
|
|
86
|
+
* Check if a verifying key hash is allowed for a program
|
|
87
|
+
*/
|
|
88
|
+
isVkAllowed(programId: string, vkHash: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Check if program parameters hash is allowed
|
|
91
|
+
*/
|
|
92
|
+
isParamsAllowed(programId: string, paramsHash: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Get programs that support interactive challenges
|
|
95
|
+
*/
|
|
96
|
+
getInteractivePrograms(): ProgramMetadata[];
|
|
97
|
+
/**
|
|
98
|
+
* Clear all registered programs (useful for testing)
|
|
99
|
+
*/
|
|
100
|
+
clear(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Get the count of registered programs
|
|
103
|
+
*/
|
|
104
|
+
get count(): number;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { ProgramMetadata, ProgramRegistry };
|
|
108
|
+
//# sourceMappingURL=ProgramRegistry.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgramRegistry.d.mts","names":[],"sources":["../../src/registry/ProgramRegistry.ts"],"mappings":";;AAMA;;UAAiB,eAAA;EA2DE;;;EAvDjB,UAAA;EAeA;;;EAVA,OAAA;EA8BA;;;EAzBA,IAAA;EA6CA;;;EAxCA,WAAA;EA+CW;;;EA1CX,iBAAA;EA+DmC;;;EA1DnC,qBAAA;EAgHgD;;;EA3GhD,aAAA;EAsC0B;;;EAjC1B,aAAA;EAgDO;;;EA3CP,oBAAA;EAsDgB;;;EAjDhB,aAAA;EA+DO;;;EA1DP,eAAA;EAiEsC;;;EA5DtC,QAAA,GAAW,MAAA;AAAA;;;;cAOA,eAAA;EAAA,QACH,QAAA;;;;EAKD,QAAA,CAAS,QAAA,EAAU,eAAA;;;;EAOnB,UAAA,CAAW,SAAA;;;;;EAQX,OAAA,CAAQ,SAAA,WAAoB,eAAA;;;;EAW5B,QAAA,CAAS,SAAA,WAAoB,eAAA;;;;EAO7B,WAAA,CAAY,SAAA;;;;EAOZ,cAAA,CAAA,GAAkB,eAAA;;;;EAOlB,WAAA,CAAY,SAAA,UAAmB,MAAA;;;;EAQ/B,eAAA,CAAgB,SAAA,UAAmB,UAAA;;;;EAcnC,sBAAA,CAAA,GAA0B,eAAA;;;;EAO1B,KAAA,CAAA;;;;MAOI,KAAA,CAAA;AAAA"}
|