[ECDSA Home][Home]
Elliptic Curve Digital Signature Algorithm (ECDSA) supports the signing of data with Elliptic Curve methods.
Elliptic Curve Digital Signature Algorithm (ECDSA)
[ECDSA Home][Home]
Elliptic Curve Digital Signature Algorithm (ECDSA) supports the signing of data with Elliptic Curve methods.
|
With ECDSA, Alice will sign a message with her private key (\(d_A\)), and then Bob will use her public key (\(Q_A\)) to verify that she signed the message (and that the message has now changed):
Alice thus has a private key (\(d_A\)) and a public key (\(Q_A=d_A.G\)). She then signs a message (\(M\)) with the following:
Bob will check with:
The following is an outlline of the code:
from ecdsa import SigningKey,NIST192p,NIST224p,NIST256p,NIST384p,NIST521p,SECP256k1 import base64 import sys import binascii msg="Hello" type = 1 cur=NIST192p if (len(sys.argv)>1): msg=str(sys.argv[1]) if (len(sys.argv)>2): type=int(sys.argv[2]) sk = SigningKey.generate(curve=cur) vk = sk.get_verifying_key() print("Secret key:\t",binascii.hexlify(sk.to_string())) print("Public key:\t",binascii.hexlify(vk.to_string())) signature = sk.sign(msg.encode()) print("Message:\t",msg) print("Type:\t\t",cur.name) print("=========================") print("Signature:\t",base64.b64encode(signature)) print("Signature:\t",binascii.hexlify(signature).decode()) print("=========================") print("Signatures match:\t",vk.verify(signature, msg.encode()))
A sample run is:
Secret key: b'996af3300b803ce0d4505807c7bcae4462658dbdc57fbda3' Public key: b'3c587e057148eed1b435a55d71df796b3bb2546c543f77cde98facd9a3378682dfc66cead94971b4b67943a5a7756cde' Message: Hello Type: NIST192p ========================= Signature: b'XAaOh3tmgoWczD75TdvPVmmQTXIMMSI9DjzImvgg61FBTYP155QJUnlqjoNTN/c7' Signature: 5c068e877b6682859ccc3ef94ddbcf5669904d720c31223d0e3cc89af820eb51414d83f5e7940952796a8e835337f73b ========================= Signatures match: True