wallet

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 8 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 AddressBinaryLen = common.AddressLength

AddressBinaryLen is the length of the binary representation of Address, in bytes.

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 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) 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) Equal added in v0.9.0

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

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

func (*Address) MarshalBinary added in v0.9.0

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

MarshalBinary marshals the address into its binary representation. Error will always be nil, it is for implementing BinaryMarshaler.

func (*Address) String

func (a *Address) String() string

String converts this address to a string.

func (*Address) UnmarshalBinary added in v0.9.0

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

UnmarshalBinary unmarshals the address from its binary representation.

type Backend

type Backend struct{}

Backend implements the utility interface defined in the wallet package.

func (*Backend) DecodeSig

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

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

func (*Backend) NewAddress added in v0.9.0

func (b *Backend) NewAddress() wallet.Address

NewAddress returns a variable of type Address, which can be used for unmarshalling an address from its binary representation.

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