keys: change to []bytes (#4950)

This commit is contained in:
Marko
2020-06-04 15:32:42 +02:00
committed by GitHub
parent d53a8d0377
commit 7c576f02ab
21 changed files with 152 additions and 160 deletions

View File

@@ -1090,7 +1090,7 @@ func (data *EvidenceData) StringIndented(indent string) string {
//--------------------------------------------------------------------------------
// BlockID defines the unique ID of a block as its Hash and its PartSetHeader
// BlockID
type BlockID struct {
Hash tmbytes.HexBytes `json:"hash"`
PartsHeader PartSetHeader `json:"parts"`

View File

@@ -4,7 +4,7 @@ import (
"testing"
"time"
"github.com/golang/protobuf/proto" // nolint: staticcheck // still used by gogoproto
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/assert"
"github.com/tendermint/tendermint/types/proto3"

View File

@@ -209,24 +209,24 @@ func (pb2tm) PubKey(pubKey abci.PubKey) (crypto.PubKey, error) {
return nil, fmt.Errorf("invalid size for PubKeyEd25519. Got %d, expected %d",
len(pubKey.Data), ed25519.PubKeySize)
}
var pk ed25519.PubKey
copy(pk[:], pubKey.Data)
var pk = make(ed25519.PubKey, ed25519.PubKeySize)
copy(pk, pubKey.Data)
return pk, nil
case ABCIPubKeyTypeSr25519:
if len(pubKey.Data) != sr25519.PubKeySize {
return nil, fmt.Errorf("invalid size for PubKeySr25519. Got %d, expected %d",
len(pubKey.Data), sr25519.PubKeySize)
}
var pk sr25519.PubKey
copy(pk[:], pubKey.Data)
var pk = make(sr25519.PubKey, sr25519.PubKeySize)
copy(pk, pubKey.Data)
return pk, nil
case ABCIPubKeyTypeSecp256k1:
if len(pubKey.Data) != secp256k1.PubKeySize {
return nil, fmt.Errorf("invalid size for PubKeySecp256k1. Got %d, expected %d",
len(pubKey.Data), secp256k1.PubKeySize)
}
var pk secp256k1.PubKey
copy(pk[:], pubKey.Data)
var pk = make(secp256k1.PubKey, secp256k1.PubKeySize)
copy(pk, pubKey.Data)
return pk, nil
default:
return nil, fmt.Errorf("unknown pubkey type %v", pubKey.Type)

View File

@@ -4,7 +4,7 @@ import (
"testing"
"time"
"github.com/golang/protobuf/proto" // nolint: staticcheck // still used by gogoproto
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

View File

@@ -360,9 +360,9 @@ func newValidator(address []byte, power int64) *Validator {
}
func randPubKey() crypto.PubKey {
var pubKey [32]byte
copy(pubKey[:], tmrand.Bytes(32))
return ed25519.PubKey(pubKey)
pubKey := make(ed25519.PubKey, ed25519.PubKeySize)
copy(pubKey, tmrand.Bytes(32))
return ed25519.PubKey(tmrand.Bytes(32))
}
func randValidator(totalVotingPower int64) *Validator {