keystore

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScryptN = 2
	ScryptP = 1
)
View Source
const (
	StandardScryptN = 1 << 18

	StandardScryptP = 1

	LightScryptN = 1 << 12

	LightScryptP = 6
)

Variables

View Source
var (
	ErrNoMatch = errors.New("no key for given address or file")
	ErrDecrypt = errors.New("could not decrypt key with given passphrase")
)
View Source
var KeyStoreScheme = "keystore"

Functions

func EncryptKey

func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error)

EncryptKey encrypt the key via auth

Types

type Key

type Key struct {
	Id         uuid.UUID
	Address    accounts.Address
	PrivateKey *crypto.PrivateKey
}

func DecryptKey

func DecryptKey(keyjson []byte, auth string) (*Key, error)

DecryptKey returns the decrypted key via auth

func (*Key) MarshalJSON

func (k *Key) MarshalJSON() (j []byte, err error)

Marshal key to json bytes

func (*Key) UnmarshalJSON

func (k *Key) UnmarshalJSON(j []byte) (err error)

UnmarshalJSON restore key from json

type KeyStore

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

KeyStore definition

func NewKeyStore

func NewKeyStore(db *db.BlockchainDB, keydir string, scryptN, scryptP int) *KeyStore

NewKeyStore new a KeyStore instance

func NewPlaintextKeyStore

func NewPlaintextKeyStore(db *db.BlockchainDB, keydir string) *KeyStore

NewPlaintextKeyStore new a PlaintextKeyStore instance

func (*KeyStore) Accounts

func (ks *KeyStore) Accounts() ([]string, error)

func (*KeyStore) Delete

func (ks *KeyStore) Delete(a accounts.Account, passphrase string) error

Delete removes the speciified account

func (*KeyStore) Find

func (ks *KeyStore) Find(addr accounts.Address) *accounts.Account

func (*KeyStore) HasAddress

func (ks *KeyStore) HasAddress(addr accounts.Address) bool

HasAddress returns if current node has the specified addr

func (*KeyStore) NewAccount

func (ks *KeyStore) NewAccount(passphrase string, accountType uint32) (accounts.Account, error)

NewAccount creates a new account

func (*KeyStore) SignHashWithPassphrase

func (ks *KeyStore) SignHashWithPassphrase(a accounts.Account, passphrase string, hash []byte) (signature []byte, err error)

SignHashWithPassphrase signs hash if the private key matching the given address can be decrypted with the given passphrase. The produced signature is in the [R || S || V] format where V is 0 or 1.

func (*KeyStore) SignTx

func (ks *KeyStore) SignTx(a accounts.Account, tx *types.Transaction, pass string) (*types.Transaction, error)

SignTx sign the specified transaction

func (*KeyStore) Update

func (ks *KeyStore) Update(a accounts.Account, passphrase, newPassphrase string) error

Update update the specified account

Jump to

Keyboard shortcuts

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