From 265fc07cc0f4fdcf6871f81b9d6f8bbc7d5cbedf Mon Sep 17 00:00:00 2001 From: Sandip Pandey Date: Wed, 7 Mar 2018 10:16:53 +0100 Subject: [PATCH] Using signer secret key instead of crypto secret key --- ipv8/attestation/trustchain/block.py | 5 +++-- test/attestation/trustchain/test_block.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ipv8/attestation/trustchain/block.py b/ipv8/attestation/trustchain/block.py index 9ea612f7c..d9eb3a8a8 100644 --- a/ipv8/attestation/trustchain/block.py +++ b/ipv8/attestation/trustchain/block.py @@ -291,7 +291,7 @@ def err(reason, double_spend=False): if linklinked is not None and linklinked.hash != self.hash: err("Double countersign fraud") if 'double_sig' in self.transaction and self.transaction['double_sig'] \ - and 'double_sig' in linklinked.transaction and linklinked.transactino['double_sig']: + and 'double_sig' in linklinked.transaction and linklinked.transaction['double_sig']: (sign_secret, private_key) = crypto.recover_double_signature( self.transaction['double_sig'], linklinked.transaction['double_sig'], @@ -331,7 +331,8 @@ def sign(self, key): # Attach custom double signature to the transaction itself sign_secret = doublesign.sha256("%s%s" % (key, self.block_id)) if self.transaction and isinstance(self.transaction, dict): - self.transaction['double_sig'] = crypto.create_custom_signature(key.key.hex_sk(), data, sign_secret) + signing_secret_key_hex = key.key.signer.sk[:32].encode('hex') + self.transaction['double_sig'] = crypto.create_custom_signature(signing_secret_key_hex, data, sign_secret) @classmethod def create(cls, transaction, database, public_key, link=None, link_pk=None): diff --git a/test/attestation/trustchain/test_block.py b/test/attestation/trustchain/test_block.py index 5bdaf3d93..611da2527 100644 --- a/test/attestation/trustchain/test_block.py +++ b/test/attestation/trustchain/test_block.py @@ -190,5 +190,6 @@ def test_double_spending(self): # Check equality of the private keys recovered_private_key = validation[2][1] - self.assertEqual(key.key.sk, recovered_private_key, "Recovered private key did not match.") + original_signing_secret_key = key.key.signer.sk[:32] + self.assertEqual(original_signing_secret_key, recovered_private_key, "Recovered private key did not match.")