Skip to content

Commit 144386c

Browse files
authored
Add ML-KEM encryption (#14)
add mlkem
1 parent ad4c347 commit 144386c

16 files changed

Lines changed: 1582 additions & 37 deletions

.env.template

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,12 @@
33
NODE_ENV=development
44
KMS_URL=https://your-kms.example.com/release
55

6+
# ML-KEM-1024 Admin Keypair (quantum-resistant encryption)
7+
# Generate with: pnpm ts-node scripts/generate-admin-keypair.ts
8+
# The public key will be exposed in /chest/attestation responses
9+
# The private key MUST stay secret - only accessible inside the TEE
10+
ADMIN_MLKEM_PUBLIC_KEY=
11+
ADMIN_MLKEM_PRIVATE_KEY=
12+
613
# Example app secret — replace with whatever your API needs
714
MY_API_KEY=

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ secrets/
5252
.tmp
5353
temp/
5454
tmp/
55+
chest.json

README.md

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010

1111
A NestJS API designed to run inside a Trusted Execution Environment (TEE), giving users cryptographic guarantees that the operator cannot access their data during processing.
1212

13+
## Features
14+
15+
- Quantum-resistant encryption ([ML-KEM-1024](https://csrc.nist.gov/pubs/fips/203/final), see [client guide](docs/CLIENT_ENCRYPTION.md))
16+
- TEE attestation ([AMD SEV-SNP](https://www.amd.com/en/developer/sev.html), [Intel TDX](https://www.intel.com/content/www/us/en/developer/tools/trust-domain-extensions/overview.html), [AWS Nitro](https://aws.amazon.com/ec2/nitro/), [Phala](https://phala.network/), see [setup guide](docs/TEE_SETUP.md))
17+
- Web3 authentication ([SIWE](https://login.xyz), see [auth guide](docs/SIWE.md))
18+
- Zero-trust security model (see [overview](docs/OVERVIEW.md))
19+
- [TypeScript](https://www.typescriptlang.org/) with [NestJS](https://nestjs.com/)
20+
1321
## Install
1422

1523
```bash
@@ -29,6 +37,13 @@ mkdir -p secrets
2937
openssl req -x509 -newkey rsa:4096 -keyout secrets/tls.key -out secrets/tls.cert -days 365 -nodes -subj "/CN=localhost"
3038
```
3139

40+
Generate ML-KEM-1024 keypair:
41+
```bash
42+
node scripts/generate-mlkem-keypair.mjs
43+
```
44+
45+
> ⚠️ The private key will be stored in `secrets/mlkem.key`. Never commit this file!
46+
3247
Start the dev server:
3348
```bash
3449
pnpm start:dev
@@ -41,40 +56,14 @@ https://localhost:3000
4156

4257
__Accept the self-signed certificate warning in your browser. Please note the 's' in 'https'.__
4358

44-
## API Endpoints
45-
46-
### Core Endpoints
47-
48-
- **`GET /chest/attestation`** - Get TEE attestation proving the service cannot access user data
49-
- Returns platform type, cryptographic report, code measurement, and timestamp
50-
- Publicly accessible (no authentication required)
51-
- Users verify the measurement matches published source code
52-
53-
- **`POST /chest/store`** - Store a secret with owner-based access control
54-
- Requires: `secret` (string) and `publicAddresses` (Ethereum addresses)
55-
- Returns: unique `slot` identifier
56-
- No authentication required for storing
57-
58-
- **`GET /chest/access/:slot`** - Access a stored secret
59-
- Requires: SIWE authentication via headers
60-
- Returns: secret if authenticated address is an owner
61-
- Protected by SIWE guard
62-
63-
### Authentication & Health
64-
65-
- **`POST /auth/nonce`** - Generate SIWE nonce for authentication
66-
- **`GET /health`** - Health check endpoint
67-
- **`GET /health/ready`** - Readiness probe
68-
- **`GET /health/live`** - Liveness probe
69-
70-
See the Swagger documentation at `https://localhost:3000` for complete API details.
71-
7259
## Docs
7360

74-
- [**Overview**](docs/OVERVIEW.md) - Complete project overview, features, installation, and API endpoints
75-
- [**TEE Setup**](docs/TEE_SETUP.md) - Platform-specific deployment instructions for AMD SEV-SNP, Intel TDX, AWS Nitro, and Phala Network
76-
- [**SIWE Authentication**](docs/SIWE.md) - Sign-In with Ethereum integration guide and client examples
77-
- [**Side Channel Attacks**](docs/SIDE_CHANNEL_ATTACKS.md) - Security considerations and mitigation strategies
61+
- [**API Reference**](docs/API_REFERENCE.md) - Complete REST API endpoint documentation
62+
- [**Overview**](docs/OVERVIEW.md) - Project overview, architecture, and security model
63+
- [**Client-Side Encryption**](docs/CLIENT_ENCRYPTION.md) - Quantum-resistant ML-KEM encryption guide
64+
- [**TEE Setup**](docs/TEE_SETUP.md) - Platform-specific deployment (AMD SEV-SNP, Intel TDX, AWS Nitro, Phala)
65+
- [**SIWE Authentication**](docs/SIWE.md) - Ethereum wallet authentication guide
66+
- [**Side Channel Attacks**](docs/SIDE_CHANNEL_ATTACKS.md) - Security considerations and mitigations
7867

7968
## License
8069

0 commit comments

Comments
 (0)