func AddKeyToKeyRingFromReader(keyring *KeyRing, name string, reader io.Reader) error {
	var err error
	var newKeyring openpgp.EntityList
	newKeyring, err = openpgp.ReadArmoredKeyRing(reader)
	if nil != err {
		return err
	}
	keyring.AddEntities(name, newKeyring)
	return nil
}
AddKeyToKeyRingFromReader imports the PGP keys stored in a Reader into the
passed KeyRing.
package pgp
import (
	"errors"
	"fmt"
	"io"
	"github.com/grafeas/voucher/v2/signer"
	"golang.org/x/crypto/openpgp"
	"golang.org/x/crypto/openpgp/packet"
)
var errEmptyKeyring = errors.New("keyring is empty")
type KeyRing struct {
	keyIds   map[string]uint64
	entities openpgp.EntityList
}
func (keyring *KeyRing) Sign(checkName, body string) (string, string, error) {
	signer, err := keyring.GetSignerByName(checkName)
	if nil != err {
		return "", "", err
	}
	signature, err := sign(signer, body)
	return signature, fmt.Sprintf("%X", signer.PrimaryKey.Fingerprint), err
}
func (keyring *KeyRing) KeysById(id uint64) []openpgp.Key {
	return keyring.entities.KeysById(id)
}
func (keyring *KeyRing) KeysByIdUsage(id uint64, requiredUsage byte) []openpgp.Key {
	return keyring.entities.KeysByIdUsage(id, requiredUsage)
}
func (keyring *KeyRing) DecryptionKeys() []openpgp.Key {
	return keyring.entities.DecryptionKeys()
}
func (keyring *KeyRing) GetSignerByName(name string) (*openpgp.Entity, error) {
	keyID := keyring.keyIds[name]
	for _, key := range keyring.KeysByIdUsage(keyID, packet.KeyFlagSign) {
		if nil != key.PublicKey && keyID == key.PublicKey.KeyId && nil != key.Entity {
			return key.Entity, nil
		}
	}
	return nil, signer.ErrNoKeyForCheck
}
func (keyring *KeyRing) AddEntities(name string, input openpgp.EntityList) {
	for _, entity := range input {
		if nil != entity.PrimaryKey {
			keyring.entities = append(keyring.entities, entity)
			keyring.keyIds[name] = entity.PrimaryKey.KeyId
		}
	}
}
func (keyring *KeyRing) Close() error {
	return nil
}
func NewKeyRing() *KeyRing {
	keyring := new(KeyRing)
	keyring.keyIds = make(map[string]uint64)
	keyring.entities = make(openpgp.EntityList, 0)
	return keyring
}