mirror of
				https://github.com/hackku21/loc-chain-app.git
				synced 2025-06-13 12:54:05 +00:00 
			
		
		
		
	Merge branch 'main' of https://github.com/hackku21/loc-chain-app into bluetooth
This commit is contained in:
		
						commit
						626edf0a76
					
				@ -1,54 +1,11 @@
 | 
				
			|||||||
import 'package:flutter/material.dart';
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
import 'package:flutter/services.dart';
 | 
					import 'package:flutter/services.dart';
 | 
				
			||||||
import 'package:flutter/widgets.dart';
 | 
					import 'package:flutter/widgets.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import 'package:fast_rsa/rsa.dart';
 | 
					import 'package:fast_rsa/rsa.dart';
 | 
				
			||||||
import 'package:fast_rsa/model/bridge.pb.dart';
 | 
					import 'package:fast_rsa/model/bridge.pb.dart';
 | 
				
			||||||
import 'package:path_provider/path_provider.dart';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import 'dart:io';
 | 
					import 'package:loc_chain_app/util/keyfile_manager.dart';
 | 
				
			||||||
 | 
					 | 
				
			||||||
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);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class KeygenPage extends StatefulWidget {
 | 
					class KeygenPage extends StatefulWidget {
 | 
				
			||||||
  KeygenPage({Key? key, required this.title}) : super(key: key);
 | 
					  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 {}
 | 
				
			||||||
@ -57,6 +57,13 @@ packages:
 | 
				
			|||||||
      url: "https://pub.dartlang.org"
 | 
					      url: "https://pub.dartlang.org"
 | 
				
			||||||
    source: hosted
 | 
					    source: hosted
 | 
				
			||||||
    version: "1.2.0"
 | 
					    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:
 | 
					  ffi:
 | 
				
			||||||
    dependency: transitive
 | 
					    dependency: transitive
 | 
				
			||||||
    description:
 | 
					    description:
 | 
				
			||||||
@ -71,6 +78,13 @@ packages:
 | 
				
			|||||||
      url: "https://pub.dartlang.org"
 | 
					      url: "https://pub.dartlang.org"
 | 
				
			||||||
    source: hosted
 | 
					    source: hosted
 | 
				
			||||||
    version: "6.1.0"
 | 
					    version: "6.1.0"
 | 
				
			||||||
 | 
					  fixnum:
 | 
				
			||||||
 | 
					    dependency: transitive
 | 
				
			||||||
 | 
					    description:
 | 
				
			||||||
 | 
					      name: fixnum
 | 
				
			||||||
 | 
					      url: "https://pub.dartlang.org"
 | 
				
			||||||
 | 
					    source: hosted
 | 
				
			||||||
 | 
					    version: "1.0.0"
 | 
				
			||||||
  flutter:
 | 
					  flutter:
 | 
				
			||||||
    dependency: "direct main"
 | 
					    dependency: "direct main"
 | 
				
			||||||
    description: flutter
 | 
					    description: flutter
 | 
				
			||||||
@ -121,6 +135,13 @@ packages:
 | 
				
			|||||||
      url: "https://pub.dartlang.org"
 | 
					      url: "https://pub.dartlang.org"
 | 
				
			||||||
    source: hosted
 | 
					    source: hosted
 | 
				
			||||||
    version: "1.8.0"
 | 
					    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:
 | 
					  path_provider_linux:
 | 
				
			||||||
    dependency: transitive
 | 
					    dependency: transitive
 | 
				
			||||||
    description:
 | 
					    description:
 | 
				
			||||||
@ -128,6 +149,13 @@ packages:
 | 
				
			|||||||
      url: "https://pub.dartlang.org"
 | 
					      url: "https://pub.dartlang.org"
 | 
				
			||||||
    source: hosted
 | 
					    source: hosted
 | 
				
			||||||
    version: "2.0.0"
 | 
					    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:
 | 
					  path_provider_platform_interface:
 | 
				
			||||||
    dependency: transitive
 | 
					    dependency: transitive
 | 
				
			||||||
    description:
 | 
					    description:
 | 
				
			||||||
@ -156,13 +184,6 @@ packages:
 | 
				
			|||||||
      url: "https://pub.dartlang.org"
 | 
					      url: "https://pub.dartlang.org"
 | 
				
			||||||
    source: hosted
 | 
					    source: hosted
 | 
				
			||||||
    version: "2.0.0"
 | 
					    version: "2.0.0"
 | 
				
			||||||
  pointycastle:
 | 
					 | 
				
			||||||
    dependency: transitive
 | 
					 | 
				
			||||||
    description:
 | 
					 | 
				
			||||||
      name: path_provider_linux
 | 
					 | 
				
			||||||
      url: "https://pub.dartlang.org"
 | 
					 | 
				
			||||||
    source: hosted
 | 
					 | 
				
			||||||
    version: "2.0.1"
 | 
					 | 
				
			||||||
  process:
 | 
					  process:
 | 
				
			||||||
    dependency: transitive
 | 
					    dependency: transitive
 | 
				
			||||||
    description:
 | 
					    description:
 | 
				
			||||||
 | 
				
			|||||||
@ -29,8 +29,8 @@ dependencies:
 | 
				
			|||||||
  # The following adds the Cupertino Icons font to your application.
 | 
					  # The following adds the Cupertino Icons font to your application.
 | 
				
			||||||
  # Use with the CupertinoIcons class for iOS style icons.
 | 
					  # Use with the CupertinoIcons class for iOS style icons.
 | 
				
			||||||
  cupertino_icons: ^1.0.2
 | 
					  cupertino_icons: ^1.0.2
 | 
				
			||||||
  path_provider: ^1.6.28
 | 
					  path_provider: ^2.0.1
 | 
				
			||||||
  fast_rsa: ^1.1.4
 | 
					  fast_rsa: ^1.4.0-nullsafety.4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dev_dependencies:
 | 
					dev_dependencies:
 | 
				
			||||||
  flutter_test:
 | 
					  flutter_test:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user