mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-12-18 04:24:29 -05:00
46 lines
1.3 KiB
Dart
46 lines
1.3 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:meta/meta.dart';
|
|
import 'package:veilid_support/veilid_support.dart';
|
|
|
|
import 'local_account/local_account.dart';
|
|
import 'user_login/user_login.dart';
|
|
|
|
@immutable
|
|
class ActiveAccountInfo {
|
|
const ActiveAccountInfo({
|
|
required this.localAccount,
|
|
required this.userLogin,
|
|
//required this.accountRecord,
|
|
});
|
|
//
|
|
|
|
TypedKey get accountRecordKey =>
|
|
userLogin.accountRecordInfo.accountRecord.recordKey;
|
|
|
|
KeyPair get conversationWriter {
|
|
final identityKey = localAccount.identityMaster.identityPublicKey;
|
|
final identitySecret = userLogin.identitySecret;
|
|
return KeyPair(key: identityKey, secret: identitySecret.value);
|
|
}
|
|
|
|
Future<VeilidCrypto> makeConversationCrypto(
|
|
TypedKey remoteIdentityPublicKey) async {
|
|
final identitySecret = userLogin.identitySecret;
|
|
final cs = await Veilid.instance.getCryptoSystem(identitySecret.kind);
|
|
final sharedSecret = await cs.generateSharedSecret(
|
|
remoteIdentityPublicKey.value,
|
|
identitySecret.value,
|
|
utf8.encode('VeilidChat Conversation'));
|
|
|
|
final messagesCrypto = await VeilidCryptoPrivate.fromSharedSecret(
|
|
identitySecret.kind, sharedSecret);
|
|
return messagesCrypto;
|
|
}
|
|
|
|
//
|
|
final LocalAccount localAccount;
|
|
final UserLogin userLogin;
|
|
//final DHTRecord accountRecord;
|
|
}
|