(self, data)
| 187 | 'sendOutOrStoreMyV4Pubkey', myAddress)) |
| 188 | |
| 189 | def processpubkey(self, data): |
| 190 | pubkeyProcessingStartTime = time.time() |
| 191 | shared.numberOfPubkeysProcessed += 1 |
| 192 | queues.UISignalQueue.put(( |
| 193 | 'updateNumberOfPubkeysProcessed', 'no data')) |
| 194 | embeddedTime, = unpack('>Q', data[8:16]) |
| 195 | readPosition = 20 # bypass the nonce, time, and object type |
| 196 | addressVersion, varintLength = decodeVarint( |
| 197 | data[readPosition:readPosition + 10]) |
| 198 | readPosition += varintLength |
| 199 | streamNumber, varintLength = decodeVarint( |
| 200 | data[readPosition:readPosition + 10]) |
| 201 | readPosition += varintLength |
| 202 | if addressVersion == 0: |
| 203 | logger.debug('(Within processpubkey) addressVersion of 0 doesn\'t make sense.') |
| 204 | return |
| 205 | if addressVersion > 4 or addressVersion == 1: |
| 206 | logger.info('This version of Bitmessage cannot handle version %s addresses.' % addressVersion) |
| 207 | return |
| 208 | if addressVersion == 2: |
| 209 | if len(data) < 146: # sanity check. This is the minimum possible length. |
| 210 | logger.debug('(within processpubkey) payloadLength less than 146. Sanity check failed.') |
| 211 | return |
| 212 | bitfieldBehaviors = data[readPosition:readPosition + 4] |
| 213 | readPosition += 4 |
| 214 | publicSigningKey = data[readPosition:readPosition + 64] |
| 215 | # Is it possible for a public key to be invalid such that trying to |
| 216 | # encrypt or sign with it will cause an error? If it is, it would |
| 217 | # be easiest to test them here. |
| 218 | readPosition += 64 |
| 219 | publicEncryptionKey = data[readPosition:readPosition + 64] |
| 220 | if len(publicEncryptionKey) < 64: |
| 221 | logger.debug('publicEncryptionKey length less than 64. Sanity check failed.') |
| 222 | return |
| 223 | readPosition += 64 |
| 224 | dataToStore = data[20:readPosition] # The data we'll store in the pubkeys table. |
| 225 | sha = hashlib.new('sha512') |
| 226 | sha.update( |
| 227 | '\x04' + publicSigningKey + '\x04' + publicEncryptionKey) |
| 228 | ripeHasher = hashlib.new('ripemd160') |
| 229 | ripeHasher.update(sha.digest()) |
| 230 | ripe = ripeHasher.digest() |
| 231 | |
| 232 | |
| 233 | logger.debug('within recpubkey, addressVersion: %s, streamNumber: %s \n\ |
| 234 | ripe %s\n\ |
| 235 | publicSigningKey in hex: %s\n\ |
| 236 | publicEncryptionKey in hex: %s' % (addressVersion, |
| 237 | streamNumber, |
| 238 | hexlify(ripe), |
| 239 | hexlify(publicSigningKey), |
| 240 | hexlify(publicEncryptionKey) |
| 241 | ) |
| 242 | ) |
| 243 | |
| 244 | |
| 245 | address = encodeAddress(addressVersion, streamNumber, ripe) |
| 246 |
no test coverage detected