Skip to content
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

Fix #221: ecdsa-modified: fix bias and omission of zero in getBigRandom() #631

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tvogel
Copy link

@tvogel tvogel commented Nov 14, 2024

I have evaluated the simple filtering approach and the approach from swiftlang/swift#39143 and found out that the former is a lot more performant than (my adaption of) the latter and still effective for fixing issue #221 .

See https://htmlpreview.github.io/?https://github.com/tvogel/jsrsasign/blob/tv/getBigRandom-comparison/src/ecdsamod-new-random.output.html for a comparison of the functions. The histograms also make the problem from #221 evident.

In most cases, the new function is faster than the previous implementation and only rarely slightly slower.

The main advantage for the dismissed alternative new2 would be that it is constant in time (depending on the limit only) but it involves consuming always exactly two big random numbers and two big multiplications.

See https://github.com/tvogel/jsrsasign/blob/tv/getBigRandom-comparison/src/ecdsamod-new-random.html for the benchmarking code.

this replaces the previously remainder-based limiting of the random number
which caused bias toward small numbers and excluded zero altogether by
simple filtering as proposed frequently in
kjur#221
and because the performance in most cases is actually faster than in the
present implementation;

also, an adaptation of swiftlang/swift#39143 has
been considered but it performed significantly slower for large integers;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant