accounts

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrivateKeyFile added in v1.13.0

func PrivateKeyFile(name string) string

PrivateKeyFile returns the private key file name for an account.

func ToConfig

func ToConfig(accounts Accounts) config.Accounts

Types

type Account

type Account struct {
	Name    string
	Address flow.Address
	Key     Key
}

Account is defined by an address and name and contains an Key which can be used for signing.

func NewEmulatorAccount

func NewEmulatorAccount(
	rw config.ReaderWriter,
	sigAlgo crypto.SignatureAlgorithm,
	hashAlgo crypto.HashAlgorithm,
) (*Account, error)

type Accounts

type Accounts []Account

Accounts is a collection of account.

func FromConfig

func FromConfig(conf *config.Config) (Accounts, error)

func (*Accounts) AddOrUpdate

func (a *Accounts) AddOrUpdate(account *Account)

AddOrUpdate add account if missing or updates if present.

func (Accounts) ByAddress

func (a Accounts) ByAddress(address flow.Address) (*Account, error)

ByAddress get an account by address.

func (Accounts) ByName

func (a Accounts) ByName(name string) (*Account, error)

ByName get an account by name or returns and error if no account found

func (*Accounts) Names

func (a *Accounts) Names() []string

func (*Accounts) Remove

func (a *Accounts) Remove(name string) error

Remove an account.

func (*Accounts) String

func (a *Accounts) String() string

type BIP44Key

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

BIP44Key implements https://github.com/onflow/flow/blob/master/flips/20201125-bip-44-multi-account.md

func (BIP44Key) HashAlgo

func (a BIP44Key) HashAlgo() crypto.HashAlgorithm

func (BIP44Key) Index

func (a BIP44Key) Index() int

func (*BIP44Key) PrivateKey

func (a *BIP44Key) PrivateKey() (*crypto.PrivateKey, error)

func (BIP44Key) SigAlgo

func (a BIP44Key) SigAlgo() crypto.SignatureAlgorithm

func (*BIP44Key) Signer

func (a *BIP44Key) Signer(ctx context.Context) (crypto.Signer, error)

func (*BIP44Key) ToConfig

func (a *BIP44Key) ToConfig() config.AccountKey

func (BIP44Key) Type

func (a BIP44Key) Type() config.KeyType

func (*BIP44Key) Validate

func (a *BIP44Key) Validate() error

type FileKey

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

FileKey represents a key that is saved in a seperate file and will be lazy-loaded.

The FileKey stores location of the file where private key is stored in hex-encoded format.

func NewFileKey

func NewFileKey(
	location string,
	index int,
	sigAlgo crypto.SignatureAlgorithm,
	hashAlgo crypto.HashAlgorithm,
	rw config.ReaderWriter,
) *FileKey

NewFileKey creates a new account key that is stored to a separate file in the provided location.

This type of the key is a more secure way of storing accounts. The config only includes the location and not the key.

func (FileKey) HashAlgo

func (a FileKey) HashAlgo() crypto.HashAlgorithm

func (FileKey) Index

func (a FileKey) Index() int

func (*FileKey) PrivateKey

func (f *FileKey) PrivateKey() (*crypto.PrivateKey, error)

func (FileKey) SigAlgo

func (a FileKey) SigAlgo() crypto.SignatureAlgorithm

func (*FileKey) Signer

func (f *FileKey) Signer(ctx context.Context) (crypto.Signer, error)

func (*FileKey) ToConfig

func (f *FileKey) ToConfig() config.AccountKey

func (FileKey) Type

func (a FileKey) Type() config.KeyType

func (FileKey) Validate

func (a FileKey) Validate() error

type HexKey

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

HexKey implements account key in hex representation.

func NewHexKeyFromPrivateKey

func NewHexKeyFromPrivateKey(
	index int,
	hashAlgo crypto.HashAlgorithm,
	privateKey crypto.PrivateKey,
) *HexKey

func (HexKey) HashAlgo

func (a HexKey) HashAlgo() crypto.HashAlgorithm

func (HexKey) Index

func (a HexKey) Index() int

func (*HexKey) PrivateKey

func (a *HexKey) PrivateKey() (*crypto.PrivateKey, error)

func (HexKey) SigAlgo

func (a HexKey) SigAlgo() crypto.SignatureAlgorithm

func (*HexKey) Signer

func (a *HexKey) Signer(ctx context.Context) (crypto.Signer, error)

func (*HexKey) ToConfig

func (a *HexKey) ToConfig() config.AccountKey

func (HexKey) Type

func (a HexKey) Type() config.KeyType

func (*HexKey) Validate

func (a *HexKey) Validate() error

type KMSKey

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

KMSKey implements Gcloud KMS system for signing.

func (KMSKey) HashAlgo

func (a KMSKey) HashAlgo() crypto.HashAlgorithm

func (KMSKey) Index

func (a KMSKey) Index() int

func (*KMSKey) PrivateKey

func (a *KMSKey) PrivateKey() (*crypto.PrivateKey, error)

func (KMSKey) SigAlgo

func (a KMSKey) SigAlgo() crypto.SignatureAlgorithm

func (*KMSKey) Signer

func (a *KMSKey) Signer(ctx context.Context) (crypto.Signer, error)

func (*KMSKey) ToConfig

func (a *KMSKey) ToConfig() config.AccountKey

ToConfig convert account key to configuration.

func (KMSKey) Type

func (a KMSKey) Type() config.KeyType

func (*KMSKey) Validate

func (a *KMSKey) Validate() error

type Key

type Key interface {
	// Type returns the key type (hex, kms, file...)
	Type() config.KeyType
	// Index returns the key index on the account
	Index() int
	// SigAlgo returns signature algorithm used for signing
	SigAlgo() crypto.SignatureAlgorithm
	// HashAlgo returns hash algorithm used for signing
	HashAlgo() crypto.HashAlgorithm
	// Signer is used when we want to sign a transaction, using the Sign() function
	Signer(ctx context.Context) (crypto.Signer, error)
	// ToConfig converts the key to the storable key format
	ToConfig() config.AccountKey
	// Validate key
	Validate() error
	// PrivateKey returns the private key if possible,
	// depends on the key type
	PrivateKey() (*crypto.PrivateKey, error)
}

Key defines functions any key representation must implement.

type PublicKey

type PublicKey struct {
	Public   crypto.PublicKey
	Weight   int
	SigAlgo  crypto.SignatureAlgorithm
	HashAlgo crypto.HashAlgorithm
}

PublicKey contains public account key information.

Jump to

Keyboard shortcuts

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