Closed jand271 closed 4 years ago
Hi, thanks for reporting. I found the bug for the Schnorr verification failure. I will post a 1.2.2 in the coming days.
I do not understand the "Point not on curve" for Brainpool-p224t1. The point generator is rejected. According python and the short Weierstrass equation y^2=x^3+a*x+b:
>>> p = 0x2DF271E14427A346910CF7A2E6CFA7B3F484E5C2CCE1C8B730E28B3F
>>> a = 0xD7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FC
>>> b = 0x4B337D934104CD7BEF271BF60CED1ED20DA14C08B3BB64F18A60888D
>>> x = 0x6AB1E344CE25FF3896424E7FFE14762ECB49F8928AC0C76029B4D580
>>> y = 0x374E9F5143E568CD23F3F4D7C0D4B1E41C8CC0D1C6ABD5F1A46DB4C
>>> left = (y*y)%p
>>> right = (x*x*x+a*x+b)%p
>>> hex(left)
'0x274e6e2e21da6f0102b6c9a84864c7a3160950f67747493e64961804'
>>> hex(right)
'0x1645c2378791b55b41505f5465bcd55faa8dddcdb091631f3d7c1f80'
>>>
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:
Curve-ID: brainpoolP224t1
Z = 2DF271E14427A346910CF7A2E6CFA7B3F484E5C2CCE1C8B730E28B3F
A = D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FC
B = 4B337D934104CD7BEF271BF60CED1ED20DA14C08B3BB64F18A60888D
x = 6AB1E344CE25FF3896424E7FFE14762ECB49F8928AC0C76029B4D580
y = 0374E9F5143E568CD23F3F4D7C0D4B1E41C8CC0D1C6ABD5F1A46DB4C
q = D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F
h = 1
Also note that in your snippet the line "secp521r1": 384,
is wrong. bitsize is 521, not 384.
You should also reduce your private key modulo the curve order. (Maybe I should do it automagically or reject it if greater than order :thinking: )
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 "
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 "
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. If it's ok for you, please close the bug. Else, continue to report here ;)
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