Preamble:
Notes:
Bugs:
VERIFY
means (I didn't check, sorry). It is somewhat moot as r, s get reduced modulo the group order when converted to Montgomery-form, but this is spooky. ECDH checks that the point is on the curve early (compute_cooordinate_internal
) so is not affected.compute_coordinate_internal
FIXME
comment, reducing the scalar modulo group order when doing a scalar-point multiply results in bias, particularly for P-256 (the bias is insignificant for P-384/P-521). This currently has fairly minimal impact, but is a case that MUST be fixed when ECDSA sign is implemented (https://github.com/C2SP/CCTV/tree/main/RFC6979 has a test case), and SHOULD be fixed for ECDH.Performance issues:
convert_jacobian_to_affine
) does 2 inversions. Computing 1/Z and then multiplying repeatedly as necessary is significantly cheaper.General recommendations:
read_uncompressed_point
should be where the is_point_on_curve
check happens. (generate_public_key_internal
should bypass the check, and just cover it with test cases as s * G
is guaranteed to be valid). "Best practice" these days leans heavily toward "there is no way to create a point that is not on the curve", so early-rejection is better.ps: On an unrelated note, Cipher/AES.h
and Cipher/AES.cpp
need to be shot into the sun and burned. Please use AES-NI (or a bitsliced implementation cribbed from BearSSL), since the current code leaks the symmetric key via cache-timing sidechannels.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too