Closed stevenroose closed 10 years ago
@izaera could you comment on this? I don't have the bandwidth at the moment.
@stevenroose does https://github.com/dartist/dart-bignum/pull/24 fix your issue?
Yes. I detected it too and it should be fixed in #24 AFAIK. The problem was that 0xFF has 1 as its MSB and Dart's BigInteger gets fooled thinking it is a negative. I tried to fix it adding a leading 0 byte if the MSB==1 and seems to work for me as extra leading zeros are supposed to be stripped.
It's incredible how this bug didn't hit me before given that I'm using BigInteger.fromBytes() intensively in cipher. I think I'll buy some lottery this week ;-P.
I don't know how I can easily test the pull request without cloning the repo to my HD. I suppose it works now, I trust in your opinions :) Thanks for the quick fix!
should be deployed to pub also
I think this is duplicate of #24. If not, please reopen.
I'm confused by
BigInteger.fromBytes
implemented in this commit. Magnitude should be interpreted unsigned, sofromBytes(1, [0xff])
should giveBigInteger(255)
, right? It doesn't. Anyway, afromBytes(1, anything)
should never give a negative number, right?I tried
And they both give
-1
. In Java, the second constructor gives 255, like I think it should do.