func (k *ExtendedKey) pubKeyBytes() []byte {
	if !k.isPrivate {
		return k.key
	}
	if len(k.pubKey) == 0 {
		pkx, pky := btcec.S256().ScalarBaseMult(k.key)
		pubKey := btcec.PublicKey{Curve: btcec.S256(), X: pkx, Y: pky}
		k.pubKey = pubKey.SerializeCompressed()
	}
	return k.pubKey
}
pubKeyBytes returns bytes for the serialized compressed public key associated
with this extended key in an efficient manner including memoization as
necessary.

When the extended key is already a public key, the key is simply returned as
is since it's already in the correct form.  However, when the extended key is
a private key, the public key will be calculated and memoized so future
accesses can simply return the cached result.
package hdkeychain
import (
	"bytes"
	"crypto/hmac"
	"crypto/rand"
	"crypto/sha512"
	"encoding/binary"
	"errors"
	"fmt"
	"math/big"
	"github.com/bitgo/prova/btcec"
	"github.com/bitgo/prova/chaincfg"
	"github.com/bitgo/prova/chaincfg/chainhash"
	"github.com/bitgo/prova/provautil"
	"github.com/bitgo/prova/provautil/base58"
)
const (
	RecommendedSeedLen = 32  
	HardenedKeyStart = 0x80000000  
	MinSeedBytes = 16  
	MaxSeedBytes = 64  
	serializedKeyLen = 4 + 1 + 4 + 4 + 32 + 33  
)
var (
	ErrDeriveHardFromPublic = errors.New("cannot derive a hardened key " +
		"from a public key")
	ErrNotPrivExtKey = errors.New("unable to create private keys from a " +
		"public extended key")
	ErrInvalidChild = errors.New("the extended key at this index is invalid")
	ErrUnusableSeed = errors.New("unusable seed")
	ErrInvalidSeedLen = fmt.Errorf("seed length must be between %d and %d "+
		"bits", MinSeedBytes*8, MaxSeedBytes*8)
	ErrBadChecksum = errors.New("bad extended key checksum")
	ErrInvalidKeyLen = errors.New("the provided serialized extended key " +
		"length is invalid")
)
var masterKey = []byte("Bitcoin seed")
type ExtendedKey struct {
	key       []byte  
	pubKey    []byte  
	chainCode []byte
	depth     uint16
	parentFP  []byte
	childNum  uint32
	version   []byte
	isPrivate bool
}
func newExtendedKey(version, key, chainCode, parentFP []byte, depth uint16,
	childNum uint32, isPrivate bool) *ExtendedKey {
	return &ExtendedKey{
		key:       key,
		chainCode: chainCode,
		depth:     depth,
		parentFP:  parentFP,
		childNum:  childNum,
		version:   version,
		isPrivate: isPrivate,
	}
}