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

add bls signer abstraction from eigensdk #985

Merged
merged 13 commits into from
Jan 15, 2025
Prev Previous commit
Next Next commit
rename sdkSigner to blssigner
  • Loading branch information
shrimalmadhur committed Jan 15, 2025
commit f1eb0ada0b99592335aac22f054246e8fb25b562
6 changes: 3 additions & 3 deletions core/chainio.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"math/big"

"github.com/Layr-Labs/eigenda/api/grpc/churner"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
Expand Down Expand Up @@ -147,7 +147,7 @@ type Writer interface {
RegisterOperator(
ctx context.Context,
keypair *KeyPair,
signer sdkSigner.Signer,
signer blssigner.Signer,
socket string,
quorumIds []QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand All @@ -160,7 +160,7 @@ type Writer interface {
RegisterOperatorWithChurn(
ctx context.Context,
keypair *KeyPair,
signer sdkSigner.Signer,
signer blssigner.Signer,
socket string,
quorumIds []QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand Down
10 changes: 5 additions & 5 deletions core/eth/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/pingcap/errors"

sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
)

type ContractBindings struct {
Expand Down Expand Up @@ -290,7 +290,7 @@ func (t *Reader) GetRegisteredQuorumIdsForOperator(ctx context.Context, operator

func (t *Reader) getRegistrationParams(
ctx context.Context,
sdkSigner sdkSigner.Signer,
blssigner blssigner.Signer,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
operatorToAvsRegistrationSigSalt [32]byte,
operatorToAvsRegistrationSigExpiry *big.Int,
Expand All @@ -306,7 +306,7 @@ func (t *Reader) getRegistrationParams(
}

msgToSignG1 := core.NewG1Point(msgToSignG1_.X, msgToSignG1_.Y)
sigBytes, err := sdkSigner.SignG1(ctx, msgToSignG1.Serialize())
sigBytes, err := blssigner.SignG1(ctx, msgToSignG1.Serialize())
if err != nil {
return nil, nil, err
}
Expand All @@ -324,7 +324,7 @@ func (t *Reader) getRegistrationParams(
Y: signature.Y.BigInt(big.NewInt(0)),
}

g1KeyHex := sdkSigner.GetPublicKeyG1()
g1KeyHex := blssigner.GetPublicKeyG1()
g1KeyBytes, err := hex.DecodeString(g1KeyHex)
if err != nil {
return nil, nil, err
Expand All @@ -340,7 +340,7 @@ func (t *Reader) getRegistrationParams(
Y: g1Point_.Y,
}

g2KeyHex := sdkSigner.GetPublicKeyG2()
g2KeyHex := blssigner.GetPublicKeyG2()
g2KeyBytes, err := hex.DecodeString(g2KeyHex)
if err != nil {
return nil, nil, err
Expand Down
6 changes: 3 additions & 3 deletions core/eth/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
regcoordinator "github.com/Layr-Labs/eigenda/contracts/bindings/RegistryCoordinator"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigensdk-go/logging"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -64,7 +64,7 @@ func NewWriter(
func (t *Writer) RegisterOperator(
ctx context.Context,
keypair *core.KeyPair,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove keypair now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signer sdkSigner.Signer,
signer blssigner.Signer,
socket string,
quorumIds []core.QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand Down Expand Up @@ -105,7 +105,7 @@ func (t *Writer) RegisterOperator(
func (t *Writer) RegisterOperatorWithChurn(
ctx context.Context,
keypair *core.KeyPair,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signer sdkSigner.Signer,
signer blssigner.Signer,
socket string,
quorumIds []core.QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand Down
8 changes: 4 additions & 4 deletions core/indexer/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
sdkSignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rpc"
Expand All @@ -53,9 +53,9 @@ func mustRegisterOperators(env *deploy.Config, logger logging.Logger) {
for _, op := range env.Operators {
tx := mustMakeOperatorTransactor(env, op, logger)

signer, err := sdkSigner.NewSigner(sdkSignerTypes.SignerConfig{
signer, err := blssigner.NewSigner(blssignerTypes.SignerConfig{
PrivateKey: op.NODE_TEST_PRIVATE_BLS,
SignerType: sdkSignerTypes.PrivateKey,
SignerType: blssignerTypes.PrivateKey,
})
Expect(err).To(BeNil())

Expand Down
10 changes: 5 additions & 5 deletions core/mock/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"sort"

"github.com/Layr-Labs/eigenda/core"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
sdkSignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
"github.com/stretchr/testify/mock"
)

Expand All @@ -27,7 +27,7 @@ var _ core.IndexedChainState = (*ChainDataMock)(nil)
type PrivateOperatorInfo struct {
*core.IndexedOperatorInfo
KeyPair *core.KeyPair
Signer sdkSigner.Signer
Signer blssigner.Signer
Host string
DispersalPort string
RetrievalPort string
Expand Down Expand Up @@ -146,9 +146,9 @@ func (d *ChainDataMock) GetTotalOperatorStateWithQuorums(ctx context.Context, bl
PubkeyG2: d.KeyPairs[id].GetPubKeyG2(),
}

signer, _ := sdkSigner.NewSigner(sdkSignerTypes.SignerConfig{
signer, _ := blssigner.NewSigner(blssignerTypes.SignerConfig{
PrivateKey: d.KeyPairs[id].PrivKey.String(),
SignerType: sdkSignerTypes.PrivateKey,
SignerType: blssignerTypes.PrivateKey,
})

private := &PrivateOperatorInfo{
Expand Down
6 changes: 3 additions & 3 deletions core/mock/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/Layr-Labs/eigenda/api/grpc/churner"
"github.com/Layr-Labs/eigenda/core"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -40,7 +40,7 @@ func (t *MockWriter) GetRegisteredQuorumIdsForOperator(ctx context.Context, oper
func (t *MockWriter) RegisterOperator(
ctx context.Context,
keypair *core.KeyPair,
signer sdkSigner.Signer,
signer blssigner.Signer,
socket string,
quorumIds []core.QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand All @@ -54,7 +54,7 @@ func (t *MockWriter) RegisterOperator(
func (t *MockWriter) RegisterOperatorWithChurn(
ctx context.Context,
keypair *core.KeyPair,
signer sdkSigner.Signer,
signer blssigner.Signer,
socket string,
quorumIds []core.QuorumID,
operatorEcdsaPrivateKey *ecdsa.PrivateKey,
Expand Down
16 changes: 8 additions & 8 deletions node/churner_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/operators/churner"
"github.com/Layr-Labs/eigensdk-go/logging"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"google.golang.org/grpc"
Expand All @@ -24,7 +24,7 @@ type ChurnerClient interface {
// Churn sends a churn request to the churner service
// The quorumIDs cannot be empty, but may contain quorums that the operator is already registered in.
// If the operator is already registered in a quorum, the churner will ignore it and continue with the other quorums.
Churn(ctx context.Context, operatorAddress string, sdkSigner sdkSigner.Signer, quorumIDs []core.QuorumID) (*churnerpb.ChurnReply, error)
Churn(ctx context.Context, operatorAddress string, blssigner blssigner.Signer, quorumIDs []core.QuorumID) (*churnerpb.ChurnReply, error)
}

type churnerClient struct {
Expand All @@ -46,7 +46,7 @@ func NewChurnerClient(churnerURL string, useSecureGrpc bool, timeout time.Durati
func (c *churnerClient) Churn(
ctx context.Context,
operatorAddress string,
sdkSigner sdkSigner.Signer,
blssigner blssigner.Signer,
quorumIDs []core.QuorumID,
) (*churnerpb.ChurnReply, error) {
if len(quorumIDs) == 0 {
Expand All @@ -60,7 +60,7 @@ func (c *churnerClient) Churn(
}
salt := crypto.Keccak256([]byte("churn"), []byte(time.Now().String()), quorumIDs[:], bytes)

g1, g2, err := getG1G2FromSdkSigner(sdkSigner)
g1, g2, err := getG1G2Fromblssigner(blssigner)
if err != nil {
return nil, err
}
Expand All @@ -77,7 +77,7 @@ func (c *churnerClient) Churn(
// sign the request
messageHash := churner.CalculateRequestHash(churnRequest)
messageHashBytes := messageHash[:]
signatureBytes, err := sdkSigner.Sign(ctx, messageHashBytes)
signatureBytes, err := blssigner.Sign(ctx, messageHashBytes)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -128,18 +128,18 @@ func (c *churnerClient) Churn(
return gc.Churn(ctx, churnRequestPb, opt)
}

func getG1G2FromSdkSigner(sdkSigner sdkSigner.Signer) (*core.G1Point, *core.G2Point, error) {
func getG1G2Fromblssigner(blssigner blssigner.Signer) (*core.G1Point, *core.G2Point, error) {
g1 := new(core.G1Point)
g2 := new(core.G2Point)
g1KeyBytes, err := hex.DecodeString(sdkSigner.GetPublicKeyG1())
g1KeyBytes, err := hex.DecodeString(blssigner.GetPublicKeyG1())
if err != nil {
return nil, nil, err
}
g1, err = g1.Deserialize(g1KeyBytes)
if err != nil {
return nil, nil, err
}
g2KeyBytes, err := hex.DecodeString(sdkSigner.GetPublicKeyG2())
g2KeyBytes, err := hex.DecodeString(blssigner.GetPublicKeyG2())
if err != nil {
return nil, nil, err
}
Expand Down
16 changes: 8 additions & 8 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/Layr-Labs/eigenda/encoding/kzg"
"github.com/Layr-Labs/eigenda/node/flags"

sdkSignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
blssignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: all lowercase


"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -77,7 +77,7 @@ type Config struct {
ReachabilityPollIntervalSec uint64
DisableNodeInfoResources bool

BlsSignerConfig sdkSignerTypes.SignerConfig
BlsSignerConfig blssignerTypes.SignerConfig

EthClientConfig geth.EthClientConfig
LoggerConfig common.LoggerConfig
Expand Down Expand Up @@ -166,11 +166,11 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
ethClientConfig = geth.ReadEthClientConfig(ctx)
}

var blsSignerConfig sdkSignerTypes.SignerConfig
var blsSignerConfig blssignerTypes.SignerConfig
if !testMode {
blsSignerCertFilePath := ctx.GlobalString(flags.BLSSignerCertFileFlag.Name)
enableTLS := len(blsSignerCertFilePath) > 0
signerType := sdkSignerTypes.Local
signerType := blssignerTypes.Local

// check if BLS remote signer configuration is provided
blsRemoteSignerEnabled := ctx.GlobalBool(flags.BLSRemoteSignerEnabledFlag.Name)
Expand All @@ -187,10 +187,10 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
}

if blsRemoteSignerEnabled {
signerType = sdkSignerTypes.Cerberus
signerType = blssignerTypes.Cerberus
}

blsSignerConfig = sdkSignerTypes.SignerConfig{
blsSignerConfig = blssignerTypes.SignerConfig{
SignerType: signerType,
Path: blsKeyFilePath,
Password: blsKeyPassword,
Expand All @@ -202,8 +202,8 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
}
} else {
privateBls := ctx.GlobalString(flags.TestPrivateBlsFlag.Name)
blsSignerConfig = sdkSignerTypes.SignerConfig{
SignerType: sdkSignerTypes.PrivateKey,
blsSignerConfig = blssignerTypes.SignerConfig{
SignerType: blssignerTypes.PrivateKey,
PrivateKey: privateBls,
}
}
Expand Down
8 changes: 4 additions & 4 deletions node/grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"github.com/Layr-Labs/eigenda/node"
"github.com/Layr-Labs/eigenda/node/grpc"
"github.com/Layr-Labs/eigensdk-go/metrics"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
sdkSignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
"github.com/consensys/gnark-crypto/ecc/bn254/fp"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -101,8 +101,8 @@ func newTestServerWithConfig(t *testing.T, mockValidator bool, config *node.Conf
if err != nil {
panic("failed to create a BLS Key")
}
signer, err := sdkSigner.NewSigner(sdkSignerTypes.SignerConfig{
SignerType: sdkSignerTypes.PrivateKey,
signer, err := blssigner.NewSigner(blssignerTypes.SignerConfig{
SignerType: blssignerTypes.PrivateKey,
PrivateKey: keyPair.PrivKey.String(),
})
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions node/grpc/server_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/Layr-Labs/eigenda/node/grpc"
nodemock "github.com/Layr-Labs/eigenda/node/mock"
"github.com/Layr-Labs/eigensdk-go/metrics"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
sdkSignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -57,8 +57,8 @@ func newTestComponents(t *testing.T, config *node.Config) *testComponents {
keyPair, err := core.GenRandomBlsKeys()
require.NoError(t, err)
require.NoError(t, err)
signer, err := sdkSigner.NewSigner(sdkSignerTypes.SignerConfig{
SignerType: sdkSignerTypes.PrivateKey,
signer, err := blssigner.NewSigner(blssignerTypes.SignerConfig{
SignerType: blssignerTypes.PrivateKey,
PrivateKey: keyPair.PrivKey.String(),
})
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions node/mock/churner_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
churnerpb "github.com/Layr-Labs/eigenda/api/grpc/churner"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/node"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
"github.com/stretchr/testify/mock"
)

Expand All @@ -16,7 +16,7 @@ type ChurnerClient struct {

var _ node.ChurnerClient = (*ChurnerClient)(nil)

func (c *ChurnerClient) Churn(ctx context.Context, operatorAddress string, signer sdkSigner.Signer, quorumIDs []core.QuorumID) (*churnerpb.ChurnReply, error) {
func (c *ChurnerClient) Churn(ctx context.Context, operatorAddress string, signer blssigner.Signer, quorumIDs []core.QuorumID) (*churnerpb.ChurnReply, error) {
args := c.Called()
var reply *churnerpb.ChurnReply
if args.Get(0) != nil {
Expand Down
6 changes: 3 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigensdk-go/metrics"
"github.com/Layr-Labs/eigensdk-go/nodeapi"
sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls"
blssigner "github.com/Layr-Labs/eigensdk-go/signer/bls"

"github.com/gammazero/workerpool"
)
Expand Down Expand Up @@ -75,7 +75,7 @@ type Node struct {
ChainID *big.Int
BLSPublicKeyHex string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this as a separate field? could we infer this from BlsSigner?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. No. will remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


BlsSigner sdkSigner.Signer
BlsSigner blssigner.Signer

RelayClient atomic.Value

Expand Down Expand Up @@ -125,7 +125,7 @@ func NewNode(
// Create ChainState Client
cst := eth.NewChainState(tx, client)

blsSigner, err := sdkSigner.NewSigner(config.BlsSignerConfig)
blsSigner, err := blssigner.NewSigner(config.BlsSignerConfig)
if err != nil {
return nil, fmt.Errorf("failed to create BLS signer: %w", err)
}
Expand Down
Loading