Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add api key to cerberus client #449

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions signer/bls/cerberus/cerberus.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"

sdkBls "github.com/Layr-Labs/eigensdk-go/crypto/bls"
"github.com/Layr-Labs/eigensdk-go/signer/bls/types"
Expand All @@ -21,6 +22,8 @@ type Config struct {
URL string
PublicKeyHex string

SignerAPIKey string

// Optional: in case if your signer uses local keystore
Password string

Expand All @@ -35,6 +38,7 @@ type Signer struct {
kmsClient v1.KeyManagerClient
pubKeyHex string
password string
signerAPIKey string
}

func New(cfg Config) (Signer, error) {
Expand All @@ -61,6 +65,7 @@ func New(cfg Config) (Signer, error) {
kmsClient: kmsClient,
pubKeyHex: cfg.PublicKeyHex,
password: cfg.Password,
signerAPIKey: cfg.SignerAPIKey,
}, nil
}

Expand All @@ -69,6 +74,9 @@ func (s Signer) Sign(ctx context.Context, msg []byte) ([]byte, error) {
return nil, types.ErrInvalidMessageLength
}

// Pass the API key to the signer client
ctx = metadata.AppendToOutgoingContext(ctx, "authorization", s.signerAPIKey)

resp, err := s.signerClient.SignGeneric(ctx, &v1.SignGenericRequest{
Data: msg,
PublicKeyG1: s.pubKeyHex,
Expand All @@ -86,6 +94,9 @@ func (s Signer) SignG1(ctx context.Context, msg []byte) ([]byte, error) {
return nil, types.ErrInvalidMessageLength
}

// Pass the API key to the signer client
ctx = metadata.AppendToOutgoingContext(ctx, "authorization", s.signerAPIKey)

resp, err := s.signerClient.SignG1(ctx, &v1.SignG1Request{
Data: msg,
PublicKeyG1: s.pubKeyHex,
Expand Down
1 change: 1 addition & 0 deletions signer/bls/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func NewSigner(cfg types.SignerConfig) (Signer, error) {
Password: cfg.CerberusPassword,
EnableTLS: cfg.EnableTLS,
TLSCertFilePath: cfg.TLSCertFilePath,
SignerAPIKey: cfg.CerberusAPIKey,
})
case types.PrivateKey:
return privatekey.New(privatekey.Config{
Expand Down
2 changes: 2 additions & 0 deletions signer/bls/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ type SignerConfig struct {
EnableTLS bool
// TLSCertFilePath is the path to the TLS cert file
TLSCertFilePath string
// CerberusAPIKey is the API key for the cerberus signer
CerberusAPIKey string
}
4 changes: 2 additions & 2 deletions signer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ go 1.21.13
replace github.com/Layr-Labs/eigensdk-go => ../../eigensdk-go

require (
github.com/Layr-Labs/cerberus-api v0.0.2-0.20250108174619-d5e1eb03fbd5
github.com/Layr-Labs/cerberus-api v0.0.2-0.20250117193600-e69c5e8b08fd
github.com/Layr-Labs/eigensdk-go v0.1.13
github.com/consensys/gnark-crypto v0.12.1
github.com/stretchr/testify v1.9.0
google.golang.org/grpc v1.64.1
)
Expand All @@ -15,7 +16,6 @@ require (
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions signer/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/Layr-Labs/cerberus-api v0.0.2-0.20250108174619-d5e1eb03fbd5 h1:s24M6HYObEuV9OSY36jUM09kp5fOhuz/g1ev2qWDPzU=
github.com/Layr-Labs/cerberus-api v0.0.2-0.20250108174619-d5e1eb03fbd5/go.mod h1:Lm4fhzy0S3P7GjerzuseGaBFVczsIKmEhIjcT52Hluo=
github.com/Layr-Labs/cerberus-api v0.0.2-0.20250117193600-e69c5e8b08fd h1:prMzW4BY6KZtWEanf5EIsyHzIZKCNV2mVIXrE6glRRM=
github.com/Layr-Labs/cerberus-api v0.0.2-0.20250117193600-e69c5e8b08fd/go.mod h1:Lm4fhzy0S3P7GjerzuseGaBFVczsIKmEhIjcT52Hluo=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40=
Expand Down
Loading