signer

package
v0.1.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldPath     = "path"
	FieldPassword = "password"
)
View Source
const (
	FieldAddress = "address"
	FieldURL     = "url"
)

Variables

View Source
var (
	ErrUnknownSignerMethod = fmt.Errorf("unknown signer method")
)

Functions

func NewLocalConfig

func NewLocalConfig(cfg SignerConfig) (types.KeystoreFileConfig, error)

NewLocalConfig creates a KeystoreFileConfig (specific config) from a SignerConfig

Types

type LocalSign

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

LocalSign is a signer that uses a local keystore file

func NewLocalSign

func NewLocalSign(name string, logger commontypes.Logger, file types.KeystoreFileConfig) *LocalSign

NewLocalSign creates a new LocalSign based on config

func NewLocalSignFromPrivateKey

func NewLocalSignFromPrivateKey(name string,
	logger commontypes.Logger,
	privateKey *ecdsa.PrivateKey) *LocalSign

NewLocalSignFromPrivateKey creates a new LocalSign based on a private key

func (*LocalSign) Initialize

func (e *LocalSign) Initialize(ctx context.Context) error

Initialize initializes the LocalSign, read key if needed

func (*LocalSign) PublicAddress

func (e *LocalSign) PublicAddress() common.Address

func (*LocalSign) SignHash

func (e *LocalSign) SignHash(ctx context.Context, hash common.Hash) ([]byte, error)

SignHash signs a hash

func (*LocalSign) String

func (e *LocalSign) String() string

type SignMethod

type SignMethod string
var (
	MethodLocal      SignMethod = "local"
	MethodWeb3Signer SignMethod = "web3signer"
)

func (SignMethod) String

func (m SignMethod) String() string

type Signer

type Signer interface {
	// Initialize the signer
	Initialize(context.Context) error
	// SignHash signs the hash using the private key
	SignHash(context.Context, common.Hash) ([]byte, error)
	// PublicKey returns the public key of the signer
	PublicAddress() common.Address
	// String returns a string representation of the signer (no secrets)
	String() string
}

func NewSigner

func NewSigner(name string, logger types.Logger, ctx context.Context, cfg SignerConfig) (Signer, error)

type SignerConfig

type SignerConfig struct {
	// Method is the method to use to sign
	Method SignMethod `jsonschema:"enum=local, enum=web3signer" mapstructure:"Method"`
	// Config is the configuration for the signer (depend on Method field)
	Config map[string]any `jsonschema:"omitempty" mapstructure:",remain"`
}

SignerConfig is the configuration for the Signer. It's generic because it support multiple methods of signing. In order to get yourself familiarized with t he exact parameters you must check local.go and web3signer.go Examples of valid values: { Method="Local", Path="path/to/keystore", Password="password" } { Method="Web3Signer", URL="http://localhost:9000", Address="0x1234567890abcdef" }

func NewLocalSignerConfig

func NewLocalSignerConfig(path, pass string) SignerConfig

NewLocalSignerConfig creates a generic config (SignerConfig)

type Web3SignerClienter

type Web3SignerClienter interface {
	EthAccounts(ctx context.Context) ([]common.Address, error)
	SignHash(ctx context.Context, address common.Address, hashToSign common.Hash) ([]byte, error)
}

type Web3SignerConfig

type Web3SignerConfig struct {
	// URL is the url of the web3 signer
	URL string
	// Address is the address of the account to use, if not specified the first account (if only 1 exposed) will be used
	Address common.Address
}

func NewWeb3SignerConfig

func NewWeb3SignerConfig(cfg SignerConfig) (Web3SignerConfig, error)

type Web3SignerSign

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

func NewWeb3SignerSign

func NewWeb3SignerSign(name string, logger types.Logger, client Web3SignerClienter,
	address common.Address) *Web3SignerSign

func NewWeb3SignerSignFromConfig

func NewWeb3SignerSignFromConfig(name string, logger types.Logger, cfg Web3SignerConfig) *Web3SignerSign

func (*Web3SignerSign) Initialize

func (e *Web3SignerSign) Initialize(ctx context.Context) error

func (*Web3SignerSign) PublicAddress

func (e *Web3SignerSign) PublicAddress() common.Address

func (*Web3SignerSign) SignHash

func (e *Web3SignerSign) SignHash(ctx context.Context, hash common.Hash) ([]byte, error)

func (*Web3SignerSign) String

func (e *Web3SignerSign) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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