key

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2021 License: GPL-3.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyAndIDMismatch = fmt.Errorf("public key does not match identifier")

ErrKeyAndIDMismatch occurs when a key identifier doesn't match it's public key

Functions

func IDFromPrivKey

func IDFromPrivKey(pk crypto.PrivKey) (string, error)

IDFromPrivKey is a wrapper for calling IDFromPubKey on a private key

func IDFromPubKey

func IDFromPubKey(pubKey crypto.PubKey) (string, error)

IDFromPubKey returns an ID string is a that is unique identifier for a keypair. For RSA keys this is the base58btc-encoded multihash string of the public key. hashes are 32-byte sha2-256 sums of public key bytes

Types

type Book

type Book interface {
	// PubKey stores the public key for a key.ID
	PubKey(ID) ic.PubKey

	// AddPubKey stores the public for a key.ID
	AddPubKey(ID, ic.PubKey) error

	// PrivKey returns the private key for a key.ID, if known
	PrivKey(ID) ic.PrivKey

	// AddPrivKey stores the private key for a key.ID
	AddPrivKey(ID, ic.PrivKey) error

	// IDsWithKeys returns all the key IDs stored in the KeyBook
	IDsWithKeys() []ID
}

Book defines the interface for keybook implementations which hold the key information

type CryptoGenerator

type CryptoGenerator interface {
	// GeneratePrivateKeyAndPeerID returns a base64 encoded private key, and a
	// peerID
	GeneratePrivateKeyAndPeerID() (string, string)
	// GenerateNickname uses a peerID to return a human-friendly nickname
	// TODO(b5): This should be moved up into the profile pacakge
	GenerateNickname(peerID string) string
	// GenerateEmptyIpfsRepo creates an empty IPFS repo at a given path
	// TODO(b5): This shouldn't be part of the CryptoGenerator interface, should
	// be moved to github.com/qri-io/qfs/qipfs
	GenerateEmptyIpfsRepo(repoPath, cfgPath string) error
}

CryptoGenerator is an interface for generating cryptographic info like private keys and peerIDs TODO(b5): I've moved this here because the key package should be the source of all cryptographic data, but this needs work. I'd like to see it reduced to just a `GeneratePrivateKey` function

type CryptoSource

type CryptoSource struct {
}

CryptoSource is a source of cryptographic info

func NewCryptoSource

func NewCryptoSource() *CryptoSource

NewCryptoSource returns a source of p2p cryptographic info that performs expensive computations like repeated primality testing

func (*CryptoSource) GenerateEmptyIpfsRepo

func (g *CryptoSource) GenerateEmptyIpfsRepo(repoPath, configPath string) error

GenerateEmptyIpfsRepo creates an empty IPFS repo in a secure manner at the given path

func (*CryptoSource) GenerateNickname

func (g *CryptoSource) GenerateNickname(peerID string) string

GenerateNickname returns a nickname using a peerID as a seed

func (*CryptoSource) GeneratePrivateKeyAndPeerID

func (g *CryptoSource) GeneratePrivateKeyAndPeerID() (privKey, peerID string)

GeneratePrivateKeyAndPeerID returns a private key and peerID

type ID

type ID = peer.ID

ID is a key identifier note that while this implementation is an alias for a peer.ID, this is not strictly a peerID.

func DecodeID

func DecodeID(s string) (ID, error)

DecodeID parses an ID string

type Store

type Store interface {
	Book
}

Store is an abstraction over a KeyBook In the future we may expand this interface to store symmetric encryption keys

func NewLocalStore

func NewLocalStore(filename string) (Store, error)

NewLocalStore constructs a local file backed key.Store

func NewMemStore

func NewMemStore() (Store, error)

NewMemStore constructs an in-memory key.Store

func NewStore

func NewStore(cfg *config.Config) (Store, error)

NewStore constructs a keys.Store backed by memory or local file

Directories

Path Synopsis
Package test contains predefined set of Keys for testing.
Package test contains predefined set of Keys for testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL