Skip to content

Commit 788469b

Browse files
authored
Merge pull request #195 from BitGo/refactor/rename-kms-to-key-provider
refactor!: rename KMS to Key Provider across codebase
2 parents d34523c + 30388aa commit 788469b

52 files changed

Lines changed: 535 additions & 483 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-and-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,4 @@ jobs:
173173
MTLS_ENABLED: true
174174
MTLS_REQUEST_CERT: true
175175
MTLS_REJECT_UNAUTHORIZED: false
176-
KMS_URL: 'https://localhost:3000/'
176+
KEY_PROVIDER_URL: 'https://localhost:3000/'

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Advanced Wallet Manager is a secure cryptocurrency signing server with two opera
3030

3131
- Lightweight server focused solely on secure signing operations
3232
- Runs on port 3080 by default
33-
- Integrates with KMS for key management
33+
- Integrates with advanced wallets key provider for key management
3434
- Handles cryptographic operations securely
3535
- Exposes minimal endpoints focused on key generation and signing
3636

@@ -56,7 +56,7 @@ Advanced Wallet Manager is a secure cryptocurrency signing server with two opera
5656
- `src/initConfig.ts` - Configuration loading and validation
5757
- `src/routes/` - Express routes for both modes
5858
- `src/api/` - API implementation for both modes
59-
- `src/kms/` - KMS client and operations
59+
- `src/advancedWalletManager/keyProviderClient/` - key provider client and operations
6060
- `src/shared/` - Shared utilities and types
6161

6262
### Configuration
@@ -73,7 +73,7 @@ Configuration is managed through environment variables with defaults defined in
7373
#### Advanced Wallet Manager Mode Specific
7474

7575
- `ADVANCED_WALLET_MANAGER_PORT` - Port to listen on (default: 3080)
76-
- `KMS_URL` - Required KMS service URL
76+
- `KEY_PROVIDER_URL` - Required key provider service URL
7777

7878
#### Master Express Mode Specific
7979

README.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Advanced wallets operate in two modes:
1616
Key features include:
1717

1818
- **Complete Infrastructure Control** - Host and manage all components in your own secure environment.
19-
- **KMS/HSM Integration** - Bring your own KMS or HSM by implementing the provided [KMS API interface specification](./kms-api-spec.yaml). Reference implementations available for [AWS HSM](./demo-kms-script/aws-interface.md) and [Dinamo HSM](./demo-kms-script/dinamo-interface.md).
19+
- **KMS/HSM Integration** - Bring your own KMS or HSM by implementing the provided [advanced wallets key provider API interface specification](./key-provider-api-spec.yaml). Reference implementations available for [AWS HSM](./demo-key-provider-script/aws-interface.md) and [Dinamo HSM](./demo-key-provider-script/dinamo-interface.md).
2020
- **Network Isolation** - Advanced Wallet Manager operates in a completely isolated network segment with no external internet access.
2121
- **mTLS Security** - Optional mutual TLS with client certificate validation for secure inter-service communications.
2222
- **Flexible Configuration** - Environment-based setup with file or variable-based certificates.
@@ -38,7 +38,7 @@ Key features include:
3838

3939
## Architecture
4040

41-
- **Advanced Wallet Manager** (Port 3080) - An isolated signing server with no internet access that only connects to your KMS API implementation for key operations.
41+
- **Advanced Wallet Manager** (Port 3080) - An isolated signing server with no internet access that only connects to your key provider API implementation for key operations.
4242
- **Master Express** (Port 3081) - An API gateway providing end-to-end wallet creation and transaction support, integrating [BitGo APIs](https://developers.bitgo.com/reference/overview#/) with secure communication to Advanced Wallet Manager.
4343

4444
## Installation
@@ -49,9 +49,9 @@ Key features include:
4949
- **npm** or **yarn** package manager.
5050
- **OpenSSL** for certificate generation.
5151
- **Docker** and **Docker Compose** for containerized deployment (or you can use **Podman** as alternative to Docker).
52-
- **KMS API Implementation** - You must implement the [KMS API interface specification](./kms-api-spec.yaml) to connect your KMS/HSM to the Advanced Wallet Manager. Reference implementations available:
53-
- [AWS HSM Implementation Example](./demo-kms-script/aws-interface.md)
54-
- [Dinamo HSM Implementation Example](./demo-kms-script/dinamo-interface.md)
52+
- **key provider API implementation** - You must implement the [key provider API interface specification](./key-provider-api-spec.yaml) to connect your KMS/HSM to the Advanced Wallet Manager. Reference implementations available:
53+
- [AWS HSM Implementation Example](./demo-key-provider-script/aws-interface.md)
54+
- [Dinamo HSM Implementation Example](./demo-key-provider-script/dinamo-interface.md)
5555

5656
### Setup
5757

@@ -119,7 +119,7 @@ TLS_MODE=disabled \
119119
BITGO_ENV=test \
120120
APP_MODE=advanced-wallet-manager \
121121
ADVANCED_WALLET_MANAGER_PORT=3080 \
122-
KMS_URL=http://localhost:3000 \
122+
KEY_PROVIDER_URL=http://localhost:3000 \
123123
npm start
124124
```
125125

@@ -168,9 +168,9 @@ curl -X POST http://localhost:3081/ping/advancedWalletManager
168168
| Variable | Description | Default | Required |
169169
| ------------------------------ | ---------------------------------- | ------- | -------- |
170170
| `ADVANCED_WALLET_MANAGER_PORT` | Port to listen on | `3080` ||
171-
| `KMS_URL` | URL to your KMS API implementation | - ||
171+
| `KEY_PROVIDER_URL` | URL to your key provider API implementation | - ||
172172

173-
> **Note:** The `KMS_URL` points to your implementation of the KMS API interface. You must implement this interface to connect your KMS/HSM. See [Prerequisites](#prerequisites) for the specification and examples.
173+
> **Note:** The `KEY_PROVIDER_URL` points to your implementation of the key provider API interface. You must implement this interface to connect your KMS/HSM. See [Prerequisites](#prerequisites) for the specification and examples.
174174
175175
### Master Express Settings
176176

@@ -232,17 +232,17 @@ curl -X POST http://localhost:3081/ping/advancedWalletManager
232232
| `AWM_SERVER_CA_CERT` | AWM server CA certificate (alternative) | PEM string |
233233
| `AWM_SERVER_CERT_ALLOW_SELF_SIGNED` | Allow self-signed AWM server certificates | Boolean (default: `false`) |
234234

235-
**For Advanced Wallet Manager → KMS:**
235+
**For Advanced Wallet Manager → key provider:**
236236

237-
| Variable | Description | Format |
238-
| ----------------------------------- | ----------------------------------------- | -------------------------- |
239-
| `KMS_CLIENT_TLS_KEY_PATH` | Client private key file path | File path |
240-
| `KMS_CLIENT_TLS_KEY` | Client private key (alternative) | PEM string |
241-
| `KMS_CLIENT_TLS_CERT_PATH` | Client certificate file path | File path |
242-
| `KMS_CLIENT_TLS_CERT` | Client certificate (alternative) | PEM string |
243-
| `KMS_SERVER_CA_CERT_PATH` | KMS server CA certificate file path | File path |
244-
| `KMS_SERVER_CA_CERT` | KMS server CA certificate (alternative) | PEM string |
245-
| `KMS_SERVER_CERT_ALLOW_SELF_SIGNED` | Allow self-signed KMS server certificates | Boolean (default: `false`) |
237+
| Variable | Description | Format |
238+
| ------------------------------------------- | -------------------------------------------------- | -------------------------- |
239+
| `KEY_PROVIDER_CLIENT_TLS_KEY_PATH` | Client private key file path | File path |
240+
| `KEY_PROVIDER_CLIENT_TLS_KEY` | Client private key (alternative) | PEM string |
241+
| `KEY_PROVIDER_CLIENT_TLS_CERT_PATH` | Client certificate file path | File path |
242+
| `KEY_PROVIDER_CLIENT_TLS_CERT` | Client certificate (alternative) | PEM string |
243+
| `KEY_PROVIDER_SERVER_CA_CERT_PATH` | Key provider server CA certificate file path | File path |
244+
| `KEY_PROVIDER_SERVER_CA_CERT` | Key provider server CA certificate (alternative) | PEM string |
245+
| `KEY_PROVIDER_SERVER_CERT_ALLOW_SELF_SIGNED` | Allow self-signed key provider server certificates | Boolean (default: `false`) |
246246

247247
> **Note:** For security reasons, when `TLS_MODE=mtls`, outbound client certificates are required and cannot reuse server certificates. When `TLS_MODE=disabled`, these certificates aren't required.
248248
@@ -276,7 +276,7 @@ podman run -d \
276276
-e TLS_MODE=mtls \
277277
-e SERVER_TLS_KEY_PATH=/app/certs/advanced-wallet-manager-key.pem \
278278
-e SERVER_TLS_CERT_PATH=/app/certs/advanced-wallet-manager-cert.pem \
279-
-e KMS_URL=host.containers.internal:3000 \
279+
-e KEY_PROVIDER_URL=host.containers.internal:3000 \
280280
-e NODE_ENV=development \
281281
-e CLIENT_CERT_ALLOW_SELF_SIGNED=true \
282282
advanced-wallet-manager
@@ -351,7 +351,7 @@ The setup creates two distinct networks:
351351
### Prerequisites
352352

353353
1. **Install Docker and Docker Compose**
354-
2. **Ensure your KMS API implementation is running** on your host machine (typically on port 3000)
354+
2. **Ensure your key provider API implementation is running** on your host machine (typically on port 3000)
355355

356356
### Quick Start
357357

@@ -434,17 +434,17 @@ For production deployments with proper mTLS security:
434434
export APP_MODE=advanced-wallet-manager
435435
export TLS_MODE=mtls
436436
export ADVANCED_WALLET_MANAGER_PORT=3080
437-
export KMS_URL=https://production-kms.example.com:3000
437+
export KEY_PROVIDER_URL=https://production-key-provider.example.com:3000
438438
# Server certificates for incoming mTLS connections
439439
export SERVER_TLS_KEY_PATH=/secure/certs/awm-server.key
440440
export SERVER_TLS_CERT_PATH=/secure/certs/awm-server.crt
441-
# Client certificates for outbound connections to KMS
442-
export KMS_CLIENT_TLS_KEY_PATH=/secure/certs/awm-kms-client.key
443-
export KMS_CLIENT_TLS_CERT_PATH=/secure/certs/awm-kms-client.crt
444-
export KMS_SERVER_CA_CERT_PATH=/secure/certs/kms-ca.crt
441+
# Client certificates for outbound connections to key provider
442+
export KEY_PROVIDER_CLIENT_TLS_KEY_PATH=/secure/certs/awm-key-provider-client.key
443+
export KEY_PROVIDER_CLIENT_TLS_CERT_PATH=/secure/certs/awm-key-provider-client.crt
444+
export KEY_PROVIDER_SERVER_CA_CERT_PATH=/secure/certs/key-provider-ca.crt
445445
# Security settings - production-grade
446446
export CLIENT_CERT_ALLOW_SELF_SIGNED=false
447-
export KMS_SERVER_CERT_ALLOW_SELF_SIGNED=false
447+
export KEY_PROVIDER_SERVER_CERT_ALLOW_SELF_SIGNED=false
448448
export MTLS_ALLOWED_CLIENT_FINGERPRINTS=sha256:1a2b3c...,sha256:4d5e6f...
449449
export BITGO_ENV=prod
450450
npm start
@@ -500,7 +500,7 @@ curl --cert /path/to/client-cert.crt --key /path/to/client-key.key \
500500
For local testing, you can generate and use demo certificates with the self-signed configuration flags:
501501

502502
- Generate demo certificates: `npm run generate-test-ssl` (creates `demo.key` and `demo.crt`).
503-
- Set `CLIENT_CERT_ALLOW_SELF_SIGNED=true`, `KMS_SERVER_CERT_ALLOW_SELF_SIGNED=true`, and `AWM_SERVER_CERT_ALLOW_SELF_SIGNED=true`.
503+
- Set `CLIENT_CERT_ALLOW_SELF_SIGNED=true`, `KEY_PROVIDER_SERVER_CERT_ALLOW_SELF_SIGNED=true`, and `AWM_SERVER_CERT_ALLOW_SELF_SIGNED=true`.
504504
- Use the demo certificates for all certificate paths (server and client).
505505
- **Important:** Demo certificates and self-signed configurations should never be used in production.
506506

@@ -509,7 +509,7 @@ For local testing, you can generate and use demo certificates with the self-sign
509509
1. **Use CA-signed certificates** instead of self-signed.
510510
2. **Set `CLIENT_CERT_ALLOW_SELF_SIGNED=false`** and server-specific allow self-signed flags to `false` in production.
511511
3. **Configure client certificate allowlisting** with `MTLS_ALLOWED_CLIENT_FINGERPRINTS`.
512-
4. **Use separate certificates** for each service (server, AWM client, KMS client).
512+
4. **Use separate certificates** for each service (server, AWM client, key provider client).
513513
5. **Regularly rotate certificates**.
514514
6. **Secure private key storage** and use appropriate file permissions.
515515
7. **Always use `TLS_MODE=mtls`** in production environments.
@@ -529,7 +529,7 @@ The output format is: `sha256:AB:CD:EF:...` which you can use in the configurati
529529
#### Certificate Requirements for Production
530530

531531
- All certificates should be CA-signed certificates issued by your organization's PKI.
532-
- Each service must use separate certificates (server cert, AWM client cert, KMS client cert).
532+
- Each service must use separate certificates (server cert, AWM client cert, key provider client cert).
533533
- Client certificates for outbound connections must be different from server certificates.
534534
- Store private keys in secure locations with restricted file permissions:
535535
```bash
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# AWS HSM KMS Implementation Documentation
1+
# AWS HSM Key Provider Implementation Documentation
22

3-
This document provides a reference implementation for integrating the 4 KMS API's with AWS HSM, covering the complete request-response flow from API handlers to HSM operations.
3+
This document provides a reference implementation for integrating the 4 key provider API's with AWS HSM, covering the complete request-response flow from API handlers to HSM operations.
44

55
## ⚠️ Security Recommendation
66

7-
For production KMS implementations, consider implementing the KMS-API in a C++ like language, because JavaScript does not support low-level memory management. Depending on your solution, direct memory management with explicit memory allocation/deallocation might be desirable.
7+
For production key provider implementations, consider implementing the key provider API in a C++ like language, because JavaScript does not support low-level memory management. Depending on your solution, direct memory management with explicit memory allocation/deallocation might be desirable.
88

99
Also consider implementing low level cryptographic operations using low-level languages like C++ or Rust. They typically provide easier and more efficient data manipulation and transaformation.
1010

@@ -14,7 +14,7 @@ When working with AWS HSM, adhere to their guidances and best practices for the
1414

1515
## API Overview
1616

17-
The KMS API provides secure key management through four main endpoints that integrate with AWS HSM:
17+
The key provider API provides secure key management through four main endpoints that integrate with AWS HSM:
1818

1919
- `POST /key` - Store private keys using envelope encryption
2020
- `GET /key/{pub}` - Retrieve private keys using envelope decryption
@@ -25,10 +25,10 @@ The KMS API provides secure key management through four main endpoints that inte
2525
All 4 API's implementation should follow roughly the same dataflow as outlined bellow:
2626

2727
```
28-
API Request → Handler → KMS Provider → AWS HSM → KMS Provider → Database (if required) → Response
28+
API Request → Handler → key provider → AWS HSM → key provider → Database (if required) → Response
2929
```
3030

31-
A KMS provider is the implementation of the code that is in charge of making the necessary calls to the HSM directly. You might have multiple providers in your solution, one for each 3rd party HSM that you wish to use, for example.
31+
A key provider is the implementation of the code that is in charge of making the necessary calls to the HSM directly. You might have multiple providers in your solution, one for each 3rd party HSM that you wish to use, for example.
3232

3333
### Handler-to-Provider Mapping
3434

@@ -41,10 +41,10 @@ A KMS provider is the implementation of the code that is in charge of making the
4141

4242
## Envelope Encryption Pattern (Recommended)
4343

44-
We recommend using a 3 level key encryption to store and protect the private keys of your advanced wallets.
45-
The 3 levels consist of the root-level key from the KMS, 2nd level data keys generated by the root level key, and the 3rd level private keys used by your wallets directly.
44+
We recommend using a 3 level key encryption to store and protect the private keys of your advanced wallets.
45+
The 3 levels consist of the root-level key from the KMS/HSM, 2nd level data keys generated by the root level key, and the 3rd level private keys used by your wallets directly.
4646

47-
### Layer 1: KMS Keys (AWS HSM)
47+
### Layer 1: Root Keys (AWS HSM)
4848
- **Key spec**: `SYMMETRIC_DEFAULT`
4949
- **Algorithm**: AES-256-GCM, used by keys generated using the specification `SYMMETRIC_DEFAULT`
5050
- **Generation**: AWS HSM
@@ -67,7 +67,7 @@ The 3 levels consist of the root-level key from the KMS, 2nd level data keys gen
6767

6868
### Root Key Creation
6969

70-
This following needs to be only run once. The KMS should be functional with just one root-level key.
70+
This following needs to be only run once. The key provider should be functional with just one root-level key.
7171

7272
```typescript
7373
import * as awskms from '@aws-sdk/client-kms';

demo-kms-script/dinamo-interface.md renamed to demo-key-provider-script/dinamo-interface.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Dinamo HSM KMS Implementation Documentation
1+
# Dinamo HSM Key Provider Implementation Documentation
22

33
## ⚠️ Security Recommendation
44

5-
**For production KMS implementations, consider implementing the KMS-API in a C++ like language, or use typed arrays like Uint8Array for all sensitive data because JavaScript does not support secure memory management.**
5+
**For production key provider implementations, consider implementing the key provider API in a C++ like language, or use typed arrays like Uint8Array for all sensitive data because JavaScript does not support secure memory management.**
66

77
**Recommended Alternatives:**
88
- **C++/Rust**: Languages with explicit memory management and secure allocation
99
- **Node.js Typed Arrays**: Use `Uint8Array` for sensitive data with explicit zeroing
1010
- **Native Addons**: Implement cryptographic operations in native C++ modules
1111
- **Hardware Security**: Use HSM-backed secure memory when available
1212

13-
This document provides a reference implementation for integrating the 4 KMS API's with Dinamo HSM, covering the complete request-response flow from API handlers to HSM operations.
13+
This document provides a reference implementation for integrating the 4 key provider API's with Dinamo HSM, covering the complete request-response flow from API handlers to HSM operations.
1414

1515
## Demo Scripts
1616

@@ -20,7 +20,7 @@ This document provides a reference implementation for integrating the 4 KMS API'
2020

2121
## Quick Overview
2222

23-
The KMS API provides secure key management through four main endpoints that integrate with Dinamo HSM:
23+
The key provider API provides secure key management through four main endpoints that integrate with Dinamo HSM:
2424

2525
- `POST /key` - Store private keys using envelope encryption
2626
- `GET /key/{pub}` - Retrieve private keys using envelope decryption
@@ -30,7 +30,7 @@ The KMS API provides secure key management through four main endpoints that inte
3030
## Architecture Flow
3131

3232
```
33-
API Request → Handler → KMS Provider → Dinamo HSM → Database → Response
33+
API Request → Handler → key provider → Dinamo HSM → Database → Response
3434
```
3535

3636
### Handler-to-Provider Mapping

docker-compose.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ services:
2222
- TLS_MODE=disabled
2323
- CLIENT_CERT_ALLOW_SELF_SIGNED=true
2424

25-
# KMS settings (required)
26-
- KMS_URL=http://172.20.0.1:3000 # UPDATE TO YOUR OWN KMS URL
27-
- KMS_SERVER_CERT_ALLOW_SELF_SIGNED=true
28-
29-
# Optional KMS TLS settings (uncomment if using mTLS with KMS)
30-
# - KMS_SERVER_CA_CERT_PATH=/path/to/kms-ca-cert.pem
31-
# - KMS_CLIENT_TLS_KEY_PATH=/path/to/kms-client-key.pem
32-
# - KMS_CLIENT_TLS_CERT_PATH=/path/to/kms-client-cert.pem
33-
# - KMS_CLIENT_TLS_KEY=<key-content>
34-
# - KMS_CLIENT_TLS_CERT=<cert-content>
25+
# Key provider settings (required)
26+
- KEY_PROVIDER_URL=http://172.20.0.1:3000 # UPDATE TO YOUR OWN key provider URL
27+
- KEY_PROVIDER_SERVER_CERT_ALLOW_SELF_SIGNED=true
28+
29+
# Optional key provider TLS settings (uncomment if using mTLS with key provider)
30+
# - KEY_PROVIDER_SERVER_CA_CERT_PATH=/path/to/key-provider-ca-cert.pem
31+
# - KEY_PROVIDER_CLIENT_TLS_KEY_PATH=/path/to/key-provider-client-key.pem
32+
# - KEY_PROVIDER_CLIENT_TLS_CERT_PATH=/path/to/key-provider-client-cert.pem
33+
# - KEY_PROVIDER_CLIENT_TLS_KEY=<key-content>
34+
# - KEY_PROVIDER_CLIENT_TLS_CERT=<cert-content>
3535

3636
# Optional server TLS settings (uncomment if using mTLS)
3737
# - SERVER_TLS_KEY_PATH=/path/to/server-key.pem

0 commit comments

Comments
 (0)