@psavelis/enterprise-blockchain 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +164 -0
  2. package/package.json +154 -0
package/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # @psavelis/enterprise-blockchain
2
+
3
+ Production-grade enterprise blockchain modules: MPC, HSM, STARK settlement, post-quantum cryptography, and protocol adapters.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@psavelis/enterprise-blockchain)](https://www.npmjs.com/package/@psavelis/enterprise-blockchain)
6
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](../../LICENSE)
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @psavelis/enterprise-blockchain
12
+ ```
13
+
14
+ ## Quick Start
15
+
16
+ ### Post-Quantum Key Exchange (ML-KEM-768)
17
+
18
+ ```typescript
19
+ import { KyberKem } from "@psavelis/enterprise-blockchain/mpc";
20
+
21
+ const kem = new KyberKem();
22
+ const params = "ml-kem-768";
23
+ const { publicKey, secretKey } = kem.generateKeyPair(params);
24
+ const { ciphertext, sharedSecret } = kem.encapsulate(publicKey, params);
25
+ const decapsulated = kem.decapsulate(ciphertext, secretKey, params);
26
+ ```
27
+
28
+ ### Post-Quantum Signatures (ML-DSA-65)
29
+
30
+ ```typescript
31
+ import { MlDsaSigner } from "@psavelis/enterprise-blockchain/mpc";
32
+
33
+ const signer = new MlDsaSigner();
34
+ const { publicKey, secretKey } = signer.generateKeyPair("ml-dsa-65");
35
+ const { signature } = signer.sign(message, secretKey, "ml-dsa-65");
36
+ const valid = signer.verify(message, signature, publicKey, "ml-dsa-65");
37
+ ```
38
+
39
+ ### STARK Settlement
40
+
41
+ ```typescript
42
+ import {
43
+ createDefaultContext,
44
+ LedgerService,
45
+ AggregatorService,
46
+ SettlementService,
47
+ } from "@psavelis/enterprise-blockchain/stark-settlement";
48
+
49
+ const ctx = createDefaultContext();
50
+ const ledger = new LedgerService(ctx);
51
+ const aggregator = new AggregatorService(ctx);
52
+ const settler = new SettlementService(ctx);
53
+
54
+ // Create accounts, submit transactions, aggregate proofs, settle
55
+ ```
56
+
57
+ ### HSM Key Management
58
+
59
+ ```typescript
60
+ import { HsmClient } from "@psavelis/enterprise-blockchain/hsm";
61
+
62
+ const hsm = new HsmClient();
63
+ hsm.initialize({ slotId: "slot-1", label: "my-hsm" });
64
+ const { keyLabel } = hsm.generateKeyPair("my-signing-key");
65
+ const signResult = hsm.sign(keyLabel, message);
66
+ const valid = hsm.verify(keyLabel, message, signResult.signature);
67
+ ```
68
+
69
+ ### Pay-to-Merkle-Root (Quantum-Safe Bitcoin)
70
+
71
+ ```typescript
72
+ import {
73
+ createP2MROutput,
74
+ createSingleSigLeaf,
75
+ createTimelockLeaf,
76
+ MerkleTree,
77
+ } from "@psavelis/enterprise-blockchain/p2mr";
78
+
79
+ const { output, tree } = createP2MROutput({
80
+ leaves: [
81
+ createSingleSigLeaf(primaryKeyHash),
82
+ createTimelockLeaf(backupKeyHash, futureTimestamp),
83
+ ],
84
+ value: 100_000_000n,
85
+ });
86
+ ```
87
+
88
+ ## Subpath Exports
89
+
90
+ | Import Path | Description |
91
+ | ------------------------------------------------------ | ----------------------------------------------------- |
92
+ | `@psavelis/enterprise-blockchain/mpc` | MPC engine, ML-KEM, ML-DSA, Hybrid KEM, Shamir SSS |
93
+ | `@psavelis/enterprise-blockchain/hsm` | PKCS#11 HSM simulator, envelope encryption |
94
+ | `@psavelis/enterprise-blockchain/p2mr` | Pay-to-Merkle-Root quantum-safe Bitcoin outputs |
95
+ | `@psavelis/enterprise-blockchain/stark-settlement` | 3-tier STARK proof aggregation, multi-rail settlement |
96
+ | `@psavelis/enterprise-blockchain/credentialing` | Clinical credential verification |
97
+ | `@psavelis/enterprise-blockchain/privacy` | Selective disclosure ledger |
98
+ | `@psavelis/enterprise-blockchain/traceability` | Supply-chain traceability |
99
+ | `@psavelis/enterprise-blockchain/aid-settlement` | Aid voucher reconciliation |
100
+ | `@psavelis/enterprise-blockchain/protocols` | Fabric/Besu/Corda adapter interfaces |
101
+ | `@psavelis/enterprise-blockchain/integrations` | SDK clients with circuit breaker patterns |
102
+ | `@psavelis/enterprise-blockchain/shared` | Utilities, crypto, stores (no telemetry re-export) |
103
+ | `@psavelis/enterprise-blockchain/shared/telemetry` | createTracer, createMeter, withSpan helpers |
104
+ | `@psavelis/enterprise-blockchain/shared/telemetry-sdk` | OpenTelemetry SDK initialization (side-effect import) |
105
+
106
+ ## Architecture
107
+
108
+ Strict hexagonal architecture with clean domain/ports/adapters separation. Domain layers never import SDK code.
109
+
110
+ ```
111
+ ┌─────────────────────────────────────────────────────────────────┐
112
+ │ Application Services │
113
+ │ LedgerService │ AggregatorService │ SettlementService │
114
+ └──────────────────────────┬──────────────────────────────────────┘
115
+
116
+ ┌──────────────────────────┴──────────────────────────────────────┐
117
+ │ Domain Ports │
118
+ │ StarkProofGeneratorPort │ LedgerPersistencePort │ SettlementPorts│
119
+ └──────────────────────────┬──────────────────────────────────────┘
120
+
121
+ ┌──────────────────────────┴──────────────────────────────────────┐
122
+ │ Infrastructure Adapters │
123
+ │ StoneProofAdapter │ MockStarkAdapter │ SolanaAdapter │ BitcoinAdapter │
124
+ └─────────────────────────────────────────────────────────────────┘
125
+ ```
126
+
127
+ ## Key Features
128
+
129
+ - **Post-Quantum Cryptography**: NIST FIPS 203 ML-KEM, FIPS 204 ML-DSA
130
+ - **Hybrid KEM**: X25519 + ML-KEM-768 for defense-in-depth
131
+ - **STARK Proofs**: 3-tier recursive aggregation (8,192 transactions per block)
132
+ - **Multi-Rail Settlement**: Solana, Bitcoin (PSBT), Fiat (ISO 20022)
133
+ - **HSM Integration**: PKCS#11-style key management with audit logging
134
+ - **Protocol Adapters**: Fabric, Besu, Corda with circuit breakers
135
+ - **OpenTelemetry**: Built-in observability with tracing and metrics
136
+
137
+ ## Peer Dependencies
138
+
139
+ Protocol-specific SDKs are optional peer dependencies:
140
+
141
+ ```bash
142
+ # For Fabric integration
143
+ npm install @hyperledger/fabric-gateway @grpc/grpc-js
144
+
145
+ # For Besu integration
146
+ npm install ethers
147
+
148
+ # For STARK proofs
149
+ npm install starknet
150
+
151
+ # For observability
152
+ npm install @opentelemetry/api @opentelemetry/sdk-node
153
+ ```
154
+
155
+ ## Documentation
156
+
157
+ - [Main Repository](https://github.com/psavelis/enterprise-blockchain)
158
+ - [Live Demo](https://github.com/psavelis/enterprise-blockchain#live-demo)
159
+ - [Architecture Guide](https://github.com/psavelis/enterprise-blockchain/blob/main/docs/architecture/README.md)
160
+ - [Skills Reference](https://github.com/psavelis/enterprise-blockchain/tree/main/skills)
161
+
162
+ ## License
163
+
164
+ Apache 2.0
package/package.json ADDED
@@ -0,0 +1,154 @@
1
+ {
2
+ "name": "@psavelis/enterprise-blockchain",
3
+ "version": "0.1.0",
4
+ "description": "Production-grade enterprise blockchain modules: MPC, HSM, STARK settlement, post-quantum cryptography, and protocol adapters.",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "author": "Paulo Savelis",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/psavelis/enterprise-blockchain.git",
11
+ "directory": "packages/enterprise-blockchain"
12
+ },
13
+ "keywords": [
14
+ "enterprise-blockchain",
15
+ "stark",
16
+ "mpc",
17
+ "hsm",
18
+ "post-quantum",
19
+ "ml-kem",
20
+ "ml-dsa",
21
+ "fabric",
22
+ "besu",
23
+ "corda"
24
+ ],
25
+ "engines": {
26
+ "node": ">=22.14.0"
27
+ },
28
+ "main": "./dist/index.js",
29
+ "module": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "import": "./dist/index.js"
35
+ },
36
+ "./shared": {
37
+ "types": "./dist/shared/index.d.ts",
38
+ "import": "./dist/shared/index.js"
39
+ },
40
+ "./mpc": {
41
+ "types": "./dist/mpc/index.d.ts",
42
+ "import": "./dist/mpc/index.js"
43
+ },
44
+ "./hsm": {
45
+ "types": "./dist/hsm/index.d.ts",
46
+ "import": "./dist/hsm/index.js"
47
+ },
48
+ "./p2mr": {
49
+ "types": "./dist/p2mr/index.d.ts",
50
+ "import": "./dist/p2mr/index.js"
51
+ },
52
+ "./stark-settlement": {
53
+ "types": "./dist/stark-settlement/index.d.ts",
54
+ "import": "./dist/stark-settlement/index.js"
55
+ },
56
+ "./credentialing": {
57
+ "types": "./dist/credentialing/index.d.ts",
58
+ "import": "./dist/credentialing/index.js"
59
+ },
60
+ "./privacy": {
61
+ "types": "./dist/privacy/index.d.ts",
62
+ "import": "./dist/privacy/index.js"
63
+ },
64
+ "./traceability": {
65
+ "types": "./dist/traceability/index.d.ts",
66
+ "import": "./dist/traceability/index.js"
67
+ },
68
+ "./aid-settlement": {
69
+ "types": "./dist/aid-settlement/index.d.ts",
70
+ "import": "./dist/aid-settlement/index.js"
71
+ },
72
+ "./protocols": {
73
+ "types": "./dist/protocols/index.d.ts",
74
+ "import": "./dist/protocols/index.js"
75
+ },
76
+ "./integrations": {
77
+ "types": "./dist/integrations/index.d.ts",
78
+ "import": "./dist/integrations/index.js"
79
+ },
80
+ "./shared/telemetry-sdk": {
81
+ "types": "./dist/shared/telemetry-sdk.d.ts",
82
+ "import": "./dist/shared/telemetry-sdk.js"
83
+ },
84
+ "./shared/telemetry": {
85
+ "types": "./dist/shared/telemetry.d.ts",
86
+ "import": "./dist/shared/telemetry.js"
87
+ }
88
+ },
89
+ "files": [
90
+ "dist",
91
+ "README.md"
92
+ ],
93
+ "scripts": {
94
+ "build": "tsc -p tsconfig.build.json",
95
+ "clean": "rm -rf dist",
96
+ "prepublishOnly": "npm run clean && npm run build",
97
+ "typecheck": "tsc --noEmit"
98
+ },
99
+ "dependencies": {
100
+ "@noble/post-quantum": "^0.6.1"
101
+ },
102
+ "peerDependencies": {
103
+ "@grpc/grpc-js": "^1.14.0",
104
+ "@grpc/proto-loader": "^0.8.0",
105
+ "@hyperledger/fabric-gateway": "^1.10.0",
106
+ "@opentelemetry/api": "^1.9.0",
107
+ "@opentelemetry/exporter-metrics-otlp-http": "^0.214.0",
108
+ "@opentelemetry/exporter-trace-otlp-http": "^0.214.0",
109
+ "@opentelemetry/resources": "^2.0.0",
110
+ "@opentelemetry/sdk-metrics": "^2.0.0",
111
+ "@opentelemetry/sdk-node": "^0.214.0",
112
+ "@opentelemetry/semantic-conventions": "^1.40.0",
113
+ "ethers": "^6.16.0",
114
+ "starknet": "^9.4.0"
115
+ },
116
+ "peerDependenciesMeta": {
117
+ "@grpc/grpc-js": {
118
+ "optional": true
119
+ },
120
+ "@grpc/proto-loader": {
121
+ "optional": true
122
+ },
123
+ "@hyperledger/fabric-gateway": {
124
+ "optional": true
125
+ },
126
+ "@opentelemetry/api": {
127
+ "optional": true
128
+ },
129
+ "@opentelemetry/exporter-metrics-otlp-http": {
130
+ "optional": true
131
+ },
132
+ "@opentelemetry/exporter-trace-otlp-http": {
133
+ "optional": true
134
+ },
135
+ "@opentelemetry/resources": {
136
+ "optional": true
137
+ },
138
+ "@opentelemetry/sdk-metrics": {
139
+ "optional": true
140
+ },
141
+ "@opentelemetry/sdk-node": {
142
+ "optional": true
143
+ },
144
+ "@opentelemetry/semantic-conventions": {
145
+ "optional": true
146
+ },
147
+ "ethers": {
148
+ "optional": true
149
+ },
150
+ "starknet": {
151
+ "optional": true
152
+ }
153
+ }
154
+ }