Documentation ¶
Index ¶
- Constants
- func AddressIsUnique(address string) error
- func CheckAlphanumeric(str string) bool
- func DeleteAccount(nickname string) error
- func ErrorAccountNotFound(nickname string) error
- func FilePath(nickname string) (string, error)
- func Filename(nickname string) string
- func Generate(nickname string, password string) (*Wallet, *WalletError)
- func GetWalletDir() (string, error)
- func GetWorkDir() (string, error)
- func Import(nickname string, privateKeyB58V string, password string) (*Wallet, *WalletError)
- func LoadFile(filePath string) (Wallet, *WalletError)
- func NicknameIsUnique(nickname string) error
- func NicknameIsValid(nickname string) bool
- func Xor(a, b []byte) ([]byte, error)
- type AccountSerialized
- type KeyPair
- type Wallet
- func (w *Wallet) DeleteFile() (err error)
- func (w *Wallet) FilePath() (string, error)
- func (w *Wallet) Filename() string
- func (wallet *Wallet) GetNonce() string
- func (wallet *Wallet) GetPrivKey() string
- func (wallet *Wallet) GetPupKey() string
- func (wallet *Wallet) GetSalt() string
- func (w *Wallet) Persist() error
- func (w *Wallet) Protect(password string) error
- func (wallet *Wallet) Sign(operation []byte) ([]byte, error)
- func (account *Wallet) ToAccountSerialized() AccountSerialized
- func (w *Wallet) Unprotect(password string) *WalletError
- func (w *Wallet) UnprotectFromCorrelationId(fromCache []byte, correlationId models.CorrelationID) error
- type WalletError
Constants ¶
const ( SecretKeyLength = 32 PBKDF2NbRound = 600_000 FileModeUserReadWriteOnly = 0o600 Base58Version = 0x00 UserAddressPrefix = "AU" PublicKeyPrefix = "P" PrivateKeyPrefix = "S" MaxNicknameLength = 32 )
Variables ¶
This section is empty.
Functions ¶
func AddressIsUnique ¶
func CheckAlphanumeric ¶
func DeleteAccount ¶
func ErrorAccountNotFound ¶
func FilePath ¶
FilePath returns the wallet file path base on the given nickname. Files are stored in
func Generate ¶
func Generate(nickname string, password string) (*Wallet, *WalletError)
Generate instantiates a new wallet, protects its private key and persists it. Everything is dynamically generated except from the nickname.
func GetWalletDir ¶
GetWalletDir returns the path where the account yaml file are stored. Note: the wallet directory is the folder where the wallet plugin binary resides.
func GetWorkDir ¶
func Import ¶
func Import(nickname string, privateKeyB58V string, password string) (*Wallet, *WalletError)
func LoadFile ¶
func LoadFile(filePath string) (Wallet, *WalletError)
func NicknameIsUnique ¶
func NicknameIsValid ¶
NicknameIsValid validates the nickname using the following rules: - must have at least 1 character - must contain only alphanumeric characters, underscores and dashes - must not exceed MaxNicknameLength characters
Types ¶
type AccountSerialized ¶
type AccountSerialized struct { Version *uint8 `yaml:"Version"` Nickname string `yaml:"Nickname"` Address string `yaml:"Address"` Salt [16]byte `yaml:"Salt,flow"` Nonce [12]byte `yaml:"Nonce,flow"` CipheredData []byte `yaml:"CipheredData,flow"` PublicKey []byte `yaml:"PublicKey,flow"` }
func (*AccountSerialized) ToAccount ¶
func (accountSerialized *AccountSerialized) ToAccount() Wallet
type KeyPair ¶
KeyPair structure contains all the information necessary to save a key pair securely.
type Wallet ¶
Wallet structure allows to link a nickname, an address and a version to one or more key pairs.
func Load ¶
Load loads the wallet that match the given name in the working directory Note: `wallet_` prefix and a `.yaml` extension are automatically added.
func LoadAll ¶
LoadAll loads all the wallets in the working directory. Note: a wallet must have: `wallet_` prefix and a `.yaml` extension.
func (*Wallet) DeleteFile ¶
Delete removes wallet from file system
func (*Wallet) GetPrivKey ¶
GetPrivKey returns the private key of the wallet. This function requires that the private key is not protected.
func (*Wallet) Persist ¶
Persist stores the wallet on the file system. Note: the wallet is stored in YAML format and in Massa Station wallet directory.
func (*Wallet) Protect ¶
Protect encrypts the private key using the given guiModal. The encryption algorithm used to protect the private key is AES-GCM and the secret key is derived from the given password using the PBKDF2 algorithm.
func (*Wallet) Sign ¶
Sign signs the given operation with the wallet. The operation is a base64 encoded string.
func (*Wallet) ToAccountSerialized ¶
func (account *Wallet) ToAccountSerialized() AccountSerialized
func (*Wallet) Unprotect ¶
func (w *Wallet) Unprotect(password string) *WalletError
Unprotect decrypts the private key using the given GUI Modal. The encryption algorithm used to unprotect the private key is AES-GCM and the secret key is derived from the given password using the PBKDF2 algorithm.
func (*Wallet) UnprotectFromCorrelationId ¶
func (w *Wallet) UnprotectFromCorrelationId(fromCache []byte, correlationId models.CorrelationID) error