github.com/hellobchain/third_party@v0.0.0-20230331131523-deb0478a2e52/hyperledger/fabric/bccsp/idemix/handlers/mock/signature_scheme.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mock 3 4 import ( 5 "github.com/hellobchain/newcryptosm/ecdsa" 6 "sync" 7 8 "github.com/hellobchain/third_party/hyperledger/fabric/bccsp" 9 "github.com/hellobchain/third_party/hyperledger/fabric/bccsp/idemix/handlers" 10 ) 11 12 type SignatureScheme struct { 13 SignStub func(cred []byte, sk handlers.Big, Nym handlers.Ecp, RNym handlers.Big, ipk handlers.IssuerPublicKey, attributes []bccsp.IdemixAttribute, msg []byte, rhIndex int, cri []byte) ([]byte, error) 14 signMutex sync.RWMutex 15 signArgsForCall []struct { 16 cred []byte 17 sk handlers.Big 18 Nym handlers.Ecp 19 RNym handlers.Big 20 ipk handlers.IssuerPublicKey 21 attributes []bccsp.IdemixAttribute 22 msg []byte 23 rhIndex int 24 cri []byte 25 } 26 signReturns struct { 27 result1 []byte 28 result2 error 29 } 30 signReturnsOnCall map[int]struct { 31 result1 []byte 32 result2 error 33 } 34 VerifyStub func(pk handlers.IssuerPublicKey, signature, digest []byte, attributes []bccsp.IdemixAttribute, hIndex int, revocationPublicKey *ecdsa.PublicKey, epoch int) error 35 verifyMutex sync.RWMutex 36 verifyArgsForCall []struct { 37 pk handlers.IssuerPublicKey 38 signature []byte 39 digest []byte 40 attributes []bccsp.IdemixAttribute 41 hIndex int 42 revocationPublicKey *ecdsa.PublicKey 43 epoch int 44 } 45 verifyReturns struct { 46 result1 error 47 } 48 verifyReturnsOnCall map[int]struct { 49 result1 error 50 } 51 invocations map[string][][]interface{} 52 invocationsMutex sync.RWMutex 53 } 54 55 func (fake *SignatureScheme) Sign(cred []byte, sk handlers.Big, Nym handlers.Ecp, RNym handlers.Big, ipk handlers.IssuerPublicKey, attributes []bccsp.IdemixAttribute, msg []byte, rhIndex int, cri []byte) ([]byte, error) { 56 var credCopy []byte 57 if cred != nil { 58 credCopy = make([]byte, len(cred)) 59 copy(credCopy, cred) 60 } 61 var attributesCopy []bccsp.IdemixAttribute 62 if attributes != nil { 63 attributesCopy = make([]bccsp.IdemixAttribute, len(attributes)) 64 copy(attributesCopy, attributes) 65 } 66 var msgCopy []byte 67 if msg != nil { 68 msgCopy = make([]byte, len(msg)) 69 copy(msgCopy, msg) 70 } 71 var criCopy []byte 72 if cri != nil { 73 criCopy = make([]byte, len(cri)) 74 copy(criCopy, cri) 75 } 76 fake.signMutex.Lock() 77 ret, specificReturn := fake.signReturnsOnCall[len(fake.signArgsForCall)] 78 fake.signArgsForCall = append(fake.signArgsForCall, struct { 79 cred []byte 80 sk handlers.Big 81 Nym handlers.Ecp 82 RNym handlers.Big 83 ipk handlers.IssuerPublicKey 84 attributes []bccsp.IdemixAttribute 85 msg []byte 86 rhIndex int 87 cri []byte 88 }{credCopy, sk, Nym, RNym, ipk, attributesCopy, msgCopy, rhIndex, criCopy}) 89 fake.recordInvocation("Sign", []interface{}{credCopy, sk, Nym, RNym, ipk, attributesCopy, msgCopy, rhIndex, criCopy}) 90 fake.signMutex.Unlock() 91 if fake.SignStub != nil { 92 return fake.SignStub(cred, sk, Nym, RNym, ipk, attributes, msg, rhIndex, cri) 93 } 94 if specificReturn { 95 return ret.result1, ret.result2 96 } 97 return fake.signReturns.result1, fake.signReturns.result2 98 } 99 100 func (fake *SignatureScheme) SignCallCount() int { 101 fake.signMutex.RLock() 102 defer fake.signMutex.RUnlock() 103 return len(fake.signArgsForCall) 104 } 105 106 func (fake *SignatureScheme) SignArgsForCall(i int) ([]byte, handlers.Big, handlers.Ecp, handlers.Big, handlers.IssuerPublicKey, []bccsp.IdemixAttribute, []byte, int, []byte) { 107 fake.signMutex.RLock() 108 defer fake.signMutex.RUnlock() 109 return fake.signArgsForCall[i].cred, fake.signArgsForCall[i].sk, fake.signArgsForCall[i].Nym, fake.signArgsForCall[i].RNym, fake.signArgsForCall[i].ipk, fake.signArgsForCall[i].attributes, fake.signArgsForCall[i].msg, fake.signArgsForCall[i].rhIndex, fake.signArgsForCall[i].cri 110 } 111 112 func (fake *SignatureScheme) SignReturns(result1 []byte, result2 error) { 113 fake.SignStub = nil 114 fake.signReturns = struct { 115 result1 []byte 116 result2 error 117 }{result1, result2} 118 } 119 120 func (fake *SignatureScheme) SignReturnsOnCall(i int, result1 []byte, result2 error) { 121 fake.SignStub = nil 122 if fake.signReturnsOnCall == nil { 123 fake.signReturnsOnCall = make(map[int]struct { 124 result1 []byte 125 result2 error 126 }) 127 } 128 fake.signReturnsOnCall[i] = struct { 129 result1 []byte 130 result2 error 131 }{result1, result2} 132 } 133 134 func (fake *SignatureScheme) Verify(pk handlers.IssuerPublicKey, signature []byte, digest []byte, attributes []bccsp.IdemixAttribute, hIndex int, revocationPublicKey *ecdsa.PublicKey, epoch int) error { 135 var signatureCopy []byte 136 if signature != nil { 137 signatureCopy = make([]byte, len(signature)) 138 copy(signatureCopy, signature) 139 } 140 var digestCopy []byte 141 if digest != nil { 142 digestCopy = make([]byte, len(digest)) 143 copy(digestCopy, digest) 144 } 145 var attributesCopy []bccsp.IdemixAttribute 146 if attributes != nil { 147 attributesCopy = make([]bccsp.IdemixAttribute, len(attributes)) 148 copy(attributesCopy, attributes) 149 } 150 fake.verifyMutex.Lock() 151 ret, specificReturn := fake.verifyReturnsOnCall[len(fake.verifyArgsForCall)] 152 fake.verifyArgsForCall = append(fake.verifyArgsForCall, struct { 153 pk handlers.IssuerPublicKey 154 signature []byte 155 digest []byte 156 attributes []bccsp.IdemixAttribute 157 hIndex int 158 revocationPublicKey *ecdsa.PublicKey 159 epoch int 160 }{pk, signatureCopy, digestCopy, attributesCopy, hIndex, revocationPublicKey, epoch}) 161 fake.recordInvocation("Verify", []interface{}{pk, signatureCopy, digestCopy, attributesCopy, hIndex, revocationPublicKey, epoch}) 162 fake.verifyMutex.Unlock() 163 if fake.VerifyStub != nil { 164 return fake.VerifyStub(pk, signature, digest, attributes, hIndex, revocationPublicKey, epoch) 165 } 166 if specificReturn { 167 return ret.result1 168 } 169 return fake.verifyReturns.result1 170 } 171 172 func (fake *SignatureScheme) VerifyCallCount() int { 173 fake.verifyMutex.RLock() 174 defer fake.verifyMutex.RUnlock() 175 return len(fake.verifyArgsForCall) 176 } 177 178 func (fake *SignatureScheme) VerifyArgsForCall(i int) (handlers.IssuerPublicKey, []byte, []byte, []bccsp.IdemixAttribute, int, *ecdsa.PublicKey, int) { 179 fake.verifyMutex.RLock() 180 defer fake.verifyMutex.RUnlock() 181 return fake.verifyArgsForCall[i].pk, fake.verifyArgsForCall[i].signature, fake.verifyArgsForCall[i].digest, fake.verifyArgsForCall[i].attributes, fake.verifyArgsForCall[i].hIndex, fake.verifyArgsForCall[i].revocationPublicKey, fake.verifyArgsForCall[i].epoch 182 } 183 184 func (fake *SignatureScheme) VerifyReturns(result1 error) { 185 fake.VerifyStub = nil 186 fake.verifyReturns = struct { 187 result1 error 188 }{result1} 189 } 190 191 func (fake *SignatureScheme) VerifyReturnsOnCall(i int, result1 error) { 192 fake.VerifyStub = nil 193 if fake.verifyReturnsOnCall == nil { 194 fake.verifyReturnsOnCall = make(map[int]struct { 195 result1 error 196 }) 197 } 198 fake.verifyReturnsOnCall[i] = struct { 199 result1 error 200 }{result1} 201 } 202 203 func (fake *SignatureScheme) Invocations() map[string][][]interface{} { 204 fake.invocationsMutex.RLock() 205 defer fake.invocationsMutex.RUnlock() 206 fake.signMutex.RLock() 207 defer fake.signMutex.RUnlock() 208 fake.verifyMutex.RLock() 209 defer fake.verifyMutex.RUnlock() 210 copiedInvocations := map[string][][]interface{}{} 211 for key, value := range fake.invocations { 212 copiedInvocations[key] = value 213 } 214 return copiedInvocations 215 } 216 217 func (fake *SignatureScheme) recordInvocation(key string, args []interface{}) { 218 fake.invocationsMutex.Lock() 219 defer fake.invocationsMutex.Unlock() 220 if fake.invocations == nil { 221 fake.invocations = map[string][][]interface{}{} 222 } 223 if fake.invocations[key] == nil { 224 fake.invocations[key] = [][]interface{}{} 225 } 226 fake.invocations[key] = append(fake.invocations[key], args) 227 } 228 229 var _ handlers.SignatureScheme = new(SignatureScheme)