signing

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 14 Imported by: 301

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context added in v0.5.2

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

Context is a context for retrieving the list of signers from a message where signers are specified by the cosmos.msg.v1.signer protobuf option. It also contains the ProtoFileResolver and address.Codec's used for resolving message descriptors and converting addresses.

func NewContext added in v0.5.2

func NewContext(options Options) (*Context, error)

NewContext creates a new Context using the provided options.

func (*Context) AddressCodec added in v0.5.2

func (c *Context) AddressCodec() address.Codec

AddressCodec returns the address codec used by the context.

func (*Context) FileResolver added in v0.5.2

func (c *Context) FileResolver() ProtoFileResolver

FileResolver returns the proto file resolver used by the context.

func (*Context) GetSigners added in v0.5.2

func (c *Context) GetSigners(msg proto.Message) ([][]byte, error)

GetSigners returns the signers for a given message.

func (*Context) TypeResolver added in v0.5.2

func (c *Context) TypeResolver() protoregistry.MessageTypeResolver

func (*Context) ValidatorAddressCodec added in v0.5.2

func (c *Context) ValidatorAddressCodec() address.Codec

ValidatorAddressCodec returns the validator address codec used by the context.

type HandlerMap added in v0.2.0

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

HandlerMap aggregates several sign mode handlers together for convenient generation of sign bytes based on sign mode.

func NewHandlerMap added in v0.2.0

func NewHandlerMap(handlers ...SignModeHandler) *HandlerMap

NewHandlerMap constructs a new sign mode handler map.

func (*HandlerMap) GetSignBytes added in v0.2.0

func (h *HandlerMap) GetSignBytes(ctx context.Context, signMode signingv1beta1.SignMode, signerData SignerData, txData TxData) ([]byte, error)

GetSignBytes returns the sign bytes for the transaction for the requested mode.

func (*HandlerMap) SupportedModes added in v0.2.0

func (h *HandlerMap) SupportedModes() []signingv1beta1.SignMode

SupportedModes lists the modes supported by this handler map.

type Options added in v0.5.2

type Options struct {
	// FileResolver is the protobuf file resolver to use for resolving message descriptors.
	// If it is nil, the global protobuf registry will be used.
	FileResolver ProtoFileResolver

	// TypeResolver is the protobuf type resolver to use for resolving message types.
	TypeResolver protoregistry.MessageTypeResolver

	// AddressCodec is the codec for converting addresses between strings and bytes.
	AddressCodec address.Codec

	// ValidatorAddressCodec is the codec for converting validator addresses between strings and bytes.
	ValidatorAddressCodec address.Codec
}

Options are options for creating Context which will be used for signing operations.

type ProtoFileResolver added in v0.5.0

type ProtoFileResolver interface {
	protodesc.Resolver
	RangeFiles(func(protoreflect.FileDescriptor) bool)
}

ProtoFileResolver is a protodesc.Resolver that also allows iterating over all files descriptors. It is a subset of the methods supported by protoregistry.Files.

type SignModeHandler added in v0.2.0

type SignModeHandler interface {
	// Mode is the sign mode supported by this handler
	Mode() signingv1beta1.SignMode

	// GetSignBytes returns the sign bytes for the provided SignerData and TxData, or an error.
	GetSignBytes(ctx context.Context, signerData SignerData, txData TxData) ([]byte, error)
}

SignModeHandler is the interface that handlers for each sign mode should implement to generate sign bytes.

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 targeting.
	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 *anypb.Any
}

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

type TxData added in v0.2.0

type TxData struct {
	// Body is the TxBody that will be part of the transaction.
	Body *txv1beta1.TxBody

	// AuthInfo is the AuthInfo that will be part of the transaction.
	AuthInfo *txv1beta1.AuthInfo

	// BodyBytes is the marshaled body bytes that will be part of TxRaw.
	BodyBytes []byte

	// AuthInfoBytes is the marshaled AuthInfo bytes that will be part of TxRaw.
	AuthInfoBytes []byte

	// BodyHasUnknownNonCriticals should be set to true if the transaction has been
	// decoded and found to have unknown non-critical fields. This is only needed
	// for amino JSON signing.
	BodyHasUnknownNonCriticals bool
}

TxData is the data about a transaction that is necessary to generate sign bytes.

Directories

Path Synopsis
internal/aminojsonpb
Code generated by protoc-gen-go-pulsar.
Code generated by protoc-gen-go-pulsar.
internal/testpb
Code generated by protoc-gen-go-pulsar.
Code generated by protoc-gen-go-pulsar.
internal/cbor
Package cbor implements just enough of the CBOR (Concise Binary Object Representation, RFC 8948) to deterministically encode simple data.
Package cbor implements just enough of the CBOR (Concise Binary Object Representation, RFC 8948) to deterministically encode simple data.
internal/textualpb
Package textualpb contains all protobuf definitions and generated codes used internally by Textual.
Package textualpb contains all protobuf definitions and generated codes used internally by Textual.

Jump to

Keyboard shortcuts

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