|
|
@@ -9,6 +9,8 @@ from cryptography.hazmat.backends import default_backend
|
|
|
from cryptography.hazmat.primitives import serialization
|
|
|
from cryptography.hazmat.primitives import hashes
|
|
|
from cryptography.hazmat.primitives.asymmetric import padding
|
|
|
+from cryptography.fernet import Fernet
|
|
|
+
|
|
|
|
|
|
class Transaction:
|
|
|
def __init__(self):
|
|
|
@@ -73,16 +75,22 @@ class Transaction:
|
|
|
block_string = string_object.encode()
|
|
|
|
|
|
# open the public key file
|
|
|
- pubkey = get_keys(contract) #Sender public key - input field neccessary
|
|
|
-
|
|
|
- encrypted_data = pubkey.encrypt(
|
|
|
- block_string,
|
|
|
- padding.OAEP(
|
|
|
- mgf=padding.MGF1(algorithm=hashes.SHA256()),
|
|
|
- algorithm=hashes.SHA256(),
|
|
|
- label=None
|
|
|
- )
|
|
|
- )
|
|
|
+ symmetric_key = get_symmetric_key(contract)
|
|
|
+ pubkey = get_keys(contract)
|
|
|
+
|
|
|
+ chiper = Fernet(symmetric_key)
|
|
|
+
|
|
|
+ encrypted_data = chiper.encrypt(block_string)
|
|
|
+
|
|
|
+ encrypted_key = rsa.encrypt(symmetric_key,pubkey) # we need an extra field in the transaction
|
|
|
+ # encrypted_data = pubkey.encrypt(
|
|
|
+ # block_string,
|
|
|
+ # padding.OAEP(
|
|
|
+ # mgf=padding.MGF1(algorithm=hashes.SHA256()),
|
|
|
+ # algorithm=hashes.SHA256(),
|
|
|
+ # label=None
|
|
|
+ # )
|
|
|
+ # )
|
|
|
|
|
|
self.hash_value = encrypted_data
|
|
|
self.log(f'Hashed: {self.hash_value}')
|