2023-07-20 15:48:55 -04:00
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:veilid/veilid.dart';
|
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'tools.dart';
|
|
|
|
|
2023-07-20 20:57:36 -04:00
|
|
|
typedef DHTRecordEncryptionFactory = DHTRecordEncryption Function();
|
|
|
|
|
2023-07-20 15:48:55 -04:00
|
|
|
abstract class DHTRecordEncryption {
|
|
|
|
factory DHTRecordEncryption.private() {
|
|
|
|
return DHTRecordEncryptionPrivate();
|
|
|
|
}
|
|
|
|
factory DHTRecordEncryption.public() {
|
|
|
|
return DHTRecordEncryptionPublic();
|
|
|
|
}
|
|
|
|
|
|
|
|
FutureOr<Uint8List> encrypt(Uint8List data);
|
|
|
|
FutureOr<Uint8List> decrypt(Uint8List data);
|
|
|
|
}
|
|
|
|
|
2023-07-20 20:57:36 -04:00
|
|
|
////////////////////////////////////
|
|
|
|
/// Private DHT Record: Encrypted with the owner's secret key
|
2023-07-20 15:48:55 -04:00
|
|
|
class DHTRecordEncryptionPrivate implements DHTRecordEncryption {
|
|
|
|
DHTRecordEncryptionPrivate() {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
FutureOr<Uint8List> encrypt(Uint8List data) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
FutureOr<Uint8List> decrypt(Uint8List data) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-20 20:57:36 -04:00
|
|
|
////////////////////////////////////
|
|
|
|
/// Public DHT Record: No encryption
|
2023-07-20 15:48:55 -04:00
|
|
|
class DHTRecordEncryptionPublic implements DHTRecordEncryption {
|
|
|
|
DHTRecordEncryptionPublic() {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
FutureOr<Uint8List> encrypt(Uint8List data) {
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
FutureOr<Uint8List> decrypt(Uint8List data) {
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|