From fb4dd5f8352e0583d59d34b6ceb9ffa7dc6029b1 Mon Sep 17 00:00:00 2001 From: vtexier <vit@free.fr> Date: Thu, 20 Feb 2020 18:16:51 +0100 Subject: [PATCH] [fix] fix context menu Save revocation document Add filename in file dialog --- .../gui/dialogs/connection_cfg/controller.py | 3 +- src/sakia/gui/dialogs/connection_cfg/model.py | 2 +- src/sakia/gui/dialogs/connection_cfg/view.py | 2 +- src/sakia/gui/navigation/controller.py | 7 ++-- .../gui/sub/password_input/controller.py | 3 +- src/sakia/services/documents.py | 32 +++++++++---------- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/sakia/gui/dialogs/connection_cfg/controller.py b/src/sakia/gui/dialogs/connection_cfg/controller.py index fea5a3a3..d91ed165 100644 --- a/src/sakia/gui/dialogs/connection_cfg/controller.py +++ b/src/sakia/gui/dialogs/connection_cfg/controller.py @@ -330,7 +330,8 @@ class ConnectionConfigController(QObject): selected_files = await QAsyncFileDialog.get_save_filename( self.view, self.tr("Save a revocation document"), - "", + "revocation-{uid}-{pubkey}-{currency}.txt".format(uid=identity.uid, pubkey=identity.pubkey[:8], + currency=identity.currency), self.tr("All text files (*.txt)"), ) if selected_files: diff --git a/src/sakia/gui/dialogs/connection_cfg/model.py b/src/sakia/gui/dialogs/connection_cfg/model.py index 9d8e8c73..92d151b2 100644 --- a/src/sakia/gui/dialogs/connection_cfg/model.py +++ b/src/sakia/gui/dialogs/connection_cfg/model.py @@ -48,7 +48,7 @@ class ConnectionConfigModel(QObject): self.connection.scrypt_r = scrypt_params.r self.connection.scrypt_p = scrypt_params.p self.connection.password = password - self.connection.pubkey = SigningKey( + self.connection.pubkey = SigningKey.from_credentials( self.connection.salt, password, scrypt_params ).pubkey diff --git a/src/sakia/gui/dialogs/connection_cfg/view.py b/src/sakia/gui/dialogs/connection_cfg/view.py index 396a2f80..12363c63 100644 --- a/src/sakia/gui/dialogs/connection_cfg/view.py +++ b/src/sakia/gui/dialogs/connection_cfg/view.py @@ -150,7 +150,7 @@ class ConnectionConfigView(QDialog, Ui_ConnectionConfigurationDialog): def action_show_pubkey(self): salt = self.edit_salt.text() password = self.edit_password.text() - pubkey = SigningKey(salt, password, self.scrypt_params).pubkey + pubkey = SigningKey.from_credentials(salt, password, self.scrypt_params).pubkey self.label_info.setText(pubkey) def account_name(self): diff --git a/src/sakia/gui/navigation/controller.py b/src/sakia/gui/navigation/controller.py index 1210084b..cd334753 100644 --- a/src/sakia/gui/navigation/controller.py +++ b/src/sakia/gui/navigation/controller.py @@ -235,7 +235,7 @@ class NavigationController(QObject): ) if not password or not secret_key: return - key = SigningKey(secret_key, password, connection.scrypt_params) + key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) identity_doc.sign([key]) identity.signature = identity_doc.signatures[0] self.model.update_identity(identity) @@ -321,7 +321,8 @@ neither your identity from the network.""" selected_files = await QAsyncFileDialog.get_save_filename( self.view, self.tr("Save a revokation document"), - "", + "revocation-{uid}-{pubkey}-{currency}.txt".format(uid=connection.uid, pubkey=connection.pubkey[:8], + currency=connection.currency), self.tr("All text files (*.txt)"), ) if selected_files: @@ -354,7 +355,7 @@ The publication of this document will remove your identity from the network.</p> ) if not password or not secret_key: return - key = SigningKey(secret_key, password, connection.scrypt_params) + key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) identity_doc.sign([key]) identity.signature = identity_doc.signatures[0] self.model.update_identity(identity) diff --git a/src/sakia/gui/sub/password_input/controller.py b/src/sakia/gui/sub/password_input/controller.py index 9a64499f..e93ab211 100644 --- a/src/sakia/gui/sub/password_input/controller.py +++ b/src/sakia/gui/sub/password_input/controller.py @@ -70,9 +70,8 @@ class PasswordInputController(QObject): if detect_non_printable(password): self.view.error(self.tr("Non printable characters in password")) return False - if ( - SigningKey(secret_key, password, self.connection.scrypt_params).pubkey + SigningKey.from_credentials(secret_key, password, self.connection.scrypt_params).pubkey != self.connection.pubkey ): self.view.error( diff --git a/src/sakia/services/documents.py b/src/sakia/services/documents.py index 512f73b5..321cc22e 100644 --- a/src/sakia/services/documents.py +++ b/src/sakia/services/documents.py @@ -152,7 +152,7 @@ class DocumentsService: connection.blockstamp, None, ) - key = SigningKey(secret_key, password, connection.scrypt_params) + key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) membership.sign([key]) self._logger.debug("Membership : {0}".format(membership.signed_raw())) responses = await self._bma_connector.broadcast( @@ -199,9 +199,9 @@ class DocumentsService: 10, connection.currency, connection.pubkey, identity.pubkey, blockUID, None ) - key = SigningKey(secret_key, password, connection.scrypt_params) - certification.sign(identity.document(), [key]) - signed_cert = certification.signed_raw(identity.document()) + key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) + certification.sign([key]) + signed_cert = certification.signed_raw() self._logger.debug("Certification : {0}".format(signed_cert)) timestamp = self._blockchain_processor.time(connection.currency) responses = await self._bma_connector.broadcast( @@ -225,14 +225,14 @@ class DocumentsService: :param str salt: The account SigningKey salt :param str password: The account SigningKey password """ - revocation = Revocation(10, currency, None) + revocation = Revocation(10, currency, identity, "") self_cert = identity.document() - key = SigningKey(salt, password) - revocation.sign(self_cert, [key]) + key = SigningKey.from_credentials(salt, password) + revocation.sign([key]) self._logger.debug( - "Self-Revokation Document : \n{0}".format(revocation.raw(self_cert)) + "Self-Revokation Document : \n{0}".format(revocation.raw()) ) self._logger.debug("Signature : \n{0}".format(revocation.signatures[0])) @@ -243,7 +243,7 @@ class DocumentsService: } self._logger.debug("Posted data : {0}".format(data)) responses = await self._bma_connector.broadcast( - currency, bma.wot.Revoke, {}, data + currency, bma.wot.revoke, data ) result = await parse_bma_responses(responses) return result @@ -256,26 +256,26 @@ class DocumentsService: :param str secret_key: The account SigningKey secret key :param str password: The account SigningKey password """ - document = Revocation(10, connection.currency, connection.pubkey, "") identity = self._identities_processor.get_identity( connection.currency, connection.pubkey, connection.uid ) if not identity: identity = self.generate_identity(connection) identity_doc = identity.document() - key = SigningKey( + key = SigningKey.from_credentials( connection.salt, connection.password, connection.scrypt_params ) identity_doc.sign([key]) identity.signature = identity_doc.signatures[0] self._identities_processor.insert_or_update_identity(identity) - self_cert = identity.document() + document = Revocation(10, connection.currency, identity.document(), "") + + key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) - key = SigningKey(secret_key, password, connection.scrypt_params) + document.sign([key]) - document.sign(self_cert, [key]) - return document.signed_raw(self_cert), identity + return document.signed_raw(), identity def tx_sources(self, amount, amount_base, currency, pubkey): """ @@ -527,7 +527,7 @@ class DocumentsService: :param str message: The message to send with the transfer """ blockstamp = self._blockchain_processor.current_buid(connection.currency) - key = SigningKey(secret_key, password, connection.scrypt_params) + key = SigningKey.from_credentials(secret_key, password, connection.scrypt_params) logging.debug("Sender pubkey:{0}".format(key.pubkey)) tx_entities = [] result = (True, ""), tx_entities -- GitLab