diff --git a/resign.go b/resign.go index e95a876..b3da777 100644 --- a/resign.go +++ b/resign.go @@ -1,6 +1,7 @@ package spec import ( + "bytes" "fmt" "github.com/attestantio/go-eth2-client/spec/phase0" @@ -14,6 +15,9 @@ func ValidateResignMessage( operator *Operator, proof *SignedProof, ) error { + if !bytes.Equal(resign.Owner[:], proof.Proof.Owner[:]) { + return fmt.Errorf("invalid owner address") + } if !ValidAmountSet(phase0.Gwei(resign.Amount)) { return fmt.Errorf("amount should be in range between 32 ETH and 2048 ETH") } diff --git a/testing/resign_test.go b/testing/resign_test.go index ae9d768..c8ab9e6 100644 --- a/testing/resign_test.go +++ b/testing/resign_test.go @@ -225,8 +225,8 @@ func TestValidateResign(t *testing.T) { )) }) - t.Run("add owner address", func(t *testing.T) { - require.NoError(t, spec.ValidateResignMessage(&spec.Resign{ + t.Run("invalid owner address", func(t *testing.T) { + require.EqualError(t, spec.ValidateResignMessage(&spec.Resign{ ValidatorPubKey: fixtures.ShareSK(fixtures.TestValidator4Operators).GetPublicKey().Serialize(), WithdrawalCredentials: fixtures.TestWithdrawalCred, Fork: fixtures.TestFork, @@ -235,7 +235,7 @@ func TestValidateResign(t *testing.T) { Amount: uint64(crypto.MAX_EFFECTIVE_BALANCE), }, fixtures.GenerateOperators(4)[0], - &fixtures.TestOperator1Proof4Operators)) + &fixtures.TestOperator1Proof4Operators), "invalid owner address") }) t.Run("invalid proof", func(t *testing.T) {