Skip to content

Commit

Permalink
support dymint signatures verification + add dymint to the default-al…
Browse files Browse the repository at this point in the history
…lowrd-clients list (#23)
  • Loading branch information
ItzhakBokris authored Dec 21, 2022
1 parent 2bdb22e commit 06ff366
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions modules/core/02-client/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

var (
// DefaultAllowedClients are "06-solomachine" and "07-tendermint"
DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint}
// DefaultAllowedClients are "01-dymint", "06-solomachine" and "07-tendermint"
DefaultAllowedClients = []string{exported.Dymint, exported.Solomachine, exported.Tendermint}

// KeyAllowedClients is store's key for AllowedClients Params
KeyAllowedClients = []byte("AllowedClients")
Expand Down
10 changes: 5 additions & 5 deletions modules/light-clients/01-dymint/types/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func (h Header) ValidateBasic() error {

// ValidateCommit checks if the given commit is a valid commit from the passed-in validatorset
func (h Header) ValidateCommit() (err error) {
chainID := h.Header.ChainID
blockID, err := tmtypes.BlockIDFromProto(&h.SignedHeader.Commit.BlockID)
if err != nil {
return sdkerrors.Wrap(err, "invalid block ID from header SignedHeader.Commit")
Expand Down Expand Up @@ -116,15 +115,16 @@ func (h Header) ValidateCommit() (err error) {
return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "validator set did not commit to header")
}
// Validate signature.
voteSignBytes := tmCommit.VoteSignBytes(chainID, valIdx)
if !bytes.Equal(commitSig.ValidatorAddress, h.Header.ProposerAddress) {
return fmt.Errorf("wrong proposer address in commit, got %X) but expected %X", valIdx, h.Header.ProposerAddress)
}
if !val.PubKey.VerifySignature(voteSignBytes, commitSig.Signature) {
headerBytes, err := h.SignedHeader.Header.Marshal()
if err != nil {
return err
}
if !val.PubKey.VerifySignature(headerBytes, commitSig.Signature) {
return fmt.Errorf("wrong signature (#%d): %X", valIdx, commitSig.Signature)
}
} else {
return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "validator set did not commit to header")
}

return nil
Expand Down

0 comments on commit 06ff366

Please sign in to comment.