Skip to content

Commit f3f9649

Browse files
authored
Merge pull request #61 from celestiaorg/tux/upgrade-kms
dep: upgrade kms
2 parents 28ed2e4 + 1130992 commit f3f9649

6 files changed

Lines changed: 41 additions & 81 deletions

File tree

README.md

Lines changed: 33 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ The DA server signs transactions using a Celestia keyring. You have two options:
3737
- The key name must match your configuration (`default_key_name`)
3838

3939
**Option 2: AWS KMS Keyring** (Recommended for production)
40-
- Key names are mapped to aliases
41-
- Supports importing existing keys for e.g.: keys generated by `cel-key`
42-
- Supports auto-creation of keys for simplified setup
40+
- Uses a single pre-configured KMS key
41+
- Minimal permissions: only `kms:GetPublicKey` and `kms:Sign` required
42+
- Key name `default_key_name` in the configuration corresponds to the KMS key alias or key ID
4343
- Works with LocalStack for local development
4444

4545
**The server will not work without a properly configured keyring.**
@@ -70,48 +70,18 @@ celestia-appd keys show my_celes_key --keyring-backend test \
7070
#### Alternative: AWS KMS Keyring Backend
7171

7272
Instead of a local keyring, you can use AWS KMS for signing Celestia transactions. This provides:
73-
- **Hardware security** - Keys are generated and stored in AWS KMS HSMs
73+
- **Hardware security** - Keys are stored in AWS KMS HSMs
7474
- **Remote signing** - No local key material needed
75-
- **Auto-creation** - Keys can be automatically created on first use
75+
- **Minimal permissions** - Only `kms:GetPublicKey` and `kms:Sign` required
7676
- **LocalStack support** - Test locally before deploying to AWS
7777

78-
##### LocalStack Setup (Development/Testing)
79-
80-
For local development, use LocalStack to emulate AWS KMS:
78+
##### Step 1: Create a KMS Key
8179

8280
```bash
83-
# Start LocalStack with KMS service
81+
# For LocalStack (development)
8482
docker run -d -p 4566:4566 localstack/localstack
8583

86-
# Configure op-alt-da to use AWS KMS with auto-creation
87-
cat > config.toml <<EOF
88-
[celestia]
89-
keyring_backend = "awskms"
90-
default_key_name = "my_celes_key"
91-
# ... other celestia settings ...
92-
93-
[celestia.awskms]
94-
region = "us-east-1"
95-
endpoint = "http://localhost:4566" # LocalStack endpoint
96-
alias_prefix = "alias/op-alt-da/"
97-
auto_create = true # Automatically create keys if they don't exist
98-
EOF
99-
100-
# Run the server - the key will be auto-created on startup!
101-
./bin/da-server --config=config.toml
102-
```
103-
104-
With `auto_create = true`, the server will automatically:
105-
1. Check if a KMS key with alias `alias/op-alt-da/<default_key_name>` exists
106-
2. If not found, create a new secp256k1 key in KMS
107-
3. Create the alias and start using it for signing
108-
109-
**Manual Key Creation (Optional)**
110-
111-
If you prefer to create keys manually or need to use existing keys:
112-
113-
```bash
114-
# Create a secp256k1 key in LocalStack
84+
# Create a secp256k1 key
11585
KEY_ID=$(aws --endpoint-url=http://localhost:4566 kms create-key \
11686
--key-spec ECC_SECG_P256K1 \
11787
--key-usage SIGN_VERIFY \
@@ -120,35 +90,43 @@ KEY_ID=$(aws --endpoint-url=http://localhost:4566 kms create-key \
12090

12191
# Create an alias for the key
12292
aws --endpoint-url=http://localhost:4566 kms create-alias \
123-
--alias-name alias/op-alt-da/my_celes_key \
93+
--alias-name alias/my_celes_key \
12494
--target-key-id $KEY_ID
125-
126-
# Set auto_create = false in config.toml
12795
```
12896

129-
##### AWS Production Setup
97+
For production AWS, omit `--endpoint-url`.
13098

131-
For production use with AWS KMS:
99+
##### Step 2: Configure the Server
132100

133101
```toml
134102
[celestia]
135103
keyring_backend = "awskms"
136-
default_key_name = "my_celes_key"
104+
default_key_name = "alias/my_celes_key" # Use full alias name
105+
# ... other celestia settings ...
137106

138107
[celestia.awskms]
139108
region = "us-east-1"
140-
endpoint = "" # Leave empty for AWS
141-
alias_prefix = "alias/op-alt-da/"
142-
auto_create = false # Disable auto-creation in production
143-
144-
# Optional: Import an existing private key
145-
import_key_name = "my_celes_key"
146-
import_key_hex = "your-32-byte-hex-private-key"
109+
endpoint = "http://localhost:4566" # Leave empty for AWS production
147110
```
148111

149-
**Important:** Ensure your AWS credentials are configured via environment variables, IAM role, or AWS credentials file. The server requires `kms:CreateKey`, `kms:CreateAlias`, `kms:GetPublicKey`, `kms:Sign`, and `kms:ListAliases` permissions.
112+
##### Step 3: Run the Server
150113

151-
To export a key from celestia keystore, use `cel-key export --keyring-dir /path/to/keyring --unarmored-hex --unsafe my_celes_key`
114+
```bash
115+
./bin/da-server --config=config.toml
116+
```
117+
118+
**IAM Permissions Required:**
119+
120+
```json
121+
{
122+
"Version": "2012-10-17",
123+
"Statement": [{
124+
"Effect": "Allow",
125+
"Action": ["kms:GetPublicKey", "kms:Sign"],
126+
"Resource": "arn:aws:kms:REGION:ACCOUNT:key/KEY_ID"
127+
}]
128+
}
129+
```
152130

153131
### 2. Build the Server
154132

@@ -257,17 +235,13 @@ core_grpc_tls_enabled = true
257235
# Keyring
258236
keyring_backend = "test" # or "awskms" for AWS KMS
259237
keyring_path = "~/.celestia-light-mocha-4/keys"
260-
default_key_name = "my_celes_key"
238+
default_key_name = "my_celes_key" # For awskms, use full alias: "alias/my_celes_key"
261239
p2p_network = "mocha-4"
262240

263-
# AWS KMS keyring
241+
# AWS KMS keyring (when keyring_backend = "awskms")
264242
[celestia.awskms]
265243
region = "us-east-1"
266244
endpoint = "" # Set to http://localhost:4566 for localstack
267-
alias_prefix = "alias/op-alt-da/"
268-
auto_create = false # Automatically create keys if they don't exist
269-
import_key_name = "my_celes_key"
270-
import_key_hex = "1234..."
271245

272246
[submission]
273247
timeout = "60s"

celestia_storage.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ func initKeyring(ctx context.Context, cfg *RPCClientConfig) (keyring.Keyring, er
211211
if cfg.TxClientConfig.AWSKMSConfig == nil {
212212
return nil, fmt.Errorf("AWS KMS config is required when using awskms backend")
213213
}
214-
kr, err = awskeyring.NewKMSKeyring(ctx, keyname, *cfg.TxClientConfig.AWSKMSConfig)
214+
kmsCfg := *cfg.TxClientConfig.AWSKMSConfig
215+
kmsCfg.KeyName = keyname
216+
kr, err = awskeyring.NewKMSKeyring(ctx, kmsCfg)
215217
default:
216218
kr, err = txClient.KeyringWithNewKey(txClient.KeyringConfig{
217219
KeyName: keyname,

cmd/daserver/config.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -382,17 +382,9 @@ func (c *Config) ToCelestiaRPCConfig() celestia.RPCClientConfig {
382382
TxWorkerAccounts: c.Celestia.TxWorkerAccounts,
383383
}
384384
if c.Celestia.KeyringBackend == "awskms" {
385-
aliasPrefix := c.Celestia.AWSKMS.AliasPrefix
386-
if aliasPrefix == "" {
387-
aliasPrefix = "alias/op-alt-da/"
388-
}
389385
txCfg.AWSKMSConfig = &awskeyring.Config{
390-
Region: c.Celestia.AWSKMS.Region,
391-
Endpoint: c.Celestia.AWSKMS.Endpoint,
392-
AliasPrefix: aliasPrefix,
393-
ImportKeyName: c.Celestia.AWSKMS.ImportKeyName,
394-
ImportKeyHex: c.Celestia.AWSKMS.ImportKeyHex,
395-
AutoCreate: c.Celestia.AWSKMS.AutoCreate,
386+
Region: c.Celestia.AWSKMS.Region,
387+
Endpoint: c.Celestia.AWSKMS.Endpoint,
396388
}
397389
}
398390
}

config.toml.example

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ tx_worker_accounts = 0
9898
region = "us-east-1"
9999
# Set to http://localhost:4566 for localstack testing. Leave empty for AWS.
100100
endpoint = ""
101-
alias_prefix = "alias/op-alt-da/"
102-
103-
# Automatically create keys if they don't exist (useful for development/testing)
104-
auto_create = false
105-
106-
# Optional: Import an existing private key into KMS on startup
107-
import_key_name = "my_celes_key"
108-
import_key_hex = ""
109101

110102
# ==============================================================================
111103
# SUBMISSION CONFIGURATION

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/aws/aws-sdk-go-v2/config v1.31.17
99
github.com/aws/aws-sdk-go-v2/credentials v1.18.21
1010
github.com/aws/aws-sdk-go-v2/service/s3 v1.90.0
11-
github.com/celestiaorg/aws-kms-keyring v0.4.0
11+
github.com/celestiaorg/aws-kms-keyring v0.5.0
1212
github.com/celestiaorg/celestia-node v0.28.4
1313
github.com/celestiaorg/go-square/v3 v3.0.2
1414
github.com/cosmos/cosmos-sdk v0.51.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,8 @@ github.com/bytedance/sonic v1.14.1/go.mod h1:gi6uhQLMbTdeP0muCnrjHLeCUPyb70ujhnN
795795
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
796796
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
797797
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
798-
github.com/celestiaorg/aws-kms-keyring v0.4.0 h1:fGTE6a5VDcNht7lq0sQRLl9X9IHu4d0b6siwFJ7visQ=
799-
github.com/celestiaorg/aws-kms-keyring v0.4.0/go.mod h1:xNjA82rcQvZarKzhnmgwEPTN9TUm3SZUWYyX8YNDlkA=
798+
github.com/celestiaorg/aws-kms-keyring v0.5.0 h1:RLYfMdl0RQivv2YUnclszoO2uy6KvKaUCwjxbcOdeac=
799+
github.com/celestiaorg/aws-kms-keyring v0.5.0/go.mod h1:xNjA82rcQvZarKzhnmgwEPTN9TUm3SZUWYyX8YNDlkA=
800800
github.com/celestiaorg/boxo v0.29.0-fork-4 h1:A202u8w3Iqjw4ZlqSukfiMbefQEN+740GUj1Z3VI960=
801801
github.com/celestiaorg/boxo v0.29.0-fork-4/go.mod h1:rXql6ncaLZZfLqDG3Cuw9ZYQKd3rMU5bk1TGXF0+ZL0=
802802
github.com/celestiaorg/celestia-app/v6 v6.2.5 h1:KwYTR0Nsb/r1lr2sOKwSVX/lMytHU4WjlkDQ/AugHxg=

0 commit comments

Comments
 (0)