store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: Apache-2.0 Imports: 22 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PubKeyFromBytes

func PubKeyFromBytes(pubKeyBytes []byte) (pubKey cryptotypes.PubKey, err error)

PubKeyFromBytes unmarshals public key bytes and returns a PubKey

func RegisterCodec

func RegisterCodec(cdc *codec.LegacyAmino)

RegisterCodec registers concrete types and interfaces on the given codec.

Types

type AES

type AES struct{}

func (AES) Decrypt

func (AES) Decrypt(cryptoText string, key string) (string, error)

func (AES) Encrypt

func (AES) Encrypt(text string, key string) (string, error)

type Crypto

type Crypto interface {
	Encrypt(data string, password string) (string, error)
	Decrypt(data string, password string) (string, error)
}

type FileDAO

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

Execute the local file system to realize the persistence of the key data, and the stored data is encrypted using `PBES2`. Can directly read the data of `iritacli` keys (--keyring-backend = file)

func (FileDAO) Delete

func (f FileDAO) Delete(name, password string) error

Delete will delete user data and use user password to verify permissions

func (FileDAO) Has

func (f FileDAO) Has(name string) bool

Has returns whether the specified user name exists

func (FileDAO) Read

func (f FileDAO) Read(name, password string) (KeyInfo, error)

Read will read encrypted data from file and decrypt with user password

func (FileDAO) Write

func (f FileDAO) Write(name, password string, info KeyInfo) error

Write will use user password to encrypt data and save to file, the file name is user name

type Info

type Info interface {
	// Human-readable type for key listing
	GetType() KeyType
	// Name of the key
	GetName() string
	// Public key
	GetPubKey() cryptotypes.PubKey
	// Bip44 Path
	GetPath() (*hd.BIP44Params, error)
	// Algo
	GetAlgo() hd.PubKeyType
}

Info is the publicly exposed information about a keypair

type KeyDAO

type KeyDAO interface {
	// Write will use user password to encrypt data and save to file, the file name is user name
	Write(name, password string, store KeyInfo) error

	// Read will read encrypted data from file and decrypt with user password
	Read(name, password string) (KeyInfo, error)

	// Delete will delete user data and use user password to verify permissions
	Delete(name, password string) error

	// Has returns whether the specified user name exists
	Has(name string) bool
}

func NewFileDAO

func NewFileDAO(dir string) KeyDAO

func NewLevelDB

func NewLevelDB(rootDir string, crypto Crypto) (KeyDAO, error)

NewLevelDB initialize a keybase based on the configuration. Use leveldb as storage

type KeyInfo

type KeyInfo struct {
	Name         string `json:"name"`
	PubKey       []byte `json:"pubkey"`
	PrivKeyArmor string `json:"priv_key_armor"`
	Algo         string `json:"algo"`
}

KeyInfo saves the basic information of the key

type KeyType

type KeyType uint

KeyType reflects a human-readable type for key listing.

const (
	TypeLocal KeyType = 0
)

Info KeyTypes

type LevelDBDAO

type LevelDBDAO struct {
	Crypto
	// contains filtered or unexported fields
}

func (LevelDBDAO) Delete

func (k LevelDBDAO) Delete(name, password string) error

Delete delete a key from the local store

func (LevelDBDAO) Has

func (k LevelDBDAO) Has(name string) bool

Delete delete a key from the local store

func (LevelDBDAO) Read

func (k LevelDBDAO) Read(name, password string) (store KeyInfo, err error)

Read read a key information from the local store

func (LevelDBDAO) ReadMetadata

func (k LevelDBDAO) ReadMetadata(name string) (store KeyInfo, err error)

ReadMetadata read a key information from the local store

func (LevelDBDAO) Write

func (k LevelDBDAO) Write(name, password string, info KeyInfo) error

Write add a key information to the local store

type MemoryDAO

type MemoryDAO struct {
	Crypto
	// contains filtered or unexported fields
}

Use memory as storage, use with caution in build environment

func NewMemory

func NewMemory(crypto Crypto) MemoryDAO

func (MemoryDAO) Delete

func (m MemoryDAO) Delete(name, password string) error

func (MemoryDAO) Has

func (m MemoryDAO) Has(name string) bool

func (MemoryDAO) Read

func (m MemoryDAO) Read(name, password string) (KeyInfo, error)

func (MemoryDAO) ReadMetadata

func (m MemoryDAO) ReadMetadata(name string) (store KeyInfo, err error)

ReadMetadata read a key information from the local store

func (MemoryDAO) Write

func (m MemoryDAO) Write(name, password string, store KeyInfo) error

Jump to

Keyboard shortcuts

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