-
Notifications
You must be signed in to change notification settings - Fork 478
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
precision of ln and pow #130
Comments
The number has no special significance.
Extra digits in the LN10 constant are necessary to calculate rounding digits.
The LN10 constant can be changed in the source file, yes. The library will throw an error if there are not enough LN10 digits to calculate and correctly round the natural logarithm function at a given precision.
That is the number of rounding digits that the power function calculates. That cannot be changed.
Precision can be controlled. The number of rounding digits is an internal matter. If a result of the power operation is incorrectly rounded the maximum error will be 1 ULP (unit in the last place), which is not likely to help anybody attack anything. A user can calculate as many rounding digits as they like anyway, by just calculating |
Thanks for the answers. I understand that these numbers are arbitrarily chosen and that the probability of incorrect (up to 1 ulp) rounding is very small because it is unlikely to have To clarify what attack vector I'm concerned about, it is possible that another implementation calculates the same function with always correct rounding, or with more accurate rounding (e.g. by using 20 rounding digits instead of 15), and arrives at a different result. Even though the difference is only 1 ulp, this can lead to consensus failure in distributed systems. One example of such distributed systems is cryptocurrency platforms where all calculations are supposed to be performed by multiple independent nodes working on different hardware and software and using different implementations of the same protocol. On another, but related, matter, in if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
Ctor.precision = wpr += 10;
denominator = pow = t = new Ctor(1);
i = 0;
rep++;
} else { I'm not sure why precision is expanded only up to 3 times ( |
Yes, I was wondering about that yesterday when I looked over the code before responding to this issue. I can't remember exactly why I did that. I notice the code has been changed in a more recent unpublished version of |
From
ln
documentation:What's the special significance of the number 25? Is it the number of rounding digits? can it be changed?
From
pow
documentation:Again, what's special about 15?
When working with user-entered data, an attacker may try to supply problematic numbers on purpose. It would be great to control precision to avoid that.
The text was updated successfully, but these errors were encountered: