Пример #1
0
        public PreKeySignalMessage(uint messageVersion, uint registrationId, May <uint> preKeyId,
                                   uint signedPreKeyId, ECPublicKey baseKey, IdentityKey identityKey,
                                   SignalMessage message)
        {
            this.version        = messageVersion;
            this.registrationId = registrationId;
            this.preKeyId       = preKeyId;
            this.signedPreKeyId = signedPreKeyId;
            this.baseKey        = baseKey;
            this.identityKey    = identityKey;
            this.message        = message;

            WhisperProtos.PreKeySignalMessage.Builder builder =
                WhisperProtos.PreKeySignalMessage.CreateBuilder()
                .SetSignedPreKeyId(signedPreKeyId)
                .SetBaseKey(ByteString.CopyFrom(baseKey.serialize()))
                .SetIdentityKey(ByteString.CopyFrom(identityKey.serialize()))
                .SetMessage(ByteString.CopyFrom(message.serialize()))
                .SetRegistrationId(registrationId);

            if (preKeyId.HasValue)                             // .isPresent()
            {
                builder.SetPreKeyId(preKeyId.ForceGetValue()); // get()
            }

            byte[] versionBytes = { ByteUtil.intsToByteHighAndLow((int)this.version, (int)CURRENT_VERSION) };
            byte[] messageBytes = builder.Build().ToByteArray();

            this.serialized = ByteUtil.combine(versionBytes, messageBytes);
        }
Пример #2
0
        public PreKeySignalMessage(uint messageVersion, uint registrationId, May <uint> preKeyId,
                                   uint signedPreKeyId, IEcPublicKey baseKey, IdentityKey identityKey,
                                   SignalMessage message)
        {
            _version        = messageVersion;
            _registrationId = registrationId;
            _preKeyId       = preKeyId;
            _signedPreKeyId = signedPreKeyId;
            _baseKey        = baseKey;
            _identityKey    = identityKey;
            _message        = message;

            WhisperProtos.PreKeySignalMessage.Builder builder =
                WhisperProtos.PreKeySignalMessage.CreateBuilder()
                .SetSignedPreKeyId(signedPreKeyId)
                .SetBaseKey(ByteString.CopyFrom(baseKey.Serialize()))
                .SetIdentityKey(ByteString.CopyFrom(identityKey.Serialize()))
                .SetMessage(ByteString.CopyFrom(message.Serialize()))
                .SetRegistrationId(registrationId);

            if (preKeyId.HasValue)                             // .isPresent()
            {
                builder.SetPreKeyId(preKeyId.ForceGetValue()); // get()
            }

            byte[] versionBytes = { ByteUtil.IntsToByteHighAndLow((int)_version, (int)CurrentVersion) };
            byte[] messageBytes = builder.Build().ToByteArray();

            _serialized = ByteUtil.Combine(versionBytes, messageBytes);
        }