types

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KeyTypeChar = map[KeyType]string{
	KeyTypeUser: "u",
	KeyTypePush: "p",
}

KeyTypeChar maps key type to their respective file prefix

Functions

This section is empty.

Types

type KeyPayload

type KeyPayload struct {
	Type          int    `json:"type" msgpack:"type"`
	FormatVersion string `json:"version" msgpack:"version"`
	SecretKey     string `json:"secretKey" msgpack:"secretKey"`
}

KeyPayload contains key data that will be stored on disk

type KeyType

type KeyType int
const (
	KeyTypeUser KeyType = iota
	KeyTypePush
)

type Keystore

type Keystore interface {
	SetOutput(out io.Writer)
	AskForPassword(prompt ...string) (string, error)
	AskForPasswordOnce(prompt ...string) (string, error)
	UnlockKeyUI(addressOrIndex, passphrase, promptMsg string) (StoredKey, string, error)
	UpdateCmd(addressOrIndex, passphrase string) error
	GetCmd(addrOrIdx, pass string, showPrivKey bool) error
	ImportCmd(keyfile string, keyType KeyType, pass string) error
	Exist(address string) (bool, error)
	GetByIndex(i int) (StoredKey, error)
	GetByIndexOrAddress(idxOrAddr string) (StoredKey, error)
	GetByAddress(addr string) (StoredKey, error)
	CreateKey(key *ed25519.Key, keyType KeyType, passphrase string) error
	CreateCmd(keyType KeyType, seed int64, passphrase string, nopass bool) (*ed25519.Key, error)
	List() (accounts []StoredKey, err error)
	ListCmd(out io.Writer) error
}

Keystore describes a module for managing keys

type StoredKey

type StoredKey interface {
	GetMeta() StoredKeyMeta
	GetKey() *ed25519.Key
	GetPayload() *KeyPayload
	Unlock(passphrase string) error
	GetFilename() string
	GetUserAddress() string
	GetPushKeyAddress() string
	IsUnprotected() bool
	GetType() KeyType
	GetUnlockedData() []byte
	GetCreatedAt() time.Time
}

StoredKey represents a locally persisted key

type StoredKeyMeta

type StoredKeyMeta map[string]interface{}

StoredKeyMeta represents additional metadata of an account

func (StoredKeyMeta) Get

func (sm StoredKeyMeta) Get(key string) interface{}

Get returns a value

func (StoredKeyMeta) HasKey

func (sm StoredKeyMeta) HasKey(key string) bool

HasKey checks whether a key exist

func (StoredKeyMeta) Map

func (sm StoredKeyMeta) Map() map[string]interface{}

Map returns base map

Jump to

Keyboard shortcuts

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