keystore

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	*crypto.KeyPair
	ID uuid.UUID
}

Key represents a keypair to be stored.

func NewKey

func NewKey() (*Key, error)

NewKey new Key

func NewKeyFromKeyPair

func NewKeyFromKeyPair(keypair crypto.KeyPair) (*Key, error)

NewKeyFromKeyPair returns a key from a keypair.

func UnmarshalKey

func UnmarshalKey(data []byte, passphrase string) (*Key, error)

UnmarshalKey decrypts the private key

func (*Key) MarshalToJSON

func (key *Key) MarshalToJSON(passphrase string) ([]byte, error)

MarshalToJSON marshals a key to json byte array.

type KeyAuthorizer

type KeyAuthorizer interface {
	Authorized(jwtToken string) (bool, UnlockedKey, error)
}

KeyAuthorizer is an interface with auth mechanism of a key.

type KeyLockUnlockLister added in v1.1.6

type KeyLockUnlockLister interface {
	LockKey(address string, jwt string) (bool, error)
	UnlockKey(address string, passphrase string) (string, error)
	ListKeys() ([]string, error)
	KeyAuthorizer
}

KeyLockUnlockLister is an interface with locking, unlocking and listing key functionality.

type ScryptParams

type ScryptParams struct {
	N          int    `json:"n"`
	R          int    `json:"r"`
	P          int    `json:"p"`
	DKeyLength int    `json:"dklen"`
	Salt       string `json:"salt"`
}

ScryptParams

type Store

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

Store handles keypair storage.

func New

func New(keysDir string, nodeIdentityData []byte) (*Store, error)

New creates a new keystore.

func (*Store) Authorized

func (ks *Store) Authorized(jwtToken string) (bool, UnlockedKey, error)

Authorized checks if a token is authorized and valid.

func (*Store) CreateKey

func (ks *Store) CreateKey(passphrase string) (string, error)

CreateKey generates a new key.

func (*Store) ListKeys

func (ks *Store) ListKeys() ([]string, error)

ListKeys lists the keys in the keysDir.

func (*Store) LockKey

func (ks *Store) LockKey(address string, jwt string) (bool, error)

LockKey removes the key from unlocked keys.

func (*Store) SaveKey

func (ks *Store) SaveKey(key *Key, passphrase string) (string, error)

SaveKey saves a key given the passphrase.

func (*Store) UnlockKey

func (ks *Store) UnlockKey(address string, passphrase string) (string, error)

UnlockKey unlocks a key by address. it will try to unlock the node_identity_key first and if not then it will proceed with the keystore dir.

type UnlockedKey

type UnlockedKey struct {
	Key *Key
	JWT string
}

UnlockedKey represents an unlocked key with a jwt token.

Jump to

Keyboard shortcuts

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