signing

package
v0.48.86 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSignBytesWithContext

func GetSignBytesWithContext(h SignModeHandler, ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error)

GetSignBytesWithContext gets the sign bytes from the sign mode handler. It checks if the sign mode handler supports SignModeHandlerWithContext, in which case it passes the context.Context argument. Otherwise, it fallbacks to GetSignBytes.

func VerifySignature

func VerifySignature(ctx context.Context, pubKey cryptotypes.PubKey, signerData SignerData, sigData signing.SignatureData, handler SignModeHandler, tx sdk.Tx) error

VerifySignature verifies a transaction signature contained in SignatureData abstracting over different signing modes and single vs multi-signatures.

Types

type SigVerifiableTx

type SigVerifiableTx interface {
	types.Tx
	GetSigners() []types.AccAddress
	GetPubKeys() ([]cryptotypes.PubKey, error) // If signer already has pubkey in context, this list will have nil in its place
	GetSignaturesV2() ([]signing.SignatureV2, error)
}

SigVerifiableTx defines a transaction interface for all signature verification handlers.

type SignModeHandler

type SignModeHandler interface {
	// DefaultMode is the default mode that is to be used with this handler if no
	// other mode is specified. This can be useful for testing and CLI usage
	DefaultMode() signing.SignMode

	// Modes is the list of modes supporting by this handler
	Modes() []signing.SignMode

	// GetSignBytes returns the sign bytes for the provided SignMode, SignerData and Tx,
	// or an error
	GetSignBytes(mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error)
}

SignModeHandler defines a interface to be implemented by types which will handle SignMode's by generating sign bytes from a Tx and SignerData

type SignModeHandlerMap

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

SignModeHandlerMap is SignModeHandler that aggregates multiple SignModeHandler's into a single handler

func NewSignModeHandlerMap

func NewSignModeHandlerMap(defaultMode signing.SignMode, handlers []SignModeHandler) SignModeHandlerMap

NewSignModeHandlerMap returns a new SignModeHandlerMap with the provided defaultMode and handlers

func (SignModeHandlerMap) DefaultMode

func (h SignModeHandlerMap) DefaultMode() signing.SignMode

DefaultMode implements SignModeHandler.DefaultMode

func (SignModeHandlerMap) GetSignBytes

func (h SignModeHandlerMap) GetSignBytes(mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error)

GetSignBytes implements SignModeHandler.GetSignBytes

func (SignModeHandlerMap) GetSignBytesWithContext

func (h SignModeHandlerMap) GetSignBytesWithContext(ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error)

GetSignBytesWithContext implements SignModeHandler.GetSignBytesWithContext

func (SignModeHandlerMap) Modes

func (h SignModeHandlerMap) Modes() []signing.SignMode

Modes implements SignModeHandler.Modes

type SignModeHandlerWithContext

type SignModeHandlerWithContext interface {
	SignModeHandler

	// GetSignBytes returns the sign bytes for the provided SignMode, SignerData and Tx,
	// or an error
	GetSignBytesWithContext(ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error)
}

SignModeHandlerWithContext is like SignModeHandler, with a new GetSignBytes method which takes an additional context.Context argument, to be used to access state. Consumers should preferably type-cast to this interface and pass in the context.Context arg, and default to SignModeHandler otherwise. This interface is created for backwards compatibility, and will be deleted once SDK versions <v0.47 are not supported anymore.

type SignerData

type SignerData struct {
	// The address of the signer.
	//
	// In case of multisigs, this should be the multisig's address.
	Address string

	// ChainID is the chain that this transaction is targeted
	ChainID string

	// AccountNumber is the account number of the signer.
	//
	// In case of multisigs, this should be the multisig account number.
	AccountNumber uint64

	// Sequence is the account sequence number of the signer that is used
	// for replay protection. This field is only useful for Legacy Amino signing,
	// since in SIGN_MODE_DIRECT the account sequence is already in the signer
	// info.
	//
	// In case of multisigs, this should be the multisig sequence.
	Sequence uint64

	// PubKey is the public key of the signer.
	//
	// In case of multisigs, this should be the pubkey of the member of the
	// multisig that is signing the current sign doc.
	PubKey cryptotypes.PubKey
}

SignerData is the specific information needed to sign a transaction that generally isn't included in the transaction body itself

type Tx

Tx defines a transaction interface that supports all standard message, signature fee, memo, tips, and auxiliary interfaces.

Jump to

Keyboard shortcuts

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