github.com/koko1123/flow-go-1@v0.29.6/module/signature/errors.go (about) 1 package signature 2 3 import ( 4 "errors" 5 "fmt" 6 ) 7 8 var ( 9 ErrInvalidSignatureFormat = errors.New("signature's binary format is invalid") 10 11 ErrInsufficientShares = errors.New("insufficient threshold signature shares") 12 13 // ErrIncompatibleBitVectorLength indicates that the bit vector's length is different than 14 // the expected length, based on the supplied node list. 15 ErrIncompatibleBitVectorLength = errors.New("bit vector has incompatible length") 16 17 // ErrIllegallyPaddedBitVector indicates that the index vector was padded with unexpected bit values. 18 ErrIllegallyPaddedBitVector = errors.New("index vector padded with unexpected bit values") 19 20 // ErrInvalidChecksum indicates that the index vector's checksum is invalid 21 ErrInvalidChecksum = errors.New("index vector's checksum is invalid") 22 ) 23 24 /* ********************* InvalidSignatureIncludedError ********************* */ 25 26 // InvalidSignatureIncludedError indicates that some signatures, included via TrustedAdd, are invalid 27 type InvalidSignatureIncludedError struct { 28 err error 29 } 30 31 func NewInvalidSignatureIncludedErrorf(msg string, args ...interface{}) error { 32 return InvalidSignatureIncludedError{ 33 err: fmt.Errorf(msg, args...), 34 } 35 } 36 37 func (e InvalidSignatureIncludedError) Error() string { return e.err.Error() } 38 func (e InvalidSignatureIncludedError) Unwrap() error { return e.err } 39 40 // IsInvalidSignatureIncludedError returns whether err is an InvalidSignatureIncludedError 41 func IsInvalidSignatureIncludedError(err error) bool { 42 var e InvalidSignatureIncludedError 43 return errors.As(err, &e) 44 } 45 46 /* ************************* InvalidSignerIdxError ************************* */ 47 48 // InvalidSignerIdxError indicates that the signer index is invalid 49 type InvalidSignerIdxError struct { 50 err error 51 } 52 53 func NewInvalidSignerIdxErrorf(msg string, args ...interface{}) error { 54 return InvalidSignerIdxError{ 55 err: fmt.Errorf(msg, args...), 56 } 57 } 58 59 func (e InvalidSignerIdxError) Error() string { return e.err.Error() } 60 func (e InvalidSignerIdxError) Unwrap() error { return e.err } 61 62 // IsInvalidSignerIdxError returns whether err is an InvalidSignerIdxError 63 func IsInvalidSignerIdxError(err error) bool { 64 var e InvalidSignerIdxError 65 return errors.As(err, &e) 66 } 67 68 /* ************************ DuplicatedSignerIdxError *********************** */ 69 70 // DuplicatedSignerIdxError indicates that a signature from the respective signer index was already added 71 type DuplicatedSignerIdxError struct { 72 err error 73 } 74 75 func NewDuplicatedSignerIdxErrorf(msg string, args ...interface{}) error { 76 return DuplicatedSignerIdxError{ 77 err: fmt.Errorf(msg, args...), 78 } 79 } 80 81 func (e DuplicatedSignerIdxError) Error() string { return e.err.Error() } 82 func (e DuplicatedSignerIdxError) Unwrap() error { return e.err } 83 84 // IsDuplicatedSignerIdxError returns whether err is an DuplicatedSignerIdxError 85 func IsDuplicatedSignerIdxError(err error) bool { 86 var e DuplicatedSignerIdxError 87 return errors.As(err, &e) 88 } 89 90 /* ********************** InsufficientSignaturesError ********************** */ 91 92 // InsufficientSignaturesError indicates that not enough signatures have been stored to complete the operation. 93 type InsufficientSignaturesError struct { 94 err error 95 } 96 97 func NewInsufficientSignaturesErrorf(msg string, args ...interface{}) error { 98 return InsufficientSignaturesError{ 99 err: fmt.Errorf(msg, args...), 100 } 101 } 102 103 func (e InsufficientSignaturesError) Error() string { return e.err.Error() } 104 func (e InsufficientSignaturesError) Unwrap() error { return e.err } 105 106 // IsInsufficientSignaturesError returns whether err is an InsufficientSignaturesError 107 func IsInsufficientSignaturesError(err error) bool { 108 var e InsufficientSignaturesError 109 return errors.As(err, &e) 110 } 111 112 /* ********************** InvalidSignerIndicesError ********************** */ 113 114 // InvalidSignerIndicesError indicates that a bit vector does not encode a valid set of signers 115 type InvalidSignerIndicesError struct { 116 err error 117 } 118 119 func NewInvalidSignerIndicesErrorf(msg string, args ...interface{}) error { 120 return InvalidSignerIndicesError{ 121 err: fmt.Errorf(msg, args...), 122 } 123 } 124 125 func (e InvalidSignerIndicesError) Error() string { return e.err.Error() } 126 func (e InvalidSignerIndicesError) Unwrap() error { return e.err } 127 128 // IsInvalidSignerIndicesError returns whether err is an InvalidSignerIndicesError 129 func IsInvalidSignerIndicesError(err error) bool { 130 var e InvalidSignerIndicesError 131 return errors.As(err, &e) 132 } 133 134 /* ********************** InvalidSignerIndicesError ********************** */ 135 136 // InvalidSigTypesError indicates that the given data not encode valid signature types 137 type InvalidSigTypesError struct { 138 err error 139 } 140 141 func NewInvalidSigTypesErrorf(msg string, args ...interface{}) error { 142 return InvalidSigTypesError{ 143 err: fmt.Errorf(msg, args...), 144 } 145 } 146 147 func (e InvalidSigTypesError) Error() string { return e.err.Error() } 148 func (e InvalidSigTypesError) Unwrap() error { return e.err } 149 150 // IsInvalidSigTypesError returns whether err is an InvalidSigTypesError 151 func IsInvalidSigTypesError(err error) bool { 152 var e InvalidSigTypesError 153 return errors.As(err, &e) 154 }