-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
site hangs if a particular hash is entered in wallet details tab #132
Comments
I see that changing:
to:
stops it hanging, and gives the same addresses for the one other test I did. I don't know what 'Barrett' is, or how 'Classic' differs from it, but at least I've pinpointed the error. I also see that changing the same line to:
also stops it hanging, but comes up with a different pair of addresses. |
After looking into this further it appears that the problem is with At the end of the function it checks twice to see if the result is negative and if so adds
In the example that fails, Before the After adding After adding And that is the value that is returned. We need to add How about this for a fix?
|
I just googled "HAC 14.61", a string found in the comment just before the definition of (See also this TeX document). Note that it ends with two while loops, to make sure the returned value isn't too high or too low. There's some text following the algorithm saying that only "a couple" of adds or subtracts are required. Maybe that wasn't meant to be taken literally: It would probably be best to put the
|
I ran a bunch of tests, found that sometimes 5 additions or 3 subtractions are needed. Found also that only 37 of 30 million tests would have failed in the existing implementation - so it's about a 1 in a million chance of hitting this bug. |
@dooglus thank you for the report and investigation. Looks like there is some code here I can use: Edit: I see the diff above. Thx. |
Yes. I'm pretty sure they used the diff I pasted at the end of #132 (comment), and added a test case. |
I've created a pull request to fix this issue here: @dooglus @jprichardson @dcousens can you guys have a look? @dooglus would you consider making a test related to your comment here? |
Fixed with pull #136 |
If you enter this hash into the wallet details tab, your browser hangs indefinitely:
It appears that
Barrett.prototype.reduce()
is looping forever (or at least for a very long time) here:This was first reported on reddit.
The text was updated successfully, but these errors were encountered: