core

package
v0.60.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Sequence core primitives

DecodeSignature takes raw signature data and returns a Signature. A Signature can Recover the WalletConfig it represents. A WalletConfig describes the configuration of signers that control a wallet.

Index

Constants

This section is empty.

Variables

View Source
var ErrSigningFunctionNotReady = fmt.Errorf("signing function not ready")

ErrSigningFunctionNotReady is returned when a signing function is not ready to sign and should be retried later.

View Source
var ErrSigningNoSigner = fmt.Errorf("no signer")

Functions

func Ecrecover

func Ecrecover(digest common.Hash, signature []byte) (common.Address, error)

func EthereumSignedMessage

func EthereumSignedMessage(message []byte) common.Hash

func RegisterCore added in v0.22.0

func RegisterCore[C WalletConfig, S Signature[C]](core Core[C, S])

func SigningOrchestrator added in v0.22.0

func SigningOrchestrator(ctx context.Context, signers map[common.Address]uint16, sign SigningFunction) chan SignerSignature

Types

type Core

type Core[C WalletConfig, S Signature[C]] interface {
	// DecodeSignature takes raw signature data and returns a Signature that can Recover a WalletConfig.
	DecodeSignature(data []byte) (S, error)

	// DecodeWalletConfig takes a decoded JSON object and returns a WalletConfig.
	DecodeWalletConfig(object any) (C, error)
}

func GetCoreForWalletConfig added in v0.22.0

func GetCoreForWalletConfig[C WalletConfig]() (Core[C, Signature[C]], error)

type ImageHash

type ImageHash struct {
	common.Hash

	// Preimage is the ImageHashable with this ImageHash, nil if unknown.
	Preimage ImageHashable
}

An ImageHash is a digest of an ImageHashable. Used for type safety and preimage recovery.

func (ImageHash) Approval

func (h ImageHash) Approval() common.Hash

Approval derives the digest that must be signed to approve the ImageHash for subsequent signatures.

func (ImageHash) ImageHash

func (h ImageHash) ImageHash() ImageHash

type ImageHashable

type ImageHashable interface {
	// ImageHash is the digest of the object.
	ImageHash() ImageHash
}

An ImageHashable is an object with an ImageHash.

type PasskeySignature

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

──────────────────────────────────────────────────────────────────────────────── PasskeySignature ────────────────────────────────────────────────────────────────────────────────

func DecodePasskeySignature

func DecodePasskeySignature(signature []byte) (PasskeySignature, error)

────────────────── Decoding ──────────────────

func (PasskeySignature) Encode

func (s PasskeySignature) Encode() []byte

────────────────── Encoding ──────────────────

func (PasskeySignature) ImageHash

func (s PasskeySignature) ImageHash() ImageHash

────────────────── Image‑hash (unchanged) ──────────────────

func (PasskeySignature) IsValid

func (s PasskeySignature) IsValid(digest common.Hash) bool

────────────────── 2) Signature validity ──────────────────

type Payload

type Payload interface {
	Address() common.Address
	ChainID() *big.Int

	Digest() PayloadDigest
}

type PayloadDigest

type PayloadDigest struct {
	common.Hash

	Address_ common.Address
	ChainID_ *big.Int

	Payload Payload
}

func (PayloadDigest) Address

func (d PayloadDigest) Address() common.Address

func (PayloadDigest) ChainID

func (d PayloadDigest) ChainID() *big.Int

func (PayloadDigest) Digest

func (d PayloadDigest) Digest() PayloadDigest

type Signature

type Signature[C WalletConfig] interface {
	// Threshold is the minimum signing weight required for a signature to be valid.
	Threshold() uint16

	// Checkpoint is the nonce of the wallet configuration that the signature applies to.
	Checkpoint() uint64

	// Recover derives the wallet configuration that the signature applies to.
	// Also returns the signature's weight.
	// If provider is not provided, EIP-1271 signatures are assumed to be NOT valid and ignored.
	// If provider is not provided and the signature contains sapient signer signatures, recovery will fail.
	// If payload is a digest without preimage and the signature contains non-compact sapient signer signatures, recovery will fail.
	// If signerSignatures is provided, it will be populated with the valid signer signatures of this signature.
	Recover(ctx context.Context, payload Payload, provider *ethrpc.Provider, signerSignatures ...SignerSignatures) (C, *big.Int, error)

	// Reduce returns an equivalent optimized signature.
	Reduce(payload Payload) Signature[C]

	// Join joins two signatures into one.
	Join(payload Payload, other Signature[C]) (Signature[C], error)

	// Data is the raw signature data.
	Data() ([]byte, error)

	// Write writes the raw signature data to a Writer.
	Write(writer io.Writer) error
}

A Signature is a decoded signature that can Recover a WalletConfig.

type SignerSignature

type SignerSignature struct {
	Signer    common.Address
	Type      SignerSignatureType
	Signature []byte
	Error     error
}

type SignerSignatureType

type SignerSignatureType int
const (
	SignerSignatureTypeEIP712 SignerSignatureType = iota + 1
	SignerSignatureTypeEthSign
	SignerSignatureTypeEIP1271
	SignerSignatureTypeSapient
	SignerSignatureTypeSapientCompact
)

type SignerSignatures

type SignerSignatures map[common.Address]struct {
	Signature         *SignerSignature
	SapientSignatures map[common.Hash]SignerSignature
}

func (SignerSignatures) Insert

func (s SignerSignatures) Insert(signer common.Address, signature SignerSignature)

func (SignerSignatures) InsertSapient

func (s SignerSignatures) InsertSapient(signer common.Address, imageHash common.Hash, signature SignerSignature)

type SigningFunction

type SigningFunction func(ctx context.Context, signer common.Address, signatures []SignerSignature) (SignerSignatureType, []byte, error)

type WalletConfig

type WalletConfig interface {
	ImageHashable

	// Threshold is the minimum signing weight required for a signature to be valid.
	Threshold() uint16

	// Checkpoint is the nonce of the wallet configuration.
	Checkpoint() uint64

	// Signers is the set of signers in the wallet configuration.
	Signers() map[common.Address]uint16

	// SignersWeight is the total weight of the signers passed to the function according to the wallet configuration.
	SignersWeight(signers []common.Address) uint16

	// IsComplete checks if the wallet configuration doesn't have pruned subtrees.
	IsComplete() bool

	// IsUsable checks if it's possible to construct signatures that meet threshold.
	IsUsable() error
}

A WalletConfig is a configuration of signers that control a wallet.

Directories

Path Synopsis
Sequence v1 core primitives
Sequence v1 core primitives
Sequence v2 core primitives
Sequence v2 core primitives

Jump to

Keyboard shortcuts

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