krab

package module
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: Apache-2.0 Imports: 11 Imported by: 1

README

krab

krab is a "semi secure" keystore that satisfies the IPFS keystore interface, allowing it to be used natively with many existing IPFS implementations, and tools. It stores keys on disk in a badger datastore, encrypting the keys before being stored in the datastore. Each time a key is fetched, it is decrypted first. A single password is used to encrypt all keys.

Multi-Language

jaywcjlove/sb

usage

There are two ways to use krab, one is to import with import "github.com/RTradeLtd/krab/v4", the other is to use RTradeLtd/kaas which exposes krab functionality via a gRPC API.

limitations

Because badger is used as the underlying data store, a single badger datastore is unable to have multiple indepent readers/writers, only readers. If you are writing to the datastore (aka, storing keys) then you must use the gRPC version, as it enables usage of a single badger datastore via multiple different services.

future improvements

  • Define groups of keys, with each group having a separate encryption password

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoSuchKey is returned if a key of the given name is not found in the store
	ErrNoSuchKey = "no key by the given name was found"
	// ErrKeyExists is returned when writing a key would overwrite an existing key
	ErrKeyExists = "key by that name already exists, refusing to overwrite"
	// ErrKeyFmt is returned when the key's format is invalid
	ErrKeyFmt = "key has invalid format"
)

Functions

func ExportKeyAsMnemonic

func ExportKeyAsMnemonic(pk ci.PrivKey) (string, error)

ExportKeyAsMnemonic is used to take an IPFS key, and return a human-readable friendly version. The idea is to allow users to easily export the keys they create, allowing them to take control of their records (ipns, tns, etc..)

func MnemonicToKey

func MnemonicToKey(phrase string) (ci.PrivKey, error)

MnemonicToKey takes an exported mnemonic phrase, and converts it to a private key

Types

type Keystore

type Keystore struct {
	// contains filtered or unexported fields
}

Keystore is used to manage an encrypted IPFS keystore

func NewKeystore

func NewKeystore(ds datastore.Batching, passphrase string) (*Keystore, error)

NewKeystore is used to create a new krab ipfs keystore manager

func (*Keystore) Delete

func (km *Keystore) Delete(name string) error

Delete is used to remove a key from our keystore

func (*Keystore) Get

func (km *Keystore) Get(name string) (ci.PrivKey, error)

Get is used to retrieve a key from our keystore

func (*Keystore) Has

func (km *Keystore) Has(name string) (bool, error)

Has is used to check whether or not the given key name exists

func (*Keystore) List

func (km *Keystore) List() ([]string, error)

List is used to list all key identifiers in our keystore

func (*Keystore) Put

func (km *Keystore) Put(name string, privKey ci.PrivKey) error

Put is used to store a key in our keystore

Jump to

Keyboard shortcuts

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