Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/mnemonics/jp_lang.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const jpLang = PolyseedLang(
isSorted: true,
hasPrefix: false,
hasAccents: false,
compose: false,
compose: true,
words: [
"あいこくしん",
"あいさつ",
Expand Down
8 changes: 3 additions & 5 deletions lib/src/mnemonics/legacy/legacy_seed_lang.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,11 @@ class LegacySeedLang {
int _getChecksumIndex(List<String> words, int prefixLen) {
var trimmedWords = '';
for (var i = 0; i < words.length; i++) {
final actualPrefixLength =
words[i].length > prefixLen ? prefixLen : words[i].length;
final actualPrefixLength = words[i].length > prefixLen ? prefixLen : words[i].length;
trimmedWords += words[i].substring(0, actualPrefixLength);
}

var checksum = crc32code(trimmedWords, Encoding.getByName('utf-8'));
var index = (checksum % words.length);
return index;
final checksum = crc32code(trimmedWords, encoding: Encoding.getByName('utf-8'));
return (checksum % words.length);
}
}
5 changes: 3 additions & 2 deletions lib/src/utils/store_uint8list_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import 'dart:typed_data';

extension StoreToList on Uint8List {
void store32(int index, int value) {
assert(value >= 0 && value <= 0xFFFFFFFF, 'value must fit in a uint32');
this[index] = value;
this[index + 1] = (value >> 8);
this[index + 2] = (value >> 8);
this[index + 3] = (value >> 8);
this[index + 2] = (value >> 16);
this[index + 3] = (value >> 24);
}

void store16(int index, int value) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ environment:
dependencies:
pointycastle: ^3.7.3
hashlib: ^1.19.2
unorm_dart: ^0.3.0
unorm_dart: ^0.3.2

dev_dependencies:
lints: ^2.1.1
Expand Down
7 changes: 7 additions & 0 deletions test/polyseed_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'dart:convert';
import 'dart:typed_data';

import 'package:polyseed/polyseed.dart';
import 'package:polyseed/src/mnemonics/es_lang.dart';
import 'package:polyseed/src/mnemonics/jp_lang.dart';
import 'package:polyseed/src/utils/store_uint8list_extension.dart';
import 'package:test/test.dart';

void main() {
Expand Down Expand Up @@ -138,6 +140,11 @@ void main() {
"340593b3fd0b2670b4727b6a9b64f3f817e2b97fcb26ea3ae8467234eb857f95");
});
});

test('store32 writes the upper bytes with distinct shifts', () {
final buf = Uint8List(4)..store32(0, 1015);
expect(buf, equals([0xF7, 0x03, 0x00, 0x00]));
});
});
}

Expand Down
Loading