func (s *onionStore) PrivateKey(onionType tor.OnionType) ([]byte, error) {
	onionPath, err := onionPath(onionType)
	if err != nil {
		return nil, err
	}
	resp, err := s.Get(context.Background(), onionPath)
	if err != nil {
		return nil, err
	}
	if len(resp.Kvs) == 0 {
		return nil, tor.ErrNoPrivateKey
	}
	return resp.Kvs[0].Value, nil
}
PrivateKey retrieves a stored private key. If it is not found, then
ErrNoPrivateKey should be returned.
package aperture
import (
	"context"
	"fmt"
	"strings"
	"github.com/lightningnetwork/lnd/tor"
	clientv3 "go.etcd.io/etcd/client/v3"
)
const (
	onionDir = "onion"
	onionV2Dir = "v2"
	onionV3Dir = "v3"
)
func onionPath(onionType tor.OnionType) (string, error) {
	var typeDir string
	switch onionType {
	case tor.V2:
		typeDir = onionV2Dir
	case tor.V3:
		typeDir = onionV3Dir
	default:
		return "", fmt.Errorf("unknown onion type %v", onionType)
	}
	return strings.Join(
		[]string{topLevelKey, onionDir, typeDir}, etcdKeyDelimeter,
	), nil
}
type onionStore struct {
	*clientv3.Client
}
var _ tor.OnionStore = (*onionStore)(nil)
func newOnionStore(client *clientv3.Client) *onionStore {
	return &onionStore{Client: client}
}
func (s *onionStore) StorePrivateKey(onionType tor.OnionType,
	privateKey []byte) error {
	onionPath, err := onionPath(onionType)
	if err != nil {
		return err
	}
	_, err = s.Client.Put(context.Background(), onionPath, string(privateKey))
	return err
}