From c74a4fb072634dc1a4e63831b5991876462030d5 Mon Sep 17 00:00:00 2001 From: Madhur Shrimal Date: Tue, 7 Jan 2025 13:17:35 -0800 Subject: [PATCH] add pubkey g2 endpoints --- signer/bls/cerberus/cerberus.go | 38 ++++++++++++++++++++++----------- signer/bls/local/local.go | 6 +++++- signer/bls/signer.go | 4 +++- signer/go.mod | 2 +- signer/go.sum | 2 ++ 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/signer/bls/cerberus/cerberus.go b/signer/bls/cerberus/cerberus.go index 0b318516..bd1f3f69 100644 --- a/signer/bls/cerberus/cerberus.go +++ b/signer/bls/cerberus/cerberus.go @@ -30,9 +30,10 @@ type Config struct { } type Signer struct { - client v1.SignerClient - pubKeyHex string - password string + signerClient v1.SignerClient + kmsClient v1.KeyManagerClient + pubKeyHex string + password string } func New(cfg Config) (Signer, error) { @@ -50,11 +51,13 @@ func New(cfg Config) (Signer, error) { log.Fatalf("did not connect: %v", err) } - client := v1.NewSignerClient(conn) + signerClient := v1.NewSignerClient(conn) + kmsClient := v1.NewKeyManagerClient(conn) return Signer{ - client: client, - pubKeyHex: cfg.PublicKeyHex, - password: cfg.Password, + signerClient: signerClient, + kmsClient: kmsClient, + pubKeyHex: cfg.PublicKeyHex, + password: cfg.Password, }, nil } @@ -66,10 +69,10 @@ func (s Signer) Sign(ctx context.Context, msg []byte) ([]byte, error) { var data [32]byte copy(data[:], msg) - resp, err := s.client.SignGeneric(ctx, &v1.SignGenericRequest{ - Data: data[:], - PublicKey: s.pubKeyHex, - Password: s.password, + resp, err := s.signerClient.SignGeneric(ctx, &v1.SignGenericRequest{ + Data: data[:], + PublicKeyG1: s.pubKeyHex, + Password: s.password, }) if err != nil { return nil, err @@ -88,6 +91,17 @@ func (s Signer) GetOperatorId() (string, error) { return publicKey.GetOperatorID(), nil } -func (s Signer) GetPublicKeyHex() string { +func (s Signer) GetPublicKeyG1() string { return s.pubKeyHex } + +func (s Signer) GetPublicKeyG2() string { + resp, err := s.kmsClient.GetKeyMetadata(context.Background(), &v1.GetKeyMetadataRequest{ + PublicKeyG1: s.pubKeyHex, + }) + if err != nil { + log.Fatalf("could not get key metadata from cerberus: %v", err) + } + + return resp.PublicKeyG2 +} diff --git a/signer/bls/local/local.go b/signer/bls/local/local.go index 1c942057..c7ce28c0 100644 --- a/signer/bls/local/local.go +++ b/signer/bls/local/local.go @@ -42,6 +42,10 @@ func (s Signer) GetOperatorId() (string, error) { return s.key.PubKey.GetOperatorID(), nil } -func (s Signer) GetPublicKeyHex() string { +func (s Signer) GetPublicKeyG1() string { return hex.EncodeToString(s.key.PubKey.Serialize()) } + +func (s Signer) GetPublicKeyG2() string { + return hex.EncodeToString(s.key.GetPubKeyG2().Serialize()) +} diff --git a/signer/bls/signer.go b/signer/bls/signer.go index cc6025ef..d5a5bb3e 100644 --- a/signer/bls/signer.go +++ b/signer/bls/signer.go @@ -16,7 +16,9 @@ type Signer interface { // This is hash of the G1 public key of the signer GetOperatorId() (string, error) - GetPublicKeyHex() string + GetPublicKeyG1() string + + GetPublicKeyG2() string } // NewSigner creates a new Signer instance based on the provided configuration. diff --git a/signer/go.mod b/signer/go.mod index c3815a4b..a901e78b 100644 --- a/signer/go.mod +++ b/signer/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.4 replace github.com/Layr-Labs/eigensdk-go => ../../eigensdk-go require ( - github.com/Layr-Labs/cerberus-api v0.0.1 + github.com/Layr-Labs/cerberus-api v0.0.2-0.20250107174124-05df6050f723 github.com/Layr-Labs/eigensdk-go v0.1.13 google.golang.org/grpc v1.64.1 ) diff --git a/signer/go.sum b/signer/go.sum index b1459292..6ea47f42 100644 --- a/signer/go.sum +++ b/signer/go.sum @@ -2,6 +2,8 @@ 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.1 h1:MSLVdxtRS1qnwLks3COnnUw/M3tjLGtbSGaLde86HRg= github.com/Layr-Labs/cerberus-api v0.0.1/go.mod h1:Lm4fhzy0S3P7GjerzuseGaBFVczsIKmEhIjcT52Hluo= +github.com/Layr-Labs/cerberus-api v0.0.2-0.20250107174124-05df6050f723 h1:f6gJS/egys133nGcOGKduiPHq9hyK9KRiEB9fARB5t0= +github.com/Layr-Labs/cerberus-api v0.0.2-0.20250107174124-05df6050f723/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=