func (s *Signatory) DecryptKey(fn PassphraseFetcher) error {
	if s.Entity == nil {
		return errors.New("private key not found")
	} else if s.Entity.PrivateKey == nil {
		return errors.New("provided key is not a private key")
	}
	if !s.Entity.PrivateKey.Encrypted {
		return nil
	}
	fname := "Unknown"
	for i := range s.Entity.Identities {
		if i != "" {
			fname = i
			break
		}
	}
	p, err := fn(fname)
	if err != nil {
		return err
	}
	return s.Entity.PrivateKey.Decrypt(p)
}
DecryptKey decrypts a private key in the Signatory.

If the key is not encrypted, this will return without error.

If the key does not exist, this will return an error.

If the key exists, but cannot be unlocked with the passphrase returned by
the PassphraseFetcher, this will return an error.

If the key is successfully unlocked, it will return nil.
package provenance
import (
	"bytes"
	"crypto"
	"encoding/hex"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"github.com/ghodss/yaml"
	"golang.org/x/crypto/openpgp"
	"golang.org/x/crypto/openpgp/clearsign"
	"golang.org/x/crypto/openpgp/packet"
	"k8s.io/helm/pkg/chartutil"
	hapi "k8s.io/helm/pkg/proto/hapi/chart"
)
var defaultPGPConfig = packet.Config{
	DefaultHash: crypto.SHA512,
}
type SumCollection struct {
	Files  map[string]string `json:"files"`
	Images map[string]string `json:"images,omitempty"`
}
type Verification struct {
	SignedBy *openpgp.Entity
	FileHash string
	FileName string
}
type Signatory struct {
	Entity *openpgp.Entity
	KeyRing openpgp.EntityList
}
func NewFromFiles(keyfile, keyringfile string) (*Signatory, error) {
	e, err := loadKey(keyfile)
	if err != nil {
		return nil, err
	}
	ring, err := loadKeyRing(keyringfile)
	if err != nil {
		return nil, err
	}
	return &Signatory{
		Entity:  e,
		KeyRing: ring,
	}, nil
}
func NewFromKeyring(keyringfile, id string) (*Signatory, error) {
	ring, err := loadKeyRing(keyringfile)
	if err != nil {
		return nil, err
	}
	s := &Signatory{KeyRing: ring}
	if id == "" {
		return s, nil
	}
	var candidate *openpgp.Entity
	vague := false
	for _, e := range ring {
		for n := range e.Identities {
			if n == id {
				s.Entity = e
				return s, nil
			}
			if strings.Contains(n, id) {
				if candidate != nil {
					vague = true
				}
				candidate = e
			}
		}
	}
	if vague {
		return s, fmt.Errorf("more than one key contain the id %q", id)
	}
	s.Entity = candidate
	return s, nil
}
type PassphraseFetcher func(name string) ([]byte, error)