diff --git a/node/churner_client.go b/node/churner_client.go index 335edbc914..bdbb2aa03b 100644 --- a/node/churner_client.go +++ b/node/churner_client.go @@ -2,6 +2,7 @@ package node import ( "context" + "crypto/rand" "crypto/tls" "errors" "time" @@ -45,8 +46,12 @@ func (c *churnerClient) Churn(ctx context.Context, operatorAddress string, keyPa return nil, errors.New("quorumIDs cannot be empty") } // generate salt - privateKeyBytes := []byte(keyPair.PrivKey.String()) - salt := crypto.Keccak256([]byte("churn"), []byte(time.Now().String()), quorumIDs[:], privateKeyBytes) + bytes := make([]byte, 32) + _, err := rand.Read(bytes) + if err != nil { + return nil, err + } + salt := crypto.Keccak256([]byte("churn"), []byte(time.Now().String()), quorumIDs[:], bytes) churnRequest := &churner.ChurnRequest{ OperatorAddress: gethcommon.HexToAddress(operatorAddress), diff --git a/node/operator.go b/node/operator.go index 10d2cf88ff..5a73ca72e0 100644 --- a/node/operator.go +++ b/node/operator.go @@ -3,6 +3,7 @@ package node import ( "context" "crypto/ecdsa" + "crypto/rand" "errors" "fmt" "math/big" @@ -70,10 +71,13 @@ func RegisterOperator(ctx context.Context, operator *Operator, transactor core.W logger.Info("Should call churner", "shouldCallChurner", shouldCallChurner) // Generate salt and expiry - - privateKeyBytes := []byte(operator.KeyPair.PrivKey.String()) + bytes := make([]byte, 32) + _, err = rand.Read(bytes) + if err != nil { + return err + } salt := [32]byte{} - copy(salt[:], crypto.Keccak256([]byte("churn"), []byte(time.Now().String()), quorumsToRegister, privateKeyBytes)) + copy(salt[:], crypto.Keccak256([]byte("churn"), []byte(time.Now().String()), quorumsToRegister, bytes)) // Get the current block number expiry := big.NewInt((time.Now().Add(10 * time.Minute)).Unix())