@sip-protocol/sdk 0.7.3 → 0.8.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 (263) hide show
  1. package/README.md +267 -0
  2. package/dist/{TransportWebUSB-TQ7WZ4LE.mjs → TransportWebUSB-YQMAGJAJ.mjs} +12 -9
  3. package/dist/browser.d.mts +10 -4
  4. package/dist/browser.d.ts +10 -4
  5. package/dist/browser.js +47556 -19603
  6. package/dist/browser.mjs +628 -48
  7. package/dist/chunk-4GRJ5MAW.mjs +152 -0
  8. package/dist/chunk-5D7A3L3W.mjs +717 -0
  9. package/dist/chunk-64AYA5F5.mjs +7834 -0
  10. package/dist/chunk-GMDGB22A.mjs +379 -0
  11. package/dist/chunk-I534WKN7.mjs +328 -0
  12. package/dist/chunk-IBZVA5Y7.mjs +1003 -0
  13. package/dist/chunk-PRRZAWJE.mjs +223 -0
  14. package/dist/{chunk-UJCSKKID.mjs → chunk-XGB3TDIC.mjs} +13 -1
  15. package/dist/{chunk-3M3HNQCW.mjs → chunk-YWGJ77A2.mjs} +28656 -13103
  16. package/dist/{chunk-6WGN57S2.mjs → chunk-Z3K7W5S3.mjs} +48 -0
  17. package/dist/constants-LHAAUC2T.mjs +51 -0
  18. package/dist/dist-2OGQ7FED.mjs +3957 -0
  19. package/dist/dist-IFHPYLDX.mjs +254 -0
  20. package/dist/fulfillment_proof-ANHVPKTB.mjs +21 -0
  21. package/dist/funding_proof-ICFZ5LHY.mjs +21 -0
  22. package/dist/{index-DIBZHOOQ.d.ts → index-DXh2IGkz.d.ts} +21239 -10304
  23. package/dist/{index-8MQz13eJ.d.mts → index-DeE1ZzA4.d.mts} +21239 -10304
  24. package/dist/index.d.mts +9 -3
  25. package/dist/index.d.ts +9 -3
  26. package/dist/index.js +48396 -19623
  27. package/dist/index.mjs +537 -19
  28. package/dist/interface-Bf7w1PLW.d.mts +679 -0
  29. package/dist/interface-Bf7w1PLW.d.ts +679 -0
  30. package/dist/{noir-DKfEzWy9.d.mts → noir-kzbLVTei.d.mts} +31 -21
  31. package/dist/{noir-DKfEzWy9.d.ts → noir-kzbLVTei.d.ts} +31 -21
  32. package/dist/proofs/halo2.d.mts +151 -0
  33. package/dist/proofs/halo2.d.ts +151 -0
  34. package/dist/proofs/halo2.js +350 -0
  35. package/dist/proofs/halo2.mjs +11 -0
  36. package/dist/proofs/kimchi.d.mts +160 -0
  37. package/dist/proofs/kimchi.d.ts +160 -0
  38. package/dist/proofs/kimchi.js +431 -0
  39. package/dist/proofs/kimchi.mjs +13 -0
  40. package/dist/proofs/noir.d.mts +1 -1
  41. package/dist/proofs/noir.d.ts +1 -1
  42. package/dist/proofs/noir.js +74 -18
  43. package/dist/proofs/noir.mjs +84 -24
  44. package/dist/solana-U3MEGU7W.mjs +280 -0
  45. package/dist/validity_proof-3POXLPNY.mjs +21 -0
  46. package/package.json +44 -11
  47. package/src/adapters/index.ts +41 -0
  48. package/src/adapters/jupiter.ts +571 -0
  49. package/src/adapters/near-intents.ts +135 -0
  50. package/src/advisor/advisor.ts +653 -0
  51. package/src/advisor/index.ts +54 -0
  52. package/src/advisor/tools.ts +303 -0
  53. package/src/advisor/types.ts +164 -0
  54. package/src/chains/ethereum/announcement.ts +536 -0
  55. package/src/chains/ethereum/bnb-optimizations.ts +474 -0
  56. package/src/chains/ethereum/commitment.ts +522 -0
  57. package/src/chains/ethereum/constants.ts +462 -0
  58. package/src/chains/ethereum/deployment.ts +596 -0
  59. package/src/chains/ethereum/gas-estimation.ts +538 -0
  60. package/src/chains/ethereum/index.ts +268 -0
  61. package/src/chains/ethereum/optimizations.ts +614 -0
  62. package/src/chains/ethereum/privacy-adapter.ts +855 -0
  63. package/src/chains/ethereum/registry.ts +584 -0
  64. package/src/chains/ethereum/rpc.ts +905 -0
  65. package/src/chains/ethereum/stealth.ts +491 -0
  66. package/src/chains/ethereum/token.ts +790 -0
  67. package/src/chains/ethereum/transfer.ts +637 -0
  68. package/src/chains/ethereum/types.ts +456 -0
  69. package/src/chains/ethereum/viewing-key.ts +455 -0
  70. package/src/chains/near/commitment.ts +608 -0
  71. package/src/chains/near/constants.ts +284 -0
  72. package/src/chains/near/function-call.ts +871 -0
  73. package/src/chains/near/history.ts +654 -0
  74. package/src/chains/near/implicit-account.ts +840 -0
  75. package/src/chains/near/index.ts +393 -0
  76. package/src/chains/near/native-transfer.ts +658 -0
  77. package/src/chains/near/nep141.ts +775 -0
  78. package/src/chains/near/privacy-adapter.ts +889 -0
  79. package/src/chains/near/resolver.ts +971 -0
  80. package/src/chains/near/rpc.ts +1016 -0
  81. package/src/chains/near/stealth.ts +419 -0
  82. package/src/chains/near/types.ts +317 -0
  83. package/src/chains/near/viewing-key.ts +876 -0
  84. package/src/chains/solana/anchor-transfer.ts +386 -0
  85. package/src/chains/solana/commitment.ts +577 -0
  86. package/src/chains/solana/constants.ts +126 -12
  87. package/src/chains/solana/ephemeral-keys.ts +543 -0
  88. package/src/chains/solana/index.ts +252 -1
  89. package/src/chains/solana/key-derivation.ts +418 -0
  90. package/src/chains/solana/kit-compat.ts +334 -0
  91. package/src/chains/solana/optimizations.ts +560 -0
  92. package/src/chains/solana/privacy-adapter.ts +605 -0
  93. package/src/chains/solana/providers/generic.ts +47 -6
  94. package/src/chains/solana/providers/helius-enhanced-types.ts +336 -0
  95. package/src/chains/solana/providers/helius-enhanced.ts +623 -0
  96. package/src/chains/solana/providers/helius.ts +186 -33
  97. package/src/chains/solana/providers/index.ts +31 -0
  98. package/src/chains/solana/providers/interface.ts +61 -18
  99. package/src/chains/solana/providers/quicknode.ts +409 -0
  100. package/src/chains/solana/providers/triton.ts +426 -0
  101. package/src/chains/solana/providers/webhook.ts +338 -67
  102. package/src/chains/solana/rpc-client.ts +1150 -0
  103. package/src/chains/solana/scan.ts +83 -66
  104. package/src/chains/solana/sol-transfer.ts +732 -0
  105. package/src/chains/solana/spl-transfer.ts +886 -0
  106. package/src/chains/solana/stealth-scanner.ts +703 -0
  107. package/src/chains/solana/sunspot-verifier.ts +453 -0
  108. package/src/chains/solana/transaction-builder.ts +755 -0
  109. package/src/chains/solana/transfer.ts +74 -5
  110. package/src/chains/solana/types.ts +57 -6
  111. package/src/chains/solana/utils.ts +110 -0
  112. package/src/chains/solana/viewing-key.ts +807 -0
  113. package/src/compliance/fireblocks.ts +921 -0
  114. package/src/compliance/index.ts +23 -0
  115. package/src/compliance/range-sas.ts +398 -33
  116. package/src/config/endpoints.ts +100 -0
  117. package/src/crypto.ts +11 -8
  118. package/src/errors.ts +82 -0
  119. package/src/evm/erc4337-relayer.ts +830 -0
  120. package/src/evm/index.ts +47 -0
  121. package/src/fees/calculator.ts +396 -0
  122. package/src/fees/index.ts +87 -0
  123. package/src/fees/near-contract.ts +429 -0
  124. package/src/fees/types.ts +268 -0
  125. package/src/index.ts +686 -1
  126. package/src/intent.ts +6 -3
  127. package/src/logger.ts +324 -0
  128. package/src/network/index.ts +80 -0
  129. package/src/network/proxy.ts +691 -0
  130. package/src/optimizations/index.ts +541 -0
  131. package/src/oracle/types.ts +1 -0
  132. package/src/privacy-backends/arcium-types.ts +727 -0
  133. package/src/privacy-backends/arcium.ts +719 -0
  134. package/src/privacy-backends/combined-privacy.ts +866 -0
  135. package/src/privacy-backends/cspl-token.ts +595 -0
  136. package/src/privacy-backends/cspl-types.ts +512 -0
  137. package/src/privacy-backends/cspl.ts +907 -0
  138. package/src/privacy-backends/health.ts +488 -0
  139. package/src/privacy-backends/inco-types.ts +323 -0
  140. package/src/privacy-backends/inco.ts +616 -0
  141. package/src/privacy-backends/index.ts +254 -4
  142. package/src/privacy-backends/interface.ts +649 -6
  143. package/src/privacy-backends/lru-cache.ts +343 -0
  144. package/src/privacy-backends/magicblock.ts +458 -0
  145. package/src/privacy-backends/mock.ts +258 -0
  146. package/src/privacy-backends/privacycash.ts +13 -17
  147. package/src/privacy-backends/private-swap.ts +570 -0
  148. package/src/privacy-backends/rate-limiter.ts +683 -0
  149. package/src/privacy-backends/registry.ts +414 -2
  150. package/src/privacy-backends/router.ts +283 -3
  151. package/src/privacy-backends/shadowwire.ts +449 -0
  152. package/src/privacy-backends/sip-native.ts +3 -0
  153. package/src/privacy-logger.ts +191 -0
  154. package/src/production-safety.ts +373 -0
  155. package/src/proofs/aggregator.ts +1029 -0
  156. package/src/proofs/browser-composer.ts +1150 -0
  157. package/src/proofs/browser.ts +113 -25
  158. package/src/proofs/cache/index.ts +127 -0
  159. package/src/proofs/cache/interface.ts +545 -0
  160. package/src/proofs/cache/key-generator.ts +188 -0
  161. package/src/proofs/cache/lru-cache.ts +481 -0
  162. package/src/proofs/cache/multi-tier-cache.ts +575 -0
  163. package/src/proofs/cache/persistent-cache.ts +788 -0
  164. package/src/proofs/compliance-proof.ts +872 -0
  165. package/src/proofs/composer/base.ts +923 -0
  166. package/src/proofs/composer/index.ts +25 -0
  167. package/src/proofs/composer/interface.ts +518 -0
  168. package/src/proofs/composer/types.ts +383 -0
  169. package/src/proofs/converters/halo2.ts +452 -0
  170. package/src/proofs/converters/index.ts +208 -0
  171. package/src/proofs/converters/interface.ts +363 -0
  172. package/src/proofs/converters/kimchi.ts +462 -0
  173. package/src/proofs/converters/noir.ts +451 -0
  174. package/src/proofs/fallback.ts +888 -0
  175. package/src/proofs/halo2.ts +42 -0
  176. package/src/proofs/index.ts +471 -0
  177. package/src/proofs/interface.ts +13 -0
  178. package/src/proofs/kimchi.ts +42 -0
  179. package/src/proofs/lazy.ts +1004 -0
  180. package/src/proofs/mock.ts +25 -1
  181. package/src/proofs/noir.ts +110 -29
  182. package/src/proofs/orchestrator.ts +960 -0
  183. package/src/proofs/parallel/concurrency.ts +297 -0
  184. package/src/proofs/parallel/dependency-graph.ts +602 -0
  185. package/src/proofs/parallel/executor.ts +420 -0
  186. package/src/proofs/parallel/index.ts +131 -0
  187. package/src/proofs/parallel/interface.ts +685 -0
  188. package/src/proofs/parallel/worker-pool.ts +644 -0
  189. package/src/proofs/providers/halo2.ts +560 -0
  190. package/src/proofs/providers/index.ts +34 -0
  191. package/src/proofs/providers/kimchi.ts +641 -0
  192. package/src/proofs/validator.ts +881 -0
  193. package/src/proofs/verifier.ts +867 -0
  194. package/src/quantum/index.ts +112 -0
  195. package/src/quantum/winternitz-vault.ts +639 -0
  196. package/src/quantum/wots.ts +611 -0
  197. package/src/settlement/backends/direct-chain.ts +1 -0
  198. package/src/settlement/index.ts +9 -0
  199. package/src/settlement/router.ts +732 -46
  200. package/src/solana/index.ts +72 -0
  201. package/src/solana/jito-relayer.ts +687 -0
  202. package/src/solana/noir-verifier-types.ts +430 -0
  203. package/src/solana/noir-verifier.ts +816 -0
  204. package/src/stealth/address-derivation.ts +193 -0
  205. package/src/stealth/ed25519.ts +431 -0
  206. package/src/stealth/index.ts +233 -0
  207. package/src/stealth/meta-address.ts +221 -0
  208. package/src/stealth/secp256k1.ts +368 -0
  209. package/src/stealth/utils.ts +194 -0
  210. package/src/stealth.ts +50 -1504
  211. package/src/sync/index.ts +106 -0
  212. package/src/sync/manager.ts +504 -0
  213. package/src/sync/mock-provider.ts +318 -0
  214. package/src/sync/oblivious.ts +625 -0
  215. package/src/tokens/index.ts +15 -0
  216. package/src/tokens/registry.ts +301 -0
  217. package/src/utils/deprecation.ts +94 -0
  218. package/src/utils/index.ts +9 -0
  219. package/src/wallet/ethereum/index.ts +68 -0
  220. package/src/wallet/ethereum/metamask-privacy.ts +420 -0
  221. package/src/wallet/ethereum/multi-wallet.ts +646 -0
  222. package/src/wallet/ethereum/privacy-adapter.ts +700 -0
  223. package/src/wallet/ethereum/types.ts +3 -1
  224. package/src/wallet/ethereum/walletconnect-adapter.ts +675 -0
  225. package/src/wallet/hardware/index.ts +10 -0
  226. package/src/wallet/hardware/ledger-privacy.ts +414 -0
  227. package/src/wallet/index.ts +71 -0
  228. package/src/wallet/near/adapter.ts +626 -0
  229. package/src/wallet/near/index.ts +86 -0
  230. package/src/wallet/near/meteor-wallet.ts +1153 -0
  231. package/src/wallet/near/my-near-wallet.ts +790 -0
  232. package/src/wallet/near/wallet-selector.ts +702 -0
  233. package/src/wallet/solana/adapter.ts +6 -4
  234. package/src/wallet/solana/index.ts +13 -0
  235. package/src/wallet/solana/privacy-adapter.ts +567 -0
  236. package/src/wallet/sui/types.ts +6 -4
  237. package/src/zcash/rpc-client.ts +13 -6
  238. package/dist/chunk-2XIVXWHA.mjs +0 -1930
  239. package/dist/chunk-3INS3PR5.mjs +0 -884
  240. package/dist/chunk-3OVABDRH.mjs +0 -17096
  241. package/dist/chunk-7RFRWDCW.mjs +0 -1504
  242. package/dist/chunk-DLDWZFYC.mjs +0 -1495
  243. package/dist/chunk-E6SZWREQ.mjs +0 -57
  244. package/dist/chunk-F6F73W35.mjs +0 -16166
  245. package/dist/chunk-G33LB27A.mjs +0 -16166
  246. package/dist/chunk-HGU6HZRC.mjs +0 -231
  247. package/dist/chunk-L2K34JCU.mjs +0 -1496
  248. package/dist/chunk-OFDBEIEK.mjs +0 -16166
  249. package/dist/chunk-SF7YSLF5.mjs +0 -1515
  250. package/dist/chunk-SN4ZDTVW.mjs +0 -16166
  251. package/dist/chunk-WWUSGOXE.mjs +0 -17129
  252. package/dist/constants-VOI7BSLK.mjs +0 -27
  253. package/dist/index-B71aXVzk.d.ts +0 -13264
  254. package/dist/index-BYZbDjal.d.ts +0 -11390
  255. package/dist/index-CHB3KuOB.d.mts +0 -11859
  256. package/dist/index-CzWPI6Le.d.ts +0 -11859
  257. package/dist/index-pOIIuwfV.d.mts +0 -13264
  258. package/dist/index-xbWjohNq.d.mts +0 -11390
  259. package/dist/solana-4O4K45VU.mjs +0 -46
  260. package/dist/solana-5EMCTPTS.mjs +0 -46
  261. package/dist/solana-NDABAZ6P.mjs +0 -56
  262. package/dist/solana-Q4NAVBTS.mjs +0 -46
  263. package/dist/solana-ZYO63LY5.mjs +0 -46
@@ -0,0 +1,679 @@
1
+ import { ProofSystem, SingleProof, HexString, ProofProviderCapabilities, ProofAggregationStrategy, ProofCompositionConfig, CompositionEventListener, ComposedProof, ProofProviderStatus, CompositionResult, VerificationResult } from '@sip-protocol/types';
2
+
3
+ /**
4
+ * Proof Composer SDK Types
5
+ *
6
+ * SDK-specific types for the proof composition system.
7
+ * These extend the base types from @sip-protocol/types with
8
+ * implementation-specific details.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+
13
+ /**
14
+ * Registration entry for a proof provider
15
+ */
16
+ interface ProofProviderRegistration {
17
+ /** Unique identifier for this provider instance */
18
+ id: string;
19
+ /** The proof system */
20
+ system: ProofSystem;
21
+ /** Provider capabilities */
22
+ capabilities: ProofProviderCapabilities;
23
+ /** Priority for provider selection (higher = preferred) */
24
+ priority: number;
25
+ /** Whether this provider is enabled */
26
+ enabled: boolean;
27
+ }
28
+ /**
29
+ * Options for registering a proof provider
30
+ */
31
+ interface RegisterProviderOptions {
32
+ /** Override existing provider with same system */
33
+ override?: boolean;
34
+ /** Priority for this provider */
35
+ priority?: number;
36
+ /** Enable immediately */
37
+ enabled?: boolean;
38
+ }
39
+ /**
40
+ * Request to generate a proof
41
+ */
42
+ interface ProofGenerationRequest {
43
+ /** Circuit to use */
44
+ circuitId: string;
45
+ /** Private inputs (not revealed) */
46
+ privateInputs: Record<string, unknown>;
47
+ /** Public inputs (revealed in proof) */
48
+ publicInputs: Record<string, unknown>;
49
+ /** Optional: specific provider to use */
50
+ providerId?: string;
51
+ /** Optional: specific proof system to use */
52
+ system?: ProofSystem;
53
+ /** Optional: timeout override */
54
+ timeoutMs?: number;
55
+ }
56
+ /**
57
+ * Result of proof generation
58
+ */
59
+ interface ProofGenerationResult {
60
+ /** Whether generation was successful */
61
+ success: boolean;
62
+ /** The generated proof (if successful) */
63
+ proof?: SingleProof;
64
+ /** Error message (if failed) */
65
+ error?: string;
66
+ /** Generation time in milliseconds */
67
+ timeMs: number;
68
+ /** Provider that generated the proof */
69
+ providerId: string;
70
+ }
71
+ /**
72
+ * Options for composing proofs
73
+ */
74
+ interface ComposeProofsOptions {
75
+ /** Proofs to compose */
76
+ proofs: SingleProof[];
77
+ /** Override default strategy */
78
+ strategy?: ProofAggregationStrategy;
79
+ /** Override default config */
80
+ config?: Partial<ProofCompositionConfig>;
81
+ /** Event listener for progress updates */
82
+ onProgress?: CompositionEventListener;
83
+ /** Abort signal for cancellation */
84
+ abortSignal?: AbortSignal;
85
+ }
86
+ /**
87
+ * Options for verifying a composed proof
88
+ */
89
+ interface VerifyComposedProofOptions {
90
+ /** The composed proof to verify */
91
+ composedProof: ComposedProof;
92
+ /** Whether to verify individual proofs */
93
+ verifyIndividual?: boolean;
94
+ /** Whether to use batch verification if available */
95
+ useBatchVerification?: boolean;
96
+ /** Timeout for verification */
97
+ timeoutMs?: number;
98
+ }
99
+ /**
100
+ * Options for aggregating proofs
101
+ */
102
+ interface AggregateProofsOptions {
103
+ /** Proofs to aggregate */
104
+ proofs: SingleProof[];
105
+ /** Target proof system for aggregated proof */
106
+ targetSystem: ProofSystem;
107
+ /** Whether to verify before aggregating */
108
+ verifyFirst?: boolean;
109
+ /** Maximum recursion depth */
110
+ maxRecursionDepth?: number;
111
+ }
112
+ /**
113
+ * Result of proof aggregation
114
+ */
115
+ interface AggregationResult {
116
+ /** Whether aggregation was successful */
117
+ success: boolean;
118
+ /** The aggregated proof (if successful) */
119
+ aggregatedProof?: HexString;
120
+ /** Error message (if failed) */
121
+ error?: string;
122
+ /** Aggregation metrics */
123
+ metrics: {
124
+ inputProofCount: number;
125
+ outputProofSize: number;
126
+ timeMs: number;
127
+ recursionDepth: number;
128
+ };
129
+ }
130
+ /**
131
+ * Options for converting proof formats
132
+ */
133
+ interface ConvertProofOptions {
134
+ /** Source proof */
135
+ proof: SingleProof;
136
+ /** Target proof system */
137
+ targetSystem: ProofSystem;
138
+ /** Whether to preserve metadata */
139
+ preserveMetadata?: boolean;
140
+ }
141
+ /**
142
+ * Result of proof conversion
143
+ */
144
+ interface ConversionResult {
145
+ /** Whether conversion was successful */
146
+ success: boolean;
147
+ /** The converted proof (if successful) */
148
+ convertedProof?: SingleProof;
149
+ /** Error message (if failed) */
150
+ error?: string;
151
+ /** Whether conversion was lossless */
152
+ lossless: boolean;
153
+ }
154
+ /**
155
+ * Cache entry for a proof
156
+ */
157
+ interface ProofCacheEntry {
158
+ /** The cached proof */
159
+ proof: SingleProof | ComposedProof;
160
+ /** When the entry was created */
161
+ createdAt: number;
162
+ /** When the entry expires */
163
+ expiresAt: number;
164
+ /** Number of times this entry was accessed */
165
+ accessCount: number;
166
+ /** Last access timestamp */
167
+ lastAccessedAt: number;
168
+ /** Size in bytes */
169
+ sizeBytes: number;
170
+ }
171
+ /**
172
+ * Cache statistics
173
+ */
174
+ interface CacheStats {
175
+ /** Total entries in cache */
176
+ entryCount: number;
177
+ /** Total size in bytes */
178
+ totalSizeBytes: number;
179
+ /** Hit rate (0-1) */
180
+ hitRate: number;
181
+ /** Number of cache hits */
182
+ hits: number;
183
+ /** Number of cache misses */
184
+ misses: number;
185
+ /** Number of evictions */
186
+ evictions: number;
187
+ }
188
+ /**
189
+ * Configuration for the worker pool
190
+ */
191
+ interface WorkerPoolConfig {
192
+ /** Minimum number of workers */
193
+ minWorkers: number;
194
+ /** Maximum number of workers */
195
+ maxWorkers: number;
196
+ /** Worker idle timeout (milliseconds) */
197
+ idleTimeoutMs: number;
198
+ /** Task queue size limit */
199
+ maxQueueSize: number;
200
+ /** Whether to use shared array buffers */
201
+ useSharedMemory: boolean;
202
+ }
203
+ /**
204
+ * Status of the worker pool
205
+ */
206
+ interface WorkerPoolStatus {
207
+ /** Number of active workers */
208
+ activeWorkers: number;
209
+ /** Number of idle workers */
210
+ idleWorkers: number;
211
+ /** Number of tasks in queue */
212
+ queuedTasks: number;
213
+ /** Number of tasks being processed */
214
+ processingTasks: number;
215
+ /** Average task completion time (milliseconds) */
216
+ avgTaskTimeMs: number;
217
+ }
218
+ /**
219
+ * Compatibility matrix entry
220
+ */
221
+ interface SystemCompatibility {
222
+ /** Source system */
223
+ source: ProofSystem;
224
+ /** Target system */
225
+ target: ProofSystem;
226
+ /** Whether conversion is supported */
227
+ conversionSupported: boolean;
228
+ /** Whether aggregation is supported */
229
+ aggregationSupported: boolean;
230
+ /** Compatibility notes */
231
+ notes?: string;
232
+ }
233
+ /**
234
+ * Full compatibility matrix
235
+ */
236
+ type CompatibilityMatrix = Record<ProofSystem, Record<ProofSystem, SystemCompatibility>>;
237
+ /**
238
+ * Fallback strategy configuration
239
+ */
240
+ interface FallbackConfig {
241
+ /** Primary proof system */
242
+ primary: ProofSystem;
243
+ /** Fallback chain (in order of preference) */
244
+ fallbackChain: ProofSystem[];
245
+ /** Whether to retry on failure */
246
+ retryOnFailure: boolean;
247
+ /** Maximum retry attempts */
248
+ maxRetries: number;
249
+ /** Delay between retries (milliseconds) */
250
+ retryDelayMs: number;
251
+ /** Whether to use exponential backoff */
252
+ exponentialBackoff: boolean;
253
+ }
254
+ /**
255
+ * Telemetry data for proof operations
256
+ */
257
+ interface ProofTelemetry {
258
+ /** Operation type */
259
+ operation: 'generate' | 'verify' | 'compose' | 'aggregate' | 'convert';
260
+ /** Proof system used */
261
+ system: ProofSystem;
262
+ /** Circuit ID */
263
+ circuitId: string;
264
+ /** Duration in milliseconds */
265
+ durationMs: number;
266
+ /** Whether operation succeeded */
267
+ success: boolean;
268
+ /** Error code (if failed) */
269
+ errorCode?: string;
270
+ /** Memory usage (bytes) */
271
+ memoryUsage?: number;
272
+ /** Timestamp */
273
+ timestamp: number;
274
+ }
275
+ /**
276
+ * Telemetry collector interface
277
+ */
278
+ interface TelemetryCollector {
279
+ /** Record a telemetry event */
280
+ record(telemetry: ProofTelemetry): void;
281
+ /** Flush pending telemetry */
282
+ flush(): Promise<void>;
283
+ /** Get aggregated metrics */
284
+ getMetrics(): ProofTelemetryMetrics;
285
+ }
286
+ /**
287
+ * Aggregated telemetry metrics
288
+ */
289
+ interface ProofTelemetryMetrics {
290
+ /** Operations by type */
291
+ operationCounts: Record<string, number>;
292
+ /** Average duration by operation type */
293
+ avgDurationMs: Record<string, number>;
294
+ /** Success rate by operation type */
295
+ successRates: Record<string, number>;
296
+ /** Total operations */
297
+ totalOperations: number;
298
+ /** Time window for these metrics */
299
+ timeWindowMs: number;
300
+ }
301
+
302
+ /**
303
+ * Proof Composer Interface
304
+ *
305
+ * Defines the core interfaces for proof composition, including:
306
+ * - ProofComposer: Main composition orchestrator
307
+ * - ComposableProofProvider: Abstract provider for proof systems
308
+ *
309
+ * @packageDocumentation
310
+ */
311
+
312
+ /**
313
+ * Abstract interface for proof providers that can participate in composition.
314
+ *
315
+ * Implementations of this interface provide proof generation and verification
316
+ * for a specific proof system (Noir, Halo2, Kimchi, etc.).
317
+ *
318
+ * @example
319
+ * ```typescript
320
+ * class Halo2Provider implements ComposableProofProvider {
321
+ * readonly system = 'halo2'
322
+ *
323
+ * async initialize() {
324
+ * // Load WASM, setup keys, etc.
325
+ * }
326
+ *
327
+ * async generateProof(request) {
328
+ * // Generate Halo2 proof
329
+ * }
330
+ *
331
+ * async verifyProof(proof) {
332
+ * // Verify Halo2 proof
333
+ * }
334
+ * }
335
+ * ```
336
+ */
337
+ interface ComposableProofProvider {
338
+ /**
339
+ * The proof system this provider implements
340
+ */
341
+ readonly system: ProofSystem;
342
+ /**
343
+ * Provider capabilities
344
+ */
345
+ readonly capabilities: ProofProviderCapabilities;
346
+ /**
347
+ * Current provider status
348
+ */
349
+ readonly status: ProofProviderStatus;
350
+ /**
351
+ * Initialize the provider.
352
+ * Must be called before generating or verifying proofs.
353
+ *
354
+ * @throws Error if initialization fails
355
+ */
356
+ initialize(): Promise<void>;
357
+ /**
358
+ * Wait for provider to be ready with optional timeout.
359
+ *
360
+ * @param timeoutMs - Maximum wait time in milliseconds (default: 30000)
361
+ * @throws Error if timeout reached or initialization fails
362
+ */
363
+ waitUntilReady(timeoutMs?: number): Promise<void>;
364
+ /**
365
+ * Generate a proof for the given request.
366
+ *
367
+ * @param request - Proof generation request
368
+ * @returns Generation result with proof or error
369
+ */
370
+ generateProof(request: ProofGenerationRequest): Promise<ProofGenerationResult>;
371
+ /**
372
+ * Verify a single proof.
373
+ *
374
+ * @param proof - The proof to verify
375
+ * @returns true if valid, false otherwise
376
+ */
377
+ verifyProof(proof: SingleProof): Promise<boolean>;
378
+ /**
379
+ * Verify multiple proofs in a batch (if supported).
380
+ *
381
+ * @param proofs - Proofs to verify
382
+ * @returns Array of verification results
383
+ */
384
+ verifyBatch?(proofs: SingleProof[]): Promise<boolean[]>;
385
+ /**
386
+ * Get available circuits for this provider.
387
+ *
388
+ * @returns Array of circuit identifiers
389
+ */
390
+ getAvailableCircuits(): string[];
391
+ /**
392
+ * Check if a specific circuit is available.
393
+ *
394
+ * @param circuitId - Circuit identifier
395
+ * @returns true if circuit is available
396
+ */
397
+ hasCircuit(circuitId: string): boolean;
398
+ /**
399
+ * Dispose of resources used by this provider.
400
+ */
401
+ dispose(): Promise<void>;
402
+ }
403
+ /**
404
+ * Main interface for the proof composition system.
405
+ *
406
+ * ProofComposer orchestrates the composition of proofs from multiple
407
+ * proof systems, handling:
408
+ * - Provider registration and management
409
+ * - Proof generation across systems
410
+ * - Proof composition and aggregation
411
+ * - Verification of composed proofs
412
+ * - Caching and optimization
413
+ *
414
+ * @example
415
+ * ```typescript
416
+ * const composer = new ProofComposer(config)
417
+ *
418
+ * // Register providers
419
+ * await composer.registerProvider(noirProvider)
420
+ * await composer.registerProvider(halo2Provider)
421
+ *
422
+ * // Generate proofs
423
+ * const proof1 = await composer.generateProof({
424
+ * circuitId: 'funding_proof',
425
+ * privateInputs: { balance: 1000n },
426
+ * publicInputs: { minRequired: 100n },
427
+ * })
428
+ *
429
+ * const proof2 = await composer.generateProof({
430
+ * circuitId: 'validity_proof',
431
+ * privateInputs: { sender: '0x...' },
432
+ * publicInputs: { intentHash: '0x...' },
433
+ * })
434
+ *
435
+ * // Compose proofs
436
+ * const result = await composer.compose({
437
+ * proofs: [proof1.proof!, proof2.proof!],
438
+ * strategy: ProofAggregationStrategy.PARALLEL,
439
+ * })
440
+ *
441
+ * // Verify composed proof
442
+ * const verification = await composer.verify({
443
+ * composedProof: result.composedProof!,
444
+ * })
445
+ * ```
446
+ */
447
+ interface ProofComposer {
448
+ /**
449
+ * Current configuration
450
+ */
451
+ readonly config: ProofCompositionConfig;
452
+ /**
453
+ * Update configuration.
454
+ *
455
+ * @param config - Partial configuration to merge
456
+ */
457
+ updateConfig(config: Partial<ProofCompositionConfig>): void;
458
+ /**
459
+ * Register a proof provider.
460
+ *
461
+ * @param provider - The provider to register
462
+ * @param options - Registration options
463
+ * @returns Registration entry
464
+ */
465
+ registerProvider(provider: ComposableProofProvider, options?: RegisterProviderOptions): Promise<ProofProviderRegistration>;
466
+ /**
467
+ * Unregister a provider.
468
+ *
469
+ * @param providerId - Provider ID to unregister
470
+ * @returns true if provider was removed
471
+ */
472
+ unregisterProvider(providerId: string): boolean;
473
+ /**
474
+ * Get a registered provider by ID.
475
+ *
476
+ * @param providerId - Provider ID
477
+ * @returns Provider or undefined
478
+ */
479
+ getProvider(providerId: string): ComposableProofProvider | undefined;
480
+ /**
481
+ * Get provider for a specific proof system.
482
+ *
483
+ * @param system - Proof system
484
+ * @returns Provider or undefined
485
+ */
486
+ getProviderForSystem(system: ProofSystem): ComposableProofProvider | undefined;
487
+ /**
488
+ * Get all registered providers.
489
+ *
490
+ * @returns Array of provider registrations
491
+ */
492
+ getProviders(): ProofProviderRegistration[];
493
+ /**
494
+ * Get available proof systems.
495
+ *
496
+ * @returns Array of available systems
497
+ */
498
+ getAvailableSystems(): ProofSystem[];
499
+ /**
500
+ * Generate a proof using the appropriate provider.
501
+ *
502
+ * @param request - Proof generation request
503
+ * @returns Generation result
504
+ */
505
+ generateProof(request: ProofGenerationRequest): Promise<ProofGenerationResult>;
506
+ /**
507
+ * Generate multiple proofs in parallel.
508
+ *
509
+ * @param requests - Array of proof requests
510
+ * @returns Array of generation results
511
+ */
512
+ generateProofs(requests: ProofGenerationRequest[]): Promise<ProofGenerationResult[]>;
513
+ /**
514
+ * Compose multiple proofs into a single composed proof.
515
+ *
516
+ * @param options - Composition options
517
+ * @returns Composition result
518
+ */
519
+ compose(options: ComposeProofsOptions): Promise<CompositionResult>;
520
+ /**
521
+ * Aggregate proofs into a single proof (if supported).
522
+ *
523
+ * @param options - Aggregation options
524
+ * @returns Aggregation result
525
+ */
526
+ aggregate(options: AggregateProofsOptions): Promise<AggregationResult>;
527
+ /**
528
+ * Verify a composed proof.
529
+ *
530
+ * @param options - Verification options
531
+ * @returns Verification result
532
+ */
533
+ verify(options: VerifyComposedProofOptions): Promise<VerificationResult>;
534
+ /**
535
+ * Verify a single proof.
536
+ *
537
+ * @param proof - Proof to verify
538
+ * @returns true if valid
539
+ */
540
+ verifySingle(proof: SingleProof): Promise<boolean>;
541
+ /**
542
+ * Convert a proof to a different format.
543
+ *
544
+ * @param options - Conversion options
545
+ * @returns Conversion result
546
+ */
547
+ convert(options: ConvertProofOptions): Promise<ConversionResult>;
548
+ /**
549
+ * Get the compatibility matrix for proof systems.
550
+ *
551
+ * @returns Compatibility matrix
552
+ */
553
+ getCompatibilityMatrix(): CompatibilityMatrix;
554
+ /**
555
+ * Check if two systems are compatible for composition.
556
+ *
557
+ * @param source - Source system
558
+ * @param target - Target system
559
+ * @returns true if compatible
560
+ */
561
+ areSystemsCompatible(source: ProofSystem, target: ProofSystem): boolean;
562
+ /**
563
+ * Get cache statistics.
564
+ *
565
+ * @returns Cache stats
566
+ */
567
+ getCacheStats(): CacheStats;
568
+ /**
569
+ * Clear the proof cache.
570
+ *
571
+ * @param olderThan - Optional: only clear entries older than this timestamp
572
+ */
573
+ clearCache(olderThan?: number): void;
574
+ /**
575
+ * Get worker pool status.
576
+ *
577
+ * @returns Worker pool status
578
+ */
579
+ getWorkerPoolStatus(): WorkerPoolStatus;
580
+ /**
581
+ * Scale worker pool.
582
+ *
583
+ * @param targetWorkers - Target number of workers
584
+ */
585
+ scaleWorkerPool(targetWorkers: number): Promise<void>;
586
+ /**
587
+ * Set fallback configuration.
588
+ *
589
+ * @param config - Fallback configuration
590
+ */
591
+ setFallbackConfig(config: FallbackConfig): void;
592
+ /**
593
+ * Get current fallback configuration.
594
+ *
595
+ * @returns Fallback config or undefined
596
+ */
597
+ getFallbackConfig(): FallbackConfig | undefined;
598
+ /**
599
+ * Add an event listener.
600
+ *
601
+ * @param listener - Event listener
602
+ * @returns Unsubscribe function
603
+ */
604
+ addEventListener(listener: CompositionEventListener): () => void;
605
+ /**
606
+ * Remove an event listener.
607
+ *
608
+ * @param listener - Listener to remove
609
+ */
610
+ removeEventListener(listener: CompositionEventListener): void;
611
+ /**
612
+ * Set telemetry collector.
613
+ *
614
+ * @param collector - Telemetry collector
615
+ */
616
+ setTelemetryCollector(collector: TelemetryCollector): void;
617
+ /**
618
+ * Initialize the composer and all providers.
619
+ */
620
+ initialize(): Promise<void>;
621
+ /**
622
+ * Dispose of resources.
623
+ */
624
+ dispose(): Promise<void>;
625
+ }
626
+ /**
627
+ * Factory for creating proof providers
628
+ */
629
+ type ProofProviderFactory = (config?: Record<string, unknown>) => Promise<ComposableProofProvider>;
630
+ /**
631
+ * Registry of proof provider factories
632
+ */
633
+ interface ProofProviderRegistry {
634
+ /** Register a provider factory */
635
+ register(system: ProofSystem, factory: ProofProviderFactory): void;
636
+ /** Get a provider factory */
637
+ get(system: ProofSystem): ProofProviderFactory | undefined;
638
+ /** Create a provider instance */
639
+ create(system: ProofSystem, config?: Record<string, unknown>): Promise<ComposableProofProvider>;
640
+ /** Get all registered systems */
641
+ getSystems(): ProofSystem[];
642
+ }
643
+ /**
644
+ * Error thrown during proof composition
645
+ */
646
+ declare class ProofCompositionError extends Error {
647
+ readonly code: string;
648
+ readonly system?: ProofSystem;
649
+ readonly proofId?: string;
650
+ readonly cause?: Error;
651
+ constructor(code: string, message: string, options?: {
652
+ system?: ProofSystem;
653
+ proofId?: string;
654
+ cause?: Error;
655
+ });
656
+ }
657
+ /**
658
+ * Error thrown when a provider is not found
659
+ */
660
+ declare class ProviderNotFoundError extends ProofCompositionError {
661
+ constructor(system: ProofSystem);
662
+ }
663
+ /**
664
+ * Error thrown when composition times out
665
+ */
666
+ declare class CompositionTimeoutError extends ProofCompositionError {
667
+ readonly timeoutMs: number;
668
+ constructor(timeoutMs: number);
669
+ }
670
+ /**
671
+ * Error thrown when proof systems are incompatible
672
+ */
673
+ declare class IncompatibleSystemsError extends ProofCompositionError {
674
+ readonly source: ProofSystem;
675
+ readonly target: ProofSystem;
676
+ constructor(source: ProofSystem, target: ProofSystem);
677
+ }
678
+
679
+ export { type AggregateProofsOptions as A, CompositionTimeoutError as C, type FallbackConfig as F, IncompatibleSystemsError as I, ProofCompositionError as P, type RegisterProviderOptions as R, type SystemCompatibility as S, type TelemetryCollector as T, type VerifyComposedProofOptions as V, type WorkerPoolConfig as W, ProviderNotFoundError as a, type ComposableProofProvider as b, type ProofComposer as c, type ProofProviderFactory as d, type ProofProviderRegistry as e, type ProofProviderRegistration as f, type ProofGenerationRequest as g, type ProofGenerationResult as h, type ComposeProofsOptions as i, type AggregationResult as j, type ConvertProofOptions as k, type ConversionResult as l, type ProofCacheEntry as m, type CacheStats as n, type WorkerPoolStatus as o, type CompatibilityMatrix as p, type ProofTelemetry as q, type ProofTelemetryMetrics as r };