diff --git a/app/abci/vote_extension_test.go b/app/abci/vote_extension_test.go index 280b5942..7d6bd6b6 100644 --- a/app/abci/vote_extension_test.go +++ b/app/abci/vote_extension_test.go @@ -38,8 +38,7 @@ func (m *mockSigner) Sign(input []byte, _ utils.SEDAKeyIndex) ([]byte, error) { if err != nil { return nil, err } - hash := crypto.Keccak256Hash(input) - signature, err := crypto.Sign(hash.Bytes(), privKey) + signature, err := crypto.Sign(input, privKey) if err != nil { return nil, err } @@ -101,8 +100,7 @@ func TestExtendVerifyVoteHandlers(t *testing.T) { require.NoError(t, err) // Recover and verify public key - hash := crypto.Keccak256Hash(mockBatch.BatchId) - sigPubKey, err := crypto.Ecrecover(hash.Bytes(), evRes.VoteExtension) + sigPubKey, err := crypto.Ecrecover(mockBatch.BatchId, evRes.VoteExtension) require.NoError(t, err) require.Equal(t, expPubKey, sigPubKey) diff --git a/app/utils/seda_keys.go b/app/utils/seda_keys.go index ef98146e..9c9315a7 100644 --- a/app/utils/seda_keys.go +++ b/app/utils/seda_keys.go @@ -166,14 +166,16 @@ func LoadSEDASigner(loadPath string) (SEDASigner, error) { return &sedaKeys{keys: keys}, nil } +// Sign returns the signature for the a given hashed input using the +// key at the given index. func (s *sedaKeys) Sign(input []byte, index SEDAKeyIndex) ([]byte, error) { privKey, err := ethcrypto.ToECDSA(s.keys[index].PrivKey.Bytes()) if err != nil { return nil, err } - hash := ethcrypto.Keccak256Hash(input) - signature, err := ethcrypto.Sign(hash.Bytes(), privKey) + // ethcrypto library already checks if input is 32 bytes (digest length) + signature, err := ethcrypto.Sign(input, privKey) if err != nil { return nil, err }