ZaStoGram_desktop/Telegram/SourceFiles/e2e_cloud/vault/password_vault.h
loop-uh 8ab3566031 Build the first core slice of E2E cloud groups
The design from the previous commit gets its first code: strongly
typed identifiers, a versioned envelope with a strict binary codec, a
freshness gate that fails closed on conflicting checkpoints, a
protected outbox that refuses to seal or upload before freshness
confirmation, the authoritative group-state machine, real
Ed25519/X25519 account identity with domain-separated signatures, an
Argon2id-bounded password vault, purpose-bound AES-256-GCM local
record protection with atomic snapshots, encrypted file manifests and
chunk streams, and a two-stage opaque Telegram document carrier. All
of it sits behind replaceable boundaries; the MLS engine itself stays
deliberately unselected, and nothing here is production cryptography
yet.

The library lands as an OBJECT target linked into Telegram. Its cmake
file has to be added by force: a bare "cmake" pattern in .gitignore
swallows any new file under Telegram/cmake, and a build recipe that
exists locally but never reaches the repository is exactly the kind of
breakage that only shows up on someone else's machine.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 22:29:13 +03:00

46 lines
1,012 B
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "e2e_cloud/vault/password_kdf.h"
#include <QtCore/QByteArray>
#include <array>
#include <cstdint>
#include <optional>
namespace E2ECloud {
using VaultMasterKey = std::array<std::uint8_t, 32>;
struct UnwrappedVaultKey {
VaultMasterKey masterKey = {};
std::uint64_t generation = 0;
Argon2idParameters parameters;
};
class PasswordVault final {
public:
explicit PasswordVault(const PasswordKdf &kdf);
[[nodiscard]] std::optional<QByteArray> wrap(
VaultMasterKey &&masterKey,
QByteArray password,
Argon2idConfig config,
std::uint64_t generation) const;
[[nodiscard]] std::optional<UnwrappedVaultKey> unwrap(
const QByteArray &wrapped,
QByteArray password) const;
private:
const PasswordKdf &_kdf;
};
} // namespace E2ECloud