@psavelis/enterprise-blockchain 0.1.0 → 1.1.1

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 (296) hide show
  1. package/README.md +15 -2
  2. package/dist/aid-settlement/application/reconciler.d.ts +13 -0
  3. package/dist/aid-settlement/application/reconciler.d.ts.map +1 -0
  4. package/dist/aid-settlement/application/reconciler.js +77 -0
  5. package/dist/aid-settlement/domain/entities.d.ts +24 -0
  6. package/dist/aid-settlement/domain/entities.d.ts.map +1 -0
  7. package/dist/aid-settlement/domain/entities.js +1 -0
  8. package/dist/aid-settlement/domain/ports.d.ts +10 -0
  9. package/dist/aid-settlement/domain/ports.d.ts.map +1 -0
  10. package/dist/aid-settlement/domain/ports.js +1 -0
  11. package/dist/aid-settlement/index.d.ts +19 -0
  12. package/dist/aid-settlement/index.d.ts.map +1 -0
  13. package/dist/aid-settlement/index.js +23 -0
  14. package/dist/aid-settlement/infrastructure/in-memory-store.d.ts +12 -0
  15. package/dist/aid-settlement/infrastructure/in-memory-store.d.ts.map +1 -0
  16. package/dist/aid-settlement/infrastructure/in-memory-store.js +17 -0
  17. package/dist/credentialing/application/clearance-evaluator.d.ts +10 -0
  18. package/dist/credentialing/application/clearance-evaluator.d.ts.map +1 -0
  19. package/dist/credentialing/application/clearance-evaluator.js +63 -0
  20. package/dist/credentialing/domain/entities.d.ts +28 -0
  21. package/dist/credentialing/domain/entities.d.ts.map +1 -0
  22. package/dist/credentialing/domain/entities.js +1 -0
  23. package/dist/credentialing/domain/ports.d.ts +9 -0
  24. package/dist/credentialing/domain/ports.d.ts.map +1 -0
  25. package/dist/credentialing/domain/ports.js +1 -0
  26. package/dist/credentialing/index.d.ts +19 -0
  27. package/dist/credentialing/index.d.ts.map +1 -0
  28. package/dist/credentialing/index.js +23 -0
  29. package/dist/credentialing/infrastructure/in-memory-store.d.ts +11 -0
  30. package/dist/credentialing/infrastructure/in-memory-store.d.ts.map +1 -0
  31. package/dist/credentialing/infrastructure/in-memory-store.js +14 -0
  32. package/dist/hsm/application/asymmetric-key-service.d.ts +23 -0
  33. package/dist/hsm/application/asymmetric-key-service.d.ts.map +1 -0
  34. package/dist/hsm/application/asymmetric-key-service.js +109 -0
  35. package/dist/hsm/application/envelope-encryption-service.d.ts +18 -0
  36. package/dist/hsm/application/envelope-encryption-service.d.ts.map +1 -0
  37. package/dist/hsm/application/envelope-encryption-service.js +59 -0
  38. package/dist/hsm/application/symmetric-key-service.d.ts +34 -0
  39. package/dist/hsm/application/symmetric-key-service.d.ts.map +1 -0
  40. package/dist/hsm/application/symmetric-key-service.js +107 -0
  41. package/dist/hsm/domain/entities.d.ts +104 -0
  42. package/dist/hsm/domain/entities.d.ts.map +1 -0
  43. package/dist/hsm/domain/entities.js +10 -0
  44. package/dist/hsm/domain/ports.d.ts +20 -0
  45. package/dist/hsm/domain/ports.d.ts.map +1 -0
  46. package/dist/hsm/domain/ports.js +1 -0
  47. package/dist/hsm/index.d.ts +48 -0
  48. package/dist/hsm/index.d.ts.map +1 -0
  49. package/dist/hsm/index.js +97 -0
  50. package/dist/hsm/infrastructure/audit-log-factory.d.ts +59 -0
  51. package/dist/hsm/infrastructure/audit-log-factory.d.ts.map +1 -0
  52. package/dist/hsm/infrastructure/audit-log-factory.js +95 -0
  53. package/dist/hsm/infrastructure/audit-log.d.ts +8 -0
  54. package/dist/hsm/infrastructure/audit-log.d.ts.map +1 -0
  55. package/dist/hsm/infrastructure/audit-log.js +18 -0
  56. package/dist/hsm/infrastructure/file-audit-log.d.ts +55 -0
  57. package/dist/hsm/infrastructure/file-audit-log.d.ts.map +1 -0
  58. package/dist/hsm/infrastructure/file-audit-log.js +128 -0
  59. package/dist/hsm/infrastructure/key-store.d.ts +9 -0
  60. package/dist/hsm/infrastructure/key-store.d.ts.map +1 -0
  61. package/dist/hsm/infrastructure/key-store.js +12 -0
  62. package/dist/hsm/infrastructure/syslog-audit-log.d.ts +64 -0
  63. package/dist/hsm/infrastructure/syslog-audit-log.d.ts.map +1 -0
  64. package/dist/hsm/infrastructure/syslog-audit-log.js +167 -0
  65. package/dist/index.d.ts +22 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +37 -0
  68. package/dist/integrations/besu-client/error-mapper.d.ts +9 -0
  69. package/dist/integrations/besu-client/error-mapper.d.ts.map +1 -0
  70. package/dist/integrations/besu-client/error-mapper.js +22 -0
  71. package/dist/integrations/besu-client/index.d.ts +65 -0
  72. package/dist/integrations/besu-client/index.d.ts.map +1 -0
  73. package/dist/integrations/besu-client/index.js +276 -0
  74. package/dist/integrations/besu-client/ports.d.ts +44 -0
  75. package/dist/integrations/besu-client/ports.d.ts.map +1 -0
  76. package/dist/integrations/besu-client/ports.js +1 -0
  77. package/dist/integrations/corda-gateway/index.d.ts +37 -0
  78. package/dist/integrations/corda-gateway/index.d.ts.map +1 -0
  79. package/dist/integrations/corda-gateway/index.js +234 -0
  80. package/dist/integrations/corda-gateway/ports.d.ts +33 -0
  81. package/dist/integrations/corda-gateway/ports.d.ts.map +1 -0
  82. package/dist/integrations/corda-gateway/ports.js +1 -0
  83. package/dist/integrations/fabric-gateway/index.d.ts +78 -0
  84. package/dist/integrations/fabric-gateway/index.d.ts.map +1 -0
  85. package/dist/integrations/fabric-gateway/index.js +214 -0
  86. package/dist/integrations/fabric-gateway/ports.d.ts +50 -0
  87. package/dist/integrations/fabric-gateway/ports.d.ts.map +1 -0
  88. package/dist/integrations/fabric-gateway/ports.js +1 -0
  89. package/dist/integrations/index.d.ts +19 -0
  90. package/dist/integrations/index.d.ts.map +1 -0
  91. package/dist/integrations/index.js +19 -0
  92. package/dist/integrations/shared/env.d.ts +4 -0
  93. package/dist/integrations/shared/env.d.ts.map +1 -0
  94. package/dist/integrations/shared/env.js +24 -0
  95. package/dist/integrations/shared/retry.d.ts +79 -0
  96. package/dist/integrations/shared/retry.d.ts.map +1 -0
  97. package/dist/integrations/shared/retry.js +315 -0
  98. package/dist/mpc/adapters.d.ts +36 -0
  99. package/dist/mpc/adapters.d.ts.map +1 -0
  100. package/dist/mpc/adapters.js +46 -0
  101. package/dist/mpc/crypto.d.ts +2 -0
  102. package/dist/mpc/crypto.d.ts.map +1 -0
  103. package/dist/mpc/crypto.js +2 -0
  104. package/dist/mpc/dsa.d.ts +134 -0
  105. package/dist/mpc/dsa.d.ts.map +1 -0
  106. package/dist/mpc/dsa.js +127 -0
  107. package/dist/mpc/field.d.ts +127 -0
  108. package/dist/mpc/field.d.ts.map +1 -0
  109. package/dist/mpc/field.js +209 -0
  110. package/dist/mpc/hybrid-kem.d.ts +96 -0
  111. package/dist/mpc/hybrid-kem.d.ts.map +1 -0
  112. package/dist/mpc/hybrid-kem.js +136 -0
  113. package/dist/mpc/index.d.ts +135 -0
  114. package/dist/mpc/index.d.ts.map +1 -0
  115. package/dist/mpc/index.js +348 -0
  116. package/dist/mpc/kyber.d.ts +134 -0
  117. package/dist/mpc/kyber.d.ts.map +1 -0
  118. package/dist/mpc/kyber.js +143 -0
  119. package/dist/mpc/ports.d.ts +67 -0
  120. package/dist/mpc/ports.d.ts.map +1 -0
  121. package/dist/mpc/ports.js +9 -0
  122. package/dist/mpc/quantum.d.ts +80 -0
  123. package/dist/mpc/quantum.d.ts.map +1 -0
  124. package/dist/mpc/quantum.js +180 -0
  125. package/dist/p2mr/adapters.d.ts +31 -0
  126. package/dist/p2mr/adapters.d.ts.map +1 -0
  127. package/dist/p2mr/adapters.js +35 -0
  128. package/dist/p2mr/index.d.ts +63 -0
  129. package/dist/p2mr/index.d.ts.map +1 -0
  130. package/dist/p2mr/index.js +59 -0
  131. package/dist/p2mr/merkle-tree.d.ts +109 -0
  132. package/dist/p2mr/merkle-tree.d.ts.map +1 -0
  133. package/dist/p2mr/merkle-tree.js +239 -0
  134. package/dist/p2mr/p2mr-output.d.ts +142 -0
  135. package/dist/p2mr/p2mr-output.d.ts.map +1 -0
  136. package/dist/p2mr/p2mr-output.js +150 -0
  137. package/dist/p2mr/ports.d.ts +52 -0
  138. package/dist/p2mr/ports.d.ts.map +1 -0
  139. package/dist/p2mr/ports.js +9 -0
  140. package/dist/p2mr/script-interpreter.d.ts +92 -0
  141. package/dist/p2mr/script-interpreter.d.ts.map +1 -0
  142. package/dist/p2mr/script-interpreter.js +535 -0
  143. package/dist/p2mr/script-leaf.d.ts +70 -0
  144. package/dist/p2mr/script-leaf.d.ts.map +1 -0
  145. package/dist/p2mr/script-leaf.js +203 -0
  146. package/dist/p2mr/spend-proof.d.ts +95 -0
  147. package/dist/p2mr/spend-proof.d.ts.map +1 -0
  148. package/dist/p2mr/spend-proof.js +358 -0
  149. package/dist/p2mr/types.d.ts +209 -0
  150. package/dist/p2mr/types.d.ts.map +1 -0
  151. package/dist/p2mr/types.js +9 -0
  152. package/dist/privacy/application/view-projector.d.ts +13 -0
  153. package/dist/privacy/application/view-projector.d.ts.map +1 -0
  154. package/dist/privacy/application/view-projector.js +85 -0
  155. package/dist/privacy/domain/entities.d.ts +26 -0
  156. package/dist/privacy/domain/entities.d.ts.map +1 -0
  157. package/dist/privacy/domain/entities.js +1 -0
  158. package/dist/privacy/domain/ports.d.ts +7 -0
  159. package/dist/privacy/domain/ports.d.ts.map +1 -0
  160. package/dist/privacy/domain/ports.js +1 -0
  161. package/dist/privacy/index.d.ts +21 -0
  162. package/dist/privacy/index.d.ts.map +1 -0
  163. package/dist/privacy/index.js +25 -0
  164. package/dist/privacy/infrastructure/in-memory-store.d.ts +8 -0
  165. package/dist/privacy/infrastructure/in-memory-store.d.ts.map +1 -0
  166. package/dist/privacy/infrastructure/in-memory-store.js +7 -0
  167. package/dist/protocols/besu-port.d.ts +80 -0
  168. package/dist/protocols/besu-port.d.ts.map +1 -0
  169. package/dist/protocols/besu-port.js +1 -0
  170. package/dist/protocols/corda-port.d.ts +103 -0
  171. package/dist/protocols/corda-port.d.ts.map +1 -0
  172. package/dist/protocols/corda-port.js +9 -0
  173. package/dist/protocols/credentialing-port.d.ts +11 -0
  174. package/dist/protocols/credentialing-port.d.ts.map +1 -0
  175. package/dist/protocols/credentialing-port.js +1 -0
  176. package/dist/protocols/fabric-port.d.ts +89 -0
  177. package/dist/protocols/fabric-port.d.ts.map +1 -0
  178. package/dist/protocols/fabric-port.js +9 -0
  179. package/dist/protocols/index.d.ts +14 -0
  180. package/dist/protocols/index.d.ts.map +1 -0
  181. package/dist/protocols/index.js +7 -0
  182. package/dist/protocols/p2mr-port.d.ts +159 -0
  183. package/dist/protocols/p2mr-port.d.ts.map +1 -0
  184. package/dist/protocols/p2mr-port.js +12 -0
  185. package/dist/protocols/privacy-port.d.ts +9 -0
  186. package/dist/protocols/privacy-port.d.ts.map +1 -0
  187. package/dist/protocols/privacy-port.js +1 -0
  188. package/dist/protocols/traceability-port.d.ts +12 -0
  189. package/dist/protocols/traceability-port.d.ts.map +1 -0
  190. package/dist/protocols/traceability-port.js +1 -0
  191. package/dist/shared/collection-store.d.ts +12 -0
  192. package/dist/shared/collection-store.d.ts.map +1 -0
  193. package/dist/shared/collection-store.js +26 -0
  194. package/dist/shared/commit.d.ts +24 -0
  195. package/dist/shared/commit.d.ts.map +1 -0
  196. package/dist/shared/commit.js +50 -0
  197. package/dist/shared/crypto.d.ts +2 -0
  198. package/dist/shared/crypto.d.ts.map +1 -0
  199. package/dist/shared/crypto.js +4 -0
  200. package/dist/shared/date.d.ts +2 -0
  201. package/dist/shared/date.d.ts.map +1 -0
  202. package/dist/shared/date.js +3 -0
  203. package/dist/shared/index.d.ts +9 -0
  204. package/dist/shared/index.d.ts.map +1 -0
  205. package/dist/shared/index.js +11 -0
  206. package/dist/shared/logger.d.ts +37 -0
  207. package/dist/shared/logger.d.ts.map +1 -0
  208. package/dist/shared/logger.js +45 -0
  209. package/dist/shared/store.d.ts +25 -0
  210. package/dist/shared/store.d.ts.map +1 -0
  211. package/dist/shared/store.js +18 -0
  212. package/dist/shared/telemetry-sdk.d.ts +26 -0
  213. package/dist/shared/telemetry-sdk.d.ts.map +1 -0
  214. package/dist/shared/telemetry-sdk.js +97 -0
  215. package/dist/shared/telemetry.d.ts +86 -0
  216. package/dist/shared/telemetry.d.ts.map +1 -0
  217. package/dist/shared/telemetry.js +137 -0
  218. package/dist/stark-settlement/application/aggregator-service.d.ts +112 -0
  219. package/dist/stark-settlement/application/aggregator-service.d.ts.map +1 -0
  220. package/dist/stark-settlement/application/aggregator-service.js +256 -0
  221. package/dist/stark-settlement/application/ledger-service.d.ts +114 -0
  222. package/dist/stark-settlement/application/ledger-service.d.ts.map +1 -0
  223. package/dist/stark-settlement/application/ledger-service.js +318 -0
  224. package/dist/stark-settlement/application/settlement-service.d.ts +104 -0
  225. package/dist/stark-settlement/application/settlement-service.d.ts.map +1 -0
  226. package/dist/stark-settlement/application/settlement-service.js +251 -0
  227. package/dist/stark-settlement/domain/entities.d.ts +365 -0
  228. package/dist/stark-settlement/domain/entities.d.ts.map +1 -0
  229. package/dist/stark-settlement/domain/entities.js +29 -0
  230. package/dist/stark-settlement/domain/ports.d.ts +485 -0
  231. package/dist/stark-settlement/domain/ports.d.ts.map +1 -0
  232. package/dist/stark-settlement/domain/ports.js +14 -0
  233. package/dist/stark-settlement/domain/value-objects.d.ts +268 -0
  234. package/dist/stark-settlement/domain/value-objects.d.ts.map +1 -0
  235. package/dist/stark-settlement/domain/value-objects.js +500 -0
  236. package/dist/stark-settlement/index.d.ts +172 -0
  237. package/dist/stark-settlement/index.d.ts.map +1 -0
  238. package/dist/stark-settlement/index.js +193 -0
  239. package/dist/stark-settlement/infrastructure/adapters/audit-adapter.d.ts +52 -0
  240. package/dist/stark-settlement/infrastructure/adapters/audit-adapter.d.ts.map +1 -0
  241. package/dist/stark-settlement/infrastructure/adapters/audit-adapter.js +154 -0
  242. package/dist/stark-settlement/infrastructure/adapters/bitcoin-adapter.d.ts +88 -0
  243. package/dist/stark-settlement/infrastructure/adapters/bitcoin-adapter.d.ts.map +1 -0
  244. package/dist/stark-settlement/infrastructure/adapters/bitcoin-adapter.js +187 -0
  245. package/dist/stark-settlement/infrastructure/adapters/clock-adapter.d.ts +59 -0
  246. package/dist/stark-settlement/infrastructure/adapters/clock-adapter.d.ts.map +1 -0
  247. package/dist/stark-settlement/infrastructure/adapters/clock-adapter.js +85 -0
  248. package/dist/stark-settlement/infrastructure/adapters/dilithium-adapter.d.ts +60 -0
  249. package/dist/stark-settlement/infrastructure/adapters/dilithium-adapter.d.ts.map +1 -0
  250. package/dist/stark-settlement/infrastructure/adapters/dilithium-adapter.js +104 -0
  251. package/dist/stark-settlement/infrastructure/adapters/event-emitter-adapter.d.ts +115 -0
  252. package/dist/stark-settlement/infrastructure/adapters/event-emitter-adapter.d.ts.map +1 -0
  253. package/dist/stark-settlement/infrastructure/adapters/event-emitter-adapter.js +191 -0
  254. package/dist/stark-settlement/infrastructure/adapters/fiat-adapter.d.ts +65 -0
  255. package/dist/stark-settlement/infrastructure/adapters/fiat-adapter.d.ts.map +1 -0
  256. package/dist/stark-settlement/infrastructure/adapters/fiat-adapter.js +207 -0
  257. package/dist/stark-settlement/infrastructure/adapters/mock-stark-adapter.d.ts +73 -0
  258. package/dist/stark-settlement/infrastructure/adapters/mock-stark-adapter.d.ts.map +1 -0
  259. package/dist/stark-settlement/infrastructure/adapters/mock-stark-adapter.js +287 -0
  260. package/dist/stark-settlement/infrastructure/adapters/solana-adapter.d.ts +78 -0
  261. package/dist/stark-settlement/infrastructure/adapters/solana-adapter.d.ts.map +1 -0
  262. package/dist/stark-settlement/infrastructure/adapters/solana-adapter.js +172 -0
  263. package/dist/stark-settlement/infrastructure/adapters/starknet-proof-adapter.d.ts +56 -0
  264. package/dist/stark-settlement/infrastructure/adapters/starknet-proof-adapter.d.ts.map +1 -0
  265. package/dist/stark-settlement/infrastructure/adapters/starknet-proof-adapter.js +261 -0
  266. package/dist/stark-settlement/infrastructure/adapters/stone-proof-adapter.d.ts +125 -0
  267. package/dist/stark-settlement/infrastructure/adapters/stone-proof-adapter.d.ts.map +1 -0
  268. package/dist/stark-settlement/infrastructure/adapters/stone-proof-adapter.js +416 -0
  269. package/dist/stark-settlement/infrastructure/persistence/ledger-store.d.ts +68 -0
  270. package/dist/stark-settlement/infrastructure/persistence/ledger-store.d.ts.map +1 -0
  271. package/dist/stark-settlement/infrastructure/persistence/ledger-store.js +238 -0
  272. package/dist/stark-settlement/infrastructure/persistence/offset-store.d.ts +30 -0
  273. package/dist/stark-settlement/infrastructure/persistence/offset-store.d.ts.map +1 -0
  274. package/dist/stark-settlement/infrastructure/persistence/offset-store.js +57 -0
  275. package/dist/stark-settlement/infrastructure/persistence/outbox-store.d.ts +45 -0
  276. package/dist/stark-settlement/infrastructure/persistence/outbox-store.d.ts.map +1 -0
  277. package/dist/stark-settlement/infrastructure/persistence/outbox-store.js +171 -0
  278. package/dist/traceability/application/recall-assessor.d.ts +13 -0
  279. package/dist/traceability/application/recall-assessor.d.ts.map +1 -0
  280. package/dist/traceability/application/recall-assessor.js +74 -0
  281. package/dist/traceability/domain/entities.d.ts +23 -0
  282. package/dist/traceability/domain/entities.d.ts.map +1 -0
  283. package/dist/traceability/domain/entities.js +1 -0
  284. package/dist/traceability/domain/ports.d.ts +23 -0
  285. package/dist/traceability/domain/ports.d.ts.map +1 -0
  286. package/dist/traceability/domain/ports.js +1 -0
  287. package/dist/traceability/domain/recall.d.ts +12 -0
  288. package/dist/traceability/domain/recall.d.ts.map +1 -0
  289. package/dist/traceability/domain/recall.js +1 -0
  290. package/dist/traceability/index.d.ts +22 -0
  291. package/dist/traceability/index.d.ts.map +1 -0
  292. package/dist/traceability/index.js +26 -0
  293. package/dist/traceability/infrastructure/in-memory-store.d.ts +13 -0
  294. package/dist/traceability/infrastructure/in-memory-store.d.ts.map +1 -0
  295. package/dist/traceability/infrastructure/in-memory-store.js +24 -0
  296. package/package.json +12 -9
@@ -0,0 +1,209 @@
1
+ /**
2
+ * P2MR (Pay-to-Merkle-Root) Core Types
3
+ *
4
+ * BIP-360-inspired quantum-safe output pattern. The on-chain commitment stores
5
+ * ONLY the Merkle root of a script tree—no public keys exposed until spend time.
6
+ *
7
+ * This eliminates the "harvest now, decrypt later" quantum threat.
8
+ */
9
+ /**
10
+ * Supported spending condition types for P2MR outputs.
11
+ *
12
+ * Each type defines what witness data is required and how verification proceeds.
13
+ */
14
+ export type ScriptLeafType = "ml-dsa-65-sig" | "timelock" | "multisig-ml-dsa" | "hsm-attested-sig";
15
+ /**
16
+ * A spending condition in the script tree.
17
+ *
18
+ * Each leaf contains:
19
+ * - The type of condition (signature, timelock, multisig, HSM)
20
+ * - SHA-256 hashes of authorized ML-DSA-65 public keys (NOT the keys themselves)
21
+ * - Condition-specific parameters (threshold, locktime, HSM slot)
22
+ *
23
+ * The actual public keys are only revealed at spend time in the witness.
24
+ */
25
+ export interface ScriptLeaf {
26
+ /** Spending condition type. */
27
+ type: ScriptLeafType;
28
+ /**
29
+ * SHA-256 hashes of authorized ML-DSA-65 public keys.
30
+ *
31
+ * For single-signature conditions, this array has exactly one element.
32
+ * For multisig conditions, this array has n elements (the full set).
33
+ *
34
+ * Format: 64 hex characters (32 bytes) per hash.
35
+ */
36
+ publicKeyHashes: string[];
37
+ /**
38
+ * For multisig: minimum number of valid signatures required.
39
+ * Defaults to publicKeyHashes.length if not specified (all required).
40
+ */
41
+ threshold?: number;
42
+ /**
43
+ * For timelock: Unix timestamp (milliseconds) after which spending is allowed.
44
+ * The witness must include a timestamp >= this value.
45
+ */
46
+ locktime?: number;
47
+ /**
48
+ * For HSM-attested: identifier of the required HSM slot.
49
+ * The witness must include attestation proof from this specific HSM.
50
+ */
51
+ hsmSlotId?: string;
52
+ }
53
+ /**
54
+ * A P2MR output stored on-chain.
55
+ *
56
+ * The critical property: only the Merkle root is stored—no public keys.
57
+ * This means a quantum adversary cannot harvest keys from unspent outputs.
58
+ */
59
+ export interface P2MROutput {
60
+ /**
61
+ * Unique identifier for this output.
62
+ * Format: UUID v4 (36 characters including hyphens).
63
+ */
64
+ outputId: string;
65
+ /**
66
+ * Merkle root of the script tree.
67
+ * Format: 64 hex characters (32 bytes SHA-256).
68
+ *
69
+ * This is the ONLY commitment stored on-chain.
70
+ */
71
+ merkleRoot: string;
72
+ /**
73
+ * Value locked in this output.
74
+ * Units depend on the platform (wei for Besu, cents for fiat, etc.).
75
+ */
76
+ value: bigint;
77
+ /**
78
+ * Block timestamp when the output was created.
79
+ * Unix timestamp in milliseconds.
80
+ */
81
+ createdAt: number;
82
+ /**
83
+ * Optional: SHA-256 hash of off-chain metadata.
84
+ * Useful for linking to detailed transaction information stored elsewhere.
85
+ */
86
+ metadataHash?: string;
87
+ }
88
+ /**
89
+ * A single node in a Merkle proof path.
90
+ *
91
+ * To verify, start with the leaf hash and iteratively combine with siblings:
92
+ * - If position is "left", compute SHA-256(sibling || current)
93
+ * - If position is "right", compute SHA-256(current || sibling)
94
+ */
95
+ export interface MerkleProofNode {
96
+ /**
97
+ * Hash of the sibling node.
98
+ * Format: 64 hex characters (32 bytes SHA-256).
99
+ */
100
+ hash: string;
101
+ /**
102
+ * Position of the sibling relative to the current node.
103
+ * "left" means sibling is on the left (comes first in concatenation).
104
+ * "right" means sibling is on the right (comes second).
105
+ */
106
+ position: "left" | "right";
107
+ }
108
+ /**
109
+ * Witness data revealed at spend time.
110
+ *
111
+ * This is the ONLY place where actual public keys appear—at the moment of spending.
112
+ * By this point, the output is being consumed, so quantum exposure is minimized.
113
+ */
114
+ export interface SpendWitness {
115
+ /**
116
+ * Revealed ML-DSA-65 public keys.
117
+ * Each key is 1952 bytes (per FIPS 204 ML-DSA-65 spec).
118
+ *
119
+ * The SHA-256 hash of each key must match an entry in the script leaf's
120
+ * publicKeyHashes array.
121
+ */
122
+ publicKeys: Uint8Array[];
123
+ /**
124
+ * ML-DSA-65 signatures over the spend message.
125
+ * Each signature is 3309 bytes (per FIPS 204 ML-DSA-65 spec).
126
+ *
127
+ * The number of signatures must satisfy the leaf's condition:
128
+ * - ml-dsa-65-sig: exactly 1
129
+ * - timelock: exactly 1
130
+ * - multisig-ml-dsa: >= threshold
131
+ * - hsm-attested-sig: exactly 1
132
+ */
133
+ signatures: Uint8Array[];
134
+ /**
135
+ * Current timestamp for timelock verification.
136
+ * Required when spending via a "timelock" leaf.
137
+ * Must be >= leaf.locktime for the spend to be valid.
138
+ */
139
+ timestamp?: number;
140
+ /**
141
+ * HSM attestation proof for HSM-attested spending.
142
+ * Required when spending via an "hsm-attested-sig" leaf.
143
+ * Format depends on the HSM (typically a signed attestation blob).
144
+ */
145
+ hsmAttestation?: string;
146
+ }
147
+ /**
148
+ * Complete proof required to spend a P2MR output.
149
+ *
150
+ * Contains:
151
+ * 1. Which output to spend
152
+ * 2. Which spending condition (leaf) is being satisfied
153
+ * 3. Merkle proof from leaf to root
154
+ * 4. Witness data (keys, signatures, condition-specific data)
155
+ */
156
+ export interface SpendProof {
157
+ /**
158
+ * ID of the output being spent.
159
+ * Must match an existing unspent P2MR output.
160
+ */
161
+ outputId: string;
162
+ /**
163
+ * The script leaf being satisfied.
164
+ * Its hash must be verifiable via the Merkle proof to the output's root.
165
+ */
166
+ revealedLeaf: ScriptLeaf;
167
+ /**
168
+ * Merkle proof from the leaf to the root.
169
+ * Array of sibling hashes with position indicators.
170
+ * Length is O(log n) where n is the number of leaves.
171
+ */
172
+ merkleProof: MerkleProofNode[];
173
+ /**
174
+ * Witness data satisfying the leaf's spending condition.
175
+ */
176
+ witness: SpendWitness;
177
+ }
178
+ /**
179
+ * Result of verifying a spend proof.
180
+ */
181
+ export interface SpendVerificationResult {
182
+ /** Whether the spend proof is valid. */
183
+ valid: boolean;
184
+ /** Human-readable reason for the result. */
185
+ reason: string;
186
+ /** Detailed audit trail of verification steps. */
187
+ auditTrail?: VerificationStep[];
188
+ }
189
+ /**
190
+ * A single step in the verification audit trail.
191
+ */
192
+ export interface VerificationStep {
193
+ /** Name of the verification step. */
194
+ step: string;
195
+ /** Whether this step passed. */
196
+ passed: boolean;
197
+ /** Additional details about this step. */
198
+ detail?: string;
199
+ }
200
+ /**
201
+ * Result of script interpretation (condition-specific verification).
202
+ */
203
+ export interface ScriptVerificationResult {
204
+ /** Whether the script condition was satisfied. */
205
+ valid: boolean;
206
+ /** Human-readable reason for the result. */
207
+ reason: string;
208
+ }
209
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/p2mr/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;;GAIG;AACH,MAAM,MAAM,cAAc,GACtB,eAAe,GACf,UAAU,GACV,iBAAiB,GACjB,kBAAkB,CAAC;AAEvB;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,IAAI,EAAE,cAAc,CAAC;IAErB;;;;;;;OAOG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;IAE1B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAMD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,UAAU,EAAE,UAAU,EAAE,CAAC;IAEzB;;;;;;;;;OASG;IACH,UAAU,EAAE,UAAU,EAAE,CAAC;IAEzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAMD;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,YAAY,EAAE,UAAU,CAAC;IAEzB;;;;OAIG;IACH,WAAW,EAAE,eAAe,EAAE,CAAC;IAE/B;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;CACvB;AAMD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,wCAAwC;IACxC,KAAK,EAAE,OAAO,CAAC;IAEf,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IAEf,kDAAkD;IAClD,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IAEb,gCAAgC;IAChC,MAAM,EAAE,OAAO,CAAC;IAEhB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kDAAkD;IAClD,KAAK,EAAE,OAAO,CAAC;IAEf,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * P2MR (Pay-to-Merkle-Root) Core Types
3
+ *
4
+ * BIP-360-inspired quantum-safe output pattern. The on-chain commitment stores
5
+ * ONLY the Merkle root of a script tree—no public keys exposed until spend time.
6
+ *
7
+ * This eliminates the "harvest now, decrypt later" quantum threat.
8
+ */
9
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { Audience, SharedOrderView } from "../domain/entities.js";
2
+ import type { OrderRepository } from "../domain/ports.js";
3
+ import type { HsmClient } from "../../hsm/index.js";
4
+ import type { Logger } from "../../shared/logger.js";
5
+ export declare class ViewProjector {
6
+ private readonly repo;
7
+ private readonly hsm?;
8
+ private readonly signerKeyLabel?;
9
+ private readonly logger;
10
+ constructor(repo: OrderRepository, logger?: Logger, hsm?: HsmClient | undefined, signerKeyLabel?: string | undefined);
11
+ createView(orderId: string, audience: Audience): SharedOrderView;
12
+ }
13
+ //# sourceMappingURL=view-projector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-projector.d.ts","sourceRoot":"","sources":["../../../src/privacy/application/view-projector.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EAER,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA4CrD,qBAAa,aAAa;IAItB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAErB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;IACrB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IANlC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAGb,IAAI,EAAE,eAAe,EACtC,MAAM,CAAC,EAAE,MAAM,EACE,GAAG,CAAC,EAAE,SAAS,YAAA,EACf,cAAc,CAAC,EAAE,MAAM,YAAA;IAK1C,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,eAAe;CAqCjE"}
@@ -0,0 +1,85 @@
1
+ import { sha256hex } from "../../shared/crypto.js";
2
+ import { noopLogger } from "../../shared/logger.js";
3
+ // Audience-specific field projection rules.
4
+ // Ref: W3C Verifiable Credentials Data Model — selective disclosure
5
+ // https://www.w3.org/TR/vc-data-model-2.0/#selective-disclosure
6
+ const fieldProjections = {
7
+ logistics: (o) => ({
8
+ buyer: o.buyer,
9
+ supplier: o.supplier,
10
+ sku: o.sku,
11
+ quantity: o.quantity,
12
+ incoterm: o.incoterm,
13
+ destinationPort: o.destinationPort,
14
+ }),
15
+ bank: (o) => ({
16
+ buyer: o.buyer,
17
+ supplier: o.supplier,
18
+ totalValueUsd: o.quantity * o.unitPriceUsd,
19
+ destinationPort: o.destinationPort,
20
+ financingBank: o.financingBank ?? "n/a",
21
+ sustainabilityGrade: o.sustainabilityGrade,
22
+ }),
23
+ regulator: (o) => ({
24
+ buyer: o.buyer,
25
+ supplier: o.supplier,
26
+ sku: o.sku,
27
+ quantity: o.quantity,
28
+ destinationPort: o.destinationPort,
29
+ sustainabilityGrade: o.sustainabilityGrade,
30
+ }),
31
+ supplier: (o) => ({
32
+ buyer: o.buyer,
33
+ sku: o.sku,
34
+ quantity: o.quantity,
35
+ unitPriceUsd: o.unitPriceUsd,
36
+ incoterm: o.incoterm,
37
+ destinationPort: o.destinationPort,
38
+ }),
39
+ };
40
+ export class ViewProjector {
41
+ repo;
42
+ hsm;
43
+ signerKeyLabel;
44
+ logger;
45
+ constructor(repo, logger, hsm, signerKeyLabel) {
46
+ this.repo = repo;
47
+ this.hsm = hsm;
48
+ this.signerKeyLabel = signerKeyLabel;
49
+ this.logger = logger ?? noopLogger;
50
+ }
51
+ createView(orderId, audience) {
52
+ const order = this.repo.orders.get(orderId);
53
+ if (!order) {
54
+ throw new Error(`Unknown order ${orderId}`);
55
+ }
56
+ const timestamp = new Date().toISOString();
57
+ // Use null byte delimiter to prevent ambiguous preimages
58
+ const preimage = [JSON.stringify(order), audience, timestamp].join("\0");
59
+ const hash = sha256hex(preimage);
60
+ let auditProof;
61
+ if (this.hsm && this.signerKeyLabel) {
62
+ // Sign the preimage directly — the HSM's createSign("SHA256") handles
63
+ // hashing internally. Signing `hash` would result in double-SHA-256.
64
+ const { signature } = this.hsm.sign(this.signerKeyLabel, preimage);
65
+ auditProof = {
66
+ hash,
67
+ signature,
68
+ signerKeyLabel: this.signerKeyLabel,
69
+ timestamp,
70
+ };
71
+ }
72
+ else {
73
+ // Use the same preimage-based hash as the signed path for consistency.
74
+ // This ensures auditProof is identical regardless of HSM availability,
75
+ // enabling verification and replay detection across configurations.
76
+ auditProof = hash;
77
+ }
78
+ return {
79
+ orderId,
80
+ audience,
81
+ data: fieldProjections[audience](order),
82
+ auditProof,
83
+ };
84
+ }
85
+ }
@@ -0,0 +1,26 @@
1
+ export interface PurchaseOrder {
2
+ readonly id: string;
3
+ readonly buyer: string;
4
+ readonly supplier: string;
5
+ readonly sku: string;
6
+ readonly quantity: number;
7
+ readonly unitPriceUsd: number;
8
+ readonly incoterm: string;
9
+ readonly destinationPort: string;
10
+ readonly financingBank?: string;
11
+ readonly sustainabilityGrade: "A" | "B" | "C";
12
+ }
13
+ export type Audience = "logistics" | "bank" | "regulator" | "supplier";
14
+ export interface SignedAuditProof {
15
+ readonly hash: string;
16
+ readonly signature: string;
17
+ readonly signerKeyLabel: string;
18
+ readonly timestamp: string;
19
+ }
20
+ export interface SharedOrderView {
21
+ readonly orderId: string;
22
+ readonly audience: Audience;
23
+ readonly data: Record<string, string | number>;
24
+ readonly auditProof: string | SignedAuditProof;
25
+ }
26
+ //# sourceMappingURL=entities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../src/privacy/domain/entities.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAC/C;AAED,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;AAEvE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAChD"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { ReadonlyStore } from "../../shared/store.js";
2
+ import type { PurchaseOrder } from "./entities.js";
3
+ export interface OrderRepository {
4
+ readonly orders: ReadonlyStore<string, PurchaseOrder>;
5
+ addOrder(order: PurchaseOrder): void;
6
+ }
7
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../../src/privacy/domain/ports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACtD,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;CACtC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ export type { PurchaseOrder, Audience, SharedOrderView, SignedAuditProof, } from "./domain/entities.js";
2
+ export type { OrderRepository } from "./domain/ports.js";
3
+ export { ViewProjector } from "./application/view-projector.js";
4
+ export { InMemoryOrderRepository } from "./infrastructure/in-memory-store.js";
5
+ import type { Audience, PurchaseOrder, SharedOrderView } from "./domain/entities.js";
6
+ import type { OrderRepository } from "./domain/ports.js";
7
+ import type { HsmClient } from "../hsm/index.js";
8
+ import type { Logger } from "../shared/logger.js";
9
+ export declare class SelectiveDisclosureLedger {
10
+ private readonly repo;
11
+ private readonly projector;
12
+ constructor(options?: {
13
+ repo?: OrderRepository;
14
+ hsm?: HsmClient;
15
+ signerKeyLabel?: string;
16
+ logger?: Logger;
17
+ });
18
+ publishOrder(order: PurchaseOrder): void;
19
+ createView(orderId: string, audience: Audience): SharedOrderView;
20
+ }
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/privacy/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,aAAa,EACb,QAAQ,EACR,eAAe,EACf,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAM9E,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,qBAAa,yBAAyB;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;gBAE9B,OAAO,CAAC,EAAE;QACpB,IAAI,CAAC,EAAE,eAAe,CAAC;QACvB,GAAG,CAAC,EAAE,SAAS,CAAC;QAChB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAiBD,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAIxC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,eAAe;CAGjE"}
@@ -0,0 +1,25 @@
1
+ // Application
2
+ export { ViewProjector } from "./application/view-projector.js";
3
+ // Infrastructure
4
+ export { InMemoryOrderRepository } from "./infrastructure/in-memory-store.js";
5
+ import { InMemoryOrderRepository } from "./infrastructure/in-memory-store.js";
6
+ import { ViewProjector } from "./application/view-projector.js";
7
+ export class SelectiveDisclosureLedger {
8
+ repo;
9
+ projector;
10
+ constructor(options) {
11
+ const hsm = options?.hsm;
12
+ const signerKeyLabel = options?.signerKeyLabel;
13
+ if ((hsm && !signerKeyLabel) || (!hsm && signerKeyLabel)) {
14
+ throw new Error("Both hsm and signerKeyLabel must be provided together for signed audit proofs");
15
+ }
16
+ this.repo = options?.repo ?? new InMemoryOrderRepository();
17
+ this.projector = new ViewProjector(this.repo, options?.logger, hsm, signerKeyLabel);
18
+ }
19
+ publishOrder(order) {
20
+ this.repo.addOrder(order);
21
+ }
22
+ createView(orderId, audience) {
23
+ return this.projector.createView(orderId, audience);
24
+ }
25
+ }
@@ -0,0 +1,8 @@
1
+ import { InMemoryStore } from "../../shared/store.js";
2
+ import type { PurchaseOrder } from "../domain/entities.js";
3
+ import type { OrderRepository } from "../domain/ports.js";
4
+ export declare class InMemoryOrderRepository implements OrderRepository {
5
+ readonly orders: InMemoryStore<string, PurchaseOrder>;
6
+ addOrder(order: PurchaseOrder): void;
7
+ }
8
+ //# sourceMappingURL=in-memory-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-store.d.ts","sourceRoot":"","sources":["../../../src/privacy/infrastructure/in-memory-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,qBAAa,uBAAwB,YAAW,eAAe;IAC7D,QAAQ,CAAC,MAAM,uCAA8C;IAE7D,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;CAGrC"}
@@ -0,0 +1,7 @@
1
+ import { InMemoryStore } from "../../shared/store.js";
2
+ export class InMemoryOrderRepository {
3
+ orders = new InMemoryStore();
4
+ addOrder(order) {
5
+ this.orders.set(order.id, order);
6
+ }
7
+ }
@@ -0,0 +1,80 @@
1
+ import type { TransactionRequest } from "ethers";
2
+ /**
3
+ * Protocol-level port for Besu/EVM blockchain capabilities.
4
+ *
5
+ * This defines what operations are available at the protocol level,
6
+ * independent of specific domain use cases (traceability, privacy, etc.).
7
+ *
8
+ * @see skills/platform-selection.md for protocol selection criteria
9
+ */
10
+ export interface BesuTransactionResult {
11
+ txHash: string;
12
+ blockNumber: number;
13
+ gasUsed: bigint;
14
+ }
15
+ export interface BesuGasEstimate {
16
+ gasLimit: bigint;
17
+ gasPrice: bigint;
18
+ maxFeePerGas?: bigint;
19
+ maxPriorityFeePerGas?: bigint;
20
+ }
21
+ /**
22
+ * Port for EVM transaction submission.
23
+ *
24
+ * Implementations handle provider connection, nonce management, and signing.
25
+ */
26
+ export interface IBesuTransactionPort {
27
+ /**
28
+ * Submit a signed transaction to the network.
29
+ * @returns Transaction hash and receipt metadata
30
+ */
31
+ submitTransaction(tx: TransactionRequest): Promise<BesuTransactionResult>;
32
+ /**
33
+ * Estimate gas for a transaction without submitting.
34
+ * @param tx Transaction to estimate
35
+ * @returns Gas estimate with price information
36
+ */
37
+ estimateGas(tx: TransactionRequest): Promise<BesuGasEstimate>;
38
+ /**
39
+ * Get the current nonce for an address.
40
+ * @param address Ethereum address
41
+ * @returns Current pending nonce
42
+ */
43
+ getNonce(address: string): Promise<number>;
44
+ }
45
+ /**
46
+ * Port for EVM contract queries (read-only operations).
47
+ */
48
+ export interface IBesuQueryPort {
49
+ /**
50
+ * Call a contract method without submitting a transaction.
51
+ * @param to Contract address
52
+ * @param data Encoded function call
53
+ * @returns Encoded return value
54
+ */
55
+ call(to: string, data: string): Promise<string>;
56
+ /**
57
+ * Get contract bytecode at an address.
58
+ * @param address Contract address
59
+ * @returns Bytecode hex string
60
+ */
61
+ getCode(address: string): Promise<string>;
62
+ }
63
+ /**
64
+ * Port for Besu privacy group operations (Tessera integration).
65
+ */
66
+ export interface IBesuPrivacyPort {
67
+ /**
68
+ * Create a new privacy group.
69
+ * @param members Public keys of privacy group members
70
+ * @returns Privacy group ID
71
+ */
72
+ createPrivacyGroup(members: string[]): Promise<string>;
73
+ /**
74
+ * Find existing privacy groups for a set of members.
75
+ * @param members Public keys to search for
76
+ * @returns Matching privacy group IDs
77
+ */
78
+ findPrivacyGroups(members: string[]): Promise<string[]>;
79
+ }
80
+ //# sourceMappingURL=besu-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"besu-port.d.ts","sourceRoot":"","sources":["../../src/protocols/besu-port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD;;;;;;;GAOG;AAEH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAE1E;;;;OAIG;IACH,WAAW,CAAC,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE9D;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhD;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvD;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACzD"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Protocol-level port for R3 Corda capabilities.
3
+ *
4
+ * This defines what operations are available at the protocol level,
5
+ * independent of specific domain use cases (credentialing, settlement, etc.).
6
+ *
7
+ * @see skills/platform-selection.md for protocol selection criteria
8
+ */
9
+ export interface CordaFlowResult<T = unknown> {
10
+ flowId: string;
11
+ status: "COMPLETED" | "FAILED" | "RUNNING";
12
+ result?: T;
13
+ error?: string;
14
+ timestamp: string;
15
+ }
16
+ export interface CordaTransactionInfo {
17
+ txId: string;
18
+ notary: string;
19
+ signers: string[];
20
+ timestamp: string;
21
+ }
22
+ /**
23
+ * Port for Corda flow invocation.
24
+ *
25
+ * Implementations handle REST API communication and flow session management.
26
+ */
27
+ export interface ICordaFlowPort {
28
+ /**
29
+ * Start a Corda flow.
30
+ * @param flowClass Fully qualified flow class name
31
+ * @param flowArgs Flow constructor arguments
32
+ * @returns Flow execution result
33
+ */
34
+ startFlow<T = unknown>(flowClass: string, flowArgs: Record<string, unknown>): Promise<CordaFlowResult<T>>;
35
+ /**
36
+ * Check the status of a running flow.
37
+ * @param flowId Flow run ID
38
+ * @returns Current flow status
39
+ */
40
+ getFlowStatus<T = unknown>(flowId: string): Promise<CordaFlowResult<T>>;
41
+ }
42
+ /**
43
+ * Port for Corda vault queries.
44
+ */
45
+ export interface ICordaVaultPort {
46
+ /**
47
+ * Query states from the vault.
48
+ * @param stateClass State class to query
49
+ * @param criteria Query criteria
50
+ * @returns Matching vault states
51
+ */
52
+ queryStates<T = unknown>(stateClass: string, criteria?: CordaQueryCriteria): Promise<CordaVaultState<T>[]>;
53
+ /**
54
+ * Get a specific state by its state ref.
55
+ * @param txId Transaction ID
56
+ * @param index Output index
57
+ * @returns State if found
58
+ */
59
+ getState<T = unknown>(txId: string, index: number): Promise<CordaVaultState<T> | undefined>;
60
+ }
61
+ export interface CordaQueryCriteria {
62
+ status?: "UNCONSUMED" | "CONSUMED" | "ALL";
63
+ contractStateTypes?: string[];
64
+ participants?: string[];
65
+ notary?: string;
66
+ }
67
+ export interface CordaVaultState<T = unknown> {
68
+ state: T;
69
+ ref: {
70
+ txId: string;
71
+ index: number;
72
+ };
73
+ notary: string;
74
+ constraint: string;
75
+ }
76
+ /**
77
+ * Port for Corda node identity operations.
78
+ */
79
+ export interface ICordaIdentityPort {
80
+ /**
81
+ * Get the current node's identity.
82
+ * @returns Node X500 name
83
+ */
84
+ getNodeIdentity(): Promise<string>;
85
+ /**
86
+ * Look up a party by name.
87
+ * @param name X500 name or organization name
88
+ * @returns Party information or undefined
89
+ */
90
+ lookupParty(name: string): Promise<CordaPartyInfo | undefined>;
91
+ /**
92
+ * Get all known network participants.
93
+ * @returns List of network participants
94
+ */
95
+ getNetworkMap(): Promise<CordaPartyInfo[]>;
96
+ }
97
+ export interface CordaPartyInfo {
98
+ name: string;
99
+ owningKey: string;
100
+ host: string;
101
+ port: number;
102
+ }
103
+ //# sourceMappingURL=corda-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"corda-port.d.ts","sourceRoot":"","sources":["../../src/protocols/corda-port.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,CAAC,GAAG,OAAO,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/B;;;;OAIG;IACH,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,WAAW,CAAC,CAAC,GAAG,OAAO,EACrB,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,kBAAkB,GAC5B,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAEjC;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,GAAG,OAAO,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,KAAK,CAAC;IAC3C,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,KAAK,EAAE,CAAC,CAAC;IACT,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnC;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAE/D;;;OAGG;IACH,aAAa,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Protocol-level port for R3 Corda capabilities.
3
+ *
4
+ * This defines what operations are available at the protocol level,
5
+ * independent of specific domain use cases (credentialing, settlement, etc.).
6
+ *
7
+ * @see skills/platform-selection.md for protocol selection criteria
8
+ */
9
+ export {};