Multi threaded eciesDecrypt

This commit is contained in:
shortcutme 2019-11-25 14:37:55 +01:00
parent c52d47b15f
commit 7b210429b5
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
6 changed files with 89 additions and 11 deletions

View file

@ -2,6 +2,7 @@ import hashlib
import base64
import lib.pybitcointools as btctools
from Crypt import Crypt
ecc_cache = {}
@ -22,10 +23,24 @@ def eciesEncrypt(data, pubkey, ephemcurve=None, ciphername='aes-256-cbc'):
mac = pyelliptic.hmac_sha256(key_m, ciphertext)
return key_e, ciphertext + mac
@Crypt.thread_pool_crypt.wrap
def eciesDecryptMulti(encrypted_datas, privatekey):
texts = [] # Decoded texts
for encrypted_data in encrypted_datas:
try:
text = eciesDecrypt(encrypted_data, privatekey).decode("utf8")
texts.append(text)
except:
texts.append(None)
return texts
def eciesDecrypt(encrypted_data, privatekey):
ecc_key = getEcc(privatekey)
return ecc_key.decrypt(base64.b64decode(encrypted_data))
def split(encrypted):
iv = encrypted[0:16]
ciphertext = encrypted[16 + 70:-32]