account

package
v0.10.1-rc2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxEntropyLength = 32
)
View Source
const (
	// UserAccountIndex is user root account
	UserAccountIndex = -1
)

Variables

This section is empty.

Functions

func CreateRandomKeyPair

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

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

Types

type Account

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

Account is used for keeping authenticated logged-in user info in the session

func New

func New(logger logging.Logger) *Account

New create an 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) CreatePodAccount

func (a *Account) CreatePodAccount(accountId int, 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(mnemonic string) (string, []byte, 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. skipcq: TCV-001

func (*Account) GenerateUserAccountFromSignature

func (a *Account) GenerateUserAccountFromSignature(signature, password string) (string, []byte, error)

GenerateUserAccountFromSignature create a new master account for a user.

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

GetEmptyAccountInfo returns blank user info skipcq: TCV-001

func (*Account) GetUserAccountInfo

func (a *Account) GetUserAccountInfo() *Info

GetUserAccountInfo returns the user info skipcq: TCV-001

func (*Account) GetWallet added in v0.5.3

func (a *Account) GetWallet() *Wallet

GetWallet returns the account.Wallet which contains the encrypted mnemonic or seed skipcq: TCV-001

func (*Account) LoadUserAccountFromSeed added in v0.9.1

func (a *Account) LoadUserAccountFromSeed(seed []byte) error

LoadUserAccountFromSeed loads the user account given the bip39 seed

type Info

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

Info is for keeping account info

func (*Info) GetAddress

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

GetAddress returns the address of the account info skipcq: TCV-001

func (*Info) GetPrivateKey

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

GetPrivateKey returns the private key from the account info

func (*Info) GetPublicKey

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

GetPublicKey returns the public key from the accoutn info

func (*Info) IsReadOnlyPod

func (ai *Info) IsReadOnlyPod() bool

IsReadOnlyPod checks if a pod account info is read only skipcq: TCV-001

func (*Info) PadSeed added in v0.9.1

func (*Info) PadSeed(seed []byte, passphrase string) ([]byte, error)

PadSeed pads the given seed with random elements to be a chunk of chunkSize

func (*Info) PadSeedName added in v0.9.3

func (*Info) PadSeedName(seed []byte, username, passphrase string) ([]byte, error)

PadSeedName pads the given seed and name with random elements to be a chunk of chunkSize

func (*Info) RemovePadFromSeed added in v0.9.1

func (*Info) RemovePadFromSeed(paddedSeed []byte, passphrase string) ([]byte, error)

RemovePadFromSeed removes the padding of random elements from the given data and returns the seed

func (*Info) RemovePadFromSeedName added in v0.9.3

func (*Info) RemovePadFromSeedName(paddedSeed []byte, passphrase string) ([]byte, string, error)

RemovePadFromSeedName removes the padding of random elements from the given data and returns the seed and name

func (*Info) SetAddress

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

SetAddress sets the address of the account info skipcq: TCV-001

type Wallet

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

Wallet is used to create root and pod accounts of user

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) CreateAccountFromSeed added in v0.9.1

func (w *Wallet) CreateAccountFromSeed(walletPath string, seed []byte) (accounts.Account, error)

CreateAccountFromSeed is used to create a new hd wallet using the given seed and the walletPath.

func (*Wallet) GenerateWalletFromSignature

func (w *Wallet) GenerateWalletFromSignature(signature, password string) (accounts.Account, string, error)

GenerateWalletFromSignature is used to create an account from a given signature

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 is 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