1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-09 17:22:21 +08:00
Files
kubo/repo/config/identity.go
Jeromy 2263539c1c do that last thing again
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2016-01-31 15:37:39 -08:00

25 lines
622 B
Go

package config
import (
"encoding/base64"
ic "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/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)
}