// 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; final vectors = (file['vectors']! as List).cast>(); 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?, ); } }); }