Skip to content

Commit

Permalink
chore: Check the signature returned by the ledger device against the …
Browse files Browse the repository at this point in the history
…public key in the keyring (backport #14460) (#14464)

Co-authored-by: Zaki Manian <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
3 people authored Jan 3, 2023
1 parent 71c1ee2 commit 58f81fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (crypto) [#14460](https://github.com/cosmos/cosmos-sdk/pull/14460) Check the signature returned by a ledger device against the public key in the keyring.
* (x/gov) [#14390](https://github.com/cosmos/cosmos-sdk/pull/14390) Add title, proposer and summary to proposal struct
* [#14356](https://github.com/cosmos/cosmos-sdk/pull/14356) Add `events.GetAttributes` and `event.GetAttribute` methods to simplify the retrieval of an attribute from event(s).
* (types) [#14332](https://github.com/cosmos/cosmos-sdk/issues/14332) Reduce state export time by 50%.
Expand Down
4 changes: 4 additions & 0 deletions crypto/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,10 @@ func SignWithLedger(k *Record, msg []byte) (sig []byte, pub types.PubKey, err er
return nil, nil, err
}

if !priv.PubKey().VerifySignature(msg, sig) {
return nil, nil, errors.New("Ledger generated an invalid signature. Perhaps you have multiple ledgers and need to try another one")
}

return sig, priv.PubKey(), nil
}

Expand Down

0 comments on commit 58f81fa

Please sign in to comment.