tlsfuzzer / python-ecdsa

pure-python ECDSA signature/verification and ECDH key agreement
Other
906 stars 311 forks source link

Different Results of verifying key #310

Closed FrankC01 closed 1 year ago

FrankC01 commented 1 year ago

Using fastcrypto a secp256r1 key-pair was generated using

mnemonic_phrase = "impulse pipe canoe catalog add weekend adjust since parent cargo item emerge royal surge unknown napkin chalk welcome swamp nest antique cram open current"
derivation_path = "m/74'/784'/0'/0/0"

Resulting in the signing/verifying key bytes (in base64):

w0XBGG6J2L2HbbAAH8XphWIAMHSFB209y5ZOlLUeFuY=
AgNgevhsriSuu3jwL8TeY9g7rQJHOdCdVC9RbAgwi7NeeA==

However, when I use ecdsa thus:

sign_key = ecdsa.SigningKey.from_string(prv_bytes, ecdsa.NIST256p, hashlib.sha3_256)
ver_key = sign_key.verifying_key
print(base64.b64encode(sign_key.to_string()).decode())
print(base64.b64encode(ver_key.to_string("compressed")).decode())

I'm getting these strings back (base64):

w0XBGG6J2L2HbbAAH8XphWIAMHSFB209y5ZOlLUeFuY=
A2B6+GyuJK67ePAvxN5j2DutAkc50J1UL1FsCDCLs154

As I am not a crypto guru, I don't understand why they would have different verifying keys?

FrankC01 commented 1 year ago

My apologies, I found the issue... it was extra bytes from the original verify key that, for some reason, was being prefixed onto the true verifying key bytes.