validator

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoPersonaTag     = eris.New("persona tag is required")
	ErrWrongNamespace   = eris.New("incorrect namespace")
	ErrMessageExpired   = eris.New("signature too old")
	ErrBadTimestamp     = eris.New("invalid future timestamp")
	ErrCacheReadFailed  = eris.New("cache read failed")
	ErrCacheWriteFailed = eris.New("cache store failed")
	ErrDuplicateMessage = eris.New("duplicate message")
	ErrInvalidSignature = eris.New("invalid signature")
)

Functions

This section is empty.

Types

type SignatureValidator

type SignatureValidator struct {
	IsDisabled               bool
	MessageExpirationSeconds uint
	HashCacheSizeKB          uint
	// contains filtered or unexported fields
}

func NewSignatureValidator

func NewSignatureValidator(disabled bool, msgExpirationSec uint, hashCacheSizeKB uint, namespace string,
	provider SignerAddressProvider,
) *SignatureValidator

func (*SignatureValidator) ValidateTransactionSignature

func (validator *SignatureValidator) ValidateTransactionSignature(tx *sign.Transaction, signerAddress string,
) error

ValidateTransactionSignature checks that the signature is valid, was signed by the persona (or signer passed in), has the correct namespace, and has not been altered. If all checks pass, it is added to the hash cache as a known message, and nil is returned. Other possible returns are ErrNoPersonaTag, ErrInvalidSignature, and ErrCacheWriteFailed. If signature validation is disabled, we only check for the presence of a persona tag.

func (*SignatureValidator) ValidateTransactionTTL

func (validator *SignatureValidator) ValidateTransactionTTL(tx *sign.Transaction) error

ValidateTransactionTTL checks that the timestamp on the message is valid, the message has not expired, and that the message is not previously handled as indicated by it being in the hash cache. returns an error (ErrMessageExpired, ErrBadTimestamp, ErrDuplicateMessage, or ErrCacheReadFailed) if there was a problem, and nil if everything was ok if signature validation is disabled, no checks are done and nil is always returned

type SignerAddressProvider

type SignerAddressProvider interface {
	// tick is used by world provider, but not by the validator package. we include it here
	// to avoid creating an extra method for a very minor bit of abstraction
	GetSignerForPersonaTag(personaTag string, tick uint64) (addr string, err error)
}

we define the particular interface we need here to avoid dragging in the whole world provider interface and making independent testing of validator require more complicated interfaces

Jump to

Keyboard shortcuts

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