1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-16 04:02:05 +08:00
Files
kubo/repo/config/identity.go
Ho-Sheng Hsiao bf22aeec0a Reorged imports from jbenet/go-ipfs to ipfs/go-ipfs
- Modified Godeps/Godeps.json by hand
- [TEST] Updated welcome docs hash to sharness
- [TEST] Updated contact doc
- [TEST] disabled breaking test (t0080-repo refs local)
2015-03-31 12:52:25 -07:00

25 lines
581 B
Go

package config
import (
"encoding/base64"
ic "github.com/ipfs/go-ipfs/p2p/crypto"
)
// Identity tracks the configuration of the local node's identity.
type Identity struct {
PeerID string
PrivKey string
}
// 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)
}