- int version;
- byte[] ownId;
- byte[] theirId;
-
- if (!isUuidCapable && ownAddress.number().isPresent() && theirAddress.number().isPresent()) {
- // Version 1: E164 user
- version = 1;
- ownId = ownAddress.number().get().getBytes();
- theirId = theirAddress.number().get().getBytes();
- } else if (isUuidCapable && theirAddress.serviceId().isPresent()) {
- // Version 2: UUID user
- version = 2;
- ownId = ownAddress.getServiceId().toByteArray();
- theirId = theirAddress.getServiceId().toByteArray();
- } else {
- return null;
- }
+ // Version 1: E164 user
+ final var version = 1;
+ final var ownId = ownNumber.getBytes(StandardCharsets.UTF_8);
+ final var theirId = theirNumber.getBytes(StandardCharsets.UTF_8);
+
+ return getFingerprint(version, ownId, ownIdentityKey, theirId, theirIdentityKey);
+ }
+
+ public static Fingerprint computeSafetyNumberForUuid(
+ ServiceId ownServiceId, IdentityKey ownIdentityKey, ServiceId theirServiceId, IdentityKey theirIdentityKey
+ ) {
+ // Version 2: UUID user
+ final var version = 2;
+ final var ownId = ownServiceId.toByteArray();
+ final var theirId = theirServiceId.toByteArray();
+
+ return getFingerprint(version, ownId, ownIdentityKey, theirId, theirIdentityKey);
+ }