crypto: Remove Ed25519 and Secp256k1 suffix on GenPrivKey
This commit is contained in:
parent
17c0029233
commit
c798702764
|
@ -16,7 +16,7 @@ func BenchmarkEncodeStatusWire(b *testing.B) {
|
|||
b.StopTimer()
|
||||
cdc := amino.NewCodec()
|
||||
ctypes.RegisterAmino(cdc)
|
||||
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKeyEd25519()}
|
||||
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKey()}
|
||||
status := &ctypes.ResultStatus{
|
||||
NodeInfo: p2p.NodeInfo{
|
||||
ID: nodeKey.ID(),
|
||||
|
@ -52,7 +52,7 @@ func BenchmarkEncodeNodeInfoWire(b *testing.B) {
|
|||
b.StopTimer()
|
||||
cdc := amino.NewCodec()
|
||||
ctypes.RegisterAmino(cdc)
|
||||
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKeyEd25519()}
|
||||
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKey()}
|
||||
nodeInfo := p2p.NodeInfo{
|
||||
ID: nodeKey.ID(),
|
||||
Moniker: "SOMENAME",
|
||||
|
@ -77,7 +77,7 @@ func BenchmarkEncodeNodeInfoBinary(b *testing.B) {
|
|||
b.StopTimer()
|
||||
cdc := amino.NewCodec()
|
||||
ctypes.RegisterAmino(cdc)
|
||||
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKeyEd25519()}
|
||||
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKey()}
|
||||
nodeInfo := p2p.NodeInfo{
|
||||
ID: nodeKey.ID(),
|
||||
Moniker: "SOMENAME",
|
||||
|
@ -98,7 +98,7 @@ func BenchmarkEncodeNodeInfoBinary(b *testing.B) {
|
|||
|
||||
func BenchmarkEncodeNodeInfoProto(b *testing.B) {
|
||||
b.StopTimer()
|
||||
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKeyEd25519()}
|
||||
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKey()}
|
||||
nodeID := string(nodeKey.ID())
|
||||
someName := "SOMENAME"
|
||||
someAddr := "SOMEADDR"
|
||||
|
|
|
@ -37,7 +37,7 @@ func main() {
|
|||
*chainID,
|
||||
*addr,
|
||||
pv,
|
||||
ed25519.GenPrivKeyEd25519(),
|
||||
ed25519.GenPrivKey(),
|
||||
)
|
||||
err := rs.Start()
|
||||
if err != nil {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// pubKey := key.PubKey()
|
||||
|
||||
// For example:
|
||||
// privKey, err := ed25519.GenPrivKeyEd25519()
|
||||
// privKey, err := ed25519.GenPrivKey()
|
||||
// if err != nil {
|
||||
// ...
|
||||
// }
|
||||
|
|
|
@ -124,10 +124,10 @@ func (privKey PrivKeyEd25519) Generate(index int) PrivKeyEd25519 {
|
|||
return PrivKeyEd25519(*newKey)
|
||||
}
|
||||
|
||||
// GenPrivKeyEd25519 generates a new ed25519 private key.
|
||||
// GenPrivKey generates a new ed25519 private key.
|
||||
// It uses OS randomness in conjunction with the current global random seed
|
||||
// in tendermint/libs/common to generate the private key.
|
||||
func GenPrivKeyEd25519() PrivKeyEd25519 {
|
||||
func GenPrivKey() PrivKeyEd25519 {
|
||||
privKey := new([64]byte)
|
||||
copy(privKey[:32], crypto.CRandBytes(32))
|
||||
// ed25519.MakePublicKey(privKey) alters the last 32 bytes of privKey.
|
||||
|
@ -137,11 +137,11 @@ func GenPrivKeyEd25519() PrivKeyEd25519 {
|
|||
return PrivKeyEd25519(*privKey)
|
||||
}
|
||||
|
||||
// GenPrivKeyEd25519FromSecret hashes the secret with SHA2, and uses
|
||||
// GenPrivKeyFromSecret hashes the secret with SHA2, and uses
|
||||
// that 32 byte output to create the private key.
|
||||
// NOTE: secret should be the output of a KDF like bcrypt,
|
||||
// if it's derived from user input.
|
||||
func GenPrivKeyEd25519FromSecret(secret []byte) PrivKeyEd25519 {
|
||||
func GenPrivKeyFromSecret(secret []byte) PrivKeyEd25519 {
|
||||
privKey32 := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes.
|
||||
privKey := new([64]byte)
|
||||
copy(privKey[:32], privKey32)
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGeneratePrivKey(t *testing.T) {
|
||||
testPriv := ed25519.GenPrivKeyEd25519()
|
||||
testPriv := ed25519.GenPrivKey()
|
||||
testGenerate := testPriv.Generate(1)
|
||||
signBytes := []byte("something to sign")
|
||||
pub := testGenerate.PubKey()
|
||||
|
@ -21,7 +21,7 @@ func TestGeneratePrivKey(t *testing.T) {
|
|||
|
||||
func TestSignAndValidateEd25519(t *testing.T) {
|
||||
|
||||
privKey := ed25519.GenPrivKeyEd25519()
|
||||
privKey := ed25519.GenPrivKey()
|
||||
pubKey := privKey.PubKey()
|
||||
|
||||
msg := crypto.CRandBytes(128)
|
||||
|
|
|
@ -63,12 +63,12 @@ func TestKeyEncodings(t *testing.T) {
|
|||
privSize, pubSize int // binary sizes
|
||||
}{
|
||||
{
|
||||
privKey: ed25519.GenPrivKeyEd25519(),
|
||||
privKey: ed25519.GenPrivKey(),
|
||||
privSize: 69,
|
||||
pubSize: 37,
|
||||
},
|
||||
{
|
||||
privKey: secp256k1.GenPrivKeySecp256k1(),
|
||||
privKey: secp256k1.GenPrivKey(),
|
||||
privSize: 37,
|
||||
pubSize: 38,
|
||||
},
|
||||
|
|
|
@ -91,7 +91,7 @@ func (key PrivKeySecp256k1) Generate(index int) PrivKeySecp256k1 {
|
|||
}
|
||||
*/
|
||||
|
||||
func GenPrivKeySecp256k1() PrivKeySecp256k1 {
|
||||
func GenPrivKey() PrivKeySecp256k1 {
|
||||
privKeyBytes := [32]byte{}
|
||||
copy(privKeyBytes[:], crypto.CRandBytes(32))
|
||||
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKeyBytes[:])
|
||||
|
@ -101,7 +101,7 @@ func GenPrivKeySecp256k1() PrivKeySecp256k1 {
|
|||
|
||||
// NOTE: secret should be the output of a KDF like bcrypt,
|
||||
// if it's derived from user input.
|
||||
func GenPrivKeySecp256k1FromSecret(secret []byte) PrivKeySecp256k1 {
|
||||
func GenPrivKeyFromSecret(secret []byte) PrivKeySecp256k1 {
|
||||
privKey32 := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes.
|
||||
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey32)
|
||||
privKeyBytes := [32]byte{}
|
||||
|
|
|
@ -47,7 +47,7 @@ func TestPubKeySecp256k1Address(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSignAndValidateSecp256k1(t *testing.T) {
|
||||
privKey := secp256k1.GenPrivKeySecp256k1()
|
||||
privKey := secp256k1.GenPrivKey()
|
||||
pubKey := privKey.PubKey()
|
||||
|
||||
msg := crypto.CRandBytes(128)
|
||||
|
|
|
@ -25,7 +25,7 @@ type ValKeys []crypto.PrivKey
|
|||
func GenValKeys(n int) ValKeys {
|
||||
res := make(ValKeys, n)
|
||||
for i := range res {
|
||||
res[i] = ed25519.GenPrivKeyEd25519()
|
||||
res[i] = ed25519.GenPrivKey()
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ func GenValKeys(n int) ValKeys {
|
|||
func (v ValKeys) Change(i int) ValKeys {
|
||||
res := make(ValKeys, len(v))
|
||||
copy(res, v)
|
||||
res[i] = ed25519.GenPrivKeyEd25519()
|
||||
res[i] = ed25519.GenPrivKey()
|
||||
return res
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ func (v ValKeys) Extend(n int) ValKeys {
|
|||
func GenSecpValKeys(n int) ValKeys {
|
||||
res := make(ValKeys, n)
|
||||
for i := range res {
|
||||
res[i] = secp256k1.GenPrivKeySecp256k1()
|
||||
res[i] = secp256k1.GenPrivKey()
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ func NewNode(config *cfg.Config,
|
|||
var (
|
||||
// TODO: persist this key so external signer
|
||||
// can actually authenticate us
|
||||
privKey = ed25519.GenPrivKeyEd25519()
|
||||
privKey = ed25519.GenPrivKey()
|
||||
pvsc = privval.NewSocketPV(
|
||||
logger.With("module", "privval"),
|
||||
config.PrivValidatorListenAddr,
|
||||
|
|
|
@ -35,9 +35,9 @@ func makeKVStoreConnPair() (fooConn, barConn kvstoreConn) {
|
|||
func makeSecretConnPair(tb testing.TB) (fooSecConn, barSecConn *SecretConnection) {
|
||||
|
||||
var fooConn, barConn = makeKVStoreConnPair()
|
||||
var fooPrvKey = ed25519.GenPrivKeyEd25519()
|
||||
var fooPrvKey = ed25519.GenPrivKey()
|
||||
var fooPubKey = fooPrvKey.PubKey()
|
||||
var barPrvKey = ed25519.GenPrivKeyEd25519()
|
||||
var barPrvKey = ed25519.GenPrivKey()
|
||||
var barPubKey = barPrvKey.PubKey()
|
||||
|
||||
// Make connections from both sides in parallel.
|
||||
|
@ -105,7 +105,7 @@ func TestSecretConnectionReadWrite(t *testing.T) {
|
|||
genNodeRunner := func(id string, nodeConn kvstoreConn, nodeWrites []string, nodeReads *[]string) cmn.Task {
|
||||
return func(_ int) (interface{}, error, bool) {
|
||||
// Initiate cryptographic private key and secret connection trhough nodeConn.
|
||||
nodePrvKey := ed25519.GenPrivKeyEd25519()
|
||||
nodePrvKey := ed25519.GenPrivKey()
|
||||
nodeSecretConn, err := MakeSecretConnection(nodeConn, nodePrvKey)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to establish SecretConnection for node: %v", err)
|
||||
|
|
|
@ -71,7 +71,7 @@ func LoadNodeKey(filePath string) (*NodeKey, error) {
|
|||
}
|
||||
|
||||
func genNodeKey(filePath string) (*NodeKey, error) {
|
||||
privKey := ed25519.GenPrivKeyEd25519()
|
||||
privKey := ed25519.GenPrivKey()
|
||||
nodeKey := &NodeKey{
|
||||
PrivKey: privKey,
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ func randPeer(ip net.IP) *peer {
|
|||
ip = net.IP{127, 0, 0, 1}
|
||||
}
|
||||
|
||||
nodeKey := NodeKey{PrivKey: ed25519.GenPrivKeyEd25519()}
|
||||
nodeKey := NodeKey{PrivKey: ed25519.GenPrivKey()}
|
||||
p := &peer{
|
||||
nodeInfo: NodeInfo{
|
||||
ID: nodeKey.ID(),
|
||||
|
|
|
@ -24,7 +24,7 @@ func TestPeerBasic(t *testing.T) {
|
|||
assert, require := assert.New(t), require.New(t)
|
||||
|
||||
// simulate remote peer
|
||||
rp := &remotePeer{PrivKey: ed25519.GenPrivKeyEd25519(), Config: cfg}
|
||||
rp := &remotePeer{PrivKey: ed25519.GenPrivKey(), Config: cfg}
|
||||
rp.Start()
|
||||
defer rp.Stop()
|
||||
|
||||
|
@ -50,7 +50,7 @@ func TestPeerSend(t *testing.T) {
|
|||
config := cfg
|
||||
|
||||
// simulate remote peer
|
||||
rp := &remotePeer{PrivKey: ed25519.GenPrivKeyEd25519(), Config: config}
|
||||
rp := &remotePeer{PrivKey: ed25519.GenPrivKey(), Config: config}
|
||||
rp.Start()
|
||||
defer rp.Stop()
|
||||
|
||||
|
@ -75,7 +75,7 @@ func createOutboundPeerAndPerformHandshake(
|
|||
{ID: testCh, Priority: 1},
|
||||
}
|
||||
reactorsByCh := map[byte]Reactor{testCh: NewTestReactor(chDescs, true)}
|
||||
pk := ed25519.GenPrivKeyEd25519()
|
||||
pk := ed25519.GenPrivKey()
|
||||
pc, err := newOutboundPeerConn(addr, config, false, pk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -357,7 +357,7 @@ func newMockPeer() mockPeer {
|
|||
_, netAddr := p2p.CreateRoutableAddr()
|
||||
mp := mockPeer{
|
||||
addr: netAddr,
|
||||
pubKey: ed25519.GenPrivKeyEd25519().PubKey(),
|
||||
pubKey: ed25519.GenPrivKey().PubKey(),
|
||||
}
|
||||
mp.BaseService = cmn.NewBaseService(nil, "MockPeer", mp)
|
||||
mp.Start()
|
||||
|
|
|
@ -259,7 +259,7 @@ func TestSwitchStopsNonPersistentPeerOnError(t *testing.T) {
|
|||
defer sw.Stop()
|
||||
|
||||
// simulate remote peer
|
||||
rp := &remotePeer{PrivKey: ed25519.GenPrivKeyEd25519(), Config: cfg}
|
||||
rp := &remotePeer{PrivKey: ed25519.GenPrivKey(), Config: cfg}
|
||||
rp.Start()
|
||||
defer rp.Stop()
|
||||
|
||||
|
@ -289,7 +289,7 @@ func TestSwitchReconnectsToPersistentPeer(t *testing.T) {
|
|||
defer sw.Stop()
|
||||
|
||||
// simulate remote peer
|
||||
rp := &remotePeer{PrivKey: ed25519.GenPrivKeyEd25519(), Config: cfg}
|
||||
rp := &remotePeer{PrivKey: ed25519.GenPrivKey(), Config: cfg}
|
||||
rp.Start()
|
||||
defer rp.Stop()
|
||||
|
||||
|
@ -319,7 +319,7 @@ func TestSwitchReconnectsToPersistentPeer(t *testing.T) {
|
|||
|
||||
// simulate another remote peer
|
||||
rp = &remotePeer{
|
||||
PrivKey: ed25519.GenPrivKeyEd25519(),
|
||||
PrivKey: ed25519.GenPrivKey(),
|
||||
Config: cfg,
|
||||
// Use different interface to prevent duplicate IP filter, this will break
|
||||
// beyond two peers.
|
||||
|
|
|
@ -135,7 +135,7 @@ func MakeSwitch(cfg *config.P2PConfig, i int, network, version string, initSwitc
|
|||
// new switch, add reactors
|
||||
// TODO: let the config be passed in?
|
||||
nodeKey := &NodeKey{
|
||||
PrivKey: ed25519.GenPrivKeyEd25519(),
|
||||
PrivKey: ed25519.GenPrivKey(),
|
||||
}
|
||||
sw := NewSwitch(cfg)
|
||||
sw.SetLogger(log.TestingLogger())
|
||||
|
|
|
@ -68,7 +68,7 @@ func (pv *FilePV) GetPubKey() crypto.PubKey {
|
|||
// GenFilePV generates a new validator with randomly generated private key
|
||||
// and sets the filePath, but does not call Save().
|
||||
func GenFilePV(filePath string) *FilePV {
|
||||
privKey := ed25519.GenPrivKeyEd25519()
|
||||
privKey := ed25519.GenPrivKey()
|
||||
return &FilePV{
|
||||
Address: privKey.PubKey().Address(),
|
||||
PubKey: privKey.PubKey(),
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestUnmarshalValidator(t *testing.T) {
|
|||
assert, require := assert.New(t), require.New(t)
|
||||
|
||||
// create some fixed values
|
||||
privKey := ed25519.GenPrivKeyEd25519()
|
||||
privKey := ed25519.GenPrivKey()
|
||||
pubKey := privKey.PubKey()
|
||||
addr := pubKey.Address()
|
||||
pubArray := [32]byte(pubKey.(ed25519.PubKeyEd25519))
|
||||
|
|
|
@ -112,7 +112,7 @@ func TestSocketPVAcceptDeadline(t *testing.T) {
|
|||
sc = NewSocketPV(
|
||||
log.TestingLogger(),
|
||||
"127.0.0.1:0",
|
||||
ed25519.GenPrivKeyEd25519(),
|
||||
ed25519.GenPrivKey(),
|
||||
)
|
||||
)
|
||||
defer sc.Stop()
|
||||
|
@ -129,7 +129,7 @@ func TestSocketPVDeadline(t *testing.T) {
|
|||
sc = NewSocketPV(
|
||||
log.TestingLogger(),
|
||||
addr,
|
||||
ed25519.GenPrivKeyEd25519(),
|
||||
ed25519.GenPrivKey(),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -152,7 +152,7 @@ func TestSocketPVDeadline(t *testing.T) {
|
|||
|
||||
_, err = p2pconn.MakeSecretConnection(
|
||||
conn,
|
||||
ed25519.GenPrivKeyEd25519(),
|
||||
ed25519.GenPrivKey(),
|
||||
)
|
||||
if err == nil {
|
||||
break
|
||||
|
@ -172,7 +172,7 @@ func TestSocketPVWait(t *testing.T) {
|
|||
sc := NewSocketPV(
|
||||
log.TestingLogger(),
|
||||
"127.0.0.1:0",
|
||||
ed25519.GenPrivKeyEd25519(),
|
||||
ed25519.GenPrivKey(),
|
||||
)
|
||||
defer sc.Stop()
|
||||
|
||||
|
@ -214,7 +214,7 @@ func TestRemoteSignerRetry(t *testing.T) {
|
|||
cmn.RandStr(12),
|
||||
ln.Addr().String(),
|
||||
types.NewMockPV(),
|
||||
ed25519.GenPrivKeyEd25519(),
|
||||
ed25519.GenPrivKey(),
|
||||
)
|
||||
defer rs.Stop()
|
||||
|
||||
|
@ -245,12 +245,12 @@ func testSetupSocketPair(
|
|||
chainID,
|
||||
addr,
|
||||
privVal,
|
||||
ed25519.GenPrivKeyEd25519(),
|
||||
ed25519.GenPrivKey(),
|
||||
)
|
||||
sc = NewSocketPV(
|
||||
logger,
|
||||
addr,
|
||||
ed25519.GenPrivKeyEd25519(),
|
||||
ed25519.GenPrivKey(),
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -150,9 +150,9 @@ func TestBeginBlockByzantineValidators(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateValidators(t *testing.T) {
|
||||
pubkey1 := ed25519.GenPrivKeyEd25519().PubKey()
|
||||
pubkey1 := ed25519.GenPrivKey().PubKey()
|
||||
val1 := types.NewValidator(pubkey1, 10)
|
||||
pubkey2 := ed25519.GenPrivKeyEd25519().PubKey()
|
||||
pubkey2 := ed25519.GenPrivKey().PubKey()
|
||||
val2 := types.NewValidator(pubkey2, 20)
|
||||
|
||||
testCases := []struct {
|
||||
|
@ -246,7 +246,7 @@ func state(nVals, height int) (State, dbm.DB) {
|
|||
vals := make([]types.GenesisValidator, nVals)
|
||||
for i := 0; i < nVals; i++ {
|
||||
secret := []byte(fmt.Sprintf("test%d", i))
|
||||
pk := ed25519.GenPrivKeyEd25519FromSecret(secret)
|
||||
pk := ed25519.GenPrivKeyFromSecret(secret)
|
||||
vals[i] = types.GenesisValidator{
|
||||
pk.PubKey(), 1000, fmt.Sprintf("test%d", i),
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ func TestABCIResponsesSaveLoad1(t *testing.T) {
|
|||
abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: nil}
|
||||
abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: nil}
|
||||
abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{
|
||||
types.TM2PB.ValidatorFromPubKeyAndPower(ed25519.GenPrivKeyEd25519().PubKey(), 10),
|
||||
types.TM2PB.ValidatorFromPubKeyAndPower(ed25519.GenPrivKey().PubKey(), 10),
|
||||
}}
|
||||
|
||||
saveABCIResponses(stateDB, block.Height, abciResponses)
|
||||
|
@ -261,7 +261,7 @@ func TestManyValidatorChangesSaveLoad(t *testing.T) {
|
|||
defer tearDown(t)
|
||||
|
||||
const height = 1
|
||||
pubkey := ed25519.GenPrivKeyEd25519().PubKey()
|
||||
pubkey := ed25519.GenPrivKey().PubKey()
|
||||
// swap the first validator with a new one ^^^ (validator set size stays the same)
|
||||
header, blockID, responses := makeHeaderPartsResponsesValPubKeyChange(state, height, pubkey)
|
||||
var err error
|
||||
|
@ -284,7 +284,7 @@ func TestManyValidatorChangesSaveLoad(t *testing.T) {
|
|||
func genValSet(size int) *types.ValidatorSet {
|
||||
vals := make([]*types.Validator, size)
|
||||
for i := 0; i < size; i++ {
|
||||
vals[i] = types.NewValidator(ed25519.GenPrivKeyEd25519().PubKey(), 10)
|
||||
vals[i] = types.NewValidator(ed25519.GenPrivKey().PubKey(), 10)
|
||||
}
|
||||
return types.NewValidatorSet(vals)
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ func makeParams(blockBytes, blockTx, blockGas, txBytes,
|
|||
}
|
||||
|
||||
func pk() []byte {
|
||||
return ed25519.GenPrivKeyEd25519().PubKey().Bytes()
|
||||
return ed25519.GenPrivKey().PubKey().Bytes()
|
||||
}
|
||||
|
||||
func TestApplyUpdates(t *testing.T) {
|
||||
|
|
|
@ -60,7 +60,7 @@ func createValidatorNode(t *testing.T) (n *monitor.Node, emMock *mock.EventMeter
|
|||
emMock = &mock.EventMeter{}
|
||||
|
||||
stubs := make(map[string]interface{})
|
||||
pubKey := ed25519.GenPrivKeyEd25519().PubKey()
|
||||
pubKey := ed25519.GenPrivKey().PubKey()
|
||||
stubs["validators"] = ctypes.ResultValidators{BlockHeight: blockHeight, Validators: []*tmtypes.Validator{tmtypes.NewValidator(pubKey, 0)}}
|
||||
stubs["status"] = ctypes.ResultStatus{ValidatorInfo: ctypes.ValidatorInfo{PubKey: pubKey}}
|
||||
cdc := amino.NewCodec()
|
||||
|
|
|
@ -78,7 +78,7 @@ func startValidatorNode(t *testing.T) (n *monitor.Node, emMock *mock.EventMeter)
|
|||
emMock = &mock.EventMeter{}
|
||||
|
||||
stubs := make(map[string]interface{})
|
||||
pubKey := ed25519.GenPrivKeyEd25519().PubKey()
|
||||
pubKey := ed25519.GenPrivKey().PubKey()
|
||||
stubs["validators"] = ctypes.ResultValidators{BlockHeight: blockHeight, Validators: []*tmtypes.Validator{tmtypes.NewValidator(pubKey, 0)}}
|
||||
stubs["status"] = ctypes.ResultStatus{ValidatorInfo: ctypes.ValidatorInfo{PubKey: pubKey}}
|
||||
cdc := amino.NewCodec()
|
||||
|
|
|
@ -40,7 +40,7 @@ func TestGenesisGood(t *testing.T) {
|
|||
// create a base gendoc from struct
|
||||
baseGenDoc := &GenesisDoc{
|
||||
ChainID: "abc",
|
||||
Validators: []GenesisValidator{{ed25519.GenPrivKeyEd25519().PubKey(), 10, "myval"}},
|
||||
Validators: []GenesisValidator{{ed25519.GenPrivKey().PubKey(), 10, "myval"}},
|
||||
}
|
||||
genDocBytes, err = cdc.MarshalJSON(baseGenDoc)
|
||||
assert.NoError(t, err, "error marshalling genDoc")
|
||||
|
@ -100,7 +100,7 @@ func randomGenesisDoc() *GenesisDoc {
|
|||
return &GenesisDoc{
|
||||
GenesisTime: time.Now().UTC(),
|
||||
ChainID: "abc",
|
||||
Validators: []GenesisValidator{{ed25519.GenPrivKeyEd25519().PubKey(), 10, "myval"}},
|
||||
Validators: []GenesisValidator{{ed25519.GenPrivKey().PubKey(), 10, "myval"}},
|
||||
ConsensusParams: DefaultConsensusParams(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type MockPV struct {
|
|||
}
|
||||
|
||||
func NewMockPV() *MockPV {
|
||||
return &MockPV{ed25519.GenPrivKeyEd25519()}
|
||||
return &MockPV{ed25519.GenPrivKey()}
|
||||
}
|
||||
|
||||
// Implements PrivValidator.
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
)
|
||||
|
||||
func TestABCIPubKey(t *testing.T) {
|
||||
pkEd := ed25519.GenPrivKeyEd25519().PubKey()
|
||||
pkSecp := secp256k1.GenPrivKeySecp256k1().PubKey()
|
||||
pkEd := ed25519.GenPrivKey().PubKey()
|
||||
pkSecp := secp256k1.GenPrivKey().PubKey()
|
||||
testABCIPubKey(t, pkEd, ABCIPubKeyTypeEd25519)
|
||||
testABCIPubKey(t, pkSecp, ABCIPubKeyTypeSecp256k1)
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ func testABCIPubKey(t *testing.T, pk crypto.PubKey, typeStr string) {
|
|||
}
|
||||
|
||||
func TestABCIValidators(t *testing.T) {
|
||||
pkEd := ed25519.GenPrivKeyEd25519().PubKey()
|
||||
pkEd := ed25519.GenPrivKey().PubKey()
|
||||
|
||||
// correct validator
|
||||
tmValExpected := &Validator{
|
||||
|
@ -112,7 +112,7 @@ func (pubKeyEddie) VerifyBytes(msg []byte, sig crypto.Signature) bool { return f
|
|||
func (pubKeyEddie) Equals(crypto.PubKey) bool { return false }
|
||||
|
||||
func TestABCIValidatorFromPubKeyAndPower(t *testing.T) {
|
||||
pubkey := ed25519.GenPrivKeyEd25519().PubKey()
|
||||
pubkey := ed25519.GenPrivKey().PubKey()
|
||||
|
||||
abciVal := TM2PB.ValidatorFromPubKeyAndPower(pubkey, 10)
|
||||
assert.Equal(t, int64(10), abciVal.Power)
|
||||
|
|
|
@ -88,7 +88,7 @@ func BenchmarkValidatorSetCopy(b *testing.B) {
|
|||
b.StopTimer()
|
||||
vset := NewValidatorSet([]*Validator{})
|
||||
for i := 0; i < 1000; i++ {
|
||||
privKey := ed25519.GenPrivKeyEd25519()
|
||||
privKey := ed25519.GenPrivKey()
|
||||
pubKey := privKey.PubKey()
|
||||
val := NewValidator(pubKey, 0)
|
||||
if !vset.Add(val) {
|
||||
|
@ -369,7 +369,7 @@ func TestSafeSubClip(t *testing.T) {
|
|||
//-------------------------------------------------------------------
|
||||
|
||||
func TestValidatorSetVerifyCommit(t *testing.T) {
|
||||
privKey := ed25519.GenPrivKeyEd25519()
|
||||
privKey := ed25519.GenPrivKey()
|
||||
pubKey := privKey.PubKey()
|
||||
v1 := NewValidator(pubKey, 1000)
|
||||
vset := NewValidatorSet([]*Validator{v1})
|
||||
|
|
|
@ -109,7 +109,7 @@ func TestVoteVerify(t *testing.T) {
|
|||
vote := examplePrevote()
|
||||
vote.ValidatorAddress = pubkey.Address()
|
||||
|
||||
err := vote.Verify("test_chain_id", ed25519.GenPrivKeyEd25519().PubKey())
|
||||
err := vote.Verify("test_chain_id", ed25519.GenPrivKey().PubKey())
|
||||
if assert.Error(t, err) {
|
||||
assert.Equal(t, ErrVoteInvalidValidatorAddress, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue