diff --git a/loc_chain_app/lib/pages/home.dart b/loc_chain_app/lib/pages/home.dart index 5d0d6c3..61e76b4 100644 --- a/loc_chain_app/lib/pages/home.dart +++ b/loc_chain_app/lib/pages/home.dart @@ -78,6 +78,4 @@ class _HomePageState extends State { content: Text(a.toString()), )); } - - Future reportExposure() async {} } diff --git a/loc_chain_app/lib/util/transaction_manager.dart b/loc_chain_app/lib/util/transaction_manager.dart index 6f2eb1c..1695b85 100644 --- a/loc_chain_app/lib/util/transaction_manager.dart +++ b/loc_chain_app/lib/util/transaction_manager.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:dbcrypt/dbcrypt.dart'; import 'package:flutter_udid/flutter_udid.dart'; import 'package:loc_chain_app/util/keyfile_manager.dart'; @@ -7,18 +8,26 @@ class Transaction { final String hash; final String pubKey; - static Future generateHash(String otherUserId) async { + static Future create(String otherUserId) async { String id = await FlutterUdid.consistentUdid; bool idLess = id.compareTo(otherUserId) < 0; var lesser = idLess ? id : otherUserId; var greater = idLess ? otherUserId : id; - // return DBCrypt() - // .hashpw("$lesser-$greater", KeyFileManager.keyPair.privateKey); - return "$lesser-$greater"; + return Transaction( + hash: DBCrypt() + .hashpw("$lesser-$greater", KeyFileManager.keyPair.privateKey), + pubKey: KeyFileManager.keyPair.publicKey, + ); } - Future generateP2PPayload(String otherUserId) async => - "${await generateHash(otherUserId)}:${KeyFileManager.keyPair.publicKey}"; + Map toJson() => { + "combinedHash": hash, + "publicKey": pubKey, + }; + + Transaction.fromJson(Map json) + : hash = json['combinedHash'], + pubKey = json['publicKey']; } class EncounterTransaction {