Skip to content

Commit

Permalink
chg: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcello33 committed Mar 6, 2024
1 parent d3b8a83 commit fdf810e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 8 additions & 3 deletions crypto/keys/secp256k1/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ func (privKey *PrivKeyOld) PubKey() cryptotypes.PubKey {
return &PubKey{Key: pk}
}
func (privKey *PrivKeyOld) Equals(other cryptotypes.LedgerPrivKey) bool {
return privKey.Equals(other)
return privKey.Type() == other.Type() && subtle.ConstantTimeCompare(privKey.Bytes(), other.Bytes()) == 1
}
func (privKey *PrivKeyOld) Type() string {
return privKey.Type()
return keyType
}
func (privKey *PrivKeyOld) Sign(msg []byte) ([]byte, error) {
return privKey.Sign(msg)
privateObject, err := ethCrypto.ToECDSA(privKey.Key)
if err != nil {
return nil, err
}

return ethCrypto.Sign(ethCrypto.Keccak256(msg), privateObject)
}

// MarshalAmino overrides Amino binary marshaling.
Expand Down
9 changes: 3 additions & 6 deletions proto/cosmos/crypto/secp256k1/keys.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1";

// PubKeyOld defines a tendermint secp256k1 public key
// Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte
// if the y-coordinate is the lexicographically largest of the two associated with
// the x-coordinate. Otherwise the first byte is a 0x03.
// This prefix is followed with the x-coordinate.
// PubKeyOld defines a tendermint uncompressed secp256k1 public key
// Key is the uncompressed form of the pubkey.
message PubKeyOld {
option (amino.name) = "tendermint/PubKeySecp256k1";
// The Amino encoding is simply the inner bytes field, and not the Amino
Expand Down Expand Up @@ -57,7 +54,7 @@ message PrivKeyOld {
bytes key = 1;
}

// PrivKey defines a comet uncompressed secp256k1 private key.
// PrivKey defines a comet secp256k1 private key.
message PrivKey {
option (amino.name) = "comet/PrivKeySecp256k1Uncompressed";
option (amino.message_encoding) = "key_field";
Expand Down

0 comments on commit fdf810e

Please sign in to comment.