signer

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package signer defines the kit's external signing boundary — the single interface between transaction construction and key material (FR-012, FR-021, FR-061). Contract: specs/008-exchange-integration-kit/contracts/signer-interface.md.

Index

Constants

View Source
const (
	CodeKeyNotFound       = "KEY_NOT_FOUND"
	CodeSummaryMismatch   = "SUMMARY_MISMATCH"
	CodePolicyRejected    = "POLICY_REJECTED"
	CodeSignerUnavailable = "SIGNER_UNAVAILABLE"
	CodeInternal          = "INTERNAL"
)

Error codes (contract semantics §4). Remote transports map these 1:1.

View Source
const (
	// SignModeDirect is the only supported sign mode in v1 (R4).
	SignModeDirect = "SIGN_MODE_DIRECT"

	// AlgorithmSecp256k1 is the only supported key algorithm.
	AlgorithmSecp256k1 = "secp256k1"

	// MsgTypeBankSend is the only message type a v1 sign doc may carry.
	MsgTypeBankSend = "/cosmos.bank.v1beta1.MsgSend"

	// DenomUsovr is the only settlement denom in v1.
	DenomUsovr = "usovr"
)

Variables

View Source
var (
	ErrKeyNotFound       = &Error{Code: CodeKeyNotFound}
	ErrSummaryMismatch   = &Error{Code: CodeSummaryMismatch}
	ErrPolicyRejected    = &Error{Code: CodePolicyRejected}
	ErrSignerUnavailable = &Error{Code: CodeSignerUnavailable}
	ErrInternal          = &Error{Code: CodeInternal}
)

Functions

func CodeOf

func CodeOf(err error) string

CodeOf maps any error to its signer code; non-signer errors map to CodeInternal, nil to "".

Types

type Error

type Error struct {
	Code   string
	Detail string
}

Error is a typed signer error. Two Errors match under errors.Is when their codes are equal, so detail-carrying instances match the sentinels below.

func NewError

func NewError(sentinel *Error, detail string) *Error

NewError attaches detail to one of the sentinel codes.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

type PublicKeyRequest

type PublicKeyRequest struct {
	KeyRef string
}

PublicKeyRequest identifies a key by an opaque exchange-side handle.

type PublicKeyResponse

type PublicKeyResponse struct {
	KeyRef              string
	Algorithm           string // AlgorithmSecp256k1
	PublicKeyCompressed []byte // 33 bytes
}

type SigningRequest

type SigningRequest struct {
	KeyRef       string
	SignMode     string // SignModeDirect
	SignDocBytes []byte
	Summary      SigningSummary
}

SigningRequest carries the exact ADR-020 SignDoc protobuf bytes to hash+sign. SignDocBytes is authoritative; Summary exists for display and cross-checking only — production signers must decode SignDocBytes and policy-check the decoded contents.

type SigningResponse

type SigningResponse struct {
	KeyRef           string
	Signature        []byte // 64 bytes R||S, low-S normalized, over SHA-256(SignDocBytes)
	PubKeyCompressed []byte // 33 bytes
}

type SigningSummary

type SigningSummary struct {
	ChainID          string
	AccountNumber    string
	Sequence         string
	MessageType      string // MsgTypeBankSend
	SenderAddress    string
	RecipientAddress string
	AmountBaseUnits  string // integer usovr string
	Denom            string // DenomUsovr
	FeeBaseUnits     string
	GasLimit         string
	Memo             string
}

SigningSummary is derived from SignDocBytes by the tx builder; signers may independently re-derive and must be able to reject on mismatch. All numeric fields are base-10 integer strings.

type TransactionSigner

type TransactionSigner interface {
	GetPublicKey(ctx context.Context, req PublicKeyRequest) (PublicKeyResponse, error)
	Sign(ctx context.Context, req SigningRequest) (SigningResponse, error)
}

TransactionSigner is implemented by every signing backend (local test signer, remote transports). Signing is stateless: chain ID, account number, and sequence travel inside SignDocBytes, so no node connectivity is needed.

Directories

Path Synopsis
Package execsigner is the adapter's `exec` signer transport: a one-shot subprocess per request with a JSON request on stdin and a JSON response on stdout (bytes base64-encoded), suiting air-gap bridges and custom HSM shims (contract: signer-interface.md §Remote signer transports).
Package execsigner is the adapter's `exec` signer transport: a one-shot subprocess per request with a JSON request on stdin and a JSON response on stdout (bytes base64-encoded), suiting air-gap bridges and custom HSM shims (contract: signer-interface.md §Remote signer transports).
Package grpcremote is the adapter's `grpc-remote` signer transport: a signer.TransactionSigner client for the sovren.signer.v1.SignerService an exchange's signing system implements (contract: signer-interface.md §Remote signer transports).
Package grpcremote is the adapter's `grpc-remote` signer transport: a signer.TransactionSigner client for the sovren.signer.v1.SignerService an exchange's signing system implements (contract: signer-interface.md §Remote signer transports).
Package local is the in-memory secp256k1 TransactionSigner (adapter kind "unsafe-local").
Package local is the in-memory secp256k1 TransactionSigner (adapter kind "unsafe-local").

Jump to

Keyboard shortcuts

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