func (ss *SecretSyncer) AllActiveKeys(ckf *ComputedKeyFamily) []*SKB {
	var res []*SKB
	for _, key := range ss.keys.PrivateKeys {
		if ret, _ := key.FindActiveKey(ckf); ret != nil {
			res = append(res, ret)
		}
	}
	return res
}
AllActiveKeys returns all the active synced PGP keys.
package libkb
import (
	"fmt"
	"strings"
	"sync"
	keybase1 "github.com/keybase/client/go/protocol"
)
type ServerPrivateKey struct {
	Kid     string `json:"kid"`
	KeyType int    `json:"key_type"`
	Bundle  string `json:"bundle"`
	Mtime   int    `json:"mtime"`
	Ctime   int    `json:"ctime"`
	KeyBits int    `json:"key_bits"`
	KeyAlgo int    `json:"key_algo"`
}
type ServerPrivateKeyMap map[string]ServerPrivateKey
type DeviceKey struct {
	Type          string               `json:"type"`
	CTime         int64                `json:"ctime"`
	MTime         int64                `json:"mtime"`
	Description   string               `json:"name"`
	Status        int                  `json:"status"`
	LksServerHalf string               `json:"lks_server_half"`
	PPGen         PassphraseGeneration `json:"passphrase_generation"`
	LastUsedTime  int64                `json:"last_used_time"`
}
func (d DeviceKey) Display() string {
	if d.Type == DeviceTypePaper {
		if strings.HasPrefix(d.Description, "Paper Key") {
			return d.Description
		}
		return fmt.Sprintf("Paper Key (%s...)", d.Description)
	}
	return d.Description
}
type DeviceKeyMap map[keybase1.DeviceID]DeviceKey
type ServerPrivateKeys struct {
	Status      APIStatus           `json:"status"`
	Version     int                 `json:"version"`
	Mtime       *int                `json:"mtime"`
	PrivateKeys ServerPrivateKeyMap `json:"private_keys"`  
	Devices     DeviceKeyMap        `json:"devices"`
}
type SecretSyncer struct {
	sync.Mutex
	Contextified
	dirty bool
	keys  *ServerPrivateKeys
}
type DeviceTypeSet map[string]bool
var DefaultDeviceTypes = DeviceTypeSet{
	DeviceTypeDesktop: true,
	DeviceTypeMobile:  true,
}
var AllDeviceTypes = DeviceTypeSet{
	DeviceTypeDesktop: true,
	DeviceTypeMobile:  true,
	DeviceTypePaper:   true,
}
func NewSecretSyncer(g *GlobalContext) *SecretSyncer {
	return &SecretSyncer{
		Contextified: NewContextified(g),
	}
}
func (ss *SecretSyncer) Clear() error {
	ss.keys = nil
	return nil
}
func (ss *SecretSyncer) loadFromStorage(uid keybase1.UID) (err error) {
	var tmp ServerPrivateKeys
	var found bool
	found, err = ss.G().LocalDb.GetInto(&tmp, ss.dbKey(uid))
	ss.G().Log.Debug("| loadFromStorage -> found=%v, err=%s", found, ErrToOk(err))
	if err != nil {
		return err
	}
	if !found {
		ss.G().Log.Debug("| Loaded empty record set")
		return nil
	}
	if ss.cachedSyncedSecretsOutOfDate(&tmp) {
		ss.G().Log.Debug("| Synced secrets out of date")
		return nil
	}
	ss.G().Log.Debug("| Loaded version %d", tmp.Version)
	ss.keys = &tmp
	return nil
}
func (ss *SecretSyncer) syncFromServer(uid keybase1.UID, sr SessionReader) (err error) {
	hargs := HTTPArgs{}
	if ss.keys != nil {
		ss.G().Log.Debug("| adding version %d to fetch_private call", ss.keys.Version)
		hargs.Add("version", I{ss.keys.Version})
	}
	var res *APIRes
	res, err = ss.G().API.Get(APIArg{
		Endpoint:    "key/fetch_private",
		Args:        hargs,
		NeedSession: true,
		SessionR:    sr,
	})
	ss.G().Log.Debug("| syncFromServer -> %s", ErrToOk(err))
	if err != nil {
		return
	}
	var obj ServerPrivateKeys
	if err = res.Body.UnmarshalAgain(&obj); err != nil {
		return
	}
	if ss.keys == nil || obj.Version > ss.keys.Version {
		ss.G().Log.Debug("| upgrade to version -> %d", obj.Version)
		ss.keys = &obj
		ss.dirty = true
	} else {
		ss.G().Log.Debug("| not changing synced keys: synced version %d not newer than existing version %d", obj.Version, ss.keys.Version)
	}
	return
}
func (ss *SecretSyncer) dbKey(uid keybase1.UID) DbKey {
	return DbKeyUID(DBUserSecretKeys, uid)
}
func (ss *SecretSyncer) store(uid keybase1.UID) (err error) {
	if !ss.dirty {
		return
	}
	if err = ss.G().LocalDb.PutObj(ss.dbKey(uid), nil, ss.keys); err != nil {
		return
	}
	ss.dirty = false
	return
}
func (ss *SecretSyncer) FindActiveKey(ckf *ComputedKeyFamily) (ret *SKB, err error) {
	if ss.keys == nil {
		return nil, nil
	}
	for _, key := range ss.keys.PrivateKeys {
		if ret, _ = key.FindActiveKey(ckf); ret != nil {
			return
		}
	}
	return
}