-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Address to the problem that the signature of bls voter cannot be verified #202
Changes from all commits
81647e0
a34c7cc
09f64e0
4b976de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import ( | |
"sync" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/tendermint/tendermint/crypto" | ||
"github.com/tendermint/tendermint/libs/bits" | ||
) | ||
|
||
|
@@ -148,11 +148,27 @@ func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error) { | |
voteSet.mtx.Lock() | ||
defer voteSet.mtx.Unlock() | ||
|
||
return voteSet.addVote(vote) | ||
return voteSet.addVote(vote, vote.Verify) | ||
} | ||
|
||
func (voteSet *VoteSet) AddAggregatedVote(vote *Vote) (added bool, err error) { | ||
if voteSet == nil { | ||
panic("AddAggregatedVote() on nil VoteSet") | ||
} | ||
voteSet.mtx.Lock() | ||
defer voteSet.mtx.Unlock() | ||
|
||
return voteSet.addVote(vote, func(chainID string, pubKey crypto.PubKey) (err error) { | ||
if !bytes.Equal(pubKey.Address(), vote.ValidatorAddress) { | ||
return ErrVoteInvalidValidatorAddress | ||
} | ||
return nil | ||
}) | ||
} | ||
|
||
// NOTE: Validates as much as possible before attempting to verify the signature. | ||
func (voteSet *VoteSet) addVote(vote *Vote) (added bool, err error) { | ||
func (voteSet *VoteSet) addVote(vote *Vote, execVoteVerify func(chainID string, | ||
pub crypto.PubKey) (err error)) (added bool, err error) { | ||
if vote == nil { | ||
return false, ErrVoteNil | ||
} | ||
|
@@ -200,7 +216,7 @@ func (voteSet *VoteSet) addVote(vote *Vote) (added bool, err error) { | |
} | ||
|
||
// Check signature. | ||
if err := vote.Verify(voteSet.chainID, voter.PubKey); err != nil { | ||
if err := execVoteVerify(voteSet.chainID, voter.PubKey); err != nil { | ||
return false, errors.Wrapf(err, "Failed to verify vote with ChainID %s and PubKey %s", voteSet.chainID, voter.PubKey) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where are the checks made that are erased here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The verification points are as follows.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The specified URL seems not to address the correct location. I can't find There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If ed25519, the function is specified as an argument of the addvote function. If bls, without doing this, it will be verified later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah~ I understood. |
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the function!
https://github.com/line/ostracon/blob/b77afffa38e44772b4b0eea976164b54e02bcb12/types/block.go#L1356
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We seem to have implemented similar logic like this: