diff --git a/encrypt-decrypt-test-bitmessage.py b/encrypt-decrypt-test-bitmessage.py new file mode 100644 index 0000000..2360347 --- /dev/null +++ b/encrypt-decrypt-test-bitmessage.py @@ -0,0 +1,88 @@ + +from binascii import hexlify, unhexlify +from struct import pack, unpack +from sys import exit + +from highlevelcrypto import makeCryptor, makePubCryptor, privToPub, hexToPubkey +from pyelliptic import ECC +from shared import decodeWalletImportFormat + +privencryptionkey = hexlify(decodeWalletImportFormat('5J9ydXT7Ep9pgbbkWei8LNsBMEdv3pgYq4nMnh2mqETzFsH7QYC')) +#privesigningkey = hexlify(decodeWalletImportFormat('5KZ69cpaXNh4GcaueuibSLae6nyYNRbq5ouX1eA2jFF75jT9Qcr')) +#privencryptionkey = hexlify(decodeWalletImportFormat('5KZ69cpaXNh4GcaueuibSLae6nyYNRbq5ouX1eA2jFF75jT9Qcr')) + +pubkey = privToPub(privencryptionkey) +c = makeCryptor(privencryptionkey) +eh = '00000000639194c10000000201019780d6685fb615a1ea82be2b981645ac02ca00201126d12e5aec99856dcc2c1bdaa964643f54524f847d36ab67810fe8bc053b180020f7dfe03154d20aa799865d36b13447f4ede4147534f5ab6b33cc4584b924056fe19f449889ebed27470fa4e16964bc1c11be1dbe5e448075aacf29782d32e90956b67f731459aeb511f6e61c905ca5314aa1fae58fbbbac2852bf4ee9da92fa8aa6df56521a10e094b3ca23582300e59e84c1aa46f7815a0d518faf5c4c7e1fc8439097b9989120811c1824e92677ddc35f0e34228b284d813bb421e0a8f020acb6eca51b0dfb6d0066ef5c7a483c02667af26551a3df7298533b203fc699647d2ff966f8615186586e5d6bf1e70c14331cc72a7614cf7b4648d32fc93a6bebdf0431c417af76f5827659c8e72c35414bcb59afa0ba8421c2665048f51e49d9d966063a269bda815ed7e9822760469cf9ed1dd182e74c61bc7e5a692cc966eae27982490a085199033dc0964b9eadbec22d5784d7b725b4c492b5d648d087c50058195ec4e7a9219f10f74dab9383dc2' +e = unhexlify(eh)[14:] +#e = unhexlify(eh) +#e = unhexlify(eh)[4:] +#print e + +c.decrypt(e) + +exit(0) + +m = '040100000001ecdc884536409bc7d387aaf521f95a6b964f20a25bc6cd597165dd6fa76b2c3cf0c8f463480bc2facfa8c9abbe386d528d876d249e0b8ead240a2c6196ba94e547e2673246034a2c920158410dfe970127bfc1efe4d4db58eb48408f338aebe07362e91936e654b3b041591a6c05e5882f51f59582db6808497d4572339d7a0dfd03e8fd03e80083d970e98aa0edec730577a43bdae373953706010a686579207468657265210046304402207ff3b4613dc5deac188b2cfdcbdaafaf567e40bc6859c4612ae9a045786bd48602205c54802071d7205ea5be91c2fc55fbf47d2316f65b9c23e2c7894b9d5d8c900f' + +#cp = ECC() +#e = cp.encrypt(unhexlify(m), hexToPubkey(pubkey)) +#print(hexlify(e)) +#print(len(e)) + +l = len(e) +print("IV") +print(hexlify(e[0:16])) +print("Curve type") +print(hexlify(e[16:18])) +print("X length") +print(hexlify(e[18:20])) +print("X") +print(hexlify(e[20:52])) +print("Y length") +print(hexlify(e[52:54])) +print("Y") +print(hexlify(e[54:86])) +print("encrypted") +print(hexlify(e[86:l-32])) +print("HMAC") +print(hexlify(e[-32:])) + +retval = c.decrypt(e) +print(retval) + +print "pubkey" +print pubkey + +m2 = hexlify(e) +offset = 0 +print "addressversion" +print unhexlify(m2)[offset:offset+1] +offset += 1 +print "stream" +print unhexlify(m2)[offset:offset+1] +offset += 1 +print "behaviour" +print unhexlify(m2)[offset:offset+4] +offset += 4 +print "signkey" +print unhexlify(m2)[offset:offset+64] +offset += 64 +print "enckey" +print unhexlify(m2)[offset:offset+64] +offset += 64 +print "trials" +print unhexlify(m2)[offset:offset+2] +offset += 2 +print "extra" +print unhexlify(m2)[offset:offset+2] +offset += 2 +print "dest" +print unhexlify(m2)[offset:offset+20] +offset += 20 +print "Encoding" +print unhexlify(m2)[offset:offset+1] +offset += 1 +print "Length" +print unhexlify(m2)[offset:offset+1] +