Closed duanyytop closed 4 years ago
dart:typed_data _ByteDataView.getUint32 package:pointycastle/src/ufixnum.dart 221:28 unpack32 package:pointycastle/src/ufixnum.dart 450:17 Register64.unpack package:pointycastle/digests/blake2b.dart 216:13 Blake2bDigest._compress package:pointycastle/digests/blake2b.dart 144:9 Blake2bDigest.update package:ckb_sdk_dart/src/crypto/blake2b.dart 20:20 Blake2b.update test/crypto/blake2b_test.dart 12:17 main..
RangeError (byteOffset): Invalid value: Not in range 0..28, inclusive: 36
And my code is
test('Blake2b hash with update', () { var blake2b = Blake2b(); for (var i = 0; i < 100; i++) { blake2b.update(hexToList( 'a79f3207ea4980b7fed79956d5934249ceac4751a4fae01a0f7c4a96884bc4e3')); } expect(blake2b.doFinalString(), '0x44f4c69744d5f8c55d642062949dcae49bc4e7ef43d388c5a12f42b5633d163e'); }); Blake2b({int digestSize = 32}) { _blake2bDigest = Blake2bDigest( digestSize: digestSize, personalization: utf8.encode(CkbHashPersonalization)); } void update(Uint8List input) { _blake2bDigest.update(input, 0, input.length); } Uint8List doFinal() { var out = Uint8List(_blake2bDigest.digestSize); var len = _blake2bDigest.doFinal(out, 0); return out.sublist(0, len); }
The same blake2b test case work well in Java language with bouncycastle library.
Can you help me? Thanks.
I have found another blake2b library which have no this bug. Thanks
dart:typed_data _ByteDataView.getUint32 package:pointycastle/src/ufixnum.dart 221:28 unpack32 package:pointycastle/src/ufixnum.dart 450:17 Register64.unpack package:pointycastle/digests/blake2b.dart 216:13 Blake2bDigest._compress package:pointycastle/digests/blake2b.dart 144:9 Blake2bDigest.update package:ckb_sdk_dart/src/crypto/blake2b.dart 20:20 Blake2b.update test/crypto/blake2b_test.dart 12:17 main..
RangeError (byteOffset): Invalid value: Not in range 0..28, inclusive: 36
And my code is
The same blake2b test case work well in Java language with bouncycastle library.
Can you help me? Thanks.