Skip to content

Commit

Permalink
Using signer secret key instead of crypto secret key
Browse files Browse the repository at this point in the history
  • Loading branch information
xoriole committed Mar 7, 2018
1 parent b30809a commit 265fc07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ipv8/attestation/trustchain/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion test/attestation/trustchain/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

0 comments on commit 265fc07

Please sign in to comment.