Merge branch 'main' of https://github.com/hackku21/loc-chain-app into bluetooth

This commit is contained in:
Thomas Atkins 2021-04-10 14:02:26 -05:00
commit 626edf0a76
6 changed files with 91 additions and 54 deletions

View File

@ -1,54 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:fast_rsa/rsa.dart';
import 'package:fast_rsa/model/bridge.pb.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';
class KeyFileManager {
static Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
static Future<File> get _pubKeyFile async {
final path = await _localPath;
return File('$path/rsa.pub');
}
static Future<File> get _privKeyFile async {
final path = await _localPath;
return File('$path/rsa');
}
static Future<KeyPair> readKeyPair() async {
try {
String privKey = await _privKeyFile.then(
(file) => file.readAsString(),
);
String pubKey = await _pubKeyFile.then(
(file) => file.readAsString(),
);
return KeyPair(
privateKey: privKey,
publicKey: pubKey,
);
} catch (e) {
print(e);
return KeyPair();
}
}
static Future<void> writeKeyPair(KeyPair pair) async {
final File privKeyFile = await _privKeyFile;
final File pubKeyFile = await _pubKeyFile;
pubKeyFile.writeAsString(pair.publicKey);
privKeyFile.writeAsString(pair.privateKey);
}
}
import 'package:loc_chain_app/util/keyfile_manager.dart';
class KeygenPage extends StatefulWidget {
KeygenPage({Key? key, required this.title}) : super(key: key);

View File

@ -0,0 +1,8 @@
import 'package:flutter/material.dart';
class SetupPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold();
}
}

View File

@ -0,0 +1,46 @@
import 'package:fast_rsa/model/bridge.pb.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';
class KeyFileManager {
static Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
static Future<File> get _pubKeyFile async {
final path = await _localPath;
return File('$path/rsa.pub');
}
static Future<File> get _privKeyFile async {
final path = await _localPath;
return File('$path/rsa');
}
static Future<KeyPair> readKeyPair() async {
try {
String privKey = await _privKeyFile.then(
(file) => file.readAsString(),
);
String pubKey = await _pubKeyFile.then(
(file) => file.readAsString(),
);
return KeyPair(
privateKey: privKey,
publicKey: pubKey,
);
} catch (e) {
print(e);
return KeyPair();
}
}
static Future<void> writeKeyPair(KeyPair pair) async {
final File privKeyFile = await _privKeyFile;
final File pubKeyFile = await _pubKeyFile;
pubKeyFile.writeAsString(pair.publicKey);
privKeyFile.writeAsString(pair.privateKey);
}
}

View File

@ -0,0 +1,5 @@
import 'package:flutter/services.dart';
import 'package:fast_rsa/model/bridge.pb.dart';
import 'package:fast_rsa/rsa.dart';
class Transaction {}

View File

@ -57,6 +57,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
fast_rsa:
dependency: "direct main"
description:
name: fast_rsa
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0-nullsafety.4"
ffi:
dependency: transitive
description:
@ -71,6 +78,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter:
dependency: "direct main"
description: flutter
@ -121,6 +135,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
path_provider:
dependency: "direct main"
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
path_provider_linux:
dependency: transitive
description:
@ -128,6 +149,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
path_provider_platform_interface:
dependency: transitive
description:
@ -156,13 +184,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
pointycastle:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
process:
dependency: transitive
description:

View File

@ -29,8 +29,8 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
path_provider: ^1.6.28
fast_rsa: ^1.1.4
path_provider: ^2.0.1
fast_rsa: ^1.4.0-nullsafety.4
dev_dependencies:
flutter_test: