From 9a6776698af66490aa892084d48b702d3b524209 Mon Sep 17 00:00:00 2001 From: Steve Moyer Date: Fri, 4 Jul 2025 10:27:12 -0400 Subject: [PATCH] doc(error): document possible varsig encoding/decoding errors --- error.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 error.go diff --git a/error.go b/error.go new file mode 100644 index 0000000..909090a --- /dev/null +++ b/error.go @@ -0,0 +1,43 @@ +package varsig + +import "errors" + +// ErrMissingSignature is returned when a varsig v0 is parsed and does +// not contain the expected signature bytes. This is expected in some +// intermediate cases, such as the UCAN v1 specification. +var ErrMissingSignature = errors.New("missing signature expected in varsig v0") + +// ErrNotYetImplemented is returned when a function is currently under +// construction. For released versions of this library, this error should +// never occur. +var ErrNotYetImplemented = errors.New("not yet implemented") + +// ErrUnexpectedSignaturePresent is returned when a signature is present +// in a varsig >= v1. +var ErrUnexpectedSignaturePresent = errors.New("unexpected signature present in varsig >= v1") + +// ErrUnexpectedSignatureSize is returned when the length of the decoded +// signature doesn't match the expected signature length as defined by the +// signing algorithm or sent via a Varsig field. +var ErrUnexpectedSignatureSize = errors.New("unexpected signature size in varsig v0") + +// ErrUnknownHashAlgoritm is returned when an unexpected value is provided +// while decoding the hashing algorithm. +var ErrUnknownHashAlgorithm = errors.New("unknown hash algorithm") + +// ErrUnsupportedPayloadEncoding is returned when an unexpected value is +// provided while decoding the payload encoding field. The allowed values +// for this field may vary based on the varsig version. +var ErrUnsupportedPayloadEncoding = errors.New("unsupported payload encoding") + +// ErrUnknownSignAlgorith is returned when the Registry doesn't have a +// parsing function for the decoded signing algorithm. +var ErrUnknownSignAlgorithm = errors.New("unknown signing algorithm") + +// ErrUnsupportedVersion is returned when an unsupported varsig version +// field is present. +var ErrUnsupportedVersion = errors.New("unsupported version") + +// ErrBadPrefix is returned when the prefix field contains a value other +// than 0x34 (encoded as a uvarint). +var ErrBadPrefix = errors.New("varsig prefix not found")