account

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserAccountIndex = -1
)

Variables

This section is empty.

Functions

func CreateRandomKeyPair

func CreateRandomKeyPair(now int64) (*ecdsa.PrivateKey, error)

CreateRandomKeyPair creates a ecdsa key pair by using the given int64 number as the random number.

Types

type Account

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

func New

func New(logger logging.Logger) *Account

New create a account object through which the entire account management is done. it uses a 12 word BIP-0039 wordlist to create a 12 word mnemonic for every user and spawns key pais whenever necessary.

func (*Account) Authorise

func (a *Account) Authorise(password string) bool

Authorise is used to check if the given password is valid for an user account. this is done by decrypting the mnemonic using the supplied password and checking the validity of the mnemonic to see if it confirms to bip-0039 list of words.

func (*Account) CreateCollectionAccount

func (a *Account) CreateCollectionAccount(accountId int, passPhrase string, createCollection bool) error

CreateCollectionAccount is used to create a new key pair for every collection (KV or Doc) created. This key pair is again derived from the same master mnemonic of the user.

func (*Account) CreatePodAccount

func (a *Account) CreatePodAccount(accountId int, passPhrase string, createPod bool) (*Info, error)

CreatePodAccount is used to create a new key pair from the master mnemonic. this key pair is used as the base key pair for a newly created pod.

func (*Account) CreateUserAccount

func (a *Account) CreateUserAccount(passPhrase, mnemonic string) (string, string, error)

CreateUserAccount create a new master account for a user. if a valid mnemonic is provided it is used, otherwise a new mnemonic is generated. The generated mnemonic is AES encrypted using the password provided.

func (*Account) DeletePodAccount

func (a *Account) DeletePodAccount(accountId int)

DeletePodAccount unloads/forgets a particular pods key value pair from the memory.

func (*Account) GetAddress

func (a *Account) GetAddress(index int) utils.Address

GetAddress returns the address of a given account index. the index -1 belongs to user root account and other indexes belong to the respective pods.

func (*Account) GetEmptyAccountInfo

func (*Account) GetEmptyAccountInfo() *Info

func (*Account) GetPodAccountInfo

func (a *Account) GetPodAccountInfo(index int) (*Info, error)

GetPodAccountInfo returns the accountInfo for a given pod index.

func (*Account) GetUserAccountInfo

func (a *Account) GetUserAccountInfo() *Info

func (*Account) GetUserPrivateKey

func (a *Account) GetUserPrivateKey(index int) *ecdsa.PrivateKey

GetUserPrivateKey retuens the private key of a given account index. the index -1 belongs to user root account and other indexes belong to the respective pods.

func (*Account) GetWallet added in v0.5.3

func (a *Account) GetWallet() *Wallet

func (*Account) LoadUserAccount

func (a *Account) LoadUserAccount(passPhrase, encryptedMnemonic string) error

LoadUserAccount loads the user account given the encrypted mnemonic and password.

type Info

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

func (*Info) DecryptContent added in v0.8.0

func (ai *Info) DecryptContent(passphrase, encryptedContent string) (string, error)

func (*Info) EncryptContent added in v0.8.0

func (*Info) EncryptContent(passphrase, data string) (string, error)

func (*Info) EncryptPublicKey added in v0.8.0

func (ai *Info) EncryptPublicKey(passPhrase string, pubKey *ecdsa.PublicKey) (string, error)

func (*Info) GetAddress

func (ai *Info) GetAddress() utils.Address

func (*Info) GetEncryptedPublicKey added in v0.8.0

func (ai *Info) GetEncryptedPublicKey(passPhrase string) (string, error)

func (*Info) GetPrivateKey

func (ai *Info) GetPrivateKey() *ecdsa.PrivateKey

func (*Info) GetPublicKey

func (ai *Info) GetPublicKey() *ecdsa.PublicKey

func (*Info) IsReadOnlyPod

func (a *Info) IsReadOnlyPod() bool

func (*Info) SetAddress

func (ai *Info) SetAddress(addr utils.Address)

type Wallet

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

func NewWallet

func NewWallet(mnemonic string) *Wallet

func (*Wallet) CreateAccount

func (*Wallet) CreateAccount(walletPath, plainMnemonic string) (accounts.Account, error)

CreateAccount is used to create a new hd wallet using the given mnemonic and the walletPath.

func (*Wallet) IsValidMnemonic added in v0.5.3

func (*Wallet) IsValidMnemonic(mnemonic string) error

IsValidMnemonic is used to validate a mnemonic to see if it is valid 12 word bip-0039 compliant.

func (*Wallet) LoadMnemonicAndCreateRootAccount

func (w *Wallet) LoadMnemonicAndCreateRootAccount(mnemonic string) (accounts.Account, string, error)

LoadMnemonicAndCreateRootAccount is used create a new user account when a user ic created. If a valid mnemonic is supplied, it is used, otherwise a bip-0039 based 12 word mnemonic is generated as used.

Jump to

Keyboard shortcuts

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