request

package
v0.0.0-...-cb07b45 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Version int       `json:"version,required"` // version of the request
	Expiry  time.Time `json:"expiry,required"`  // avoid replay attacks
	Address string    `json:"address,required"` // address of the sender, must match the signature
	Data    []byte    `json:"data,required"`    // data to be sent to the server
}

func Decrypt

func Decrypt(hexkey string, req string) (*Request, error)

Decrypt decrypts the base64 encoded request data using a private key

func New

func New(address string, data []byte) *Request

func (*Request) Encrypt

func (r *Request) Encrypt(pubhexkey string) (string, error)

Encrypt encrypts the request data using the public key, result is base64 encoded

func (*Request) GenerateSignature

func (r *Request) GenerateSignature(hexkey string) (string, error)

GenerateSignature generates a signature for the request using a private key

func (*Request) RecoverAddress

func (r *Request) RecoverAddress(signature string) (*common.Address, error)

RecoverAddress uses the provided signature and returns the corresponding address

func (*Request) VerifySignature

func (r *Request) VerifySignature(signature string) bool

VerifySignature verifies the provided signature using the public key against a marshalled version of the request

Jump to

Keyboard shortcuts

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