github.com/bytom/bytom@v1.1.2-0.20221014091027-bbcba3df6075/testutil/keys.go (about)

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