vault

package
v2.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: Apache-2.0 Imports: 21 Imported by: 6

Documentation

Index

Constants

View Source
const (
	IVLength                   = 16
	MasterKeyLength            = 32
	ScryptSaltLength           = 8
	ScryptN                    = 1 << 15
	ScryptR                    = 8
	ScryptP                    = 1
	WalletVersion              = 2
	MinCompatibleWalletVersion = 1
	MaxCompatibleWalletVersion = 2
)

Variables

This section is empty.

Functions

func PasswordToAesKeyHash

func PasswordToAesKeyHash(password []byte) []byte

func PasswordToAesKeyScrypt

func PasswordToAesKeyScrypt(password []byte, scryptData *ScryptData) ([]byte, error)

Types

type Account

type Account struct {
	PrivateKey  []byte
	PublicKey   []byte
	ProgramHash common.Uint160
}

func NewAccount

func NewAccount() (*Account, error)

func NewAccountWithSeed

func NewAccountWithSeed(seed []byte) (*Account, error)

func (*Account) PrivKey

func (a *Account) PrivKey() []byte

func (*Account) PubKey

func (a *Account) PubKey() []byte

type ScryptData

type ScryptData struct {
	Salt string
	N    int
	R    int
	P    int
}

type Wallet

type Wallet struct {
	*WalletStore
	PasswordHash []byte
	// contains filtered or unexported fields
}

func GetWallet

func GetWallet(getPasswordFunc func() ([]byte, error)) (*Wallet, error)

func NewWallet

func NewWallet(path string, password []byte) (*Wallet, error)

func OpenWallet

func OpenWallet(path string, password []byte) (*Wallet, error)

func RestoreWallet added in v2.0.3

func RestoreWallet(path string, password, seed []byte) (*Wallet, error)

func (*Wallet) ChangePassword

func (w *Wallet) ChangePassword(oldPassword, newPassword []byte) error

func (*Wallet) GetContract

func (w *Wallet) GetContract() (*program.ProgramContext, error)

func (*Wallet) GetDefaultAccount

func (w *Wallet) GetDefaultAccount() (*Account, error)

func (*Wallet) Sign

func (w *Wallet) Sign(txn *transaction.Transaction) error

func (*Wallet) VerifyPassword

func (w *Wallet) VerifyPassword(password []byte) error

type WalletData

type WalletData struct {
	Version       int
	IV            string
	MasterKey     string
	SeedEncrypted string
	Address       string
	Scrypt        *ScryptData
}

func NewWalletData

func NewWalletData(account *Account, password, masterKey, iv, scryptSalt []byte, scryptN, scryptR, scryptP int) (*WalletData, error)

func (*WalletData) DecryptAccount

func (walletData *WalletData) DecryptAccount(password []byte) (*Account, error)

func (*WalletData) DecryptMasterKey

func (walletData *WalletData) DecryptMasterKey(password []byte) ([]byte, error)

func (*WalletData) VerifyPassword

func (walletData *WalletData) VerifyPassword(password []byte) error

type WalletStore

type WalletStore struct {
	*WalletData
	Path string
	sync.RWMutex
}

func LoadWalletStore

func LoadWalletStore(fullPath string) (*WalletStore, error)

func NewWalletStore

func NewWalletStore(path string, walletData *WalletData) (*WalletStore, error)

func (*WalletStore) Save

func (s *WalletStore) Save() error

Jump to

Keyboard shortcuts

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