github.com/koko1123/flow-go-1@v0.29.6/fvm/errors/txVerifier.go (about) 1 package errors 2 3 import ( 4 "github.com/koko1123/flow-go-1/model/flow" 5 ) 6 7 // NewInvalidProposalSignatureError constructs a new CodedError which indicates 8 // that no valid signature is provided for the proposal key. 9 func NewInvalidProposalSignatureError( 10 proposal flow.ProposalKey, 11 err error, 12 ) CodedError { 13 return WrapCodedError( 14 ErrCodeInvalidProposalSignatureError, 15 err, 16 "invalid proposal key: public key %d on account %s does not have a "+ 17 "valid signature", 18 proposal.KeyIndex, 19 proposal.Address) 20 } 21 22 // InvalidProposalSeqNumberError indicates that proposal key sequence number does not match the on-chain value. 23 type InvalidProposalSeqNumberError struct { 24 currentSeqNumber uint64 25 providedSeqNumber uint64 26 27 CodedError 28 } 29 30 // NewInvalidProposalSeqNumberError constructs a new InvalidProposalSeqNumberError 31 func NewInvalidProposalSeqNumberError( 32 proposal flow.ProposalKey, 33 currentSeqNumber uint64, 34 ) CodedError { 35 return InvalidProposalSeqNumberError{ 36 currentSeqNumber: currentSeqNumber, 37 providedSeqNumber: proposal.SequenceNumber, 38 CodedError: NewCodedError( 39 ErrCodeInvalidProposalSeqNumberError, 40 "invalid proposal key: public key %d on account %s has sequence "+ 41 "number %d, but given %d", 42 proposal.KeyIndex, 43 proposal.Address, 44 currentSeqNumber, 45 proposal.SequenceNumber), 46 } 47 } 48 49 // CurrentSeqNumber returns the current sequence number 50 func (e InvalidProposalSeqNumberError) CurrentSeqNumber() uint64 { 51 return e.currentSeqNumber 52 } 53 54 // ProvidedSeqNumber returns the provided sequence number 55 func (e InvalidProposalSeqNumberError) ProvidedSeqNumber() uint64 { 56 return e.providedSeqNumber 57 } 58 59 // NewInvalidPayloadSignatureError constructs a new CodedError which indicates 60 // that signature verification for a key in this transaction has failed. This 61 // error is the result of failure in any of the following conditions: 62 // - provided hashing method is not supported 63 // - signature size or format is invalid 64 // - signature verification failed 65 func NewInvalidPayloadSignatureError( 66 txnSig flow.TransactionSignature, 67 err error, 68 ) CodedError { 69 return WrapCodedError( 70 ErrCodeInvalidPayloadSignatureError, 71 err, 72 "invalid payload signature: public key %d on account %s does not have"+ 73 " a valid signature", 74 txnSig.KeyIndex, 75 txnSig.Address) 76 } 77 78 func IsInvalidPayloadSignatureError(err error) bool { 79 return HasErrorCode(err, ErrCodeInvalidPayloadSignatureError) 80 } 81 82 // NewInvalidEnvelopeSignatureError constructs a new CodedError which indicates 83 // that signature verification for a envelope key in this transaction has 84 // failed. Tthis error is the result of failure in any of the following 85 // conditions: 86 // - provided hashing method is not supported 87 // - signature size or format is invalid 88 // - signature verification failed 89 func NewInvalidEnvelopeSignatureError( 90 txnSig flow.TransactionSignature, 91 err error, 92 ) CodedError { 93 return WrapCodedError( 94 ErrCodeInvalidEnvelopeSignatureError, 95 err, 96 "invalid envelope key: public key %d on account %s does not have a "+ 97 "valid signature", 98 txnSig.KeyIndex, 99 txnSig.Address) 100 } 101 102 func IsInvalidEnvelopeSignatureError(err error) bool { 103 return HasErrorCode(err, ErrCodeInvalidEnvelopeSignatureError) 104 }