wallet

package
v0.0.0-...-8619d99 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeSig

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

DecodeSig decodes the given io.Reader to a wallet signature.

func Hash

func Hash(msg []byte) []byte

Hash returns the SHA256 of msg.

Types

type Account

type Account ecdsa.PrivateKey

Account identifies a Fabric identity by its X509 certificate's private key. The only supported type is *ecdsa.PrivateKey because that's the only type used in Fabric currently.

func NewRandomAccount

func NewRandomAccount(rng io.Reader) *Account

NewRandomAccount creates a new Account using the randomness provided by rng. The default curve (P-256) is used.

func (*Account) Address

func (a *Account) Address() wallet.Address

Address of this Account.

func (*Account) ECDSA

func (a *Account) ECDSA() *ecdsa.PrivateKey

ECDSA returns the private key.

func (*Account) FabricAddress

func (a *Account) FabricAddress() *Address

FabricAddress returns the public key of this account as this package's Address type.

func (*Account) SignData

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

SignData signs the data with this account. The data is hashed before signing.

type Address

type Address ecdsa.PublicKey

Address identifies a Fabric identity by its X509 certificate's public key. The only supported type is *ecdsa.PublicKey because that's the only type used in Fabric currently.

func AddressFromX509Certificate

func AddressFromX509Certificate(cert *x509.Certificate) (*Address, error)

AddressFromX509Certificate extracts the public key from the given certificate.

func NewRandomAddress

func NewRandomAddress(rng io.Reader) *Address

NewRandomAddress creates a new Address using the randomness provided by rng. The default curve (P-256) is used.

func (*Address) Clone

func (a *Address) Clone() *Address

Clone duplicates the Address.

func (*Address) Cmp

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

Cmp checks the ordering of two Addresses according to following definition: -1 if (a.X < b.X) || ((a.X == b.X) && (a.Y < b.Y)). 0 if (a.X == b.X) && (a.Y == b.Y). +1 if (a.X > b.X) || ((a.X == b.X) && (a.Y > b.Y)). So the X coordinate takes precedence over the Y coordinate. Pancis if the passed address is of the wrong type or the curves are not the same.

func (*Address) ECDSA

func (a *Address) ECDSA() *ecdsa.PublicKey

ECDSA returns the public key.

func (*Address) Equal

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

Equal returns wether the two addresses are equal. The implementation must be equivalent to checking `Address.Cmp(Address) == 0`.

func (*Address) MarshalBinary

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

MarshalBinary allows to marshal Address in ASN1.

func (*Address) MarshalJSON

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

func (*Address) String

func (a *Address) String() string

func (*Address) UnmarshalBinary

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

UnmarshalBinary allows to unmarshal Address from ASN1.

func (*Address) UnmarshalJSON

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

type Backend

type Backend struct{}

Backend provides useful methods for hl fabric.

func (Backend) DecodeSig

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

DecodeSig reads a signature from the provided reader.

func (Backend) NewAddress

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 (b Backend) VerifySignature(msg []byte, sig wallet.Sig, a wallet.Address) (bool, error)

VerifySignature verifies that signature sig is a valid signature by a on message msg. If the signature does not match the address, it returns false, nil.

type Randomizer

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

Randomizer wraps a Wallet to derive new random parameters from it.

func NewRandomizer

func NewRandomizer() *Randomizer

NewRandomizer returns a Randomizer containing a fresh, random Wallet.

func (*Randomizer) NewRandomAddress

func (r *Randomizer) NewRandomAddress(rng *rand.Rand) wallet.Address

NewRandomAddress should return a new random address generated from the passed rng.

func (*Randomizer) NewWallet

func (r *Randomizer) NewWallet() test.Wallet

NewWallet returns a fresh, temporary Wallet that doesn't hold any accounts yet.

func (*Randomizer) RandomWallet

func (r *Randomizer) RandomWallet() test.Wallet

RandomWallet returns a fixed random wallet that is part of the randomizer's state.

type Wallet

type Wallet map[wallet.AddrKey]*Account

Wallet contains multiple Account's identifiable by their AddrKey.

func NewWallet

func NewWallet(accs ...*Account) Wallet

NewWallet creates a new Wallet that will contain the optionally provided accounts.

func (Wallet) Add

func (w Wallet) Add(acc *Account)

Add adds the given Account to the Wallet.

func (Wallet) DecrementUsage

func (w Wallet) DecrementUsage(wallet.Address)

DecrementUsage - noop.

func (Wallet) IncrementUsage

func (w Wallet) IncrementUsage(wallet.Address)

IncrementUsage - noop.

func (Wallet) LockAll

func (w Wallet) LockAll()

LockAll - noop.

func (Wallet) NewRandomAccount

func (w Wallet) NewRandomAccount(rng *rand.Rand) wallet.Account

NewRandomAccount generates a new random Account and adds it to the Wallet.

func (Wallet) Unlock

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

Unlock returns the account for the provided address.

Jump to

Keyboard shortcuts

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