func loadKeyFile(fi string) (ci.PrivKey, error) { data, err := ioutil.ReadFile(fi) if err != nil { return nil, err } return ci.UnmarshalPrivateKey(data) }
// DecodePrivateKey is a helper to decode the users PrivateKey func (i *Identity) DecodePrivateKey(passphrase string) (ic.PrivKey, error) { pkb, err := base64.StdEncoding.DecodeString(i.PrivKey) if err != nil { return nil, err } // currently storing key unencrypted. in the future we need to encrypt it. // TODO(security) return ic.UnmarshalPrivateKey(pkb) }
func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) { if err := validateName(name); err != nil { return nil, err } kp := filepath.Join(ks.dir, name) data, err := ioutil.ReadFile(kp) if err != nil { if os.IsNotExist(err) { return nil, ErrNoSuchKey } return nil, err } return ci.UnmarshalPrivateKey(data) }