github.com/Bytom/bytom@v1.1.2-0.20210127130405-ae40204c0b09/testutil/keys.go (about)

     1  package testutil
     2  
     3  import (
     4  	"github.com/bytom/bytom/crypto/ed25519"
     5  	"github.com/bytom/bytom/crypto/ed25519/chainkd"
     6  )
     7  
     8  var (
     9  	TestXPub chainkd.XPub
    10  	TestXPrv chainkd.XPrv
    11  	TestPub  ed25519.PublicKey
    12  	TestPubs []ed25519.PublicKey
    13  )
    14  
    15  type zeroReader struct{}
    16  
    17  func (z zeroReader) Read(buf []byte) (int, error) {
    18  	for i := range buf {
    19  		buf[i] = 0
    20  	}
    21  	return len(buf), nil
    22  }
    23  
    24  func init() {
    25  	var err error
    26  	TestXPrv, TestXPub, err = chainkd.NewXKeys(zeroReader{})
    27  	if err != nil {
    28  		panic(err)
    29  	}
    30  	TestPub = TestXPub.PublicKey()
    31  	TestPubs = []ed25519.PublicKey{TestPub}
    32  }