Documentation ¶
Index ¶
- Constants
- func CreateRandomKeyPair(now int64) (*ecdsa.PrivateKey, error)
- type Account
- func (a *Account) Authorise(password string) bool
- func (a *Account) CreateCollectionAccount(accountId int, passPhrase string, createCollection bool) error
- func (a *Account) CreatePodAccount(accountId int, passPhrase string, createPod bool) (*Info, error)
- func (a *Account) CreateUserAccount(passPhrase, mnemonic string) (string, string, error)
- func (a *Account) DeletePodAccount(accountId int)
- func (a *Account) GetAddress(index int) utils.Address
- func (*Account) GetEmptyAccountInfo() *Info
- func (a *Account) GetPodAccountInfo(index int) (*Info, error)
- func (a *Account) GetUserAccountInfo() *Info
- func (a *Account) GetUserPrivateKey(index int) *ecdsa.PrivateKey
- func (a *Account) GetWallet() *Wallet
- func (a *Account) LoadUserAccount(passPhrase, encryptedMnemonic string) error
- type Info
- func (ai *Info) DecryptContent(passphrase, encryptedContent string) (string, error)
- func (*Info) EncryptContent(passphrase, data string) (string, error)
- func (ai *Info) EncryptPublicKey(passPhrase string, pubKey *ecdsa.PublicKey) (string, error)
- func (ai *Info) GetAddress() utils.Address
- func (ai *Info) GetEncryptedPublicKey(passPhrase string) (string, error)
- func (ai *Info) GetPrivateKey() *ecdsa.PrivateKey
- func (ai *Info) GetPublicKey() *ecdsa.PublicKey
- func (a *Info) IsReadOnlyPod() bool
- func (ai *Info) SetAddress(addr utils.Address)
- type Wallet
Constants ¶
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 ¶
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 ¶
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 ¶
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.
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 ¶
func (*Account) GetPodAccountInfo ¶
GetPodAccountInfo returns the accountInfo for a given pod index.
func (*Account) GetUserAccountInfo ¶
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) LoadUserAccount ¶
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 (*Info) EncryptContent ¶ added in v0.8.0
func (*Info) EncryptPublicKey ¶ added in v0.8.0
func (*Info) GetAddress ¶
func (*Info) GetEncryptedPublicKey ¶ added in v0.8.0
func (*Info) GetPrivateKey ¶
func (ai *Info) GetPrivateKey() *ecdsa.PrivateKey
func (*Info) GetPublicKey ¶
func (*Info) IsReadOnlyPod ¶
func (*Info) SetAddress ¶
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
func (*Wallet) CreateAccount ¶
CreateAccount is used to create a new hd wallet using the given mnemonic 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 ic created. If a valid mnemonic is supplied, it is used, otherwise a bip-0039 based 12 word mnemonic is generated as used.