mirror of
https://github.com/hackku21/loc-chain-app.git
synced 2024-10-27 20:34:05 +00:00
updated keygen to conform with backend
This commit is contained in:
parent
8c2dc2a1b7
commit
be205fddc8
@ -2,8 +2,8 @@ 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:openpgp/openpgp.dart';
|
||||
import 'package:openpgp/model/bridge.pb.dart';
|
||||
|
||||
import 'package:loc_chain_app/util/keyfile_manager.dart';
|
||||
|
||||
@ -25,13 +25,18 @@ class _KeygenState extends State<KeygenPage> {
|
||||
if (!keyPair.hasPublicKey()) {
|
||||
initKeyPair();
|
||||
} else {
|
||||
setState(() => _keyPair = keyPair);
|
||||
setState(() {
|
||||
_keyPair.publicKey = keyPair.publicKey;
|
||||
_keyPair.privateKey = keyPair.privateKey;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> initKeyPair() async {
|
||||
var keyPair = await RSA.generate(2048);
|
||||
var options = KeyOptions()..rsaBits = 2048;
|
||||
var keyPair =
|
||||
await OpenPGP.generate(options: Options()..keyOptions = options);
|
||||
await KeyFileManager.writeKeyPair(keyPair);
|
||||
setState(() {
|
||||
_keyPair = keyPair;
|
||||
@ -64,7 +69,7 @@ class _KeygenState extends State<KeygenPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('RSA Key Configuration'),
|
||||
title: Text('PGP Key Configuration'),
|
||||
),
|
||||
body: Center(
|
||||
child: LayoutBuilder(
|
||||
@ -85,7 +90,7 @@ class _KeygenState extends State<KeygenPage> {
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: initKeyPair,
|
||||
child: Text('Reset RSA Key'),
|
||||
child: Text('Reset PGP Key'),
|
||||
style: Theme.of(context).elevatedButtonTheme.style,
|
||||
),
|
||||
],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:fast_rsa/model/bridge.pb.dart';
|
||||
import 'package:openpgp/model/bridge.pb.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'dart:io';
|
||||
|
||||
@ -31,10 +31,8 @@ class KeyFileManager {
|
||||
String pubKey = await _pubKeyFile.then(
|
||||
(file) => file.readAsString(),
|
||||
);
|
||||
keyPair = KeyPair(
|
||||
privateKey: privKey,
|
||||
publicKey: pubKey,
|
||||
);
|
||||
keyPair.publicKey = pubKey;
|
||||
keyPair.privateKey = privKey;
|
||||
return keyPair;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
Loading…
Reference in New Issue
Block a user