Skip to content

Commit

Permalink
chg: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcello33 committed Mar 13, 2024
1 parent f98b3ae commit 722da0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crypto/keys/ed25519/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ var (
// in SDK except in a tendermint validator context.
func (pubKey *PubKey) Address() crypto.Address {
if len(pubKey.Key) != PubKeySize {
panic("pubkey is incorrect size")
panic(fmt.Sprintf("length of pubkey is incorrect %d != %d", len(pubKey.Key), PubKeySize))

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
}
// For ADR-28 compatible address we would need to
// return address.Hash(proto.MessageName(pubKey), pubKey.Key)
Expand Down
13 changes: 11 additions & 2 deletions crypto/keys/secp256k1/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error {

// Address returns an ethereum style addresses
func (pubKey *PubKeyOld) Address() crypto.Address {
return pubKey.Address()
if len(pubKey.Key) != PubKeySize {
panic(fmt.Sprintf("length of pubkey is incorrect %d != %d", len(pubKey.Key), PubKeySize))

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
}

return crypto.Address(ethCrypto.Keccak256(pubKey.Key[1:])[12:])
}

// Bytes returns the pubkey byte format.
Expand All @@ -291,7 +295,12 @@ func (pubKey *PubKeyOld) Equals(other cryptotypes.PubKey) bool {
}

func (pubKey *PubKeyOld) VerifySignature(msg []byte, sigStr []byte) bool {
return pubKey.VerifySignature(msg, sigStr)
if len(sigStr) != SigSize {
return false
}

hash := ethCrypto.Keccak256(msg)
return ethCrypto.VerifySignature(pubKey.Key, hash, sigStr[:64])
}

// MarshalAmino overrides Amino binary marshaling.
Expand Down

0 comments on commit 722da0a

Please sign in to comment.