We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 23bfd74 commit 35a6be9Copy full SHA for 35a6be9
src/security.py
@@ -0,0 +1,18 @@
1
+from cryptography.hazmat.primitives.asymmetric import ec
2
+from cryptography.hazmat.primitives import serialization
3
+
4
+class Security:
5
+ def __init__(self):
6
+ self.private_key = ec.generate_private_key(ec.SECP256R1())
7
+ self.public_key = self.private_key.public_key()
8
9
+ def sign_transaction(self, transaction):
10
+ signature = self.private_key.sign(transaction.encode())
11
+ return signature
12
13
+ def verify_signature(self, transaction, signature):
14
+ try:
15
+ self.public_key.verify(signature, transaction.encode())
16
+ return True
17
+ except Exception:
18
+ return False
0 commit comments