diff --git a/api/clients/v2/dispersal_request_signer.go b/api/clients/v2/dispersal_request_signer.go index 4ab4a9e09..be104de94 100644 --- a/api/clients/v2/dispersal_request_signer.go +++ b/api/clients/v2/dispersal_request_signer.go @@ -4,10 +4,11 @@ import ( "context" "crypto/ecdsa" "fmt" + grpc "github.com/Layr-Labs/eigenda/api/grpc/node/v2" "github.com/Layr-Labs/eigenda/api/hashing" aws2 "github.com/Layr-Labs/eigenda/common/aws" - "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/kms" ) @@ -33,12 +34,19 @@ func NewDispersalRequestSigner( endpoint string, keyID string) (DispersalRequestSigner, error) { - keyManager := kms.New(kms.Options{ - Region: region, - BaseEndpoint: aws.String(endpoint), - }) + // Load the AWS SDK configuration, which will automatically detect credentials + // from environment variables, IAM roles, or AWS config files + cfg, err := config.LoadDefaultConfig(ctx, + config.WithRegion(region), + ) + if err != nil { + return nil, fmt.Errorf("failed to load AWS config: %w", err) + } + + // Create KMS client with the loaded configuration + kmsClient := kms.NewFromConfig(cfg) - key, err := aws2.LoadPublicKeyKMS(ctx, keyManager, keyID) + key, err := aws2.LoadPublicKeyKMS(ctx, kmsClient, keyID) if err != nil { return nil, fmt.Errorf("failed to get ecdsa public key: %w", err) } @@ -46,7 +54,7 @@ func NewDispersalRequestSigner( return &requestSigner{ keyID: keyID, publicKey: key, - keyManager: keyManager, + keyManager: kmsClient, }, nil } diff --git a/disperser/cmd/controller/config.go b/disperser/cmd/controller/config.go index 5a81b5f51..b766107e1 100644 --- a/disperser/cmd/controller/config.go +++ b/disperser/cmd/controller/config.go @@ -1,6 +1,7 @@ package main import ( + "context" "fmt" "github.com/Layr-Labs/eigenda/common" @@ -11,6 +12,8 @@ import ( "github.com/Layr-Labs/eigenda/disperser/cmd/controller/flags" "github.com/Layr-Labs/eigenda/disperser/controller" "github.com/Layr-Labs/eigenda/indexer" + "github.com/Layr-Labs/eigensdk-go/aws/kms" + "github.com/ethereum/go-ethereum/crypto" "github.com/urfave/cli" ) @@ -100,5 +103,19 @@ func NewConfig(ctx *cli.Context) (Config, error) { if !config.DisperserStoreChunksSigningDisabled && config.DisperserKMSKeyID == "" { return Config{}, fmt.Errorf("DisperserKMSKeyID is required when StoreChunks() signing is enabled") } + + // KMS debugging + kmsClient, err := kms.NewKMSClient(context.Background(), config.AwsClientConfig.Region) + if err != nil { + fmt.Printf("failed to create KMS client: %v\n", err) + return config, nil + } + pubKey, err := kms.GetECDSAPublicKey(context.Background(), kmsClient, config.DisperserKMSKeyID) + if err != nil { + fmt.Printf("failed to get public key from KMS: %v\n", err) + return config, nil + } + addr := crypto.PubkeyToAddress(*pubKey) + fmt.Printf("public key: %v, address: %s\n", pubKey, addr.Hex()) return config, nil }