dapp

package module
v0.0.0-...-d98639d Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 9 Imported by: 0

README

go-dapp

Package dapp provides to for making dapps, for the Go programming language.

These include ethereum and other evm based networks.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-dapp

GoDoc

Examples

Here is an example of verifying a signature:

import "github.com/reiver/go-dapp"

// ...

var addressHexadecimalString   string = "--PUT-THE-HEXADECIMAL-ADDRESS-HERE--"
var messageHexadecimalString   string = "--PUT-THE-HEXADECIMAL-MESSAGE-HERE--"
var signatureHexadecimalString string = "--PUT-THE-HEXIDECIMAL-SIGNATURE-HERE--"

// This is the adddress you expect.
address, err := dapp.LoadAddressFromHexadecimalString(addressHexadecimalString)
if nil != err {
	return err
}

message, err := dapp.LoadMessageFromHexadecimalString(messageHexadecimalString)
if nil != err {
	return err
}

signature, err := dapp.LoadSignatureFromHexadecimalString(signatureHexadecimalString)
if nil != err {
	return err
}

addressFromSignature, err := dapp.LoadAddressFromMessageAndSignature(message, signature)
if nil != err {
	return err
}

var verified bool = (address == addressFromSignature)

Import

To import package dapp use import code like the follownig:

import "github.com/reiver/go-dapp"

Installation

To install package dapp do the following:

GOPROXY=direct go get https://github.com/reiver/go-dapp

Author

Package dapp was written by Charles Iliya Krempeaux

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

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

func LoadAddressFromBytes

func LoadAddressFromBytes(data []byte) (Address, error)

func LoadAddressFromHexadecimalString

func LoadAddressFromHexadecimalString(hexstr string) (Address, error)

func NoAddress

func NoAddress() Address

func (Address) Bytes

func (receiver Address) Bytes() []byte

func (Address) HexadecimalString

func (receiver Address) HexadecimalString() string

type Digest

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

func LoadDigestFromBytes

func LoadDigestFromBytes(data []byte) (Digest, error)

func LoadDigestFromHexadecimalString

func LoadDigestFromHexadecimalString(hexstr string) (Digest, error)

func NoDigest

func NoDigest() Digest

func (Digest) Bytes

func (receiver Digest) Bytes() []byte

func (Digest) HexadecimalString

func (receiver Digest) HexadecimalString() string

type Message

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

func LoadMessageFromBytes

func LoadMessageFromBytes(data []byte) (Message, error)

func LoadMessageFromHexadecimalString

func LoadMessageFromHexadecimalString(hexstr string) (Message, error)

func NoMessage

func NoMessage() Message

func (Message) Bytes

func (receiver Message) Bytes() []byte

func (Message) EthereumTextHashDigest

func (receiver Message) EthereumTextHashDigest() Digest

func (Message) HexadecimalString

func (receiver Message) HexadecimalString() string

type PublicKey

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

func LoadPublicKeyFromBytes

func LoadPublicKeyFromBytes(data []byte) (PublicKey, error)

func LoadPublicKeyFromEthereumTextHashDigestAndSignature

func LoadPublicKeyFromEthereumTextHashDigestAndSignature(ethereumTextHashDigest Digest, signature Signature) (PublicKey, error)

func LoadPublicKeyFromHexadecimalString

func LoadPublicKeyFromHexadecimalString(hexstr string) (PublicKey, error)

func LoadPublicKeyFromMessageAndSignature

func LoadPublicKeyFromMessageAndSignature(message Message, signature Signature) (PublicKey, error)

func NoPublicKey

func NoPublicKey() PublicKey

func (PublicKey) Address

func (receiver PublicKey) Address() (Address, error)

func (PublicKey) Bytes

func (receiver PublicKey) Bytes() []byte

func (PublicKey) ECDSAPublicKey

func (receiver PublicKey) ECDSAPublicKey() (ecdsa.PublicKey, error)

func (PublicKey) HexadecimalString

func (receiver PublicKey) HexadecimalString() string

type Signature

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

func LoadSignatureFromBytes

func LoadSignatureFromBytes(data []byte) (Signature, error)

func LoadSignatureFromHexadecimalString

func LoadSignatureFromHexadecimalString(hexstr string) (Signature, error)

func NoSignature

func NoSignature() Signature

func (Signature) Bytes

func (receiver Signature) Bytes() []byte

func (Signature) HexadecimalString

func (receiver Signature) HexadecimalString() string

func (Signature) SigningAddress

func (receiver Signature) SigningAddress(message Message) (Address, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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