Skip to content

Commit

Permalink
Create multi_signature.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Nov 26, 2024
1 parent 8e9e1e4 commit 2fd20e1
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions QuantumNexusProtocol/src/cryptography/multi_signature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from ecdsa import SigningKey, VerifyingKey, SECP256k1
from hashlib import sha256

class MultiSignature:
def __init__(self):
self.signers = []

def add_signer(self):
sk = SigningKey.generate(curve=SECP256k1)
self.signers.append(sk)

def sign(self, message):
signatures = []
for sk in self.signers:
signature = sk.sign(message)
signatures.append(signature)
return signatures

def verify(self, message, signatures):
for i, sk in enumerate(self.signers):
vk = sk.get_verifying_key()
if not vk.verify(signatures[i], message):
return False
return True

# Example usage
if __name__ == "__main__":
multi_sig = MultiSignature()
multi_sig.add_signer()
multi_sig.add_signer()
message = b"Multi-signature message"
signatures = multi_sig.sign(message)
is_valid = multi_sig.verify(message, signatures)
print(f"All signatures valid: {is_valid}")

0 comments on commit 2fd20e1

Please sign in to comment.