Closed stevenroose closed 7 years ago
Will fix, write extra tests for ufixnum and look for other cases were this happens.
This is bad, a lot of my tests in Dartcoin failed once I pulled this update, even though the Pointy Castle ones didn't. Let me see this through. I'm gonna push a roll back release for now so I don't break people's code.
Turned out to be a typo. Added extra tests and pushed the fix.
(@izaera I find it strange that you didn't think if this :p)
Due to Dart's lack of a native type for byte arrays, Pointy Castle, and most Dart developers, use
Uint8List
as a replacement. However,Uint8List
is only a view on aByteBuffer
.Consider the example:
Now look at this method: https://github.com/PointyCastle/pointycastle/blob/master/lib/src/ufixnum.dart#L193 The
inp
field is directly passed along from aDigest.update
call. So when we passbytes2
in there, theByteData
view will use the sameByteBuffer
asbytes1
has.What that line should be is
But then again. This is just a while trickery around the bad design of Dart's types.