public SignalMessage(uint messageVersion, byte[] macKey, IEcPublicKey senderRatchetKey, uint counter, uint previousCounter, byte[] ciphertext, IdentityKey senderIdentityKey, IdentityKey receiverIdentityKey) { byte[] version = { ByteUtil.IntsToByteHighAndLow((int)messageVersion, (int)CurrentVersion) }; byte[] message = new SignalMessage { ratchedKeyOneofCase_ = RatchedKeyOneofOneofCase.RatchetKey, RatchetKey = ByteString.CopyFrom(senderRatchetKey.Serialize()), //TODO serialize ok? counterOneofCase_ = CounterOneofOneofCase.Counter, Counter = counter, previousCounterOneofCase_ = PreviousCounterOneofOneofCase.PreviousCounter, PreviousCounter = previousCounter, ciphertextOneofCase_ = CiphertextOneofOneofCase.Ciphertext, Ciphertext = ByteString.CopyFrom(ciphertext), }.ToByteArray(); byte[] mac = GetMac(senderIdentityKey, receiverIdentityKey, macKey, ByteUtil.Combine(version, message)); _serialized = ByteUtil.Combine(version, message, mac); _senderRatchetKey = senderRatchetKey; _counter = counter; _previousCounter = previousCounter; _ciphertext = ciphertext; _messageVersion = messageVersion; }
public KeyExchangeMessage(uint messageVersion, uint sequence, uint flags, ECPublicKey baseKey, byte[] baseKeySignature, ECPublicKey ratchetKey, IdentityKey identityKey) { this.supportedVersion = CipherTextMessage.CURRENT_VERSION; this.version = messageVersion; this.sequence = sequence; this.flags = flags; this.baseKey = baseKey; this.baseKeySignature = baseKeySignature; this.ratchetKey = ratchetKey; this.identityKey = identityKey; byte[] version = { ByteUtil.IntsToByteHighAndLow((int)this.version, (int)this.supportedVersion) }; WhisperProtos.KeyExchangeMessage.Builder builder = WhisperProtos.KeyExchangeMessage .CreateBuilder() .SetId((sequence << 5) | flags) //(sequence << 5) | flags .SetBaseKey(ByteString.CopyFrom(baseKey.Serialize())) .SetRatchetKey(ByteString.CopyFrom(ratchetKey.Serialize())) .SetIdentityKey(ByteString.CopyFrom(identityKey.Serialize())); if (messageVersion >= 3) { builder.SetBaseKeySignature(ByteString.CopyFrom(baseKeySignature)); } this.serialized = ByteUtil.Combine(version, builder.Build().ToByteArray()); }
private byte[] GetFingerprint(int iterations, string stableIdentifier, List <IdentityKey> unsortedIdentityKeys) { try { IHashAlgorithmProvider digest = WinRTCrypto.HashAlgorithmProvider.OpenAlgorithm(HashAlgorithm.Sha512); byte[] publicKey = GetLogicalKeyBytes(unsortedIdentityKeys); byte[] hash = ByteUtil.Combine(ByteUtil.ShortToByteArray(FingerprintVersion), publicKey, Encoding.UTF8.GetBytes(stableIdentifier)); for (int i = 0; i < iterations; i++) { hash = digest.HashData(ByteUtil.Combine(new byte[][] { hash, publicKey })); } return(hash); } catch (Exception e) { Debug.Assert(false, e.Message); throw e; } }
public DeviceConsistencyCommitment(int generation, List <IdentityKey> identityKeys) { try { List <IdentityKey> sortedIdentityKeys = new List <IdentityKey>(identityKeys); sortedIdentityKeys.Sort(new IdentityKeyComparator()); IHashAlgorithmProvider messageDigest = WinRTCrypto.HashAlgorithmProvider.OpenAlgorithm(HashAlgorithm.Sha512); _serialized = messageDigest.HashData(ByteUtil.Combine(new byte[][] { Encoding.UTF8.GetBytes(Version), ByteUtil.IntToByteArray(generation) })); foreach (IdentityKey commitment in sortedIdentityKeys) { _serialized = messageDigest.HashData(ByteUtil.Combine(new byte[][] { _serialized, commitment.GetPublicKey().Serialize() })); } _generation = generation; } catch (Exception e) { Debug.Assert(false, e.Message); throw e; } }
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); }
/// Derive an extended key from an extended key public ExtendedKey Derive(Secp256K1 secp, uint n) { var nBytes = BitConverter.GetBytes(n); if (BitConverter.IsLittleEndian) { Array.Reverse(nBytes); } var seed = ByteUtil.Combine(Key.Value, nBytes); var blake2B = new HMACBlake2B(Chaincode, 64 * 8); var derived = blake2B.ComputeHash(seed); var secretKey = SecretKey.From_slice(secp, derived.Take(32).ToArray()); secretKey.Add_assign(secp, Key); // TODO check if key != 0 ? var chainCode = derived.Skip(32).Take(32).ToArray(); return(new ExtendedKey { Depth = (byte)(Depth + 1), RootKeyId = Identifier(secp), NChild = n, Chaincode = chainCode, Key = secretKey }); }
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; PreKeySignalMessage preKeySignalMessage = new PreKeySignalMessage { SignedPreKeyId = signedPreKeyId, BaseKey = ByteString.CopyFrom(baseKey.Serialize()), IdentityKey = ByteString.CopyFrom(identityKey.Serialize()), Message = ByteString.CopyFrom(message.Serialize()), RegistrationId = registrationId }; if (preKeyId.HasValue) // .isPresent() { preKeySignalMessage.PreKeyId = preKeyId.ForceGetValue(); // get() } byte[] versionBytes = { ByteUtil.IntsToByteHighAndLow((int)_version, (int)CurrentVersion) }; byte[] messageBytes = preKeySignalMessage.ToByteArray(); _serialized = ByteUtil.Combine(versionBytes, messageBytes); }
public void TestCombine() { AssertEquals("00000000 01111111", ByteUtil.Combine(new byte[] { 0x00 }, new byte[] { 0x7f })); AssertEquals("00000000 01000000 01111111 00111111", ByteUtil.Combine(new byte[] { 0x00, 0x40 }, new byte[] { 0x7f, 0x3f })); AssertEquals("00000000", ByteUtil.Combine(new byte[] { 0x00 }, new byte[] { })); AssertEquals("01111111", ByteUtil.Combine(new byte[] { }, new byte[] { 0x7f })); }
/// <summary>发送数据 /// </summary> public override Task <FastDFSResp> SendRequestAsync <T>(FastDFSReq <T> request) { _taskCompletionSource = new TaskCompletionSource <FastDFSResp>(); //上下文,当前的信息 _context = BuildContext <T>(request); var bodyBuffer = request.EncodeBody(Option); if (request.Header.Length == 0) { request.Header.Length = request.InputStream != null ? request.InputStream.Length + bodyBuffer.Length : bodyBuffer.Length; } var headerBuffer = request.Header.ToBytes(); var newBuffer = ByteUtil.Combine(headerBuffer, bodyBuffer); //流文件发送 if (request.InputStream != null) { _channel.WriteAsync(Unpooled.WrappedBuffer(newBuffer)); var stream = new FixChunkedStream(request.InputStream); _channel.WriteAndFlushAsync(stream); } else { _channel.WriteAndFlushAsync(Unpooled.WrappedBuffer(newBuffer)); } return(_taskCompletionSource.Task); }
public static byte[] EncodeHeader(IDictionary <string, string> header) { var headerKeyCount = header != null ? header.Count : 0; var headerKeyCountBytes = BitConverter.GetBytes(headerKeyCount); var bytesList = new List <byte[]>(); bytesList.Add(headerKeyCountBytes); if (headerKeyCount > 0) { foreach (var entry in header) { byte[] keyBytes; byte[] keyLengthBytes; byte[] valueBytes; byte[] valueLengthBytes; ByteUtil.EncodeString(entry.Key, out keyLengthBytes, out keyBytes); ByteUtil.EncodeString(entry.Value, out valueLengthBytes, out valueBytes); bytesList.Add(keyLengthBytes); bytesList.Add(keyBytes); bytesList.Add(valueLengthBytes); bytesList.Add(valueBytes); } } return(ByteUtil.Combine(bytesList.ToArray())); }
public PreKeyWhisperMessage(uint messageVersion, uint registrationId, May <uint> preKeyId, uint signedPreKeyId, ECPublicKey baseKey, IdentityKey identityKey, WhisperMessage message) { this.version = messageVersion; this.registrationId = registrationId; this.preKeyId = preKeyId; this.signedPreKeyId = signedPreKeyId; this.baseKey = baseKey; this.identityKey = identityKey; this.message = message; WhisperProtos.PreKeyWhisperMessage.Builder builder = WhisperProtos.PreKeyWhisperMessage.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); }
public static byte[] BuildResponseMessage(RemotingResponse response) { var requestSequenceBytes = BitConverter.GetBytes(response.RequestSequence); var requestCodeBytes = BitConverter.GetBytes(response.RequestCode); var requestTypeBytes = BitConverter.GetBytes(response.RequestType); var requestTimeBytes = ByteUtil.EncodeDateTime(response.RequestTime); var requestHeaderBytes = HeaderUtil.EncodeHeader(response.RequestHeader); var requestHeaderLengthBytes = BitConverter.GetBytes(requestHeaderBytes.Length); var responseCodeBytes = BitConverter.GetBytes(response.ResponseCode); var responseTimeBytes = ByteUtil.EncodeDateTime(response.ResponseTime); var responseHeaderBytes = HeaderUtil.EncodeHeader(response.ResponseHeader); var responseHeaderLengthBytes = BitConverter.GetBytes(requestHeaderBytes.Length); return(ByteUtil.Combine( requestSequenceBytes, requestCodeBytes, requestTypeBytes, requestTimeBytes, requestHeaderLengthBytes, requestHeaderBytes, responseCodeBytes, responseTimeBytes, responseHeaderLengthBytes, responseHeaderBytes, response.ResponseBody)); }
public DeviceConsistencyCommitment(int generation, List <IdentityKey> identityKeys) { try { List <IdentityKey> sortedIdentityKeys = new List <IdentityKey>(identityKeys); sortedIdentityKeys.Sort(new IdentityKeyComparator()); SHA512 messageDigest = SHA512.Create(); _serialized = messageDigest.ComputeHash(ByteUtil.Combine(new byte[][] { Encoding.UTF8.GetBytes(Version), ByteUtil.IntToByteArray(generation) })); foreach (IdentityKey commitment in sortedIdentityKeys) { _serialized = messageDigest.ComputeHash(ByteUtil.Combine(new byte[][] { _serialized, commitment.GetPublicKey().Serialize() })); } _generation = generation; } catch (Exception e) { Debug.Assert(false, e.Message); throw e; } }
public static string GenerateFor(DeviceConsistencyCommitment commitment, List <DeviceConsistencySignature> signatures) { try { List <DeviceConsistencySignature> sortedSignatures = new List <DeviceConsistencySignature>(signatures); sortedSignatures.Sort(new SignatureComparator()); IHashAlgorithmProvider messageDigest = WinRTCrypto.HashAlgorithmProvider.OpenAlgorithm(HashAlgorithm.Sha512); byte[] hash = messageDigest.HashData(ByteUtil.Combine(new byte[][] { ByteUtil.ShortToByteArray(CodeVersion), commitment.ToByteArray() })); foreach (DeviceConsistencySignature signature in sortedSignatures) { hash = messageDigest.HashData(ByteUtil.Combine(new byte[][] { hash, signature.GetVrfOutput() })); } string digits = GetEncodedChunk(hash, 0) + GetEncodedChunk(hash, 5); return(digits.Substring(0, 6)); } catch (Exception e) { Debug.Assert(false, e.Message); throw e; } }
private byte[] GetFingerprint(int iterations, string stableIdentifier, List <IdentityKey> unsortedIdentityKeys) { try { SHA512 digest = SHA512.Create(); byte[] publicKey = GetLogicalKeyBytes(unsortedIdentityKeys); byte[] hash = ByteUtil.Combine(ByteUtil.ShortToByteArray(FingerprintVersion), publicKey, Encoding.UTF8.GetBytes(stableIdentifier)); for (int i = 0; i < iterations; i++) { hash = digest.ComputeHash(ByteUtil.Combine(new byte[][] { hash, publicKey })); } return(hash); } catch (Exception e) { Debug.Assert(false, e.Message); throw e; } }
/// <summary>EncodeBody /// </summary> public override byte[] EncodeBody(ClusterConfiguration configuration) { var groupNameBuffer = EndecodeUtil.EncodeGroupName(GroupName, configuration.Charset); var fileIdBuffer = EndecodeUtil.EncodeString(FileId, configuration.Charset); //var length = Consts.FDFS_GROUP_NAME_MAX_LEN + fileIdBuffer.Length; return(ByteUtil.Combine(groupNameBuffer, fileIdBuffer)); }
/// <summary>EncodeBody /// </summary> public override byte[] EncodeBody(FastDFSOption option) { var fileIdLengthBuffer = ByteUtil.LongToBuffer(FileId.Length); var fileSizeBuffer = ByteUtil.LongToBuffer(InputStream.Length); var fileIdBuffer = ByteUtil.StringToByte(FileId, option.Charset); //long length = Consts.FDFS_PROTO_PKG_LEN_SIZE + Consts.FDFS_PROTO_PKG_LEN_SIZE + FileId.Length + RequestStream.Length; return(ByteUtil.Combine(fileIdLengthBuffer, fileSizeBuffer, fileIdBuffer)); }
public SenderKeyGroupMessage(byte[] groupId, byte[] senderKey) { byte[] version = { ByteUtil.IntsToByteHighAndLow((int)CURRENT_VERSION, (int)CURRENT_VERSION) }; byte[] protobuf = WhisperProtos.SenderKeyGroupMessage.CreateBuilder() .SetGroupId(ByteString.CopyFrom(groupId)) .SetSenderKey(ByteString.CopyFrom(senderKey)) .Build().ToByteArray(); this.groupId = groupId; this.senderKey = senderKey; this.serialized = ByteUtil.Combine(version, protobuf); }
public static string CreateMessageId(long messagePosition) { if (_brokerNameBytes == null) { _brokerNameBytes = Encoding.UTF8.GetBytes(BrokerController.Instance.Setting.BrokerInfo.BrokerName); _brokerNameLengthBytes = BitConverter.GetBytes(_brokerNameBytes.Length); } var positionBytes = BitConverter.GetBytes(messagePosition); var messageIdBytes = ByteUtil.Combine(_brokerNameLengthBytes, _brokerNameBytes, positionBytes); return(ObjectId.ToHexString(messageIdBytes)); }
public override async ValueTask <FastDFSResp> SendRequestAsync <T>(FastDFSReq <T> request) { _tcs = new TaskCompletionSource <FastDFSResp>(); _resp = new T(); //上下文,当前的信息 _context = BuildContext <T>(request); var bodyBuffer = request.EncodeBody(Configuration); if (request.Header.Length == 0) { request.Header.Length = request.InputStream != null ? request.InputStream.Length + bodyBuffer.Length : bodyBuffer.Length; } var headerBuffer = request.Header.ToBytes(); var newBuffer = ByteUtil.Combine(headerBuffer, bodyBuffer); //流文件发送 if (request.InputStream != null) { await _client.SendAsync(newBuffer); using (request.InputStream) { var chunkSize = 8192; while (true) { var availableBytes = request.InputStream.Length - request.InputStream.Position; if (availableBytes <= 0) { break; } int readChunkSize = (int)Math.Min(chunkSize, availableBytes); var buffers = new byte[readChunkSize]; _ = await request.InputStream.ReadAsync(buffers, 0, buffers.Length); await _client.SendAsync(buffers); } } } else { await _client.SendAsync(newBuffer); } return(await _tcs.Task); }
public static byte[] ApplyDifference(ScalarValue baseValue, TwinValue diffValue) { int subtraction = ((IntegerValue)diffValue.First).Value; byte[] baseVal = baseValue.Bytes; byte[] diff = diffValue.Second.Bytes; if (subtraction < 0) { subtraction = (-1 * subtraction) - 1; return(ByteUtil.Combine(diff, 0, diff.Length, baseVal, subtraction, baseVal.Length)); } return(ByteUtil.Combine(baseVal, 0, baseVal.Length - subtraction, diff, 0, diff.Length)); }
public byte[] Serialize(object obj) { var data = SerializerFactory.Serializer(obj); if (data.Length > 1024 * 1 * 1024) { return(ByteUtil.Combine(CompressedBytes, CompressionUtil.Compress(data))); } else { return(ByteUtil.Combine(UnCompressedBytes, data)); } }
/// <summary>EncodeBody /// </summary> public override byte[] EncodeBody(ClusterConfiguration configuration) { var groupNameBuffer = EndecodeUtil.EncodeGroupName(GroupName, configuration.Charset); //文件偏移量 var offsetBuffer = EndecodeUtil.EncodeLong(Offset); //下载文件的大小,全部下载用0 var byteSizeBuffer = EndecodeUtil.EncodeLong(ByteSize); //文件FileId数组 var fileIdBuffer = EndecodeUtil.EncodeString(FileId, configuration.Charset); //long length = Consts.FDFS_PROTO_PKG_LEN_SIZE + Consts.FDFS_PROTO_PKG_LEN_SIZE + Consts.FDFS_GROUP_NAME_MAX_LEN + FileId.Length; return(ByteUtil.Combine(offsetBuffer, byteSizeBuffer, groupNameBuffer, fileIdBuffer)); }
public static string CreateStreamId(IPAddress ipAddress, int port, long streamPosition) { if (_ipBytes == null) { _ipBytes = ipAddress.GetAddressBytes(); } if (_portBytes == null) { _portBytes = BitConverter.GetBytes(port); } var positionBytes = BitConverter.GetBytes(streamPosition); var streamIdBytes = ByteUtil.Combine(_ipBytes, _portBytes, positionBytes); return(ObjectId.ToHexString(streamIdBytes)); }
public static string CreateMessageId(long messagePosition) { if (_ipBytes == null) { _ipBytes = BrokerController.Instance.Setting.BrokerInfo.ProducerAddress.ToEndPoint().Address.GetAddressBytes(); } if (_portBytes == null) { _portBytes = BitConverter.GetBytes(BrokerController.Instance.Setting.BrokerInfo.ProducerAddress.ToEndPoint().Port); } var positionBytes = BitConverter.GetBytes(messagePosition); var messageIdBytes = ByteUtil.Combine(_ipBytes, _portBytes, positionBytes); return(ObjectId.ToHexString(messageIdBytes)); }
public SenderKeyDistributionMessage(uint id, uint iteration, byte[] chainKey, IEcPublicKey signatureKey) { byte[] version = { ByteUtil.IntsToByteHighAndLow((int)CurrentVersion, (int)CurrentVersion) }; byte[] protobuf = WhisperProtos.SenderKeyDistributionMessage.CreateBuilder() .SetId(id) .SetIteration(iteration) .SetChainKey(ByteString.CopyFrom(chainKey)) .SetSigningKey(ByteString.CopyFrom(signatureKey.Serialize())) .Build().ToByteArray(); _id = id; _iteration = iteration; _chainKey = chainKey; _signatureKey = signatureKey; _serialized = ByteUtil.Combine(version, protobuf); }
public SenderKeyMessage(uint keyId, uint iteration, byte[] ciphertext, ECPrivateKey signatureKey) { byte[] version = { ByteUtil.IntsToByteHighAndLow((int)CURRENT_VERSION, (int)CURRENT_VERSION) }; byte[] message = WhisperProtos.SenderKeyMessage.CreateBuilder() .SetId(keyId) .SetIteration(iteration) .SetCiphertext(ByteString.CopyFrom(ciphertext)) .Build().ToByteArray(); byte[] signature = GetSignature(signatureKey, ByteUtil.Combine(version, message)); this.serialized = ByteUtil.Combine(version, message, signature); this.messageVersion = CURRENT_VERSION; this.keyId = keyId; this.iteration = iteration; this.ciphertext = ciphertext; }
public SenderKeyDistributionMessage(uint id, uint iteration, byte[] chainKey, IEcPublicKey signatureKey) { byte[] version = { ByteUtil.IntsToByteHighAndLow((int)CurrentVersion, (int)CurrentVersion) }; byte[] protobuf = new SenderKeyDistributionMessage { Id = id, Iteration = iteration, ChainKey = ByteString.CopyFrom(chainKey), SigningKey = ByteString.CopyFrom(signatureKey.Serialize()) }.ToByteArray(); _id = id; _iteration = iteration; _chainKey = chainKey; _signatureKey = signatureKey; _serialized = ByteUtil.Combine(version, protobuf); }
public static byte[] EncodeMessageStoreResult(BatchMessageStoreResult result) { var bytesList = new List <byte[]>(); //queueId var queueIdBytes = BitConverter.GetBytes(result.QueueId); //topic var topicBytes = Encoding.UTF8.GetBytes(result.Topic); var topicLengthBytes = BitConverter.GetBytes(topicBytes.Length); //messageCount var messageCountBytes = BitConverter.GetBytes(result.MessageResults.Count()); bytesList.AddRange(new byte[][] { queueIdBytes, topicLengthBytes, topicBytes, messageCountBytes }); //messages foreach (var message in result.MessageResults) { //messageId byte[] messageIdLengthBytes; byte[] messageIdBytes; ByteUtil.EncodeString(message.MessageId, out messageIdLengthBytes, out messageIdBytes); //code var codeBytes = BitConverter.GetBytes(message.Code); //queueOffset var queueOffsetBytes = BitConverter.GetBytes(message.QueueOffset); //createdTimeTicks var createdTimeTicksBytes = BitConverter.GetBytes(message.CreatedTime.Ticks); //storedTimeTicks var storedTimeTicksBytes = BitConverter.GetBytes(message.StoredTime.Ticks); //tag byte[] tagLengthBytes = null; byte[] tagBytes = null; ByteUtil.EncodeString(message.Tag, out tagLengthBytes, out tagBytes); bytesList.AddRange(new byte[][] { messageIdLengthBytes, messageIdBytes, codeBytes, queueOffsetBytes, createdTimeTicksBytes, storedTimeTicksBytes, tagLengthBytes, tagBytes }); } return(ByteUtil.Combine(bytesList)); }
public SenderKeyMessage(uint keyId, uint iteration, byte[] ciphertext, IEcPrivateKey signatureKey) { byte[] version = { ByteUtil.IntsToByteHighAndLow((int)CurrentVersion, (int)CurrentVersion) }; byte[] message = WhisperProtos.SenderKeyMessage.CreateBuilder() .SetId(keyId) .SetIteration(iteration) .SetCiphertext(ByteString.CopyFrom(ciphertext)) .Build().ToByteArray(); byte[] signature = GetSignature(signatureKey, ByteUtil.Combine(version, message)); _serialized = ByteUtil.Combine(version, message, signature); _messageVersion = CurrentVersion; _keyId = keyId; _iteration = iteration; _ciphertext = ciphertext; }