BulkRound::Descriptor BulkRound::ParseDescriptor(const QByteArray &data) { Descriptor descriptor; QDataStream desstream(data); desstream >> descriptor; _expected_bulk_size += descriptor.Length(); return descriptor; }
QByteArray BulkRound::GenerateXorMessage(int idx) { if(_my_idx == idx) { return _my_xor_message; } Descriptor descriptor = _descriptors[idx]; QByteArray seed = GetDhKey().GetSharedSecret(descriptor.PublicDh()); QByteArray msg(descriptor.Length(), 0); CryptoRandom(seed).GenerateBlock(msg); QByteArray hash = Hash().ComputeHash(msg); if(descriptor.XorMessageHashes()[GetGroup().GetIndex(GetLocalId())] != hash) { qWarning() << "Invalid hash"; } return msg; }