key

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateHashWithoutSign

func CalculateHashWithoutSign(txBody *types.TxBody) []byte

CalculateHashWithoutSign return hash of tx without sign field

func EncryptKey

func EncryptKey(key []byte, pass string) ([]byte, error)

EncryptKey encrypts a key with a given export for exporting

func GetKeystore

func GetKeystore(key *PrivateKey, passphrase string) ([]byte, error)

GetKeystore encrypts a keystore file

func SignTx

func SignTx(tx *types.Tx, key *aergokey) error

SignTx return tx signature using stored key

func VerifyTx

func VerifyTx(tx *types.Tx) error

VerifyTx return result to verify sign

func VerifyTxWithAddress

func VerifyTxWithAddress(tx *types.Tx, address []byte) error

Types

type AergoStorage

type AergoStorage struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewAergoStorage

func NewAergoStorage(storePath string) (*AergoStorage, error)

func (*AergoStorage) Close

func (ks *AergoStorage) Close()

func (*AergoStorage) List

func (ks *AergoStorage) List() ([]Identity, error)

func (*AergoStorage) Load

func (ks *AergoStorage) Load(identity Identity, passphrase string) (*PrivateKey, error)

func (*AergoStorage) Save

func (ks *AergoStorage) Save(identity Identity, passphrase string, key *PrivateKey) (Identity, error)

type BadgerStorage

type BadgerStorage struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func LoadBadgerStorage

func LoadBadgerStorage(storePath string) (*BadgerStorage, error)

func NewBadgerStorage

func NewBadgerStorage(storePath string) (*BadgerStorage, error)

func (*BadgerStorage) Close

func (ks *BadgerStorage) Close()

func (*BadgerStorage) List

func (ks *BadgerStorage) List() ([]Identity, error)

func (*BadgerStorage) Load

func (ks *BadgerStorage) Load(identity Identity, password string) (*PrivateKey, error)

func (*BadgerStorage) Save

func (ks *BadgerStorage) Save(identity Identity, password string, key *PrivateKey) (Identity, error)

type Identity

type Identity = []byte

Identity is a raw, i.e. decoded address generated from a public key

type PrivateKey

type PrivateKey = btcec.PrivateKey

PrivateKey is a raw, decrypted private key

func LoadKeystore

func LoadKeystore(keystore []byte, passphrase string) (*PrivateKey, error)

LoadKeystore decrypts a keystore file

type Storage

type Storage interface {
	Save(identity Identity, passphrase string, key *PrivateKey) (Identity, error)
	Load(identity Identity, passphrase string) (*PrivateKey, error)
	List() ([]Identity, error)
	Close()
}

Storage defines an interfaces for persistent storage of identities

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Store stucture of keystore

func NewStore

func NewStore(storePath string, unlockTimeout uint) *Store

NewStore make new instance of keystore

func (*Store) AddKey

func (ks *Store) AddKey(key *btcec.PrivateKey, pass string) (Identity, error)

func (*Store) CloseStore

func (ks *Store) CloseStore()

CloseStore locks all addresses and closes the storage

func (*Store) CreateKey

func (ks *Store) CreateKey(pass string) (Identity, error)

CreateKey make new key in keystore and return it's address

func (*Store) ExportKey

func (ks *Store) ExportKey(addr Identity, pass string) ([]byte, error)

ExportKey is to export encrypted key

func (*Store) GetAddresses

func (ks *Store) GetAddresses() ([]Identity, error)

GetAddresses returns the list of stored addresses

func (*Store) GetKey

func (ks *Store) GetKey(address []byte, pass string) (*aergokey, error)

func (*Store) ImportKey

func (ks *Store) ImportKey(imported []byte, oldpass string, newpass string) (Identity, error)

ImportKey is to import encrypted key

func (*Store) Lock

func (ks *Store) Lock(addr Identity, pass string) (Identity, error)

Lock locks an account

func (*Store) Sign

func (ks *Store) Sign(addr Identity, pass string, hash []byte) ([]byte, error)

Sign return signature using stored key

func (*Store) SignTx

func (ks *Store) SignTx(tx *types.Tx, requester []byte) error

SignTx return transaction which signed with unlocked key. if requester is nil, requester is assumed to tx.Account

func (*Store) Unlock

func (ks *Store) Unlock(addr Identity, pass string) (Identity, error)

Unlock is to unlock account for signing

func (*Store) VerifyTx

func (ks *Store) VerifyTx(tx *types.Tx) error

VerifyTx return result to varify sign

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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