Browse Source

crypto: Remove Ed25519 and Secp256k1 suffix on GenPrivKey

pull/1966/head
ValarDragon 6 years ago
parent
commit
c798702764
29 changed files with 62 additions and 62 deletions
  1. +4
    -4
      benchmarks/codec_test.go
  2. +1
    -1
      cmd/priv_val_server/main.go
  3. +1
    -1
      crypto/doc.go
  4. +4
    -4
      crypto/ed25519/ed25519.go
  5. +2
    -2
      crypto/ed25519/ed25519_test.go
  6. +2
    -2
      crypto/encoding/amino/encode_test.go
  7. +2
    -2
      crypto/secp256k1/secp256k1.go
  8. +1
    -1
      crypto/secp256k1/secpk256k1_test.go
  9. +3
    -3
      lite/helpers.go
  10. +1
    -1
      node/node.go
  11. +3
    -3
      p2p/conn/secret_connection_test.go
  12. +1
    -1
      p2p/key.go
  13. +1
    -1
      p2p/peer_set_test.go
  14. +3
    -3
      p2p/peer_test.go
  15. +1
    -1
      p2p/pex/pex_reactor_test.go
  16. +3
    -3
      p2p/switch_test.go
  17. +1
    -1
      p2p/test_util.go
  18. +1
    -1
      privval/priv_validator.go
  19. +1
    -1
      privval/priv_validator_test.go
  20. +7
    -7
      privval/socket_test.go
  21. +3
    -3
      state/execution_test.go
  22. +4
    -4
      state/state_test.go
  23. +1
    -1
      tools/tm-monitor/monitor/monitor_test.go
  24. +1
    -1
      tools/tm-monitor/monitor/node_test.go
  25. +2
    -2
      types/genesis_test.go
  26. +1
    -1
      types/priv_validator.go
  27. +4
    -4
      types/protobuf_test.go
  28. +2
    -2
      types/validator_set_test.go
  29. +1
    -1
      types/vote_test.go

+ 4
- 4
benchmarks/codec_test.go View File

@ -16,7 +16,7 @@ func BenchmarkEncodeStatusWire(b *testing.B) {
b.StopTimer() b.StopTimer()
cdc := amino.NewCodec() cdc := amino.NewCodec()
ctypes.RegisterAmino(cdc) ctypes.RegisterAmino(cdc)
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKeyEd25519()}
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKey()}
status := &ctypes.ResultStatus{ status := &ctypes.ResultStatus{
NodeInfo: p2p.NodeInfo{ NodeInfo: p2p.NodeInfo{
ID: nodeKey.ID(), ID: nodeKey.ID(),
@ -52,7 +52,7 @@ func BenchmarkEncodeNodeInfoWire(b *testing.B) {
b.StopTimer() b.StopTimer()
cdc := amino.NewCodec() cdc := amino.NewCodec()
ctypes.RegisterAmino(cdc) ctypes.RegisterAmino(cdc)
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKeyEd25519()}
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKey()}
nodeInfo := p2p.NodeInfo{ nodeInfo := p2p.NodeInfo{
ID: nodeKey.ID(), ID: nodeKey.ID(),
Moniker: "SOMENAME", Moniker: "SOMENAME",
@ -77,7 +77,7 @@ func BenchmarkEncodeNodeInfoBinary(b *testing.B) {
b.StopTimer() b.StopTimer()
cdc := amino.NewCodec() cdc := amino.NewCodec()
ctypes.RegisterAmino(cdc) ctypes.RegisterAmino(cdc)
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKeyEd25519()}
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKey()}
nodeInfo := p2p.NodeInfo{ nodeInfo := p2p.NodeInfo{
ID: nodeKey.ID(), ID: nodeKey.ID(),
Moniker: "SOMENAME", Moniker: "SOMENAME",
@ -98,7 +98,7 @@ func BenchmarkEncodeNodeInfoBinary(b *testing.B) {
func BenchmarkEncodeNodeInfoProto(b *testing.B) { func BenchmarkEncodeNodeInfoProto(b *testing.B) {
b.StopTimer() b.StopTimer()
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKeyEd25519()}
nodeKey := p2p.NodeKey{PrivKey: ed25519.GenPrivKey()}
nodeID := string(nodeKey.ID()) nodeID := string(nodeKey.ID())
someName := "SOMENAME" someName := "SOMENAME"
someAddr := "SOMEADDR" someAddr := "SOMEADDR"


+ 1
- 1
cmd/priv_val_server/main.go View File

@ -37,7 +37,7 @@ func main() {
*chainID, *chainID,
*addr, *addr,
pv, pv,
ed25519.GenPrivKeyEd25519(),
ed25519.GenPrivKey(),
) )
err := rs.Start() err := rs.Start()
if err != nil { if err != nil {


+ 1
- 1
crypto/doc.go View File

@ -22,7 +22,7 @@
// pubKey := key.PubKey() // pubKey := key.PubKey()
// For example: // For example:
// privKey, err := ed25519.GenPrivKeyEd25519()
// privKey, err := ed25519.GenPrivKey()
// if err != nil { // if err != nil {
// ... // ...
// } // }


+ 4
- 4
crypto/ed25519/ed25519.go View File

@ -124,10 +124,10 @@ func (privKey PrivKeyEd25519) Generate(index int) PrivKeyEd25519 {
return PrivKeyEd25519(*newKey) 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 // It uses OS randomness in conjunction with the current global random seed
// in tendermint/libs/common to generate the private key. // in tendermint/libs/common to generate the private key.
func GenPrivKeyEd25519() PrivKeyEd25519 {
func GenPrivKey() PrivKeyEd25519 {
privKey := new([64]byte) privKey := new([64]byte)
copy(privKey[:32], crypto.CRandBytes(32)) copy(privKey[:32], crypto.CRandBytes(32))
// ed25519.MakePublicKey(privKey) alters the last 32 bytes of privKey. // ed25519.MakePublicKey(privKey) alters the last 32 bytes of privKey.
@ -137,11 +137,11 @@ func GenPrivKeyEd25519() PrivKeyEd25519 {
return PrivKeyEd25519(*privKey) 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. // that 32 byte output to create the private key.
// NOTE: secret should be the output of a KDF like bcrypt, // NOTE: secret should be the output of a KDF like bcrypt,
// if it's derived from user input. // 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. privKey32 := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes.
privKey := new([64]byte) privKey := new([64]byte)
copy(privKey[:32], privKey32) copy(privKey[:32], privKey32)


+ 2
- 2
crypto/ed25519/ed25519_test.go View File

@ -10,7 +10,7 @@ import (
) )
func TestGeneratePrivKey(t *testing.T) { func TestGeneratePrivKey(t *testing.T) {
testPriv := ed25519.GenPrivKeyEd25519()
testPriv := ed25519.GenPrivKey()
testGenerate := testPriv.Generate(1) testGenerate := testPriv.Generate(1)
signBytes := []byte("something to sign") signBytes := []byte("something to sign")
pub := testGenerate.PubKey() pub := testGenerate.PubKey()
@ -21,7 +21,7 @@ func TestGeneratePrivKey(t *testing.T) {
func TestSignAndValidateEd25519(t *testing.T) { func TestSignAndValidateEd25519(t *testing.T) {
privKey := ed25519.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
pubKey := privKey.PubKey() pubKey := privKey.PubKey()
msg := crypto.CRandBytes(128) msg := crypto.CRandBytes(128)


+ 2
- 2
crypto/encoding/amino/encode_test.go View File

@ -63,12 +63,12 @@ func TestKeyEncodings(t *testing.T) {
privSize, pubSize int // binary sizes privSize, pubSize int // binary sizes
}{ }{
{ {
privKey: ed25519.GenPrivKeyEd25519(),
privKey: ed25519.GenPrivKey(),
privSize: 69, privSize: 69,
pubSize: 37, pubSize: 37,
}, },
{ {
privKey: secp256k1.GenPrivKeySecp256k1(),
privKey: secp256k1.GenPrivKey(),
privSize: 37, privSize: 37,
pubSize: 38, pubSize: 38,
}, },


+ 2
- 2
crypto/secp256k1/secp256k1.go View File

@ -91,7 +91,7 @@ func (key PrivKeySecp256k1) Generate(index int) PrivKeySecp256k1 {
} }
*/ */
func GenPrivKeySecp256k1() PrivKeySecp256k1 {
func GenPrivKey() PrivKeySecp256k1 {
privKeyBytes := [32]byte{} privKeyBytes := [32]byte{}
copy(privKeyBytes[:], crypto.CRandBytes(32)) copy(privKeyBytes[:], crypto.CRandBytes(32))
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKeyBytes[:]) priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKeyBytes[:])
@ -101,7 +101,7 @@ func GenPrivKeySecp256k1() PrivKeySecp256k1 {
// NOTE: secret should be the output of a KDF like bcrypt, // NOTE: secret should be the output of a KDF like bcrypt,
// if it's derived from user input. // 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. privKey32 := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes.
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey32) priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey32)
privKeyBytes := [32]byte{} privKeyBytes := [32]byte{}


+ 1
- 1
crypto/secp256k1/secpk256k1_test.go View File

@ -47,7 +47,7 @@ func TestPubKeySecp256k1Address(t *testing.T) {
} }
func TestSignAndValidateSecp256k1(t *testing.T) { func TestSignAndValidateSecp256k1(t *testing.T) {
privKey := secp256k1.GenPrivKeySecp256k1()
privKey := secp256k1.GenPrivKey()
pubKey := privKey.PubKey() pubKey := privKey.PubKey()
msg := crypto.CRandBytes(128) msg := crypto.CRandBytes(128)


+ 3
- 3
lite/helpers.go View File

@ -25,7 +25,7 @@ type ValKeys []crypto.PrivKey
func GenValKeys(n int) ValKeys { func GenValKeys(n int) ValKeys {
res := make(ValKeys, n) res := make(ValKeys, n)
for i := range res { for i := range res {
res[i] = ed25519.GenPrivKeyEd25519()
res[i] = ed25519.GenPrivKey()
} }
return res return res
} }
@ -34,7 +34,7 @@ func GenValKeys(n int) ValKeys {
func (v ValKeys) Change(i int) ValKeys { func (v ValKeys) Change(i int) ValKeys {
res := make(ValKeys, len(v)) res := make(ValKeys, len(v))
copy(res, v) copy(res, v)
res[i] = ed25519.GenPrivKeyEd25519()
res[i] = ed25519.GenPrivKey()
return res return res
} }
@ -48,7 +48,7 @@ func (v ValKeys) Extend(n int) ValKeys {
func GenSecpValKeys(n int) ValKeys { func GenSecpValKeys(n int) ValKeys {
res := make(ValKeys, n) res := make(ValKeys, n)
for i := range res { for i := range res {
res[i] = secp256k1.GenPrivKeySecp256k1()
res[i] = secp256k1.GenPrivKey()
} }
return res return res
} }


+ 1
- 1
node/node.go View File

@ -197,7 +197,7 @@ func NewNode(config *cfg.Config,
var ( var (
// TODO: persist this key so external signer // TODO: persist this key so external signer
// can actually authenticate us // can actually authenticate us
privKey = ed25519.GenPrivKeyEd25519()
privKey = ed25519.GenPrivKey()
pvsc = privval.NewSocketPV( pvsc = privval.NewSocketPV(
logger.With("module", "privval"), logger.With("module", "privval"),
config.PrivValidatorListenAddr, config.PrivValidatorListenAddr,


+ 3
- 3
p2p/conn/secret_connection_test.go View File

@ -35,9 +35,9 @@ func makeKVStoreConnPair() (fooConn, barConn kvstoreConn) {
func makeSecretConnPair(tb testing.TB) (fooSecConn, barSecConn *SecretConnection) { func makeSecretConnPair(tb testing.TB) (fooSecConn, barSecConn *SecretConnection) {
var fooConn, barConn = makeKVStoreConnPair() var fooConn, barConn = makeKVStoreConnPair()
var fooPrvKey = ed25519.GenPrivKeyEd25519()
var fooPrvKey = ed25519.GenPrivKey()
var fooPubKey = fooPrvKey.PubKey() var fooPubKey = fooPrvKey.PubKey()
var barPrvKey = ed25519.GenPrivKeyEd25519()
var barPrvKey = ed25519.GenPrivKey()
var barPubKey = barPrvKey.PubKey() var barPubKey = barPrvKey.PubKey()
// Make connections from both sides in parallel. // 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 { genNodeRunner := func(id string, nodeConn kvstoreConn, nodeWrites []string, nodeReads *[]string) cmn.Task {
return func(_ int) (interface{}, error, bool) { return func(_ int) (interface{}, error, bool) {
// Initiate cryptographic private key and secret connection trhough nodeConn. // Initiate cryptographic private key and secret connection trhough nodeConn.
nodePrvKey := ed25519.GenPrivKeyEd25519()
nodePrvKey := ed25519.GenPrivKey()
nodeSecretConn, err := MakeSecretConnection(nodeConn, nodePrvKey) nodeSecretConn, err := MakeSecretConnection(nodeConn, nodePrvKey)
if err != nil { if err != nil {
t.Errorf("Failed to establish SecretConnection for node: %v", err) t.Errorf("Failed to establish SecretConnection for node: %v", err)


+ 1
- 1
p2p/key.go View File

@ -71,7 +71,7 @@ func LoadNodeKey(filePath string) (*NodeKey, error) {
} }
func genNodeKey(filePath string) (*NodeKey, error) { func genNodeKey(filePath string) (*NodeKey, error) {
privKey := ed25519.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
nodeKey := &NodeKey{ nodeKey := &NodeKey{
PrivKey: privKey, PrivKey: privKey,
} }


+ 1
- 1
p2p/peer_set_test.go View File

@ -17,7 +17,7 @@ func randPeer(ip net.IP) *peer {
ip = net.IP{127, 0, 0, 1} ip = net.IP{127, 0, 0, 1}
} }
nodeKey := NodeKey{PrivKey: ed25519.GenPrivKeyEd25519()}
nodeKey := NodeKey{PrivKey: ed25519.GenPrivKey()}
p := &peer{ p := &peer{
nodeInfo: NodeInfo{ nodeInfo: NodeInfo{
ID: nodeKey.ID(), ID: nodeKey.ID(),


+ 3
- 3
p2p/peer_test.go View File

@ -24,7 +24,7 @@ func TestPeerBasic(t *testing.T) {
assert, require := assert.New(t), require.New(t) assert, require := assert.New(t), require.New(t)
// simulate remote peer // simulate remote peer
rp := &remotePeer{PrivKey: ed25519.GenPrivKeyEd25519(), Config: cfg}
rp := &remotePeer{PrivKey: ed25519.GenPrivKey(), Config: cfg}
rp.Start() rp.Start()
defer rp.Stop() defer rp.Stop()
@ -50,7 +50,7 @@ func TestPeerSend(t *testing.T) {
config := cfg config := cfg
// simulate remote peer // simulate remote peer
rp := &remotePeer{PrivKey: ed25519.GenPrivKeyEd25519(), Config: config}
rp := &remotePeer{PrivKey: ed25519.GenPrivKey(), Config: config}
rp.Start() rp.Start()
defer rp.Stop() defer rp.Stop()
@ -75,7 +75,7 @@ func createOutboundPeerAndPerformHandshake(
{ID: testCh, Priority: 1}, {ID: testCh, Priority: 1},
} }
reactorsByCh := map[byte]Reactor{testCh: NewTestReactor(chDescs, true)} reactorsByCh := map[byte]Reactor{testCh: NewTestReactor(chDescs, true)}
pk := ed25519.GenPrivKeyEd25519()
pk := ed25519.GenPrivKey()
pc, err := newOutboundPeerConn(addr, config, false, pk) pc, err := newOutboundPeerConn(addr, config, false, pk)
if err != nil { if err != nil {
return nil, err return nil, err


+ 1
- 1
p2p/pex/pex_reactor_test.go View File

@ -357,7 +357,7 @@ func newMockPeer() mockPeer {
_, netAddr := p2p.CreateRoutableAddr() _, netAddr := p2p.CreateRoutableAddr()
mp := mockPeer{ mp := mockPeer{
addr: netAddr, addr: netAddr,
pubKey: ed25519.GenPrivKeyEd25519().PubKey(),
pubKey: ed25519.GenPrivKey().PubKey(),
} }
mp.BaseService = cmn.NewBaseService(nil, "MockPeer", mp) mp.BaseService = cmn.NewBaseService(nil, "MockPeer", mp)
mp.Start() mp.Start()


+ 3
- 3
p2p/switch_test.go View File

@ -259,7 +259,7 @@ func TestSwitchStopsNonPersistentPeerOnError(t *testing.T) {
defer sw.Stop() defer sw.Stop()
// simulate remote peer // simulate remote peer
rp := &remotePeer{PrivKey: ed25519.GenPrivKeyEd25519(), Config: cfg}
rp := &remotePeer{PrivKey: ed25519.GenPrivKey(), Config: cfg}
rp.Start() rp.Start()
defer rp.Stop() defer rp.Stop()
@ -289,7 +289,7 @@ func TestSwitchReconnectsToPersistentPeer(t *testing.T) {
defer sw.Stop() defer sw.Stop()
// simulate remote peer // simulate remote peer
rp := &remotePeer{PrivKey: ed25519.GenPrivKeyEd25519(), Config: cfg}
rp := &remotePeer{PrivKey: ed25519.GenPrivKey(), Config: cfg}
rp.Start() rp.Start()
defer rp.Stop() defer rp.Stop()
@ -319,7 +319,7 @@ func TestSwitchReconnectsToPersistentPeer(t *testing.T) {
// simulate another remote peer // simulate another remote peer
rp = &remotePeer{ rp = &remotePeer{
PrivKey: ed25519.GenPrivKeyEd25519(),
PrivKey: ed25519.GenPrivKey(),
Config: cfg, Config: cfg,
// Use different interface to prevent duplicate IP filter, this will break // Use different interface to prevent duplicate IP filter, this will break
// beyond two peers. // beyond two peers.


+ 1
- 1
p2p/test_util.go View File

@ -135,7 +135,7 @@ func MakeSwitch(cfg *config.P2PConfig, i int, network, version string, initSwitc
// new switch, add reactors // new switch, add reactors
// TODO: let the config be passed in? // TODO: let the config be passed in?
nodeKey := &NodeKey{ nodeKey := &NodeKey{
PrivKey: ed25519.GenPrivKeyEd25519(),
PrivKey: ed25519.GenPrivKey(),
} }
sw := NewSwitch(cfg) sw := NewSwitch(cfg)
sw.SetLogger(log.TestingLogger()) sw.SetLogger(log.TestingLogger())


+ 1
- 1
privval/priv_validator.go View File

@ -68,7 +68,7 @@ func (pv *FilePV) GetPubKey() crypto.PubKey {
// GenFilePV generates a new validator with randomly generated private key // GenFilePV generates a new validator with randomly generated private key
// and sets the filePath, but does not call Save(). // and sets the filePath, but does not call Save().
func GenFilePV(filePath string) *FilePV { func GenFilePV(filePath string) *FilePV {
privKey := ed25519.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
return &FilePV{ return &FilePV{
Address: privKey.PubKey().Address(), Address: privKey.PubKey().Address(),
PubKey: privKey.PubKey(), PubKey: privKey.PubKey(),


+ 1
- 1
privval/priv_validator_test.go View File

@ -48,7 +48,7 @@ func TestUnmarshalValidator(t *testing.T) {
assert, require := assert.New(t), require.New(t) assert, require := assert.New(t), require.New(t)
// create some fixed values // create some fixed values
privKey := ed25519.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
pubKey := privKey.PubKey() pubKey := privKey.PubKey()
addr := pubKey.Address() addr := pubKey.Address()
pubArray := [32]byte(pubKey.(ed25519.PubKeyEd25519)) pubArray := [32]byte(pubKey.(ed25519.PubKeyEd25519))


+ 7
- 7
privval/socket_test.go View File

@ -112,7 +112,7 @@ func TestSocketPVAcceptDeadline(t *testing.T) {
sc = NewSocketPV( sc = NewSocketPV(
log.TestingLogger(), log.TestingLogger(),
"127.0.0.1:0", "127.0.0.1:0",
ed25519.GenPrivKeyEd25519(),
ed25519.GenPrivKey(),
) )
) )
defer sc.Stop() defer sc.Stop()
@ -129,7 +129,7 @@ func TestSocketPVDeadline(t *testing.T) {
sc = NewSocketPV( sc = NewSocketPV(
log.TestingLogger(), log.TestingLogger(),
addr, addr,
ed25519.GenPrivKeyEd25519(),
ed25519.GenPrivKey(),
) )
) )
@ -152,7 +152,7 @@ func TestSocketPVDeadline(t *testing.T) {
_, err = p2pconn.MakeSecretConnection( _, err = p2pconn.MakeSecretConnection(
conn, conn,
ed25519.GenPrivKeyEd25519(),
ed25519.GenPrivKey(),
) )
if err == nil { if err == nil {
break break
@ -172,7 +172,7 @@ func TestSocketPVWait(t *testing.T) {
sc := NewSocketPV( sc := NewSocketPV(
log.TestingLogger(), log.TestingLogger(),
"127.0.0.1:0", "127.0.0.1:0",
ed25519.GenPrivKeyEd25519(),
ed25519.GenPrivKey(),
) )
defer sc.Stop() defer sc.Stop()
@ -214,7 +214,7 @@ func TestRemoteSignerRetry(t *testing.T) {
cmn.RandStr(12), cmn.RandStr(12),
ln.Addr().String(), ln.Addr().String(),
types.NewMockPV(), types.NewMockPV(),
ed25519.GenPrivKeyEd25519(),
ed25519.GenPrivKey(),
) )
defer rs.Stop() defer rs.Stop()
@ -245,12 +245,12 @@ func testSetupSocketPair(
chainID, chainID,
addr, addr,
privVal, privVal,
ed25519.GenPrivKeyEd25519(),
ed25519.GenPrivKey(),
) )
sc = NewSocketPV( sc = NewSocketPV(
logger, logger,
addr, addr,
ed25519.GenPrivKeyEd25519(),
ed25519.GenPrivKey(),
) )
) )


+ 3
- 3
state/execution_test.go View File

@ -150,9 +150,9 @@ func TestBeginBlockByzantineValidators(t *testing.T) {
} }
func TestUpdateValidators(t *testing.T) { func TestUpdateValidators(t *testing.T) {
pubkey1 := ed25519.GenPrivKeyEd25519().PubKey()
pubkey1 := ed25519.GenPrivKey().PubKey()
val1 := types.NewValidator(pubkey1, 10) val1 := types.NewValidator(pubkey1, 10)
pubkey2 := ed25519.GenPrivKeyEd25519().PubKey()
pubkey2 := ed25519.GenPrivKey().PubKey()
val2 := types.NewValidator(pubkey2, 20) val2 := types.NewValidator(pubkey2, 20)
testCases := []struct { testCases := []struct {
@ -246,7 +246,7 @@ func state(nVals, height int) (State, dbm.DB) {
vals := make([]types.GenesisValidator, nVals) vals := make([]types.GenesisValidator, nVals)
for i := 0; i < nVals; i++ { for i := 0; i < nVals; i++ {
secret := []byte(fmt.Sprintf("test%d", i)) secret := []byte(fmt.Sprintf("test%d", i))
pk := ed25519.GenPrivKeyEd25519FromSecret(secret)
pk := ed25519.GenPrivKeyFromSecret(secret)
vals[i] = types.GenesisValidator{ vals[i] = types.GenesisValidator{
pk.PubKey(), 1000, fmt.Sprintf("test%d", i), pk.PubKey(), 1000, fmt.Sprintf("test%d", i),
} }


+ 4
- 4
state/state_test.go View File

@ -79,7 +79,7 @@ func TestABCIResponsesSaveLoad1(t *testing.T) {
abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: nil} abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: nil}
abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: nil} abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: nil}
abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{ 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) saveABCIResponses(stateDB, block.Height, abciResponses)
@ -261,7 +261,7 @@ func TestManyValidatorChangesSaveLoad(t *testing.T) {
defer tearDown(t) defer tearDown(t)
const height = 1 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) // swap the first validator with a new one ^^^ (validator set size stays the same)
header, blockID, responses := makeHeaderPartsResponsesValPubKeyChange(state, height, pubkey) header, blockID, responses := makeHeaderPartsResponsesValPubKeyChange(state, height, pubkey)
var err error var err error
@ -284,7 +284,7 @@ func TestManyValidatorChangesSaveLoad(t *testing.T) {
func genValSet(size int) *types.ValidatorSet { func genValSet(size int) *types.ValidatorSet {
vals := make([]*types.Validator, size) vals := make([]*types.Validator, size)
for i := 0; i < size; i++ { 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) return types.NewValidatorSet(vals)
} }
@ -371,7 +371,7 @@ func makeParams(blockBytes, blockTx, blockGas, txBytes,
} }
func pk() []byte { func pk() []byte {
return ed25519.GenPrivKeyEd25519().PubKey().Bytes()
return ed25519.GenPrivKey().PubKey().Bytes()
} }
func TestApplyUpdates(t *testing.T) { func TestApplyUpdates(t *testing.T) {


+ 1
- 1
tools/tm-monitor/monitor/monitor_test.go View File

@ -60,7 +60,7 @@ func createValidatorNode(t *testing.T) (n *monitor.Node, emMock *mock.EventMeter
emMock = &mock.EventMeter{} emMock = &mock.EventMeter{}
stubs := make(map[string]interface{}) 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["validators"] = ctypes.ResultValidators{BlockHeight: blockHeight, Validators: []*tmtypes.Validator{tmtypes.NewValidator(pubKey, 0)}}
stubs["status"] = ctypes.ResultStatus{ValidatorInfo: ctypes.ValidatorInfo{PubKey: pubKey}} stubs["status"] = ctypes.ResultStatus{ValidatorInfo: ctypes.ValidatorInfo{PubKey: pubKey}}
cdc := amino.NewCodec() cdc := amino.NewCodec()


+ 1
- 1
tools/tm-monitor/monitor/node_test.go View File

@ -78,7 +78,7 @@ func startValidatorNode(t *testing.T) (n *monitor.Node, emMock *mock.EventMeter)
emMock = &mock.EventMeter{} emMock = &mock.EventMeter{}
stubs := make(map[string]interface{}) 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["validators"] = ctypes.ResultValidators{BlockHeight: blockHeight, Validators: []*tmtypes.Validator{tmtypes.NewValidator(pubKey, 0)}}
stubs["status"] = ctypes.ResultStatus{ValidatorInfo: ctypes.ValidatorInfo{PubKey: pubKey}} stubs["status"] = ctypes.ResultStatus{ValidatorInfo: ctypes.ValidatorInfo{PubKey: pubKey}}
cdc := amino.NewCodec() cdc := amino.NewCodec()


+ 2
- 2
types/genesis_test.go View File

@ -40,7 +40,7 @@ func TestGenesisGood(t *testing.T) {
// create a base gendoc from struct // create a base gendoc from struct
baseGenDoc := &GenesisDoc{ baseGenDoc := &GenesisDoc{
ChainID: "abc", ChainID: "abc",
Validators: []GenesisValidator{{ed25519.GenPrivKeyEd25519().PubKey(), 10, "myval"}},
Validators: []GenesisValidator{{ed25519.GenPrivKey().PubKey(), 10, "myval"}},
} }
genDocBytes, err = cdc.MarshalJSON(baseGenDoc) genDocBytes, err = cdc.MarshalJSON(baseGenDoc)
assert.NoError(t, err, "error marshalling genDoc") assert.NoError(t, err, "error marshalling genDoc")
@ -100,7 +100,7 @@ func randomGenesisDoc() *GenesisDoc {
return &GenesisDoc{ return &GenesisDoc{
GenesisTime: time.Now().UTC(), GenesisTime: time.Now().UTC(),
ChainID: "abc", ChainID: "abc",
Validators: []GenesisValidator{{ed25519.GenPrivKeyEd25519().PubKey(), 10, "myval"}},
Validators: []GenesisValidator{{ed25519.GenPrivKey().PubKey(), 10, "myval"}},
ConsensusParams: DefaultConsensusParams(), ConsensusParams: DefaultConsensusParams(),
} }
} }

+ 1
- 1
types/priv_validator.go View File

@ -48,7 +48,7 @@ type MockPV struct {
} }
func NewMockPV() *MockPV { func NewMockPV() *MockPV {
return &MockPV{ed25519.GenPrivKeyEd25519()}
return &MockPV{ed25519.GenPrivKey()}
} }
// Implements PrivValidator. // Implements PrivValidator.


+ 4
- 4
types/protobuf_test.go View File

@ -12,8 +12,8 @@ import (
) )
func TestABCIPubKey(t *testing.T) { 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, pkEd, ABCIPubKeyTypeEd25519)
testABCIPubKey(t, pkSecp, ABCIPubKeyTypeSecp256k1) testABCIPubKey(t, pkSecp, ABCIPubKeyTypeSecp256k1)
} }
@ -26,7 +26,7 @@ func testABCIPubKey(t *testing.T, pk crypto.PubKey, typeStr string) {
} }
func TestABCIValidators(t *testing.T) { func TestABCIValidators(t *testing.T) {
pkEd := ed25519.GenPrivKeyEd25519().PubKey()
pkEd := ed25519.GenPrivKey().PubKey()
// correct validator // correct validator
tmValExpected := &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 (pubKeyEddie) Equals(crypto.PubKey) bool { return false }
func TestABCIValidatorFromPubKeyAndPower(t *testing.T) { func TestABCIValidatorFromPubKeyAndPower(t *testing.T) {
pubkey := ed25519.GenPrivKeyEd25519().PubKey()
pubkey := ed25519.GenPrivKey().PubKey()
abciVal := TM2PB.ValidatorFromPubKeyAndPower(pubkey, 10) abciVal := TM2PB.ValidatorFromPubKeyAndPower(pubkey, 10)
assert.Equal(t, int64(10), abciVal.Power) assert.Equal(t, int64(10), abciVal.Power)


+ 2
- 2
types/validator_set_test.go View File

@ -88,7 +88,7 @@ func BenchmarkValidatorSetCopy(b *testing.B) {
b.StopTimer() b.StopTimer()
vset := NewValidatorSet([]*Validator{}) vset := NewValidatorSet([]*Validator{})
for i := 0; i < 1000; i++ { for i := 0; i < 1000; i++ {
privKey := ed25519.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
pubKey := privKey.PubKey() pubKey := privKey.PubKey()
val := NewValidator(pubKey, 0) val := NewValidator(pubKey, 0)
if !vset.Add(val) { if !vset.Add(val) {
@ -369,7 +369,7 @@ func TestSafeSubClip(t *testing.T) {
//------------------------------------------------------------------- //-------------------------------------------------------------------
func TestValidatorSetVerifyCommit(t *testing.T) { func TestValidatorSetVerifyCommit(t *testing.T) {
privKey := ed25519.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
pubKey := privKey.PubKey() pubKey := privKey.PubKey()
v1 := NewValidator(pubKey, 1000) v1 := NewValidator(pubKey, 1000)
vset := NewValidatorSet([]*Validator{v1}) vset := NewValidatorSet([]*Validator{v1})


+ 1
- 1
types/vote_test.go View File

@ -109,7 +109,7 @@ func TestVoteVerify(t *testing.T) {
vote := examplePrevote() vote := examplePrevote()
vote.ValidatorAddress = pubkey.Address() 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) { if assert.Error(t, err) {
assert.Equal(t, ErrVoteInvalidValidatorAddress, err) assert.Equal(t, ErrVoteInvalidValidatorAddress, err)
} }


Loading…
Cancel
Save