TgWitness / Documentation

What has been tested →

Documentation / 08

Telegram Evidence: Hash Chains & Signatures

Messages change. Your record of what you saw shouldn't, and anyone should be able to check that.

Two small experiments below. Fake messages, everything runs in your browser, nothing goes to Telegram.

From a chat export to a verifiable record

A Telegram Desktop export saves the history you can see right now as HTML or JSON. TgWitness adds a running journal of changes, signatures on every record and checkpoints others can compare against.

TaskTelegram Desktop exportTgWitness
Read saved conversationsHTML or JSON with selected mediaSaved chats, searchable journal and offline reports
Follow a change over timeThe history available when exportedOld versions, later edits and deletions, all kept
Check files after handoverStandard HTML/JSON export files are unsignedSigned manifest, signed records and sealed reports, checked against a trusted key
Compare with an earlier retained stateKeep a separate reference copy or hashSigned checkpoints, a separate witness and optional external timestamps

The comparison is based on the Telegram Desktop export code as of 2 November 2026.

One message, three observations

A new message, an edit and a deletion become three separate records. The edit doesn't overwrite the first one, and the deletion doesn't erase it.

01 / MESSAGE JOURNEYIllustrative sequence
Telegram delivers an update to the collector, which appends a journal record. TelegramCollectorJournal update →append →
CURRENT CHAT VIEW Message #42
Message deleted

The message has disappeared from the chat view.

OBSERVATION JOURNAL 3 records
  1. 01
    message.new

    Meet at 10:00

    ✓
  2. 02
    message.edited

    Meet at 11:00

    ✓
  3. 03
    message.deleted

    Deletion notice for #42

    ✓

All three received observations remain in the journal.

Simplified path for one already selected source. Operational records also share the real journal. Capture depends on what the account can see and what Telegram delivers.

Change a record. Follow the hash.

Every record contains the hash of the one before it. A checkpoint kept somewhere else pins the journal length and the last hash.

02 / HASH-CHAIN SANDBOXReal SHA-256 · sample records
RECORD 01Message receivedh₁ = SHA-256(e₁)Links to 64 zeroes
RECORD 02Meet at 11:00h₂ = SHA-256(e₂)Includes h₁
RECORD 03Deletion observedh₃ = SHA-256(e₃)Includes h₂
RETAINED ELSEWHERE3 records · head h₃Compare this fixed boundary with the supplied journal.

Altering an event changes its hash. Rebuilding the chain changes its head. Removing the tail makes it shorter than the retained checkpoint.

This sandbox computes hashes, not signatures. The real verifier also checks every event’s Ed25519 signature, sequence and link. Rebuilding hashes alone cannot create valid signatures under the trusted key.

The actual rules, in a few lines

HASH + SIGNATURE
h0 = 064
hi = hex(SHA-256(C(ei)))
σi = Ed25519.Sign(sk, unhex(hi))

C is the nine event fields as UTF-8 JSON: sorted keys, no extra whitespace, no ASCII escaping, no NaN/infinity. previous_hash is hi−1, h0 is 64 zeros, signatures cover the 32 raw digest bytes.

The fields: seq, observed_at, source_at, kind, chat_id, message_id, actor_id, payload, previous_hash. Full spec: event encoding.

RETAINED CHECKPOINT
Nexport ≥ Ncheckpoint
hexport[Ncheckpoint] = Hcheckpoint

Check the checkpoint signature against the pinned key, then compare it with the journal. A later export can be longer, but it has to match at the checkpoint.

Three questions, three different checks

Signatures answer "was it changed", checkpoints answer "does it match what was there before", test messages answer "did we catch everything". What verification proves.

Next: a whole-account investigation from start to case package.

Export Clinic: watch the controlled Desktop experiment. Compare the two-minute film, the original recording and seven pairs of test exports. Local modification is disclosed.