diff --git a/core/chainio.go b/core/chainio.go index e28572832a..4a708bd04c 100644 --- a/core/chainio.go +++ b/core/chainio.go @@ -6,6 +6,7 @@ import ( "math/big" "github.com/Layr-Labs/eigenda/api/grpc/churner" + sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" ) @@ -143,6 +144,7 @@ type Writer interface { RegisterOperator( ctx context.Context, keypair *KeyPair, + signer sdkSigner.Signer, socket string, quorumIds []QuorumID, operatorEcdsaPrivateKey *ecdsa.PrivateKey, @@ -155,6 +157,7 @@ type Writer interface { RegisterOperatorWithChurn( ctx context.Context, keypair *KeyPair, + signer sdkSigner.Signer, socket string, quorumIds []QuorumID, operatorEcdsaPrivateKey *ecdsa.PrivateKey, diff --git a/core/eth/reader.go b/core/eth/reader.go index a0c4364c1a..8822513731 100644 --- a/core/eth/reader.go +++ b/core/eth/reader.go @@ -3,6 +3,7 @@ package eth import ( "context" "crypto/ecdsa" + "encoding/hex" "math/big" "strings" @@ -27,6 +28,8 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/pingcap/errors" + + sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls" ) type ContractBindings struct { @@ -269,6 +272,7 @@ func (t *Reader) GetRegisteredQuorumIdsForOperator(ctx context.Context, operator func (t *Reader) getRegistrationParams( ctx context.Context, keypair *core.KeyPair, + sdkSigner sdkSigner.Signer, operatorEcdsaPrivateKey *ecdsa.PrivateKey, operatorToAvsRegistrationSigSalt [32]byte, operatorToAvsRegistrationSigExpiry *big.Int, @@ -283,20 +287,50 @@ func (t *Reader) getRegistrationParams( return nil, nil, err } + msgToSignG1 := core.NewG1Point(msgToSignG1_.X, msgToSignG1_.Y) - signature := keypair.SignHashedToCurveMessage(msgToSignG1) + sigBytes, err := sdkSigner.SignG1(ctx, msgToSignG1.Serialize()) + if err != nil { + return nil, nil, err + } + sig := new(core.Signature) + signature, err := sig.Deserialize(sigBytes) + if err != nil { + return nil, nil, err + } signedMessageHashParam := regcoordinator.BN254G1Point{ X: signature.X.BigInt(big.NewInt(0)), Y: signature.Y.BigInt(big.NewInt(0)), } - g1Point_ := pubKeyG1ToBN254G1Point(keypair.GetPubKeyG1()) + g1KeyHex := sdkSigner.GetPublicKeyG1() + g1KeyBytes, err := hex.DecodeString(g1KeyHex) + if err != nil { + return nil, nil, err + } + g1point := new(core.G1Point) + _, err = g1point.Deserialize(g1KeyBytes) + if err != nil { + return nil, nil, err + } + g1Point_ := pubKeyG1ToBN254G1Point(g1point) g1Point := regcoordinator.BN254G1Point{ X: g1Point_.X, Y: g1Point_.Y, } - g2Point_ := pubKeyG2ToBN254G2Point(keypair.GetPubKeyG2()) + + g2KeyHex := sdkSigner.GetPublicKeyG2() + g2KeyBytes, err := hex.DecodeString(g2KeyHex) + if err != nil { + return nil, nil, err + } + g2point := new(core.G2Point) + _, err = g2point.Deserialize(g2KeyBytes) + if err != nil { + return nil, nil, err + } + g2Point_ := pubKeyG2ToBN254G2Point(g2point) g2Point := regcoordinator.BN254G2Point{ X: g2Point_.X, Y: g2Point_.Y, diff --git a/core/eth/writer.go b/core/eth/writer.go index d088b6871f..3d71092a37 100644 --- a/core/eth/writer.go +++ b/core/eth/writer.go @@ -14,6 +14,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" "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -59,6 +60,7 @@ func NewWriter( func (t *Writer) RegisterOperator( ctx context.Context, keypair *core.KeyPair, + signer sdkSigner.Signer, socket string, quorumIds []core.QuorumID, operatorEcdsaPrivateKey *ecdsa.PrivateKey, @@ -66,7 +68,7 @@ func (t *Writer) RegisterOperator( operatorToAvsRegistrationSigExpiry *big.Int, ) error { - params, operatorSignature, err := t.getRegistrationParams(ctx, keypair, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry) + params, operatorSignature, err := t.getRegistrationParams(ctx, keypair, signer, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry) if err != nil { t.logger.Error("Failed to get registration params", "err", err) return err @@ -99,6 +101,7 @@ func (t *Writer) RegisterOperator( func (t *Writer) RegisterOperatorWithChurn( ctx context.Context, keypair *core.KeyPair, + signer sdkSigner.Signer, socket string, quorumIds []core.QuorumID, operatorEcdsaPrivateKey *ecdsa.PrivateKey, @@ -107,7 +110,7 @@ func (t *Writer) RegisterOperatorWithChurn( churnReply *churner.ChurnReply, ) error { - params, operatorSignature, err := t.getRegistrationParams(ctx, keypair, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry) + params, operatorSignature, err := t.getRegistrationParams(ctx, keypair, signer, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry) if err != nil { t.logger.Error("Failed to get registration params", "err", err) return err diff --git a/core/indexer/state_test.go b/core/indexer/state_test.go index 06b62f28cd..d1f4714c5d 100644 --- a/core/indexer/state_test.go +++ b/core/indexer/state_test.go @@ -27,6 +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" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" @@ -51,6 +53,12 @@ func mustRegisterOperators(env *deploy.Config, logger logging.Logger) { for _, op := range env.Operators { tx := mustMakeOperatorTransactor(env, op, logger) + signer, err := sdkSigner.NewSigner(sdkSignerTypes.SignerConfig{ + PrivateKey: op.NODE_TEST_PRIVATE_BLS, + SignerType: sdkSignerTypes.PrivateKey, + }) + Expect(err).To(BeNil()) + keyPair, err := core.MakeKeyPairFromString(op.NODE_TEST_PRIVATE_BLS) Expect(err).To(BeNil()) @@ -64,7 +72,7 @@ func mustRegisterOperators(env *deploy.Config, logger logging.Logger) { privKey, err := crypto.HexToECDSA(op.NODE_PRIVATE_KEY) Expect(err).To(BeNil()) - err = tx.RegisterOperator(context.Background(), keyPair, socket, quorums, privKey, salt, expiry) + err = tx.RegisterOperator(context.Background(), keyPair, signer, socket, quorums, privKey, salt, expiry) Expect(err).To(BeNil()) } } diff --git a/core/mock/state.go b/core/mock/state.go index 2c2934357c..44970cbfd0 100644 --- a/core/mock/state.go +++ b/core/mock/state.go @@ -8,6 +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" "github.com/stretchr/testify/mock" ) @@ -25,6 +27,7 @@ var _ core.IndexedChainState = (*ChainDataMock)(nil) type PrivateOperatorInfo struct { *core.IndexedOperatorInfo KeyPair *core.KeyPair + Signer sdkSigner.Signer Host string DispersalPort string RetrievalPort string @@ -143,9 +146,15 @@ func (d *ChainDataMock) GetTotalOperatorStateWithQuorums(ctx context.Context, bl PubkeyG2: d.KeyPairs[id].GetPubKeyG2(), } + signer, _ := sdkSigner.NewSigner(sdkSignerTypes.SignerConfig{ + PrivateKey: d.KeyPairs[id].PrivKey.String(), + SignerType: sdkSignerTypes.Local, + }) + private := &PrivateOperatorInfo{ IndexedOperatorInfo: indexed, KeyPair: d.KeyPairs[id], + Signer: signer, Host: host, DispersalPort: dispersalPort, RetrievalPort: retrievalPort, diff --git a/core/mock/writer.go b/core/mock/writer.go index b28f88b5f1..06c0e4dfab 100644 --- a/core/mock/writer.go +++ b/core/mock/writer.go @@ -7,6 +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" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/mock" @@ -39,26 +40,28 @@ func (t *MockWriter) GetRegisteredQuorumIdsForOperator(ctx context.Context, oper func (t *MockWriter) RegisterOperator( ctx context.Context, keypair *core.KeyPair, + signer sdkSigner.Signer, socket string, quorumIds []core.QuorumID, operatorEcdsaPrivateKey *ecdsa.PrivateKey, operatorToAvsRegistrationSigSalt [32]byte, operatorToAvsRegistrationSigExpiry *big.Int, ) error { - args := t.Called(ctx, keypair, socket, quorumIds, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry) + args := t.Called(ctx, keypair, signer, socket, quorumIds, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry) return args.Error(0) } func (t *MockWriter) RegisterOperatorWithChurn( ctx context.Context, keypair *core.KeyPair, + signer sdkSigner.Signer, socket string, quorumIds []core.QuorumID, operatorEcdsaPrivateKey *ecdsa.PrivateKey, operatorToAvsRegistrationSigSalt [32]byte, operatorToAvsRegistrationSigExpiry *big.Int, churnReply *churner.ChurnReply) error { - args := t.Called(ctx, keypair, socket, quorumIds, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry, churnReply) + args := t.Called(ctx, keypair, signer, socket, quorumIds, operatorEcdsaPrivateKey, operatorToAvsRegistrationSigSalt, operatorToAvsRegistrationSigExpiry, churnReply) return args.Error(0) } diff --git a/disperser/dataapi/v2/server_v2_test.go b/disperser/dataapi/v2/server_v2_test.go index cf731ae166..51994f2e0b 100644 --- a/disperser/dataapi/v2/server_v2_test.go +++ b/disperser/dataapi/v2/server_v2_test.go @@ -64,7 +64,7 @@ var ( dockertestResource *dockertest.Resource deployLocalStack bool - mockLogger = logging.NewNoopLogger() + mockLogger = testutils.GetLogger() blobstore = inmem.NewBlobStore() mockPrometheusApi = &prommock.MockPrometheusApi{} prometheusClient = dataapi.NewPrometheusClient(mockPrometheusApi, "test-cluster") diff --git a/go.mod b/go.mod index 7bcded79af..b66b69490c 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,10 @@ module github.com/Layr-Labs/eigenda -go 1.21 - -toolchain go1.21.1 +go 1.21.13 require ( - github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241211213446-c5ffb53d14b0 - github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20241211213446-c5ffb53d14b0 + github.com/Layr-Labs/eigensdk-go v0.2.0-beta.1.0.20250108183217-59122e8557bc + github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20250108183217-59122e8557bc github.com/aws/aws-sdk-go-v2 v1.26.1 github.com/aws/aws-sdk-go-v2/credentials v1.17.11 github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.13.12 @@ -47,7 +45,7 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/KyleBanks/depth v1.2.1 // indirect - github.com/Layr-Labs/cerberus-api v0.0.1 // indirect + github.com/Layr-Labs/cerberus-api v0.0.2-0.20250108174619-d5e1eb03fbd5 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect diff --git a/go.sum b/go.sum index 67747814cb..f567bc2588 100644 --- a/go.sum +++ b/go.sum @@ -8,12 +8,14 @@ github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -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/eigensdk-go v0.1.14-0.20241211213446-c5ffb53d14b0 h1:w8JMZum+by34GhtswK19r2jkSaZb8Y9fOEijAv1wJAA= -github.com/Layr-Labs/eigensdk-go v0.1.14-0.20241211213446-c5ffb53d14b0/go.mod h1:aYdNURUhaqeYOS+Cq12TfSdPbjFfiLaHkxPdR4Exq/s= -github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20241211213446-c5ffb53d14b0 h1:Zf/bwHZlX+4anEkPLz2l9WSYPxTfACxNulgSupqxTGk= -github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20241211213446-c5ffb53d14b0/go.mod h1:ibvhYLQhmBqj+MqI+gjY2nRw7+QcbbLhHOBageOA0zY= +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/eigensdk-go v0.2.0-beta.1.0.20250108021201-9313acc6a60a h1:79C0Rti47GLaViqq6oS6cZKsyq/ccwVsyK0WIWZNSIM= +github.com/Layr-Labs/eigensdk-go v0.2.0-beta.1.0.20250108021201-9313acc6a60a/go.mod h1:G4yqiK+5NfUuEMVGGncOEm7QskuGRPmKA7bKxpPzPT4= +github.com/Layr-Labs/eigensdk-go v0.2.0-beta.1.0.20250108183217-59122e8557bc h1:NMM+LULjQu8vSbDtWSxWFDCEb16hCNILp+ZD1JLpc6U= +github.com/Layr-Labs/eigensdk-go v0.2.0-beta.1.0.20250108183217-59122e8557bc/go.mod h1:G4yqiK+5NfUuEMVGGncOEm7QskuGRPmKA7bKxpPzPT4= +github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20250108183217-59122e8557bc h1:dKLTQUvD4Bd+A7Yoj06Al+eWVSxlWk7x8/f/ZTKqYsQ= +github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20250108183217-59122e8557bc/go.mod h1:p/coyQpMG0aaF+JekxNoacPWP6FqSuWLI2YpiC+YVKs= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= diff --git a/node/churner_client.go b/node/churner_client.go index bdbb2aa03b..abcb8dfbe0 100644 --- a/node/churner_client.go +++ b/node/churner_client.go @@ -4,6 +4,7 @@ import ( "context" "crypto/rand" "crypto/tls" + "encoding/hex" "errors" "time" @@ -11,6 +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" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "google.golang.org/grpc" @@ -22,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, keyPair *core.KeyPair, quorumIDs []core.QuorumID) (*churnerpb.ChurnReply, error) + Churn(ctx context.Context, operatorAddress string, keyPair *core.KeyPair, sdkSigner sdkSigner.Signer, quorumIDs []core.QuorumID) (*churnerpb.ChurnReply, error) } type churnerClient struct { @@ -41,7 +43,13 @@ func NewChurnerClient(churnerURL string, useSecureGrpc bool, timeout time.Durati } } -func (c *churnerClient) Churn(ctx context.Context, operatorAddress string, keyPair *core.KeyPair, quorumIDs []core.QuorumID) (*churnerpb.ChurnReply, error) { +func (c *churnerClient) Churn( + ctx context.Context, + operatorAddress string, + keyPair *core.KeyPair, + sdkSigner sdkSigner.Signer, + quorumIDs []core.QuorumID, +) (*churnerpb.ChurnReply, error) { if len(quorumIDs) == 0 { return nil, errors.New("quorumIDs cannot be empty") } @@ -53,10 +61,14 @@ func (c *churnerClient) Churn(ctx context.Context, operatorAddress string, keyPa } salt := crypto.Keccak256([]byte("churn"), []byte(time.Now().String()), quorumIDs[:], bytes) + g1, g2, err := getG1G2FromSdkSigner(sdkSigner) + if err != nil { + return nil, err + } churnRequest := &churner.ChurnRequest{ OperatorAddress: gethcommon.HexToAddress(operatorAddress), - OperatorToRegisterPubkeyG1: keyPair.PubKey, - OperatorToRegisterPubkeyG2: keyPair.GetPubKeyG2(), + OperatorToRegisterPubkeyG1: g1, + OperatorToRegisterPubkeyG2: g2, OperatorRequestSignature: &core.Signature{}, QuorumIDs: quorumIDs, } @@ -64,7 +76,21 @@ func (c *churnerClient) Churn(ctx context.Context, operatorAddress string, keyPa copy(churnRequest.Salt[:], salt) // sign the request - churnRequest.OperatorRequestSignature = keyPair.SignMessage(churner.CalculateRequestHash(churnRequest)) + messageHash := churner.CalculateRequestHash(churnRequest) + var messageHashBytes []byte + copy(messageHashBytes, messageHash[:]) + signatureBytes, err := sdkSigner.Sign(ctx, messageHashBytes) + if err != nil { + return nil, err + } + signature := new(core.Signature) + g1Signature, err := signature.Deserialize(signatureBytes) + if err != nil { + return nil, err + } + churnRequest.OperatorRequestSignature = &core.Signature{ + G1Point: g1Signature, + } // convert to protobuf churnRequestPb := &churnerpb.ChurnRequest{ @@ -103,3 +129,25 @@ func (c *churnerClient) Churn(ctx context.Context, operatorAddress string, keyPa return gc.Churn(ctx, churnRequestPb, opt) } + +func getG1G2FromSdkSigner(sdkSigner sdkSigner.Signer) (*core.G1Point, *core.G2Point, error) { + g1 := new(core.G1Point) + g2 := new(core.G2Point) + g1KeyBytes, err := hex.DecodeString(sdkSigner.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()) + if err != nil { + return nil, nil, err + } + g2, err = g2.Deserialize(g2KeyBytes) + if err != nil { + return nil, nil, err + } + return g1, g2, nil +} diff --git a/node/config.go b/node/config.go index 5d3e3770f2..45676d8801 100644 --- a/node/config.go +++ b/node/config.go @@ -63,7 +63,6 @@ type Config struct { QuorumIDList []core.QuorumID DbPath string LogPath string - PrivateBls string ID core.OperatorID BLSOperatorStateRetrieverAddr string EigenDAServiceManagerAddr string @@ -156,8 +155,6 @@ func NewConfig(ctx *cli.Context) (*Config, error) { ethClientConfig = geth.ReadEthClientConfig(ctx) } - // Decrypt BLS key - var privateBls string var blsSignerConfig sdkSignerTypes.SignerConfig if !testMode { blsSignerCertFilePath := ctx.GlobalString(flags.BLSSignerCertFileFlag.Name) @@ -193,7 +190,11 @@ func NewConfig(ctx *cli.Context) (*Config, error) { TLSCertFilePath: ctx.GlobalString(flags.BLSSignerCertFileFlag.Name), } } else { - privateBls = ctx.GlobalString(flags.TestPrivateBlsFlag.Name) + privateBls := ctx.GlobalString(flags.TestPrivateBlsFlag.Name) + blsSignerConfig = sdkSignerTypes.SignerConfig{ + SignerType: sdkSignerTypes.PrivateKey, + PrivateKey: privateBls, + } } internalDispersalFlag := ctx.GlobalString(flags.InternalDispersalPortFlag.Name) @@ -230,7 +231,6 @@ func NewConfig(ctx *cli.Context) (*Config, error) { OverrideStoreDurationBlocks: ctx.GlobalInt64(flags.OverrideStoreDurationBlocksFlag.Name), QuorumIDList: ids, DbPath: ctx.GlobalString(flags.DbPathFlag.Name), - PrivateBls: privateBls, EthClientConfig: ethClientConfig, EncoderConfig: kzg.ReadCLIConfig(ctx), LoggerConfig: *loggerConfig, diff --git a/node/mock/churner_client.go b/node/mock/churner_client.go index a69d4f4eb7..382404c844 100644 --- a/node/mock/churner_client.go +++ b/node/mock/churner_client.go @@ -6,6 +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" "github.com/stretchr/testify/mock" ) @@ -15,7 +16,7 @@ type ChurnerClient struct { var _ node.ChurnerClient = (*ChurnerClient)(nil) -func (c *ChurnerClient) Churn(ctx context.Context, operatorAddress string, keyPair *core.KeyPair, quorumIDs []core.QuorumID) (*churnerpb.ChurnReply, error) { +func (c *ChurnerClient) Churn(ctx context.Context, operatorAddress string, keyPair *core.KeyPair, signer sdkSigner.Signer, quorumIDs []core.QuorumID) (*churnerpb.ChurnReply, error) { args := c.Called() var reply *churnerpb.ChurnReply if args.Get(0) != nil { diff --git a/node/node.go b/node/node.go index f1f122d5f7..643a0dc08a 100644 --- a/node/node.go +++ b/node/node.go @@ -131,34 +131,18 @@ func NewNode( // Create ChainState Client cst := eth.NewChainState(tx, client) - var keyPair *core.KeyPair - var blsSigner sdkSigner.Signer - var blsPublicKeyHex string - if config.PrivateBls != "" { - nodeLogger.Info("using local keystore private key for BLS signing") - // Generate BLS keys - keyPair, err = core.MakeKeyPairFromString(config.PrivateBls) - if err != nil { - return nil, err - } - - config.ID = keyPair.GetPubKeyG1().GetOperatorID() - blsPublicKeyHex = hex.EncodeToString(keyPair.PubKey.Serialize()) - } else { - nodeLogger.Info("using eigensdk BLS signer for BLS signing") - blsSigner, err = sdkSigner.NewSigner(config.BlsSignerConfig) - if err != nil { - return nil, fmt.Errorf("failed to create BLS signer: %w", err) - } - operatorID, err := blsSigner.GetOperatorId() - if err != nil { - return nil, fmt.Errorf("failed to get operator ID: %w", err) - } - config.ID, err = core.OperatorIDFromHex(operatorID) - if err != nil { - return nil, fmt.Errorf("failed to convert operator ID: %w", err) - } - blsPublicKeyHex = blsSigner.GetPublicKeyHex() + blsSigner, err := sdkSigner.NewSigner(config.BlsSignerConfig) + if err != nil { + return nil, fmt.Errorf("failed to create BLS signer: %w", err) + } + blsPublicKeyHex := blsSigner.GetPublicKeyG1() + operatorID, err := blsSigner.GetOperatorId() + if err != nil { + return nil, fmt.Errorf("failed to get operator ID: %w", err) + } + config.ID, err = core.OperatorIDFromHex(operatorID) + if err != nil { + return nil, fmt.Errorf("failed to convert operator ID: %w", err) } // Setup Node Api @@ -216,7 +200,6 @@ func NewNode( n := &Node{ Config: config, Logger: nodeLogger, - KeyPair: keyPair, Metrics: metrics, NodeApi: nodeApi, Store: store, @@ -585,11 +568,6 @@ func (n *Node) ProcessBatch(ctx context.Context, header *core.BatchHeader, blobs } func (n *Node) SignMessage(ctx context.Context, data [32]byte) (*core.Signature, error) { - // This use case is only used for testing purposes. - if n.KeyPair != nil { - return n.KeyPair.SignMessage(data), nil - } - signature, err := n.BlsSigner.Sign(ctx, data[:]) if err != nil { return nil, fmt.Errorf("failed to sign message: %w", err) diff --git a/node/operator.go b/node/operator.go index 5a73ca72e0..fe2f0d6683 100644 --- a/node/operator.go +++ b/node/operator.go @@ -12,6 +12,7 @@ import ( "github.com/Layr-Labs/eigenda/core" "github.com/Layr-Labs/eigensdk-go/logging" + sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls" "github.com/ethereum/go-ethereum/crypto" ) @@ -21,6 +22,7 @@ type Operator struct { Timeout time.Duration PrivKey *ecdsa.PrivateKey KeyPair *core.KeyPair + Signer sdkSigner.Signer OperatorId core.OperatorID QuorumIDs []core.QuorumID RegisterNodeAtStart bool @@ -84,15 +86,15 @@ func RegisterOperator(ctx context.Context, operator *Operator, transactor core.W // if we should call the churner, call it if shouldCallChurner { - churnReply, err := churnerClient.Churn(ctx, operator.Address, operator.KeyPair, quorumsToRegister) + churnReply, err := churnerClient.Churn(ctx, operator.Address, operator.KeyPair, operator.Signer, quorumsToRegister) if err != nil { return fmt.Errorf("failed to request churn approval: %w", err) } - return transactor.RegisterOperatorWithChurn(ctx, operator.KeyPair, operator.Socket, quorumsToRegister, operator.PrivKey, salt, expiry, churnReply) + return transactor.RegisterOperatorWithChurn(ctx, operator.KeyPair, operator.Signer, operator.Socket, quorumsToRegister, operator.PrivKey, salt, expiry, churnReply) } else { // other wise just register normally - return transactor.RegisterOperator(ctx, operator.KeyPair, operator.Socket, quorumsToRegister, operator.PrivKey, salt, expiry) + return transactor.RegisterOperator(ctx, operator.KeyPair, operator.Signer, operator.Socket, quorumsToRegister, operator.PrivKey, salt, expiry) } } diff --git a/node/operator_test.go b/node/operator_test.go index bf33637a31..f786d35468 100644 --- a/node/operator_test.go +++ b/node/operator_test.go @@ -15,6 +15,8 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls" + sdkSignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types" ) func TestRegisterOperator(t *testing.T) { @@ -22,6 +24,11 @@ func TestRegisterOperator(t *testing.T) { operatorID := [32]byte(hexutil.MustDecode("0x3fbfefcdc76462d2cdb7d0cea75f27223829481b8b4aa6881c94cb2126a316ad")) keyPair, err := core.GenRandomBlsKeys() assert.NoError(t, err) + signer, err := sdkSigner.NewSigner(sdkSignerTypes.SignerConfig{ + PrivateKey: keyPair.PrivKey.String(), + SignerType: sdkSignerTypes.Local, + }) + assert.NoError(t, err) // Create a new operator operator := &node.Operator{ Address: "0xB7Ad27737D88B07De48CDc2f379917109E993Be4", @@ -29,6 +36,7 @@ func TestRegisterOperator(t *testing.T) { Timeout: 10 * time.Second, PrivKey: nil, KeyPair: keyPair, + Signer: signer, OperatorId: operatorID, QuorumIDs: []core.QuorumID{0, 1}, RegisterNodeAtStart: false, diff --git a/node/plugin/cmd/main.go b/node/plugin/cmd/main.go index 6fa489c203..da7508f6a3 100644 --- a/node/plugin/cmd/main.go +++ b/node/plugin/cmd/main.go @@ -68,6 +68,7 @@ func pluginOps(ctx *cli.Context) { } log.Printf("Info: Bls key read and decrypted from %s", config.BlsKeyFile) + // TODO(madhur): use sdkSigner operatorID := keyPair.GetPubKeyG1().GetOperatorID() sk, privateKey, err := plugin.GetECDSAPrivateKey(config.EcdsaKeyFile, config.EcdsaKeyPassword) diff --git a/operators/churner/tests/churner_test.go b/operators/churner/tests/churner_test.go index 6267667fd1..d0a2ef500d 100644 --- a/operators/churner/tests/churner_test.go +++ b/operators/churner/tests/churner_test.go @@ -24,6 +24,8 @@ import ( "github.com/Layr-Labs/eigenda/operators/churner" "github.com/Layr-Labs/eigensdk-go/crypto/bls" "github.com/Layr-Labs/eigensdk-go/logging" + sdkSigner "github.com/Layr-Labs/eigensdk-go/signer/bls" + sdkSignerTypes "github.com/Layr-Labs/eigensdk-go/signer/bls/types" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/assert" @@ -104,8 +106,15 @@ func TestChurner(t *testing.T) { var tx *eth.Writer var operatorPrivateKey *ecdsa.PrivateKey var keyPair *dacore.KeyPair + var signer sdkSigner.Signer for i, op := range testConfig.Operators { socket := fmt.Sprintf("%s:%s:%s", op.NODE_HOSTNAME, op.NODE_DISPERSAL_PORT, op.NODE_RETRIEVAL_PORT) + opSigner, err := sdkSigner.NewSigner(sdkSignerTypes.SignerConfig{ + Path: op.NODE_BLS_KEY_FILE, + Password: op.NODE_BLS_KEY_PASSWORD, + SignerType: sdkSignerTypes.Local, + }) + assert.NoError(t, err) kp, err := bls.ReadPrivateKeyFromFile(op.NODE_BLS_KEY_FILE, op.NODE_BLS_KEY_PASSWORD) assert.NoError(t, err) g1point := &core.G1Point{ @@ -131,10 +140,11 @@ func TestChurner(t *testing.T) { // This operator will churn others operatorAddr = sk.Address.Hex() keyPair = opKeyPair + signer = opSigner operatorPrivateKey = sk.PrivateKey break } - err = tx.RegisterOperator(ctx, opKeyPair, socket, quorumIDsUint8, sk.PrivateKey, salt, expiry) + err = tx.RegisterOperator(ctx, opKeyPair, opSigner, socket, quorumIDsUint8, sk.PrivateKey, salt, expiry) assert.NoError(t, err) } assert.Greater(t, len(lowestStakeOperatorAddr), 0) @@ -184,7 +194,7 @@ func TestChurner(t *testing.T) { salt32 := [32]byte{} copy(salt32[:], salt) expiry := big.NewInt((time.Now().Add(10 * time.Minute)).Unix()) - err = tx.RegisterOperatorWithChurn(ctx, keyPair, "localhost:8080", quorumIDsUint8, operatorPrivateKey, salt32, expiry, reply) + err = tx.RegisterOperatorWithChurn(ctx, keyPair, signer, "localhost:8080", quorumIDsUint8, operatorPrivateKey, salt32, expiry, reply) assert.NoError(t, err) } diff --git a/retriever/v2/server_test.go b/retriever/v2/server_test.go index 5585c9d4f3..d74b27f236 100644 --- a/retriever/v2/server_test.go +++ b/retriever/v2/server_test.go @@ -10,6 +10,7 @@ import ( commonpb "github.com/Layr-Labs/eigenda/api/grpc/common" commonpbv2 "github.com/Layr-Labs/eigenda/api/grpc/common/v2" pb "github.com/Layr-Labs/eigenda/api/grpc/retriever/v2" + "github.com/Layr-Labs/eigenda/common/testutils" "github.com/Layr-Labs/eigenda/core" coremock "github.com/Layr-Labs/eigenda/core/mock" "github.com/Layr-Labs/eigenda/encoding" @@ -19,7 +20,6 @@ import ( "github.com/Layr-Labs/eigenda/encoding/utils/codec" "github.com/Layr-Labs/eigenda/retriever/mock" retriever "github.com/Layr-Labs/eigenda/retriever/v2" - "github.com/Layr-Labs/eigensdk-go/logging" "github.com/consensys/gnark-crypto/ecc/bn254" "github.com/consensys/gnark-crypto/ecc/bn254/fp" "github.com/stretchr/testify/require" @@ -62,7 +62,7 @@ func newTestServer(t *testing.T) *retriever.Server { var err error config := &retriever.Config{} - logger := logging.NewNoopLogger() + logger := testutils.GetLogger() indexedChainState, err = coremock.MakeChainDataMock(map[uint8]int{ 0: numOperators, diff --git a/test/integration_test.go b/test/integration_test.go index 2ca442c940..d777e7d114 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -362,7 +362,6 @@ func mustMakeOperators(t *testing.T, cst *coremock.ChainDataMock, logger logging ExpirationPollIntervalSec: 10, DbPath: dbPath, LogPath: logPath, - PrivateBls: string(op.KeyPair.GetPubKeyG1().Serialize()), ID: id, QuorumIDList: registeredQuorums, } @@ -409,6 +408,7 @@ func mustMakeOperators(t *testing.T, cst *coremock.ChainDataMock, logger logging Config: config, Logger: logger, KeyPair: op.KeyPair, + BlsSigner: op.Signer, Metrics: metrics, Store: store, ChainState: cst,