account

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LastVersion    = 1
	UnknownVersion = 0
)
View Source
const (
	MaxNicknameLength = 32
)

Variables

View Source
var (
	ErrInvalidPrivateKey = errors.New("invalid private key")
	ErrRuntime           = errors.New("runtime execution")
	ErrInvalidParameter  = errors.New("invalid parameter")
)
View Source
var ErrInvalidNickname = errors.New("nickname invalid")

Functions

func CheckAlphanumeric

func CheckAlphanumeric(str string) bool

func NicknameIsValid

func NicknameIsValid(nickname string) bool

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

func NicknameIsValidForLoading(nickname string) bool

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 New

func New(
	version uint8,
	nickname string,
	address *types.Address,
	salt [16]byte,
	nonce [12]byte,
	encryptedPrivateKey *types.EncryptedPrivateKey,
	publicKey *types.PublicKey,
) (*Account, error)

func NewAccount

func NewAccount(t *testing.T) *Account

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) Marshal

func (a *Account) Marshal() ([]byte, error)

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) Sign

func (a *Account) Sign(password *memguard.LockedBuffer, data []byte) ([]byte, error)

Sign signs the data with the private key 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.

func (*Account) Unmarshal

func (a *Account) Unmarshal(data []byte) error

func (*Account) VerifySignature

func (a *Account) VerifySignature(data, signature []byte) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL