Skip to content

Commit

Permalink
fix a few trivials
Browse files Browse the repository at this point in the history
  • Loading branch information
torao committed Nov 10, 2020
1 parent 2be6328 commit dd4293d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 44 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/pkg/errors"

"github.com/tendermint/tendermint/privval"
)

Expand Down
1 change: 1 addition & 0 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/pkg/errors"

"github.com/tendermint/tendermint/libs/fail"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
Expand Down
42 changes: 3 additions & 39 deletions types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -922,44 +922,8 @@ func (commit *Commit) ToProto() *tmproto.Commit {
return c
}

// VerifyAndPackSignatures validates the signatures in this commit and then reduces the size of the commit by
// aggregating the signatures that can be aggregated.
func (commit *Commit) VerifyAndPackSignatures(chainID string, vals []*Validator) error {
if err := commit.verifySignatures(chainID, vals); err != nil {
return err
}

// aggregate BLS-scheme signatures
/*
for i := range commit.Signatures {
commitSig := &commit.Signatures[i]
if commitSig.Absent() {
continue // OK, some signatures can be absent.
}
// BLS signature aggregation for all signatures that have been verified to be cleared.
// Signatures that fail to validate are rejected and be Absent.
if commitSig.Signature != nil && len(commitSig.Signature) == bls.SignatureSize {
if commit.AggregatedSignature == nil {
commit.AggregatedSignature = commitSig.Signature
commitSig.Signature = nil
} else {
aggrSig, err := bls.AddSignature(commit.AggregatedSignature, commitSig.Signature)
if err == nil {
commit.AggregatedSignature = aggrSig
commitSig.Signature = nil
}
// The BLS signature that fail to aggregate is remained intact.
}
fmt.Printf("*** Commit.VerifyAndPackSignatures(): signature aggregated\n")
}
}
*/

return nil
}

func (commit *Commit) verifySignatures(chainID string, vals []*Validator) error {
// VerifySignatures validates the signatures in this commit.
func (commit *Commit) VerifySignatures(chainID string, vals []*Validator) error {
blsPubKeys := make([]bls.PubKeyBLS12, 0, len(commit.Signatures))
messages := make([][]byte, 0, len(commit.Signatures))
for idx, commitSig := range commit.Signatures {
Expand Down Expand Up @@ -1298,7 +1262,7 @@ func BlockIDFromProto(bID *tmproto.BlockID) (*BlockID, error) {
return blockID, blockID.ValidateBasic()
}

// GetBLSPubKey is a utility function for referencing a specified public key as a BLS key for signature.
// GetSignatureKey is a utility function for referencing a specified public key as a BLS key for signature.
// If the key is not BLS, return nil
func GetSignatureKey(pubKey crypto.PubKey) *bls.PubKeyBLS12 {
for {
Expand Down
10 changes: 5 additions & 5 deletions types/voter_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (voters *VoterSet) VerifyCommit(chainID string, blockID BlockID,
}

// Validate signature.
if err := commit.VerifyAndPackSignatures(chainID, voters.Voters); err != nil {
if err := commit.VerifySignatures(chainID, voters.Voters); err != nil {
return err
}

Expand Down Expand Up @@ -220,7 +220,7 @@ func (voters *VoterSet) VerifyCommitLight(chainID string, blockID BlockID,
// return as soon as +2/3 of the signatures are verified
if talliedVotingPower > votingPowerNeeded {
// Validate signature.
if err := commit.VerifyAndPackSignatures(chainID, voters.Voters); err != nil {
if err := commit.VerifySignatures(chainID, voters.Voters); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -298,7 +298,7 @@ func (voters *VoterSet) VerifyFutureCommit(newSet *VoterSet, chainID string,
}

// Validate signature.
if err := commit.VerifyAndPackSignatures(chainID, vals); err != nil {
if err := commit.VerifySignatures(chainID, vals); err != nil {
return err
}

Expand Down Expand Up @@ -370,7 +370,7 @@ func (voters *VoterSet) VerifyCommitTrusting(chainID string, blockID BlockID,
}

// Validate signature.
if err := commit.VerifyAndPackSignatures(chainID, vals); err != nil {
if err := commit.VerifySignatures(chainID, vals); err != nil {
return err
}

Expand Down Expand Up @@ -439,7 +439,7 @@ func (voters *VoterSet) VerifyCommitLightTrusting(chainID string, blockID BlockI
_, val := voters.GetByAddress(cs.ValidatorAddress)
vals = append(vals, val)
}
if err := commit.VerifyAndPackSignatures(chainID, vals); err != nil {
if err := commit.VerifySignatures(chainID, vals); err != nil {
return err
}
return nil
Expand Down

0 comments on commit dd4293d

Please sign in to comment.