From c7987027641d7925b896adcabefeb3f0e3062e58 Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Fri, 20 Jul 2018 10:44:21 -0700 Subject: [PATCH] crypto: Remove Ed25519 and Secp256k1 suffix on GenPrivKey --- benchmarks/codec_test.go | 8 ++++---- cmd/priv_val_server/main.go | 2 +- crypto/doc.go | 2 +- crypto/ed25519/ed25519.go | 8 ++++---- crypto/ed25519/ed25519_test.go | 4 ++-- crypto/encoding/amino/encode_test.go | 4 ++-- crypto/secp256k1/secp256k1.go | 4 ++-- crypto/secp256k1/secpk256k1_test.go | 2 +- lite/helpers.go | 6 +++--- node/node.go | 2 +- p2p/conn/secret_connection_test.go | 6 +++--- p2p/key.go | 2 +- p2p/peer_set_test.go | 2 +- p2p/peer_test.go | 6 +++--- p2p/pex/pex_reactor_test.go | 2 +- p2p/switch_test.go | 6 +++--- p2p/test_util.go | 2 +- privval/priv_validator.go | 2 +- privval/priv_validator_test.go | 2 +- privval/socket_test.go | 14 +++++++------- state/execution_test.go | 6 +++--- state/state_test.go | 8 ++++---- tools/tm-monitor/monitor/monitor_test.go | 2 +- tools/tm-monitor/monitor/node_test.go | 2 +- types/genesis_test.go | 4 ++-- types/priv_validator.go | 2 +- types/protobuf_test.go | 8 ++++---- types/validator_set_test.go | 4 ++-- types/vote_test.go | 2 +- 29 files changed, 62 insertions(+), 62 deletions(-) diff --git a/benchmarks/codec_test.go b/benchmarks/codec_test.go index 9e12bbe9..09487563 100644 --- a/benchmarks/codec_test.go +++ b/benchmarks/codec_test.go @@ -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" diff --git a/cmd/priv_val_server/main.go b/cmd/priv_val_server/main.go index 7b008049..03aa57f4 100644 --- a/cmd/priv_val_server/main.go +++ b/cmd/priv_val_server/main.go @@ -37,7 +37,7 @@ func main() { *chainID, *addr, pv, - ed25519.GenPrivKeyEd25519(), + ed25519.GenPrivKey(), ) err := rs.Start() if err != nil { diff --git a/crypto/doc.go b/crypto/doc.go index 112cd21e..41b3f302 100644 --- a/crypto/doc.go +++ b/crypto/doc.go @@ -22,7 +22,7 @@ // pubKey := key.PubKey() // For example: -// privKey, err := ed25519.GenPrivKeyEd25519() +// privKey, err := ed25519.GenPrivKey() // if err != nil { // ... // } diff --git a/crypto/ed25519/ed25519.go b/crypto/ed25519/ed25519.go index 20732d79..4b0772d5 100644 --- a/crypto/ed25519/ed25519.go +++ b/crypto/ed25519/ed25519.go @@ -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) diff --git a/crypto/ed25519/ed25519_test.go b/crypto/ed25519/ed25519_test.go index b8a34e58..acbb4460 100644 --- a/crypto/ed25519/ed25519_test.go +++ b/crypto/ed25519/ed25519_test.go @@ -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) diff --git a/crypto/encoding/amino/encode_test.go b/crypto/encoding/amino/encode_test.go index 450e7d63..74812aa6 100644 --- a/crypto/encoding/amino/encode_test.go +++ b/crypto/encoding/amino/encode_test.go @@ -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, }, diff --git a/crypto/secp256k1/secp256k1.go b/crypto/secp256k1/secp256k1.go index c2f5d974..ecdfcefa 100644 --- a/crypto/secp256k1/secp256k1.go +++ b/crypto/secp256k1/secp256k1.go @@ -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{} diff --git a/crypto/secp256k1/secpk256k1_test.go b/crypto/secp256k1/secpk256k1_test.go index 4c53871a..849f1dfd 100644 --- a/crypto/secp256k1/secpk256k1_test.go +++ b/crypto/secp256k1/secpk256k1_test.go @@ -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) diff --git a/lite/helpers.go b/lite/helpers.go index b98abdc8..9f404f24 100644 --- a/lite/helpers.go +++ b/lite/helpers.go @@ -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 } diff --git a/node/node.go b/node/node.go index 607efb12..e333c667 100644 --- a/node/node.go +++ b/node/node.go @@ -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, diff --git a/p2p/conn/secret_connection_test.go b/p2p/conn/secret_connection_test.go index 70c79e18..27dca034 100644 --- a/p2p/conn/secret_connection_test.go +++ b/p2p/conn/secret_connection_test.go @@ -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) diff --git a/p2p/key.go b/p2p/key.go index d8054684..4d1ecd82 100644 --- a/p2p/key.go +++ b/p2p/key.go @@ -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, } diff --git a/p2p/peer_set_test.go b/p2p/peer_set_test.go index a6a76f27..4582ab64 100644 --- a/p2p/peer_set_test.go +++ b/p2p/peer_set_test.go @@ -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(), diff --git a/p2p/peer_test.go b/p2p/peer_test.go index edfc5cf6..f0e91532 100644 --- a/p2p/peer_test.go +++ b/p2p/peer_test.go @@ -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 diff --git a/p2p/pex/pex_reactor_test.go b/p2p/pex/pex_reactor_test.go index 99eb433f..8d54693f 100644 --- a/p2p/pex/pex_reactor_test.go +++ b/p2p/pex/pex_reactor_test.go @@ -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() diff --git a/p2p/switch_test.go b/p2p/switch_test.go index 8fe56972..2ce29776 100644 --- a/p2p/switch_test.go +++ b/p2p/switch_test.go @@ -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. diff --git a/p2p/test_util.go b/p2p/test_util.go index 37c0ba3c..fdf9ae76 100644 --- a/p2p/test_util.go +++ b/p2p/test_util.go @@ -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()) diff --git a/privval/priv_validator.go b/privval/priv_validator.go index 34adcef2..5b056d8a 100644 --- a/privval/priv_validator.go +++ b/privval/priv_validator.go @@ -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(), diff --git a/privval/priv_validator_test.go b/privval/priv_validator_test.go index a129e07b..548ca6ca 100644 --- a/privval/priv_validator_test.go +++ b/privval/priv_validator_test.go @@ -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)) diff --git a/privval/socket_test.go b/privval/socket_test.go index 8f1e9a20..461ce3f8 100644 --- a/privval/socket_test.go +++ b/privval/socket_test.go @@ -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(), ) ) diff --git a/state/execution_test.go b/state/execution_test.go index 6ed42ed4..81510fb9 100644 --- a/state/execution_test.go +++ b/state/execution_test.go @@ -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), } diff --git a/state/state_test.go b/state/state_test.go index fa50693c..05c1859e 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -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) { diff --git a/tools/tm-monitor/monitor/monitor_test.go b/tools/tm-monitor/monitor/monitor_test.go index e089d338..9694e577 100644 --- a/tools/tm-monitor/monitor/monitor_test.go +++ b/tools/tm-monitor/monitor/monitor_test.go @@ -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() diff --git a/tools/tm-monitor/monitor/node_test.go b/tools/tm-monitor/monitor/node_test.go index 1925a8b7..10c2a13f 100644 --- a/tools/tm-monitor/monitor/node_test.go +++ b/tools/tm-monitor/monitor/node_test.go @@ -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() diff --git a/types/genesis_test.go b/types/genesis_test.go index 106e15fb..925bba79 100644 --- a/types/genesis_test.go +++ b/types/genesis_test.go @@ -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(), } } diff --git a/types/priv_validator.go b/types/priv_validator.go index 93225562..1642be41 100644 --- a/types/priv_validator.go +++ b/types/priv_validator.go @@ -48,7 +48,7 @@ type MockPV struct { } func NewMockPV() *MockPV { - return &MockPV{ed25519.GenPrivKeyEd25519()} + return &MockPV{ed25519.GenPrivKey()} } // Implements PrivValidator. diff --git a/types/protobuf_test.go b/types/protobuf_test.go index bfb2dea1..6ee79b90 100644 --- a/types/protobuf_test.go +++ b/types/protobuf_test.go @@ -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) diff --git a/types/validator_set_test.go b/types/validator_set_test.go index c8566677..1756f789 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -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}) diff --git a/types/vote_test.go b/types/vote_test.go index 5de451d4..836baa61 100644 --- a/types/vote_test.go +++ b/types/vote_test.go @@ -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) }