// 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; Json readJson(String path) => jsonDecode(File(path).readAsStringSync()) as Json; List section(Json file, String name) => (file[name]! as List).cast(); 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']]); }); }