|
@@ -9,7 +9,8 @@ from create_keys import make_keys, get_private_key, get_plain_key
|
|
|
import os
|
|
import os
|
|
|
from cryptography.hazmat.primitives import hashes
|
|
from cryptography.hazmat.primitives import hashes
|
|
|
from cryptography.hazmat.primitives.asymmetric import padding
|
|
from cryptography.hazmat.primitives.asymmetric import padding
|
|
|
-
|
|
|
|
|
|
|
+from cryptography.fernet import Fernet
|
|
|
|
|
+import rsa
|
|
|
|
|
|
|
|
def new_contract():
|
|
def new_contract():
|
|
|
def add():
|
|
def add():
|
|
@@ -120,7 +121,7 @@ def add_term():
|
|
|
attr = str(change.get())
|
|
attr = str(change.get())
|
|
|
value = str(values.get())
|
|
value = str(values.get())
|
|
|
comment = str(comments.get())
|
|
comment = str(comments.get())
|
|
|
- transactions = [x.data for x in conn.root.find_transactions(iden)]
|
|
|
|
|
|
|
+ transactions = conn.root.find_transactions(iden)
|
|
|
transactions = decrypt_transactions(transactions, str(contract.get()))
|
|
transactions = decrypt_transactions(transactions, str(contract.get()))
|
|
|
state = current_contract_state(transactions, iden)
|
|
state = current_contract_state(transactions, iden)
|
|
|
|
|
|
|
@@ -299,17 +300,25 @@ def get_updates(transactions, iden=None, attr=None, accepted=None):
|
|
|
return updates
|
|
return updates
|
|
|
|
|
|
|
|
def decrypt_transactions(transactions, name):
|
|
def decrypt_transactions(transactions, name):
|
|
|
- private_key = get_plain_key(name)
|
|
|
|
|
|
|
+ private_key = get_private_key(name)
|
|
|
decrypted = []
|
|
decrypted = []
|
|
|
|
|
+
|
|
|
for encrypted in transactions:
|
|
for encrypted in transactions:
|
|
|
- decrypting_message = private_key.decrypt(
|
|
|
|
|
- encrypted,
|
|
|
|
|
- padding.OAEP(
|
|
|
|
|
- mgf=padding.MGF1(algorithm=hashes.SHA256()),
|
|
|
|
|
- algorithm=hashes.SHA256(),
|
|
|
|
|
- label=None
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- decrypted.append(decrypting_message)
|
|
|
|
|
|
|
+ decrypted_key = rsa.decrypt(encrypted['encrypted key'],private_key)
|
|
|
|
|
+ cipher = Fernet(decrypted_key)
|
|
|
|
|
+ decrypted.append(cipher.decrypt(encrypted['data']))
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ # old code
|
|
|
|
|
+ # for encrypted in transactions:
|
|
|
|
|
+ # decrypting_message = private_key.decrypt(
|
|
|
|
|
+ # encrypted,
|
|
|
|
|
+ # padding.OAEP(
|
|
|
|
|
+ # mgf=padding.MGF1(algorithm=hashes.SHA256()),
|
|
|
|
|
+ # algorithm=hashes.SHA256(),
|
|
|
|
|
+ # label=None
|
|
|
|
|
+ # )
|
|
|
|
|
+ # )
|
|
|
|
|
+ # decrypted.append(decrypting_message)
|
|
|
|
|
|
|
|
return decrypted
|
|
return decrypted
|