Skip to content

Commit

Permalink
add pubkey g2 endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Jan 7, 2025
1 parent 3328a1c commit c74a4fb
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
38 changes: 26 additions & 12 deletions signer/bls/cerberus/cerberus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}

Expand All @@ -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
Expand All @@ -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
}
6 changes: 5 additions & 1 deletion signer/bls/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
4 changes: 3 additions & 1 deletion signer/bls/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion signer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 2 additions & 0 deletions signer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit c74a4fb

Please sign in to comment.