mirror of
https://github.com/hackku21/loc-chain-app.git
synced 2024-10-27 20:34:05 +00:00
updated p2p transaction to use json
This commit is contained in:
parent
fc08292542
commit
0b803719a0
@ -78,6 +78,4 @@ class _HomePageState extends State<HomePage> {
|
|||||||
content: Text(a.toString()),
|
content: Text(a.toString()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> reportExposure() async {}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:dbcrypt/dbcrypt.dart';
|
||||||
import 'package:flutter_udid/flutter_udid.dart';
|
import 'package:flutter_udid/flutter_udid.dart';
|
||||||
import 'package:loc_chain_app/util/keyfile_manager.dart';
|
import 'package:loc_chain_app/util/keyfile_manager.dart';
|
||||||
|
|
||||||
@ -7,18 +8,26 @@ class Transaction {
|
|||||||
final String hash;
|
final String hash;
|
||||||
final String pubKey;
|
final String pubKey;
|
||||||
|
|
||||||
static Future<String> generateHash(String otherUserId) async {
|
static Future<Transaction> create(String otherUserId) async {
|
||||||
String id = await FlutterUdid.consistentUdid;
|
String id = await FlutterUdid.consistentUdid;
|
||||||
bool idLess = id.compareTo(otherUserId) < 0;
|
bool idLess = id.compareTo(otherUserId) < 0;
|
||||||
var lesser = idLess ? id : otherUserId;
|
var lesser = idLess ? id : otherUserId;
|
||||||
var greater = idLess ? otherUserId : id;
|
var greater = idLess ? otherUserId : id;
|
||||||
// return DBCrypt()
|
return Transaction(
|
||||||
// .hashpw("$lesser-$greater", KeyFileManager.keyPair.privateKey);
|
hash: DBCrypt()
|
||||||
return "$lesser-$greater";
|
.hashpw("$lesser-$greater", KeyFileManager.keyPair.privateKey),
|
||||||
|
pubKey: KeyFileManager.keyPair.publicKey,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> generateP2PPayload(String otherUserId) async =>
|
Map<String, dynamic> toJson() => {
|
||||||
"${await generateHash(otherUserId)}:${KeyFileManager.keyPair.publicKey}";
|
"combinedHash": hash,
|
||||||
|
"publicKey": pubKey,
|
||||||
|
};
|
||||||
|
|
||||||
|
Transaction.fromJson(Map<String, dynamic> json)
|
||||||
|
: hash = json['combinedHash'],
|
||||||
|
pubKey = json['publicKey'];
|
||||||
}
|
}
|
||||||
|
|
||||||
class EncounterTransaction {
|
class EncounterTransaction {
|
||||||
|
Loading…
Reference in New Issue
Block a user