Omnibus commited on
Commit
f7093ab
·
1 Parent(s): 1708c7f

Update app_og.py

Browse files
Files changed (1) hide show
  1. app_og.py +14 -0
app_og.py CHANGED
@@ -72,6 +72,11 @@ def sign(data,in2):
72
  "signature": signature
73
  }
74
  return data_json
 
 
 
 
 
75
 
76
  def encrypt_text(data,pub_im,priv_im,address):
77
  pub_key = stegan2.decode(pub_im)
@@ -151,6 +156,15 @@ def decrypt_text(im,in2):
151
  # Decrypt the data with the AES session key
152
  cipher_aes = AES.new(session_key, AES.MODE_EAX, nonce)
153
  data = cipher_aes.decrypt_and_verify(ciphertext, tag)
 
 
 
 
 
 
 
 
 
154
  return(data.decode("utf-8"))
155
 
156
  def test_fn(im1,im2):
 
72
  "signature": signature
73
  }
74
  return data_json
75
+
76
+ def validate_signature(public_key: bytes, signature: bytes, transaction_data: bytes):
77
+ public_key_object = RSA.import_key(public_key)
78
+ transaction_hash = SHA256.new(transaction_data)
79
+ pkcs1_15.new(public_key_object).verify(transaction_hash, signature)
80
 
81
  def encrypt_text(data,pub_im,priv_im,address):
82
  pub_key = stegan2.decode(pub_im)
 
156
  # Decrypt the data with the AES session key
157
  cipher_aes = AES.new(session_key, AES.MODE_EAX, nonce)
158
  data = cipher_aes.decrypt_and_verify(ciphertext, tag)
159
+
160
+ public_key = private_key.publickey().export_key('PEM')
161
+ data_val = data[0]
162
+ signature = data[1]
163
+ transaction_hash = SHA256.new(data_val)
164
+
165
+ #transaction
166
+
167
+ print (pkcs1_15.new(public_key).verify(transaction_hash, signature))
168
  return(data.decode("utf-8"))
169
 
170
  def test_fn(im1,im2):