PreKeySignalMessage constructor
PreKeySignalMessage(
- Uint8List serialized
Implementation
PreKeySignalMessage(Uint8List serialized) {
try {
_version = ByteUtil.highBitsToInt(serialized[0]);
final preKeyWhisperMessage =
signal_protos.PreKeySignalMessage.fromBuffer(serialized.sublist(1));
if (!preKeyWhisperMessage.hasSignedPreKeyId() ||
!preKeyWhisperMessage.hasBaseKey() ||
!preKeyWhisperMessage.hasIdentityKey() ||
!preKeyWhisperMessage.hasMessage()) {
throw InvalidMessageException('Incomplete message.');
}
this.serialized = serialized;
registrationId = preKeyWhisperMessage.registrationId;
preKeyId = preKeyWhisperMessage.hasPreKeyId()
? Optional.of(preKeyWhisperMessage.preKeyId)
: const Optional.empty();
signedPreKeyId = preKeyWhisperMessage.hasSignedPreKeyId()
? preKeyWhisperMessage.signedPreKeyId
: -1;
baseKey = Curve.decodePoint(
Uint8List.fromList(preKeyWhisperMessage.baseKey), 0);
identityKey = IdentityKey(Curve.decodePoint(
Uint8List.fromList(preKeyWhisperMessage.identityKey), 0));
message = SignalMessage.fromSerialized(
Uint8List.fromList(preKeyWhisperMessage.message));
} on InvalidKeyException catch (e) {
throw InvalidMessageException(e.detailMessage);
} on LegacyMessageException catch (e) {
throw InvalidMessageException(e.detailMessage);
}
}