Documentation ¶
Index ¶
- Constants
- Variables
- func CheckAlphanumeric(str string) bool
- func NicknameIsValid(nickname string) bool
- func NicknameIsValidForLoading(nickname string) bool
- type Account
- func Generate(password *memguard.LockedBuffer, nickname string) (*Account, error)
- func New(version uint8, nickname string, address *types.Address, salt [16]byte, ...) (*Account, error)
- func NewAccount(t *testing.T) *Account
- func NewFromPrivateKey(password *memguard.LockedBuffer, nickname string, ...) (*Account, error)
- func (a *Account) HasAccess(password *memguard.LockedBuffer) bool
- func (a *Account) Marshal() ([]byte, error)
- func (a *Account) PrivateKeyBytesInClear(password *memguard.LockedBuffer) (*memguard.LockedBuffer, error)
- func (a *Account) PrivateKeyTextInClear(password *memguard.LockedBuffer) (*memguard.LockedBuffer, error)
- func (a *Account) Sign(password *memguard.LockedBuffer, data []byte) ([]byte, error)
- func (a *Account) SignWithPrivateKey(privateKey *memguard.LockedBuffer, data []byte) []byte
- func (a *Account) Unmarshal(data []byte) error
- func (a *Account) VerifySignature(data, signature []byte) bool
Constants ¶
const ( LastVersion = 1 UnknownVersion = 0 )
const (
MaxNicknameLength = 32
)
Variables ¶
var ( ErrInvalidPrivateKey = errors.New("invalid private key") ErrRuntime = errors.New("runtime execution") ErrInvalidParameter = errors.New("invalid parameter") )
var ErrInvalidNickname = errors.New("nickname invalid")
Functions ¶
func CheckAlphanumeric ¶
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
func NicknameIsValidForLoading ¶ added in v0.3.0
NicknameIsValidForLoading validates the nickname using the following rules: - must have at least 1 character - must contain only alphanumeric characters, underscores and dashes - must not exceed 53 characters The length is 53 because for importing or loading an account file, we want to accept the address as a nickname, because massa-client uses the address as the nickname when saving the account file.
Types ¶
type Account ¶
type Account struct { Version *uint8 `yaml:"Version"` Nickname string `yaml:"Nickname,omitempty"` Address *types.Address `yaml:"Address,omitempty"` Salt [16]byte `yaml:"Salt,flow"` Nonce [12]byte `yaml:"Nonce,flow"` CipheredData *types.EncryptedPrivateKey `yaml:"CipheredData,flow"` PublicKey *types.PublicKey `yaml:"PublicKey,flow"` }
func Generate ¶
func Generate(password *memguard.LockedBuffer, nickname string) (*Account, error)
Generate generates a new account with a random private key. It destroys the password.
func NewAccount ¶
func NewFromPrivateKey ¶
func NewFromPrivateKey(password *memguard.LockedBuffer, nickname string, privateKeyText *memguard.LockedBuffer) (*Account, error)
NewFromPrivateKey creates a new account from a private key. It destroys the password.
func (*Account) HasAccess ¶
func (a *Account) HasAccess(password *memguard.LockedBuffer) bool
HasAccess returns true if the password is valid for the account. It destroys the password.
func (*Account) PrivateKeyBytesInClear ¶
func (a *Account) PrivateKeyBytesInClear(password *memguard.LockedBuffer) (*memguard.LockedBuffer, error)
func (*Account) PrivateKeyTextInClear ¶
func (a *Account) PrivateKeyTextInClear(password *memguard.LockedBuffer) (*memguard.LockedBuffer, error)
PrivateKeyTextInClear returns the private key in clear and destroys the password.
func (*Account) SignWithPrivateKey ¶
func (a *Account) SignWithPrivateKey(privateKey *memguard.LockedBuffer, data []byte) []byte
SignWithPrivateKey signs the data with the private key and destroys the private key.