We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from_public_key_recovery
pubkey = "fe27389aada80332ec2478814eb3c81de9d1109bc3c21d23853a43bd16ed176057371f3ce271d1ef423ef6fa56f97925a07036158bf90bb87c6c24f248932554" msg = "3045022100c3c38c977a3c11214f76eb59616a69838dbc14fc0d666e16c0d65989f7f9245b022037861ec5d4599caf17d80da102a89616a545cfca1932253bc2a539a0c9cb66e8" msg = bytes.fromhex(msg) raw_msg = "9302bda273a887cb40c13e02a50b4071a31fd3aae3ae04021b0b843dd61ad18e" raw_msg = bytes.fromhex(raw_msg) # right data _r = 0x00c3c38c977a3c11214f76eb59616a69838dbc14fc0d666e16c0d65989f7f9245b _s = 0x37861ec5d4599caf17d80da102a89616a545cfca1932253bc2a539a0c9cb66e8 signature = msg data = raw_msg curve = ecdsa.curves.SECP256k1 print("correct", _r, _s) generator = curve.generator r, s = ecdsa.util.sigdecode_der(signature, generator.order()) print(r, s) pubkey = ecdsa.VerifyingKey.from_public_key_recovery( signature=signature, data=data, curve=curve, sigdecode=ecdsa.util.sigdecode_der) print(hexlify(pubkey[0].to_string()), hexlify(pubkey[1].to_string()))
Then i got error
correct 88546510979682037774707173221481493851486333744139811890585270440885638210651 25114176564622922097833533925221099216470038098832442934481636541806701930216 88546510979682037774707173221481493851486333744139811890585270440885638210651 25114176564622922097833533925221099216470038098832442934481636541806701930216 Traceback (most recent call last): File "C:\Users\hasee\Desktop\test2.py", line 85, in <module> signature=signature, data=data, curve=curve, sigdecode=ecdsa.util.sigdecode_der) File "D:\anaconda3\envs\py37\lib\site-packages\ecdsa\keys.py", line 89, in from_public_key_recovery return klass.from_public_key_recovery_with_digest(signature, digest, curve, hashfunc=sha1, sigdecode=sigdecode_string) File "D:\anaconda3\envs\py37\lib\site-packages\ecdsa\keys.py", line 97, in from_public_key_recovery_with_digest r, s = sigdecode(signature, generator.order()) File "D:\anaconda3\envs\py37\lib\site-packages\ecdsa\util.py", line 238, in sigdecode_string assert len(signature) == 2 * l, (len(signature), 2 * l) AssertionError: (71, 64)
So i view #102 and code, then found the reason https://github.com/warner/python-ecdsa/blob/master/src/ecdsa/keys.py#L89 The code should be return klass.from_public_key_recovery_with_digest(signature, digest, curve, hashfunc=sha1, sigdecode=sigdecode)
return klass.from_public_key_recovery_with_digest(signature, digest, curve, hashfunc=sha1, sigdecode=sigdecode)
After changing the code, i got the correct public key
correct is 88546510979682037774707173221481493851486333744139811890585270440885638210651 25114176564622922097833533925221099216470038098832442934481636541806701930216 88546510979682037774707173221481493851486333744139811890585270440885638210651 25114176564622922097833533925221099216470038098832442934481636541806701930216 b'fe27389aada80332ec2478814eb3c81de9d1109bc3c21d23853a43bd16ed176057371f3ce271d1ef423ef6fa56f97925a07036158bf90bb87c6c24f248932554' b'9eb524f1401c38df84374fa68047d5cbdabe5ac710406012fc162a588347e8856fa4850ef58394a91cb8c413ccf6b5e2fbc97755c1cbf833020e97e2cfec062a'
The text was updated successfully, but these errors were encountered:
sigdecode is the default signature decoding method, why do you think that the default is wrong? why it shouldn't be sigdecode_string?
sigdecode
sigdecode_string
Sorry, something went wrong.
no, scratch that, I though that the issue was with default value of the parameter
yes, it's a bug
To fix issue tlsfuzzer#108
fbb3604
fixed the issue that keys.py#Line89 using the wrong parameter
Merge pull request #110 from kcorlidy/master
72621b1
To fix issue #108
No branches or pull requests
Then i got error
So i view #102 and code, then found the reason
https://github.com/warner/python-ecdsa/blob/master/src/ecdsa/keys.py#L89
The code should be
return klass.from_public_key_recovery_with_digest(signature, digest, curve, hashfunc=sha1, sigdecode=sigdecode)
After changing the code, i got the correct public key
The text was updated successfully, but these errors were encountered: