mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-12 06:41:31 +00:00
privkey fix
This commit is contained in:
@@ -19,8 +19,8 @@ import (
|
||||
type PrivKeys []crypto.PrivKey
|
||||
|
||||
// genPrivKeys produces an array of private keys to generate commits.
|
||||
func GenPrivKeys(n int) privKeys {
|
||||
res := make(privKeys, n)
|
||||
func GenPrivKeys(n int) PrivKeys {
|
||||
res := make(PrivKeys, n)
|
||||
for i := range res {
|
||||
res[i] = ed25519.GenPrivKey()
|
||||
}
|
||||
@@ -28,22 +28,22 @@ func GenPrivKeys(n int) privKeys {
|
||||
}
|
||||
|
||||
// Change replaces the key at index i.
|
||||
func (pkz privKeys) Change(i int) privKeys {
|
||||
res := make(privKeys, len(pkz))
|
||||
func (pkz PrivKeys) Change(i int) PrivKeys {
|
||||
res := make(PrivKeys, len(pkz))
|
||||
copy(res, pkz)
|
||||
res[i] = ed25519.GenPrivKey()
|
||||
return res
|
||||
}
|
||||
|
||||
// Extend adds n more keys (to remove, just take a slice).
|
||||
func (pkz privKeys) Extend(n int) privKeys {
|
||||
extra := genPrivKeys(n)
|
||||
func (pkz PrivKeys) Extend(n int) PrivKeys {
|
||||
extra := GenPrivKeys(n)
|
||||
return append(pkz, extra...)
|
||||
}
|
||||
|
||||
// GenSecpPrivKeys produces an array of secp256k1 private keys to generate commits.
|
||||
func GenSecpPrivKeys(n int) privKeys {
|
||||
res := make(privKeys, n)
|
||||
func GenSecpPrivKeys(n int) PrivKeys {
|
||||
res := make(PrivKeys, n)
|
||||
for i := range res {
|
||||
res[i] = secp256k1.GenPrivKey()
|
||||
}
|
||||
@@ -51,7 +51,7 @@ func GenSecpPrivKeys(n int) privKeys {
|
||||
}
|
||||
|
||||
// ExtendSecp adds n more secp256k1 keys (to remove, just take a slice).
|
||||
func (pkz privKeys) ExtendSecp(n int) privKeys {
|
||||
func (pkz PrivKeys) ExtendSecp(n int) PrivKeys {
|
||||
extra := GenSecpPrivKeys(n)
|
||||
return append(pkz, extra...)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (pkz privKeys) ExtendSecp(n int) privKeys {
|
||||
// The first key has weight `init` and it increases by `inc` every step
|
||||
// so we can have all the same weight, or a simple linear distribution
|
||||
// (should be enough for testing).
|
||||
func (pkz privKeys) ToValidators(init, inc int64) *types.ValidatorSet {
|
||||
func (pkz PrivKeys) ToValidators(init, inc int64) *types.ValidatorSet {
|
||||
res := make([]*types.Validator, len(pkz))
|
||||
for i, k := range pkz {
|
||||
res[i] = types.NewValidator(k.PubKey(), init+int64(i)*inc)
|
||||
@@ -69,7 +69,7 @@ func (pkz privKeys) ToValidators(init, inc int64) *types.ValidatorSet {
|
||||
}
|
||||
|
||||
// signHeader properly signs the header with all keys from first to last exclusive.
|
||||
func (pkz privKeys) signHeader(header *types.Header, first, last int) *types.Commit {
|
||||
func (pkz PrivKeys) signHeader(header *types.Header, first, last int) *types.Commit {
|
||||
commitSigs := make([]*types.CommitSig, len(pkz))
|
||||
|
||||
// We need this list to keep the ordering.
|
||||
@@ -129,7 +129,7 @@ func genHeader(chainID string, height int64, txs types.Txs,
|
||||
}
|
||||
|
||||
// GenSignedHeader calls genHeader and signHeader and combines them into a SignedHeader.
|
||||
func (pkz privKeys) GenSignedHeader(chainID string, height int64, txs types.Txs,
|
||||
func (pkz PrivKeys) GenSignedHeader(chainID string, height int64, txs types.Txs,
|
||||
valset, nextValset *types.ValidatorSet, appHash, consHash, resHash []byte, first, last int) types.SignedHeader {
|
||||
|
||||
header := genHeader(chainID, height, txs, valset, nextValset, appHash, consHash, resHash)
|
||||
@@ -141,7 +141,7 @@ func (pkz privKeys) GenSignedHeader(chainID string, height int64, txs types.Txs,
|
||||
}
|
||||
|
||||
// GenFullCommit calls genHeader and signHeader and combines them into a FullCommit.
|
||||
func (pkz privKeys) GenFullCommit(chainID string, height int64, txs types.Txs,
|
||||
func (pkz PrivKeys) GenFullCommit(chainID string, height int64, txs types.Txs,
|
||||
valset, nextValset *types.ValidatorSet, appHash, consHash, resHash []byte, first, last int) FullCommit {
|
||||
|
||||
header := genHeader(chainID, height, txs, valset, nextValset, appHash, consHash, resHash)
|
||||
|
||||
Reference in New Issue
Block a user