This commit is contained in:
Thomas Atkins 2021-04-10 16:04:34 -05:00
commit f91bc61a8c
3 changed files with 12 additions and 3 deletions

View File

@ -2,6 +2,7 @@ import 'package:fast_rsa/model/bridge.pb.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:sqflite/sqflite.dart'; import 'package:sqflite/sqflite.dart';
import 'package:fast_rsa/rsa.dart'; import 'package:fast_rsa/rsa.dart';
import 'package:dbcrypt/dbcrypt.dart';
import 'package:loc_chain_app/util/keyfile_manager.dart'; import 'package:loc_chain_app/util/keyfile_manager.dart';
@ -14,14 +15,14 @@ class Transaction {
} }
late final String _id; late final String _id;
final String hash; final String hash;
static Future<String> signTransaction(String otherUserId) async { static Future<String> generateHash(String otherUserId) async {
String id = await SharedPreferences.getInstance() String id = await SharedPreferences.getInstance()
.then((s) => s.getString('userName') ?? ''); .then((s) => s.getString('userName') ?? '');
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 RSA.signPKCS1v15("$lesser-$greater", Hash.HASH_SHA256, return DBCrypt()
KeyFileManager.keyPair.privateKey); .hashpw("$lesser-$greater", KeyFileManager.keyPair.privateKey);
} }
} }

View File

@ -50,6 +50,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.0.2"
dbcrypt:
dependency: "direct main"
description:
name: dbcrypt
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:

View File

@ -32,6 +32,7 @@ dependencies:
path_provider: ^2.0.1 path_provider: ^2.0.1
fast_rsa: ^1.4.0-nullsafety.4 fast_rsa: ^1.4.0-nullsafety.4
sqflite: ^2.0.0+3 sqflite: ^2.0.0+3
dbcrypt: ^2.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: