fudgebucket27 / PoseidonSharp

Poseidon Hashing and EDDSA Library in C# built for use with Loopring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding a "0" to the wrong number hash

taranasus opened this issue · comments

string sha256HashAsPositiveHexString = "0" + sha256HashNumber.ToString("x2");

Hey fudgy, little bug for ya. So on that line what you're doing is you're taking the base10 number you get from the sha256HashString and converting it to base16 and adding a zero to that.

This is wrong, because the result you get from sha256HashNumber.ToString("x2") is not the same as the original sha256HashBytes when it's a negative number. I wouldn't be able to say why, but it just is. What you should be doing is:

string sha256HashAsPositiveHexString = "0" + sha256HashString;

I've gotten a few times a bug with that line and this seems to fix it ;) Good luck!

Fixed