Documentation ¶
Index ¶
- Constants
- func CreateRandomKeyPair(now int64) (*ecdsa.PrivateKey, error)
- type Account
- func (a *Account) CreatePodAccount(accountId int, createPod bool) (*Info, error)
- func (a *Account) CreateUserAccount(mnemonic string) (string, []byte, error)
- func (a *Account) DeletePodAccount(accountId int)
- func (a *Account) GetAddress(index int) utils.Address
- func (*Account) GetEmptyAccountInfo() *Info
- func (a *Account) GetUserAccountInfo() *Info
- func (a *Account) GetWallet() *Wallet
- func (a *Account) LoadUserAccountFromSeed(seed []byte) error
- type Info
- func (ai *Info) GetAddress() utils.Address
- func (ai *Info) GetPrivateKey() *ecdsa.PrivateKey
- func (ai *Info) GetPublicKey() *ecdsa.PublicKey
- func (ai *Info) IsReadOnlyPod() bool
- func (*Info) PadSeed(seed []byte, passphrase string) ([]byte, error)
- func (*Info) PadSeedName(seed []byte, username string, passphrase string) ([]byte, error)
- func (*Info) RemovePadFromSeed(paddedSeed []byte, passphrase string) ([]byte, error)
- func (*Info) RemovePadFromSeedName(paddedSeed []byte, passphrase string) ([]byte, string, error)
- func (ai *Info) SetAddress(addr utils.Address)
- type Wallet
- func (*Wallet) CreateAccount(walletPath, plainMnemonic string) (accounts.Account, error)
- func (w *Wallet) CreateAccountFromSeed(walletPath string, seed []byte) (accounts.Account, error)
- func (*Wallet) IsValidMnemonic(mnemonic string) error
- func (w *Wallet) LoadMnemonicAndCreateRootAccount(mnemonic string) (accounts.Account, string, error)
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
DeletePodAccount unloads/forgets a particular pods key value pair from the memory. skipcq: TCV-001
func (*Account) GetAddress ¶
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 ¶
GetEmptyAccountInfo returns blank user info skipcq: TCV-001
func (*Account) GetUserAccountInfo ¶
GetUserAccountInfo returns the user info skipcq: TCV-001
func (*Account) GetWallet ¶ added in v0.5.3
GetWallet returns the account.Wallet which contains the encrypted mnemonic or seed skipcq: TCV-001
func (*Account) LoadUserAccountFromSeed ¶ added in v0.9.1
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 ¶
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 ¶
GetPublicKey returns the public key from the accoutn info
func (*Info) IsReadOnlyPod ¶
IsReadOnlyPod checks if a pod account info is read only skipcq: TCV-001
func (*Info) PadSeed ¶ added in v0.9.1
PadSeed pads the given seed with random elements to be a chunk of chunkSize
func (*Info) PadSeedName ¶ added in v0.9.3
PadSeedName pads the given seed and name with random elements to be a chunk of chunkSize
func (*Info) RemovePadFromSeed ¶ added in v0.9.1
RemovePadFromSeed removes the padding of random elements from the given data and returns the seed
func (*Info) RemovePadFromSeedName ¶ added in v0.9.3
RemovePadFromSeedName removes the padding of random elements from the given data and returns the seed and name
func (*Info) SetAddress ¶
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 ¶
CreateAccount is used to create a new hd wallet using the given mnemonic and the walletPath.
func (*Wallet) CreateAccountFromSeed ¶ added in v0.9.1
CreateAccountFromSeed is used to create a new hd wallet using the given seed and the walletPath.
func (*Wallet) IsValidMnemonic ¶ added in v0.5.3
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.