Fix #761 #762

Merged
Atheros1 merged 2 commits from master into master 2015-01-08 23:12:52 +01:00
3 changed files with 36 additions and 35 deletions

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'bitmessageui.ui' # Form implementation generated from reading ui file 'bitmessageui.ui'
# #
# Created: Fri Aug 01 15:30:14 2014 # Created: Mon Jan 05 16:21:20 2015
# by: PyQt4 UI code generator 4.10.3 # by: PyQt4 UI code generator 4.10.3
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -625,11 +625,11 @@ class Ui_MainWindow(object):
item.setText(_translate("MainWindow", "Stream #", None)) item.setText(_translate("MainWindow", "Stream #", None))
item = self.tableWidgetConnectionCount.horizontalHeaderItem(1) item = self.tableWidgetConnectionCount.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Connections", None)) item.setText(_translate("MainWindow", "Connections", None))
self.labelTotalConnections.setText(_translate("MainWindow", "Total connections: 0", None)) self.labelTotalConnections.setText(_translate("MainWindow", "Total connections:", None))
self.labelStartupTime.setText(_translate("MainWindow", "Since startup at asdf:", None)) self.labelStartupTime.setText(_translate("MainWindow", "Since startup:", None))
self.labelMessageCount.setText(_translate("MainWindow", "Processed 0 person-to-person message.", None)) self.labelMessageCount.setText(_translate("MainWindow", "Processed 0 person-to-person messages.", None))
self.labelPubkeyCount.setText(_translate("MainWindow", "Processed 0 public key.", None)) self.labelPubkeyCount.setText(_translate("MainWindow", "Processed 0 public keys.", None))
self.labelBroadcastCount.setText(_translate("MainWindow", "Processed 0 broadcast.", None)) self.labelBroadcastCount.setText(_translate("MainWindow", "Processed 0 broadcasts.", None))
self.labelLookupsPerSecond.setText(_translate("MainWindow", "Inventory lookups per second: 0", None)) self.labelLookupsPerSecond.setText(_translate("MainWindow", "Inventory lookups per second: 0", None))
self.labelBytesRecvCount.setText(_translate("MainWindow", "Down: 0 KB/s", None)) self.labelBytesRecvCount.setText(_translate("MainWindow", "Down: 0 KB/s", None))
self.labelBytesSentCount.setText(_translate("MainWindow", "Up: 0 KB/s", None)) self.labelBytesSentCount.setText(_translate("MainWindow", "Up: 0 KB/s", None))

View File

@ -976,7 +976,7 @@ p, li { white-space: pre-wrap; }
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Total connections: 0</string> <string>Total connections:</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="labelStartupTime"> <widget class="QLabel" name="labelStartupTime">
@ -989,7 +989,7 @@ p, li { white-space: pre-wrap; }
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Since startup at asdf:</string> <string>Since startup:</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="labelMessageCount"> <widget class="QLabel" name="labelMessageCount">
@ -1002,7 +1002,7 @@ p, li { white-space: pre-wrap; }
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Processed 0 person-to-person message.</string> <string>Processed 0 person-to-person messages.</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="labelPubkeyCount"> <widget class="QLabel" name="labelPubkeyCount">
@ -1015,7 +1015,7 @@ p, li { white-space: pre-wrap; }
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Processed 0 public key.</string> <string>Processed 0 public keys.</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="labelBroadcastCount"> <widget class="QLabel" name="labelBroadcastCount">
@ -1028,7 +1028,7 @@ p, li { white-space: pre-wrap; }
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Processed 0 broadcast.</string> <string>Processed 0 broadcasts.</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="labelLookupsPerSecond"> <widget class="QLabel" name="labelLookupsPerSecond">

View File

@ -7,6 +7,7 @@ import ctypes
import hashlib import hashlib
import highlevelcrypto import highlevelcrypto
from addresses import * from addresses import *
from debug import logger
from pyelliptic import arithmetic from pyelliptic import arithmetic
import tr import tr
@ -85,20 +86,19 @@ class addressGenerator(threading.Thread):
potentialPrivEncryptionKey = OpenSSL.rand(32) potentialPrivEncryptionKey = OpenSSL.rand(32)
potentialPubEncryptionKey = highlevelcrypto.pointMult( potentialPubEncryptionKey = highlevelcrypto.pointMult(
potentialPrivEncryptionKey) potentialPrivEncryptionKey)
# print 'potentialPubSigningKey', potentialPubSigningKey.encode('hex')
# print 'potentialPubEncryptionKey',
# potentialPubEncryptionKey.encode('hex')
ripe = hashlib.new('ripemd160') ripe = hashlib.new('ripemd160')
sha = hashlib.new('sha512') sha = hashlib.new('sha512')
sha.update( sha.update(
potentialPubSigningKey + potentialPubEncryptionKey) potentialPubSigningKey + potentialPubEncryptionKey)
ripe.update(sha.digest()) ripe.update(sha.digest())
# print 'potential ripe.digest',
# ripe.digest().encode('hex')
if ripe.digest()[:numberOfNullBytesDemandedOnFrontOfRipeHash] == '\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash: if ripe.digest()[:numberOfNullBytesDemandedOnFrontOfRipeHash] == '\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash:
break break
print 'Generated address with ripe digest:', ripe.digest().encode('hex') logger.info('Generated address with ripe digest: %s' % 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.' try:
logger.info('Address generator calculated %s addresses at %s addresses per second before finding one with the correct ripe-prefix.' % (numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix, numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix / (time.time() - startTime)))
except ZeroDivisionError:
# The user must have a pretty fast computer. time.time() - startTime equaled zero.
pass
address = encodeAddress(addressVersionNumber, streamNumber, ripe.digest()) address = encodeAddress(addressVersionNumber, streamNumber, ripe.digest())
# An excellent way for us to store our keys is in Wallet Import Format. Let us convert now. # An excellent way for us to store our keys is in Wallet Import Format. Let us convert now.
@ -108,14 +108,12 @@ class addressGenerator(threading.Thread):
privSigningKey).digest()).digest()[0:4] privSigningKey).digest()).digest()[0:4]
privSigningKeyWIF = arithmetic.changebase( privSigningKeyWIF = arithmetic.changebase(
privSigningKey + checksum, 256, 58) privSigningKey + checksum, 256, 58)
# print 'privSigningKeyWIF',privSigningKeyWIF
privEncryptionKey = '\x80' + potentialPrivEncryptionKey privEncryptionKey = '\x80' + potentialPrivEncryptionKey
checksum = hashlib.sha256(hashlib.sha256( checksum = hashlib.sha256(hashlib.sha256(
privEncryptionKey).digest()).digest()[0:4] privEncryptionKey).digest()).digest()[0:4]
privEncryptionKeyWIF = arithmetic.changebase( privEncryptionKeyWIF = arithmetic.changebase(
privEncryptionKey + checksum, 256, 58) privEncryptionKey + checksum, 256, 58)
# print 'privEncryptionKeyWIF',privEncryptionKeyWIF
shared.config.add_section(address) shared.config.add_section(address)
shared.config.set(address, 'label', label) shared.config.set(address, 'label', label)
@ -178,9 +176,6 @@ class addressGenerator(threading.Thread):
potentialPrivSigningKey) potentialPrivSigningKey)
potentialPubEncryptionKey = highlevelcrypto.pointMult( potentialPubEncryptionKey = highlevelcrypto.pointMult(
potentialPrivEncryptionKey) potentialPrivEncryptionKey)
# print 'potentialPubSigningKey', potentialPubSigningKey.encode('hex')
# print 'potentialPubEncryptionKey',
# potentialPubEncryptionKey.encode('hex')
signingKeyNonce += 2 signingKeyNonce += 2
encryptionKeyNonce += 2 encryptionKeyNonce += 2
ripe = hashlib.new('ripemd160') ripe = hashlib.new('ripemd160')
@ -188,13 +183,16 @@ class addressGenerator(threading.Thread):
sha.update( sha.update(
potentialPubSigningKey + potentialPubEncryptionKey) potentialPubSigningKey + potentialPubEncryptionKey)
ripe.update(sha.digest()) ripe.update(sha.digest())
# print 'potential ripe.digest',
# ripe.digest().encode('hex')
if ripe.digest()[:numberOfNullBytesDemandedOnFrontOfRipeHash] == '\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash: if ripe.digest()[:numberOfNullBytesDemandedOnFrontOfRipeHash] == '\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash:
break break
print 'ripe.digest', ripe.digest().encode('hex')
print 'Address generator calculated', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix, 'addresses at', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix / (time.time() - startTime), 'keys per second.' logger.info('Generated address with ripe digest: %s' % ripe.digest().encode('hex'))
try:
logger.info('Address generator calculated %s addresses at %s addresses per second before finding one with the correct ripe-prefix.' % (numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix, numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix / (time.time() - startTime)))
except ZeroDivisionError:
# The user must have a pretty fast computer. time.time() - startTime equaled zero.
pass
address = encodeAddress(addressVersionNumber, streamNumber, ripe.digest()) address = encodeAddress(addressVersionNumber, streamNumber, ripe.digest())
saveAddressToDisk = True saveAddressToDisk = True
@ -222,14 +220,19 @@ class addressGenerator(threading.Thread):
privEncryptionKeyWIF = arithmetic.changebase( privEncryptionKeyWIF = arithmetic.changebase(
privEncryptionKey + checksum, 256, 58) privEncryptionKey + checksum, 256, 58)
addressAlreadyExists = False
try: try:
shared.config.add_section(address) shared.config.add_section(address)
addressAlreadyExists = False
except: except:
print address, 'already exists. Not adding it again.'
addressAlreadyExists = True addressAlreadyExists = True
if not addressAlreadyExists:
print 'label:', label if addressAlreadyExists:
logger.info('%s already exists. Not adding it again.' % address)
shared.UISignalQueue.put((
'updateStatusBar', tr.translateText("MainWindow","%1 is already in 'Your Identities'. Not adding it again.").arg(address)))
else:
logger.debug('label: %s' % label)
shared.config.set(address, 'label', label) shared.config.set(address, 'label', label)
shared.config.set(address, 'enabled', 'true') shared.config.set(address, 'enabled', 'true')
shared.config.set(address, 'decoy', 'false') shared.config.set(address, 'decoy', 'false')
@ -262,18 +265,16 @@ class addressGenerator(threading.Thread):
elif addressVersionNumber == 4: elif addressVersionNumber == 4:
shared.workerQueue.put(( shared.workerQueue.put((
'sendOutOrStoreMyV4Pubkey', address)) 'sendOutOrStoreMyV4Pubkey', address))
shared.UISignalQueue.put((
'updateStatusBar', tr.translateText("MainWindow", "Done generating address")))
# Done generating addresses. # Done generating addresses.
if command == 'createDeterministicAddresses' or command == 'joinChan' or command == 'createChan': if command == 'createDeterministicAddresses' or command == 'joinChan' or command == 'createChan':
shared.apiAddressGeneratorReturnQueue.put( shared.apiAddressGeneratorReturnQueue.put(
listOfNewAddressesToSendOutThroughTheAPI) listOfNewAddressesToSendOutThroughTheAPI)
shared.UISignalQueue.put((
'updateStatusBar', tr.translateText("MainWindow", "Done generating address")))
# shared.reloadMyAddressHashes()
elif command == 'getDeterministicAddress': elif command == 'getDeterministicAddress':
shared.apiAddressGeneratorReturnQueue.put(address) shared.apiAddressGeneratorReturnQueue.put(address)
#todo: return things to the API if createChan or joinChan assuming saveAddressToDisk
else: else:
raise Exception( raise Exception(
"Error in the addressGenerator thread. Thread was given a command it could not understand: " + command) "Error in the addressGenerator thread. Thread was given a command it could not understand: " + command)