You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dateKeys-dart/test/primitives_vm_test.dart

44 lines
1.3 KiB

// The primitives against files: the copy of test/vectors/primitives.json
// that primitives_test.dart reads, a Dart constant for the tests compiled to
// JavaScript, is the JSON file byte for byte, as
// tool/gen_primitive_vectors.go writes both; and the strict Ed25519
// verification gives the results of testdata/vectors/ed25519_strict.json of
// datekeys-go.
@TestOn('vm')
library;
import 'dart:convert';
import 'dart:io';
import 'package:datekeys/datekeys.dart' show fromHex;
import 'package:datekeys/src/curve25519.dart';
import 'package:test/test.dart';
import 'vectors/primitives.g.dart';
void main() {
test('primitives.g.dart holds primitives.json', () {
final file = File('test/vectors/primitives.json').readAsStringSync();
expect(primitivesJson, file);
});
test('testdata/vectors/ed25519_strict.json', () {
final file = jsonDecode(
File('testdata/vectors/ed25519_strict.json').readAsStringSync(),
) as Map<String, Object?>;
final vectors = (file['vectors']! as List).cast<Map<String, Object?>>();
expect(vectors, isNotEmpty);
for (final v in vectors) {
expect(
verifyStrict(
fromHex(v['public_key']! as String),
fromHex(v['message']! as String),
fromHex(v['signature']! as String),
),
v['valid'],
reason: v['name'] as String?,
);
}
});
}

Powered by TurnKey Linux.