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

47 lines
1.2 KiB

// The Go values that the tests on Node.js carry in bls12381_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 'bls12381_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 generators and H2 are those of tlock_ibe.json', () {
final v = section(
readJson('testdata/vectors/tlock_ibe.json'),
'vectors',
).first;
expect(
[generatorG1, generatorG2, h2OfGenerators],
[v['g1'], v['g2'], v['h2']],
);
});
test('the hashes to G1 are those of bls12381_vectors.json', () {
final hashes = section(
readJson('test/vectors/bls12381_vectors.json'),
'hash_to_g1',
);
final round = hashes.firstWhere(
(v) => v['label'] == 'the identity of round 1000',
);
expect(hashOfRound1000, round['point']);
final abc = hashes.firstWhere(
(v) => (v['label']! as String).contains('msg "abc"'),
);
expect([hashOfAbcX, hashOfAbcY], [abc['x'], abc['y']]);
});
}

Powered by TurnKey Linux.