wallet

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package wallet contains the off-chain identity and signature handling of go-perun's internet computer backend. It uses ed25519 keys as identities and the EdDSA signature algorithm. Anonymously import the package from your application to inject the backend into go-perun.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account ed.PrivateKey

Account is an ed25519 signing key. It signs messages for a perun off-chain identity in internet computer channels.

func (Account) Address

func (a Account) Address() wallet.Address

func (Account) L2Address

func (a Account) L2Address() Address

func (Account) SignData

func (a Account) SignData(data []byte) ([]byte, error)

type Address

type Address ed.PublicKey

Address is an ed25519 public key and represents a perun off-chain identity in internet computer channels.

func AsAddr

func AsAddr(acc wallet.Address) *Address

func (*Address) Cmp

func (a *Address) Cmp(b wallet.Address) int

func (*Address) Equal

func (a *Address) Equal(b wallet.Address) bool

func (*Address) MarshalBinary

func (a *Address) MarshalBinary() ([]byte, error)

func (*Address) String

func (a *Address) String() string

func (*Address) UnmarshalBinary

func (a *Address) UnmarshalBinary(data []byte) error

type Backend

type Backend struct{}

func (Backend) DecodeSig

func (Backend) DecodeSig(r io.Reader) (wallet.Sig, error)

func (Backend) NewAddress

func (Backend) NewAddress() wallet.Address

func (Backend) VerifySignature

func (Backend) VerifySignature(
	msg []byte,
	sign wallet.Sig,
	a wallet.Address,
) (ok bool, err error)

type FsWallet

type FsWallet struct {
	// contains filtered or unexported fields
}

FsWallet is a garbage-collected file system key store, removing all keys when they are no longer used. Generated keys will not be persisted to permanent storage unless IncrementUsage() is called on them. Once a key is no longer used (as indicated by DecrementUsage()), it is deleted from storage.

func CreateOrLoadFsWallet

func CreateOrLoadFsWallet(path string, gen io.Reader) (*FsWallet, error)

CreateOrLoadFsWallet loads the wallet from the requested path, otherwise, it creates a new one and saves it to the requested path.

func NewRAMWallet

func NewRAMWallet(gen io.Reader) (*FsWallet, error)

NewRAMWallet creates an unpersisted FsWallet.

func NewWallet

func NewWallet() *FsWallet

func (*FsWallet) DecrementUsage

func (w *FsWallet) DecrementUsage(a wallet.Address)

DecrementUsage completements IncrementUsage().

func (*FsWallet) IncrementUsage

func (w *FsWallet) IncrementUsage(a wallet.Address)

IncrementUsage tracks how many times an account is in use. Use DecrementUsage() when an account is no longer used. Once the counter reaches 0, the account is deleted.

func (*FsWallet) LockAll

func (w *FsWallet) LockAll()

LockAll disables all currently unlocked accounts.

func (*FsWallet) NewAccount

func (w *FsWallet) NewAccount() Account

NewAccount creates a fresh unlocked account. This account is not persisted until IncrementUsage() is called on it.

func (*FsWallet) NewRandomAccount

func (w *FsWallet) NewRandomAccount(_ *rand.Rand) wallet.Account

NewRandomAccount creates a new random account using the wallet package.

func (*FsWallet) Unlock

func (w *FsWallet) Unlock(a wallet.Address) (wallet.Account, error)

Unlock retrieves the account belonging to the requested address.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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