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/ibe_constants_test.dart

50 lines
1.3 KiB

// The Go values that the tests on Node.js carry in ibe_constants.dart are
// those of the JSON that Go wrote.
@TestOn('vm')
library;
import 'dart:convert';
import 'dart:io';
import 'package:test/test.dart';
import 'ibe_constants.dart';
typedef Json = Map<String, Object?>;
Json readJson(String path) => jsonDecode(File(path).readAsStringSync()) as Json;
List<Json> section(Json file, String name) =>
(file[name]! as List).cast<Json>();
void main() {
test('the encryption is the one of tlock_vectors.json', () {
final e = section(
readJson('test/vectors/tlock_vectors.json'),
'encrypt',
).firstWhere((e) => e['name'] == 'a 16-byte message for round 1000');
expect(
[
encrypt1000Id,
encrypt1000Msg,
encrypt1000Sigma,
encrypt1000U,
encrypt1000V,
encrypt1000W,
],
[e['id'], e['msg'], e['sigma'], e['u'], e['v'], e['w']],
);
});
test('H3 and H4 are those of ibe_vectors.json', () {
final ibe = readJson('test/vectors/ibe_vectors.json');
final h3 = section(ibe, 'h3').firstWhere((v) => v['iterations'] == 3);
expect(
[h3Sigma, h3Msg, h3R, h3Iterations3],
[h3['sigma'], h3['msg'], h3['r'], h3['iterations']],
);
final h4 = section(ibe, 'h4').first;
expect([h4Sigma, h4Of16], [h4['sigma'], h4['h4_16']]);
});
}

Powered by TurnKey Linux.