-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
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
Trouble with certain curves #14
Comments
Hi, thanks for reporting. I do not understand the "Point not on curve" for Brainpool-p224t1. The point generator is rejected.
So indeed the generator is not on curve which is so weird! I took the value here : https://tools.ietf.org/html/rfc5639#page-10:
Also note that in your snippet the line |
So the main issue is the verifications problems among the curves.
HOWEVER:
REGARDING "Point not on curve”:
I get the following exception if I don’t catch it. I was’t trying to print the actual exception (but I think this is something else from above).
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
ECpy version: 1.2.1
Passed: frp256v1
Passed: secp521r1
Passed: secp384r1
Passed: secp256k1
Passed: secp256r1
FAILED: secp224k1
FAILED: secp224r1
FAILED: secp192k1
Passed: secp192r1
FAILED: secp160k1
FAILED: secp160r1
FAILED: secp160r2
Passed: Brainpool-p512t1
Passed: Brainpool-p512r1
Passed: Brainpool-p384t1
Passed: Brainpool-p384r1
Passed: Brainpool-p320t1
Passed: Brainpool-p320r1
Passed: Brainpool-p256r1
Passed: Brainpool-p256t1
FAILED: Brainpool-p224r1
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2961, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-9ae6d6e2234f>", line 1, in <module>
runfile('/Users/jasonanderson/OneDrive - Leland Stanford Junior University/coursework/SPR2020_AA290/templates/weird.py', wdir='/Users/jasonanderson/OneDrive - Leland Stanford Junior University/coursework/SPR2020_AA290/templates')
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/jasonanderson/OneDrive - Leland Stanford Junior University/coursework/SPR2020_AA290/templates/weird.py", line 71, in <module>
testVerify(signer, msg, curve, bit_length)
File "/Users/jasonanderson/OneDrive - Leland Stanford Junior University/coursework/SPR2020_AA290/templates/weird.py", line 14, in testVerify
cv = Curve.get_curve(curve_string)
File "/Users/jasonanderson/Library/Python/3.6/lib/python/site-packages/ecpy/curves.py", line 80, in get_curve
cv = WeierstrassCurve(cp)
File "/Users/jasonanderson/Library/Python/3.6/lib/python/site-packages/ecpy/curves.py", line 330, in __init__
'a','b','field','generator','order','cofactor'))
File "/Users/jasonanderson/Library/Python/3.6/lib/python/site-packages/ecpy/curves.py", line 112, in _set
self._domain['generator'] = Point(x,y,self)
File "/Users/jasonanderson/Library/Python/3.6/lib/python/site-packages/ecpy/curves.py", line 981, in __init__
raise ECPyException("Point not on curve")
ecpy.curves.ECPyException: <unprintable ECPyException object>
REGARDING "secp521r1": 384, I deliberately changes it from 521 because I got the following error occasionally.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2961, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-9ae6d6e2234f>", line 1, in <module>
runfile('/Users/jasonanderson/OneDrive - Leland Stanford Junior University/coursework/SPR2020_AA290/templates/weird.py', wdir='/Users/jasonanderson/OneDrive - Leland Stanford Junior University/coursework/SPR2020_AA290/templates')
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/jasonanderson/OneDrive - Leland Stanford Junior University/coursework/SPR2020_AA290/templates/weird.py", line 71, in <module>
testVerify(signer, msg, curve, bit_length)
File "/Users/jasonanderson/OneDrive - Leland Stanford Junior University/coursework/SPR2020_AA290/templates/weird.py", line 17, in testVerify
sig = signer.sign(msg, pv_key)
File "/Users/jasonanderson/Library/Python/3.6/lib/python/site-packages/ecpy/ecschnorr.py", line 147, in sign
sig = self._do_sign(msg, pv_key,k)
File "/Users/jasonanderson/Library/Python/3.6/lib/python/site-packages/ecpy/ecschnorr.py", line 174, in _do_sign
yQ = (Q.y).to_bytes(size,'big')
OverflowError: int too big to convert
So I really don’t know anything about cryptography, so on the principle of abstraction, I think it would be a good idea to have automatic random key generation (if none is provided) and the ability to move to/from PEM files (which I am pulling from PyCryptodome with pyopenssl). I am having to do both for my research application.
Thanks for helping me out! LOL, I need to implement ECSchnorr NIST-P192, so I look forward to the fix.
Feel free to adapt my code into a unit test.
|
version 1.2.3 is out. |
Hoping that I am missing something obvious. I actually want to use NIST-P192.
After running the following a couple of times (sometimes the key int is too large), I get the following results for the curves.
Yields
The text was updated successfully, but these errors were encountered: