signer

package
v0.0.0-...-0b85bb3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ECSignature

type ECSignature struct {
	V byte
	R common.Hash
	S common.Hash
}

ECSignature contains the parameters of an elliptic curve signature

type KlayRPCSigner

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

KlayRPCSigner is a signer that uses a call to Klaytn JSON-RPC method `klay_call` to produce a signature

func (*KlayRPCSigner) KlaySign

func (e *KlayRPCSigner) KlaySign(message []byte, signerAddress common.Address) (*ECSignature, error)

KlaySign signs a message via the `klay_sign` Klaytn JSON-RPC call

type LocalSigner

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

LocalSigner is a signer that produces an `klay_sign`-compatible signature locally using a private key

func (*LocalSigner) GetSignerAddress

func (l *LocalSigner) GetSignerAddress() common.Address

GetSignerAddress returns the signerAddress corresponding to LocalSigner's private key

func (*LocalSigner) KlaySign

func (l *LocalSigner) KlaySign(message []byte, signerAddress common.Address) (*ECSignature, error)

KlaySign mimicks the signing of `klay_sign` locally its supplied private key

type NameValueType

type NameValueType struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
	Typ   string      `json:"type"`
}

NameValueType is a very simple struct with Name, Value and Type. It's meant for simple json structures used to communicate signing-info about typed data with the UI

func (*NameValueType) Pprint

func (nvt *NameValueType) Pprint(depth int) string

Pprint returns a pretty-printed version of nvt

type Signer

type Signer interface {
	KlaySign(message []byte, signerAddress common.Address) (*ECSignature, error)
}

Signer defines the methods needed to act as a elliptic curve signer

func NewKlayRPCSigner

func NewKlayRPCSigner(rpcClient *rpc.Client) Signer

NewKlayRPCSigner instantiates a new KlayRPCSigner

func NewLocalSigner

func NewLocalSigner(privateKey *ecdsa.PrivateKey) Signer

NewLocalSigner instantiates a new LocalSigner

type Type

type Type struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type TypePriority

type TypePriority struct {
	Type  string
	Value uint
}

type TypedData

type TypedData struct {
	Types       Types            `json:"types"`
	PrimaryType string           `json:"primaryType"`
	Domain      TypedDataDomain  `json:"domain"`
	Message     TypedDataMessage `json:"message"`
}

func (*TypedData) Dependencies

func (typedData *TypedData) Dependencies(primaryType string, found []string) []string

Dependencies returns an array of custom types ordered by their hierarchical reference tree

func (*TypedData) EncodeData

func (typedData *TypedData) EncodeData(primaryType string, data map[string]interface{}, depth int) (hexutil.Bytes, error)

EncodeData generates the following encoding: `enc(value₁) ‖ enc(value₂) ‖ … ‖ enc(valueₙ)`

each encoded member is 32-byte long

func (*TypedData) EncodePrimitiveValue

func (typedData *TypedData) EncodePrimitiveValue(encType string, encValue interface{}, depth int) ([]byte, error)

EncodePrimitiveValue deals with the primitive values found while searching through the typed data

func (*TypedData) EncodeType

func (typedData *TypedData) EncodeType(primaryType string) hexutil.Bytes

EncodeType generates the following encoding: `name ‖ "(" ‖ member₁ ‖ "," ‖ member₂ ‖ "," ‖ … ‖ memberₙ ")"`

each member is written as `type ‖ " " ‖ name` encodings cascade down and are sorted by name

func (*TypedData) Format

func (typedData *TypedData) Format() ([]*NameValueType, error)

Format returns a representation of typedData, which can be easily displayed by a user-interface without in-depth knowledge about 712 rules

func (*TypedData) HashStruct

func (typedData *TypedData) HashStruct(primaryType string, data TypedDataMessage) (hexutil.Bytes, error)

HashStruct generates a keccak256 hash of the encoding of the provided data

func (*TypedData) Map

func (typedData *TypedData) Map() map[string]interface{}

Map generates a map version of the typed data

func (*TypedData) TypeHash

func (typedData *TypedData) TypeHash(primaryType string) hexutil.Bytes

TypeHash creates the keccak256 hash of the data

type TypedDataDomain

type TypedDataDomain struct {
	Name              string                `json:"name"`
	Version           string                `json:"version"`
	ChainId           *math.HexOrDecimal256 `json:"chainId"`
	VerifyingContract string                `json:"verifyingContract"`
	Salt              string                `json:"salt"`
}

func (*TypedDataDomain) Map

func (domain *TypedDataDomain) Map() map[string]interface{}

Map is a helper function to generate a map version of the domain

type TypedDataMessage

type TypedDataMessage = map[string]interface{}

type Types

type Types map[string][]Type

type ValidatorData

type ValidatorData struct {
	Address common.Address
	Message hexutil.Bytes
}

func UnmarshalValidatorData

func UnmarshalValidatorData(data interface{}) (ValidatorData, error)

UnmarshalValidatorData converts the bytes input to typed data

Jump to

Keyboard shortcuts

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