wallet

package
v0.0.0-...-1b5cee2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Helper

type Helper struct{}

Helper provides wallet helper functionalities without knowing about wallet private and public keys.

func NewVerifier

func NewVerifier() Helper

NewVerifier creates new wallet Helper verifier.

func (Helper) AddressToPubKey

func (h Helper) AddressToPubKey(address string) (ed25519.PublicKey, error)

AddressToPubKey creates ED25519 public key from address, or returns error otherwise.

func (Helper) Verify

func (h Helper) Verify(message, signature []byte, hash [32]byte, address string) error

Verify verifies if message is signed by given key and hash is equal.

type Wallet

type Wallet struct {
	Private ed25519.PrivateKey `json:"private" bson:"private"`
	Public  ed25519.PublicKey  `json:"public" bson:"public"`
}

Wallet holds public and private key of the wallet owner.

func DecodeGOBWallet

func DecodeGOBWallet(data []byte) (Wallet, error)

DecodeGOBWallet tries to decode Wallet from gob representation or returns error otherwise.

func New

func New() (Wallet, error)

New tries to creates a new Wallet or returns error otherwise.

func (*Wallet) Address

func (w *Wallet) Address() string

Address creates address from the public key that contains wallet version and checksum.

func (*Wallet) ChecksumLength

func (w *Wallet) ChecksumLength() int

ChecksumLength returns checksum length.

func (*Wallet) EncodeGOB

func (w *Wallet) EncodeGOB() ([]byte, error)

EncodeGOB tries to encodes Wallet in to the gob representation or returns error otherwise.

func (*Wallet) Sign

func (w *Wallet) Sign(message []byte) (digest [32]byte, signature []byte)

Sign signs the message with Ed25519 signature. Returns digest hash sha256 and signature.

func (*Wallet) Verify

func (w *Wallet) Verify(message, signature []byte, hash [32]byte) bool

Verify verifies message ED25519 signature and hash. Uses hashing sha256.

func (*Wallet) Version

func (w *Wallet) Version() byte

Version returns wallet version.

Jump to

Keyboard shortcuts

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