mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-05-06 08:15:26 -04:00
work
This commit is contained in:
parent
20bdf07f24
commit
fb93e07ef2
6 changed files with 86 additions and 58 deletions
|
@ -10,7 +10,8 @@ class DHTRecord {
|
|||
|
||||
static Future<DHTRecord> create(VeilidRoutingContext dhtctx,
|
||||
{DHTSchema schema = const DHTSchema.dflt(oCnt: 1),
|
||||
int defaultSubkey = 0}) async {
|
||||
int defaultSubkey = 0,
|
||||
DHTRecordEncryption encrypt = DHTRecordEncryption.private}) async {
|
||||
DHTRecordDescriptor recordDescriptor = await dhtctx.createDHTRecord(schema);
|
||||
return DHTRecord(
|
||||
dhtctx: dhtctx,
|
||||
|
@ -20,7 +21,8 @@ class DHTRecord {
|
|||
|
||||
static Future<DHTRecord> open(
|
||||
VeilidRoutingContext dhtctx, TypedKey recordKey, KeyPair? writer,
|
||||
{int defaultSubkey = 0}) async {
|
||||
{int defaultSubkey = 0,
|
||||
DHTRecordEncryption encrypt = DHTRecordEncryption.private}) async {
|
||||
DHTRecordDescriptor recordDescriptor =
|
||||
await dhtctx.openDHTRecord(recordKey, writer);
|
||||
return DHTRecord(
|
||||
|
|
49
lib/tools/dht_record_encryption.dart
Normal file
49
lib/tools/dht_record_encryption.dart
Normal file
|
@ -0,0 +1,49 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:veilid/veilid.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'tools.dart';
|
||||
|
||||
abstract class DHTRecordEncryption {
|
||||
factory DHTRecordEncryption.private() {
|
||||
return DHTRecordEncryptionPrivate();
|
||||
}
|
||||
factory DHTRecordEncryption.public() {
|
||||
return DHTRecordEncryptionPublic();
|
||||
}
|
||||
|
||||
FutureOr<Uint8List> encrypt(Uint8List data);
|
||||
FutureOr<Uint8List> decrypt(Uint8List data);
|
||||
}
|
||||
|
||||
class DHTRecordEncryptionPrivate implements DHTRecordEncryption {
|
||||
DHTRecordEncryptionPrivate() {
|
||||
//
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<Uint8List> encrypt(Uint8List data) {
|
||||
//
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<Uint8List> decrypt(Uint8List data) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
class DHTRecordEncryptionPublic implements DHTRecordEncryption {
|
||||
DHTRecordEncryptionPublic() {
|
||||
//
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<Uint8List> encrypt(Uint8List data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<Uint8List> decrypt(Uint8List data) {
|
||||
return data;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue