feat: Implement getting fingerprints

This commit is contained in:
2023-06-15 16:18:42 +02:00
parent af33ed51d1
commit f1ec8d1793
2 changed files with 47 additions and 3 deletions

View File

@@ -1,4 +1,3 @@
import 'dart:convert';
import 'package:cryptography/cryptography.dart';
import 'package:hex/hex.dart';
import 'package:meta/meta.dart';
@@ -356,6 +355,7 @@ class OmemoDoubleRatchet {
..message = headerBytes;
}
/// Returns a copy of the ratchet.
OmemoDoubleRatchet clone() {
return OmemoDoubleRatchet(
dhs,
@@ -375,6 +375,15 @@ class OmemoDoubleRatchet {
);
}
/// Computes the fingerprint of the double ratchet, according to
/// XEP-0384.
Future<String> get fingerprint async {
final curveKey = await ik.toCurve25519();
return HEX.encode(
await curveKey.getBytes(),
);
}
@visibleForTesting
Future<bool> equals(OmemoDoubleRatchet other) async {
final dhrMatch = dhr == null