mirror of
https://github.com/hackku21/loc-chain-app.git
synced 2024-10-27 20:34:05 +00:00
Merge pull request #2 from hackku21/feature/firebase-connection
Feature/firebase connection
This commit is contained in:
commit
2283029f31
@ -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);
|
||||
|
8
loc_chain_app/lib/pages/setup.dart
Normal file
8
loc_chain_app/lib/pages/setup.dart
Normal file
@ -0,0 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SetupPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold();
|
||||
}
|
||||
}
|
46
loc_chain_app/lib/util/keyfile_manager.dart
Normal file
46
loc_chain_app/lib/util/keyfile_manager.dart
Normal 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);
|
||||
}
|
||||
}
|
5
loc_chain_app/lib/util/transaction.dart
Normal file
5
loc_chain_app/lib/util/transaction.dart
Normal 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 {}
|
@ -63,14 +63,14 @@ packages:
|
||||
name: fast_rsa
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.6"
|
||||
version: "1.4.0-nullsafety.4"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
version: "1.0.0"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -84,7 +84,7 @@ packages:
|
||||
name: fixnum
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.10.11"
|
||||
version: "1.0.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -134,35 +134,35 @@ packages:
|
||||
name: path_provider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.28"
|
||||
version: "2.0.1"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1+2"
|
||||
version: "2.0.0"
|
||||
path_provider_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.4+8"
|
||||
version: "2.0.0"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
version: "2.0.1"
|
||||
path_provider_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.4+3"
|
||||
version: "2.0.0"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -176,7 +176,7 @@ packages:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
version: "2.0.0"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -190,7 +190,7 @@ packages:
|
||||
name: protobuf
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
version: "2.0.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@ -258,14 +258,14 @@ packages:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.4+1"
|
||||
version: "2.0.5"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.2"
|
||||
version: "0.2.0"
|
||||
sdks:
|
||||
dart: ">=2.12.0 <3.0.0"
|
||||
flutter: ">=1.12.13+hotfix.5"
|
||||
flutter: ">=1.20.0"
|
||||
|
@ -28,8 +28,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:
|
||||
|
Loading…
Reference in New Issue
Block a user