account work

This commit is contained in:
Christien Rioux 2023-07-16 21:41:40 -04:00
parent f44fdb8eeb
commit 90fc2e5f85
9 changed files with 422 additions and 25 deletions

View file

@ -4,6 +4,19 @@ import 'package:veilid/veilid.dart';
part 'identity.freezed.dart';
part 'identity.g.dart';
// AccountOwnerInfo is the key and owner info for the account dht key that is
// stored in the identity key
@freezed
class AccountOwnerInfo with _$AccountOwnerInfo {
const factory AccountOwnerInfo({
// Top level account keys and secrets
required Map<String, TypedKeyPair> accountKeyPairs,
}) = _AccountOwnerInfo;
factory AccountOwnerInfo.fromJson(Map<String, dynamic> json) =>
_$AccountOwnerInfoFromJson(json);
}
// Identity Key points to accounts associated with this identity
// accounts field has a map of service name or uuid to account key pairs
// DHT Schema: DFLT(1)
@ -55,6 +68,16 @@ class IdentityMaster with _$IdentityMaster {
_$IdentityMasterFromJson(json);
}
extension IdentityMasterExtension on IdentityMaster {
KeyPair identityWriter(SecretKey secret) {
return KeyPair(key: identityPublicKey, secret: secret);
}
KeyPair masterWriter(SecretKey secret) {
return KeyPair(key: masterPublicKey, secret: secret);
}
}
// Identity Master with secrets
// Not freezed because we never persist this class in its entirety
class IdentityMasterWithSecrets {