print'Let us make an address from scratch. Suppose we generate two random 32 byte values and call the first one the signing key and the second one the encryption key:'
QMessageBox.about(self,_translate("MainWindow","Address version number"),_translate(
"MainWindow","Concerning the address %1, Bitmessage cannot understand address version numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(addressVersionNumber)))
continue
@ -2200,9 +2200,9 @@ class MyForm(QtGui.QMainWindow):
else:
# User selected 'Use the same stream as an existing
@ -38,7 +38,7 @@ class addressGenerator(threading.Thread):
else:
sys.stderr.write(
'Programming error: A structure with the wrong number of values was passed into the addressGeneratorQueue. Here is the queueValue: %s\n'%repr(queueValue))
ifaddressVersionNumber<3oraddressVersionNumber>3:
ifaddressVersionNumber<3oraddressVersionNumber>4:
sys.stderr.write(
'Program error: For some reason the address generator queue has been given a request to create at least one version %s address which it cannot do.\n'%addressVersionNumber)
ifnonceTrialsPerByte==0:
@ -51,26 +51,125 @@ class addressGenerator(threading.Thread):
print'Generated address with ripe digest:',ripe.digest().encode('hex')
print'Address generator calculated',numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix,'addresses at',numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix/(time.time()-startTime),'addresses per second before finding one with the correct ripe-prefix.'
@ -84,187 +183,93 @@ class addressGenerator(threading.Thread):
else:
ifripe.digest()[:1]=='\x00':
break
print'Generated address with ripe digest:',ripe.digest().encode('hex')
print'Address generator calculated',numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix,'addresses at',numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix/(time.time()-startTime),'addresses per second before finding one with the correct ripe-prefix.'
'(Within the recgetpubkey function) Someone requested one of my pubkeys but the requestedAddressVersionNumber doesn\'t match my actual address version number. They shouldn\'t have done that. Ignoring.\n')
myAddress=''
ifrequestedAddressVersionNumber<=3:
requestedHash=data[readPosition:readPosition+20]
iflen(requestedHash)!=20:
print'The length of the requested hash is not 20 bytes. Something is wrong. Ignoring.'
iflastPubkeySendTime>time.time()-shared.lengthOfTimeToHoldOnToAllPubkeys:# If the last time we sent our pubkey was more recent than 28 days ago...
withshared.printLock:
print'Found getpubkey-requested-hash in my list of EC hashes BUT we already sent it recently. Ignoring request. The lastPubkeySendTime is:',lastPubkeySendTime
return
withshared.printLock:
print'Found getpubkey-requested-hash in my list of EC hashes. Telling Worker thread to do the POW for a pubkey message and send it out.'
ifrequestedAddressVersionNumber==2:
shared.workerQueue.put((
'doPOWForMyV2Pubkey',requestedHash))
elifrequestedAddressVersionNumber==3:
shared.workerQueue.put((
'sendOutOrStoreMyV3Pubkey',requestedHash))
else:
print'the hash requested in this getpubkey request is:',requestedHash.encode('hex')
ifrequestedHashinshared.myAddressesByHash:# if this address hash is one of mine
myAddress=shared.myAddressesByHash[requestedHash]
elifrequestedAddressVersionNumber>=4:
requestedTag=data[readPosition:readPosition+32]
iflen(requestedTag)!=32:
print'The length of the requested tag is not 32 bytes. Something is wrong. Ignoring.'
return
withshared.printLock:
print'the tag requested in this getpubkey request is:',requestedTag.encode('hex')
'(Within the recgetpubkey function) Someone requested one of my pubkeys but the requestedAddressVersionNumber doesn\'t match my actual address version number. They shouldn\'t have done that. Ignoring.\n')
return
ifshared.safeConfigGetBoolean(myAddress,'chan'):
withshared.printLock:
print'Ignoring getpubkey request because it is for one of my chan addresses. The other party should already have the pubkey.'
return
try:
lastPubkeySendTime=int(shared.config.get(
myAddress,'lastpubkeysendtime'))
except:
lastPubkeySendTime=0
iflastPubkeySendTime>time.time()-shared.lengthOfTimeToHoldOnToAllPubkeys:# If the last time we sent our pubkey was more recent than 28 days ago...
withshared.printLock:
print'Found getpubkey-requested-item in my list of EC hashes BUT we already sent it recently. Ignoring request. The lastPubkeySendTime is:',lastPubkeySendTime
return
withshared.printLock:
print'Found getpubkey-requested-hash in my list of EC hashes. Telling Worker thread to do the POW for a pubkey message and send it out.'
ifrequestedAddressVersionNumber==2:
shared.workerQueue.put((
'doPOWForMyV2Pubkey',requestedHash))
elifrequestedAddressVersionNumber==3:
shared.workerQueue.put((
'sendOutOrStoreMyV3Pubkey',requestedHash))
elifrequestedAddressVersionNumber==4:
shared.workerQueue.put((
'sendOutOrStoreMyV4Pubkey',myAddress))
# We have received an inv message
@ -1498,7 +1604,7 @@ class receiveDataThread(threading.Thread):
privEncryptionKey=hashlib.sha512(hashlib.sha512(encodeVarint(toAddressVersionNumber)+encodeVarint(toStreamNumber)+toRipe).digest()).digest()[:32]# Note that this is the first half of the sha512 hash.
shared.neededPubkeys[toripe]=highlevelcrypto.makeCryptor(privEncryptionKey.encode('hex'))# We'll need this for when we receive a pubkey reply: it will be encrypted and we'll need to decrypt it.
# Initialize the shared.ackdataForWhichImWatching data structure using data
# from the sql database.
@ -64,23 +69,8 @@ class singleWorker(threading.Thread):
self.doPOWForMyV2Pubkey(data)
elifcommand=='sendOutOrStoreMyV3Pubkey':
self.sendOutOrStoreMyV3Pubkey(data)
"""elif command == 'newpubkey':
toAddressVersion,toStreamNumber,toRipe=data
iftoRipeinshared.neededPubkeys:
print'We have been awaiting the arrival of this pubkey.'
delshared.neededPubkeys[toRipe]
t=(toRipe,)
shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''UPDATE sent SET status='doingmsgpow' WHERE toripe=? AND status='awaitingpubkey' and folder='sent'''')
shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release()
self.sendMsg()
else:
withshared.printLock:
print'We don\'t need this pub key. We didn\'t ask for it. Pubkey hash:',toRipe.encode('hex')
"""
elifcommand=='sendOutOrStoreMyV4Pubkey':
self.sendOutOrStoreMyV4Pubkey(data)
else:
withshared.printLock:
sys.stderr.write(
@ -150,7 +140,7 @@ class singleWorker(threading.Thread):
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr.translateText("MainWindow","Message sent. Sent on %1").arg(unicode(
@ -683,14 +777,23 @@ class singleWorker(threading.Thread):
toAddress)+'. Please report this error to Atheros.')
return
shared.neededPubkeys[ripe]=0
ifaddressVersionNumber<=3:
shared.neededPubkeys[ripe]=0
elifaddressVersionNumber>=4:
privEncryptionKey=hashlib.sha512(hashlib.sha512(encodeVarint(addressVersionNumber)+encodeVarint(streamNumber)+ripe).digest()).digest()[:32]# Note that this is the first half of the sha512 hash.
shared.neededPubkeys[ripe]=highlevelcrypto.makeCryptor(privEncryptionKey.encode('hex'))# We'll need this for when we receive a pubkey reply: it will be encrypted and we'll need to decrypt it.
-300,300)))# the current time plus or minus five minutes.
payload+=encodeVarint(addressVersionNumber)
payload+=encodeVarint(streamNumber)
payload+=ripe
withshared.printLock:
print'making request for pubkey with ripe:',ripe.encode('hex')
ifaddressVersionNumber<=3:
payload+=ripe
withshared.printLock:
print'making request for pubkey with ripe:',ripe.encode('hex')
else:
payload+=hashlib.sha512(hashlib.sha512(encodeVarint(addressVersionNumber)+encodeVarint(streamNumber)+ripe).digest()).digest()[32:]# Note that this is the second half of the sha512 hash.
withshared.printLock:
print'making request for v4 pubkey with ripe:',ripe.encode('hex')
# print 'trial value', trialValue
statusbar='Doing the computations necessary to request the recipient\'s public key.'
@ -709,7 +812,7 @@ class singleWorker(threading.Thread):
@ -5,7 +5,7 @@ lengthOfTimeToLeaveObjectsInInventory = 237600 # Equals two days and 18 hours.
lengthOfTimeToHoldOnToAllPubkeys=2419200# Equals 4 weeks. You could make this longer if you want but making it shorter would not be advisable because there is a very small possibility that it could keep you from obtaining a needed pubkey for a period of time.
maximumAgeOfObjectsThatIAdvertiseToOthers=216000# Equals two days and 12 hours
maximumAgeOfNodesThatIAdvertiseToOthers=10800# Equals three hours
useVeryEasyProofOfWorkForTesting=False # If you set this to True while on the normal network, you won't be able to send or sometimes receive messages.
useVeryEasyProofOfWorkForTesting=True # If you set this to True while on the normal network, you won't be able to send or sometimes receive messages.
# Libraries.
@ -311,9 +311,9 @@ def flushInventory():
#Note that the singleCleanerThread clears out the inventory dictionary from time to time, although it only clears things that have been in the dictionary for a long time. This clears the inventory dictionary Now.