wallet

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package wallet implements go-perun's wallet interface for the ethereum backend. It makes use of go-ethereum's keystore module for storing, reading, and generating keys, as well as signing.

Index

Constants

View Source
const SigLen = 65

SigLen length of a signature in byte. ref https://godoc.org/github.com/ethereum/go-ethereum/crypto/secp256k1#Sign ref https://github.com/ethereum/go-ethereum/blob/54b271a86dd748f3b0bcebeaf678dc34e0d6177a/crypto/signature_cgo.go#L66

Variables

This section is empty.

Functions

func AsEthAddr added in v0.2.1

func AsEthAddr(a wallet.Address) common.Address

AsEthAddr is a helper function to convert an address interface back into an ethereum address.

func DecodeAddress

func DecodeAddress(r io.Reader) (wallet.Address, error)

DecodeAddress decodes an address from an io.Reader.

func DecodeSig

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

DecodeSig reads a []byte with length of an ethereum signature.

func PrefixedHash added in v0.4.1

func PrefixedHash(data []byte) []byte

PrefixedHash adds an ethereum specific prefix to the hash of given data, rehashes the results and returns it.

func VerifySignature

func VerifySignature(msg []byte, sig wallet.Sig, a wallet.Address) (bool, error)

VerifySignature verifies if a signature was made by this account.

Types

type Address

type Address common.Address

Address represents an ethereum address as a perun address.

func AsWalletAddr added in v0.4.0

func AsWalletAddr(addr common.Address) *Address

AsWalletAddr is a helper function to convert an ethereum address to an address interface.

func (*Address) Bytes

func (a *Address) Bytes() []byte

Bytes returns the address as a byte slice.

func (*Address) Cmp added in v0.4.0

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

Cmp checks ordering of two addresses.

0 if a==b,

-1 if a < b, +1 if a > b. https://godoc.org/bytes#Compare

func (*Address) Decode

func (a *Address) Decode(r io.Reader) error

Decode decodes an address from a io.Reader. Part of the go-perun/pkg/io.Serializer interface.

func (*Address) Encode

func (a *Address) Encode(w io.Writer) error

Encode encodes this address into a io.Writer. Part of the go-perun/pkg/io.Serializer interface.

func (*Address) Equals

func (a *Address) Equals(addr wallet.Address) bool

Equals checks the equality of two addresses. The implementation must be equivalent to checking `Address.Cmp(Address) == 0`.

func (*Address) String

func (a *Address) String() string

String converts this address to a string.

type Backend

type Backend struct{}

Backend implements the utility interface defined in the wallet package.

func (*Backend) DecodeAddress

func (*Backend) DecodeAddress(r io.Reader) (wallet.Address, error)

DecodeAddress decodes an address from an io.Reader.

func (*Backend) DecodeSig

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

DecodeSig reads a []byte with length of an ethereum signature.

func (*Backend) VerifySignature

func (*Backend) VerifySignature(msg []byte, sig wallet.Sig, a wallet.Address) (bool, error)

VerifySignature verifies a signature.

Directories

Path Synopsis
Package hd contains perun wallet and accounts implementation for accessing accounts stored in an ethereum hierarchial deterministic (HD) wallet.
Package hd contains perun wallet and accounts implementation for accessing accounts stored in an ethereum hierarchial deterministic (HD) wallet.
Package keystore contains perun wallet and accounts implementation for accessing accounts stored in ethereum keystore.
Package keystore contains perun wallet and accounts implementation for accessing accounts stored in ethereum keystore.
Package simple contains a simplistic implementation of the perun wallet, account, and transactor interfaces.
Package simple contains a simplistic implementation of the perun wallet, account, and transactor interfaces.
Package test contains utilities for generating random ethereum accounts and addresses.
Package test contains utilities for generating random ethereum accounts and addresses.

Jump to

Keyboard shortcuts

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