From 71cf7816bfbb1d0a8cba38deb77d7b2cb8fb3892 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Tue, 26 Nov 2024 14:01:19 +0700 Subject: [PATCH] Create digital_signatures.py --- .../src/cryptography/digital_signatures.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 QuantumNexusProtocol/src/cryptography/digital_signatures.py diff --git a/QuantumNexusProtocol/src/cryptography/digital_signatures.py b/QuantumNexusProtocol/src/cryptography/digital_signatures.py new file mode 100644 index 000000000..33a578467 --- /dev/null +++ b/QuantumNexusProtocol/src/cryptography/digital_signatures.py @@ -0,0 +1,20 @@ +from ecdsa import SigningKey, VerifyingKey, SECP256k1 + +class DigitalSignature: + def __init__(self): + self.sk = SigningKey.generate(curve=SECP256k1) + self.v k = self.sk.get_verifying_key() + + def sign(self, message): + return self.sk.sign(message) + + def verify(self, message, signature): + return self.vk.verify(signature, message) + +# Example usage +if __name__ == "__main__": + message = b"Digital signature message" + ds = DigitalSignature() + signature = ds.sign(message) + is_valid = ds.verify(message, signature) + print(f"Signature valid: {is_valid}")