Is this video real?
Provenance is the record of where a picture, a sound or a text came from and what was done to it. Watermarks and content credentials are two ways to carry it, and deepfake detectors try to work without it.
A cloned voice asking a finance team to pay an invoice is a real kind of fraud. Knowing what each check proves, and what it cannot, is part of building generators responsibly.
By the end of this lesson
Note
I can judge how far a watermark, a content credential or a deepfake detector can be trusted.
Key words
| Word | What it means |
|---|---|
| Provenance | a record of where media came from and what changed it |
| Watermark | a hidden signal a generator adds for a checker to find |
| Content credentials | a signed record of origin attached to a file |
| Deepfake | generated media that shows a real person doing what they never did |
| False positive | a real item wrongly flagged as fake |
| Base rate | how common something is before any test |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
4 questionsA text watermark is a hidden count
Here is one published idea for a text watermark. A secret key splits the vocabulary into green and red halves, and the generator is nudged towards green tokens. A reader sees ordinary text.
A checker with the key counts the green tokens. Plain text is about half green. Far more than half is unlikely by chance, and a z-score says how unlikely: how many spreads above half the count sits.
Worked example: 200 tokens, half green by chance
| Step | Value |
|---|---|
| Expected green by chance | 200 × 0.5 = 100 |
| Spread by chance | √(200 × 0.25) = 7.07 |
| Green tokens counted | 140 |
| z-score | (140 - 100) / 7.07 = 5.66 |
| Reading | Above about 4: almost never by chance |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsWrite the watermark checker
docker exec jupyter sh -c "printf '%s\n' 'import numpy as np' 'green = set(np.random.default_rng(42).permutation(1000)[:500].tolist())' 'r = np.random.default_rng(7)' 'def check(name, tokens):' ' hits = sum(1 for t in tokens if t in green)' ' z = (hits - 0.5 * len(tokens)) / np.sqrt(0.25 * len(tokens))' ' print(name, hits, \"green of\", len(tokens), \"z =\", round(z, 2))' 'greens = np.array(sorted(green))' 'plain = r.integers(0, 1000, 200)' 'marked = np.where(r.random(200) < 0.8, r.choice(greens, 200), r.integers(0, 1000, 200))' 'reworded = np.where(r.random(200) < 0.4, r.integers(0, 1000, 200), marked)' 'check(\"plain text:\", plain)' 'check(\"watermarked:\", marked)' 'check(\"reworded:\", reworded)' 'check(\"short piece:\", marked[:20])' > steps/mark.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Check four texts for the watermark
docker exec jupyter python3 steps/mark.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
What mark.py printed
| Text | Green | z-score |
|---|---|---|
| Plain text, 200 tokens | 109 | 1.27 |
| Watermarked, 200 tokens | 174 | 10.47 |
| Watermarked, then 40% reworded | 133 | 4.67 |
| First 20 watermarked tokens | 17 | 3.13 |
The cells students fill in are left blank in this preview.
What a watermark can and cannot prove
Rewording cut the z-score from 10.47 to 4.67, and heavier rewording cuts it further. A short piece carries little evidence even when every token is marked. A checker finds only watermarks whose key it holds, and a generator run without one adds none.
Picture and sound watermarks can be weakened by cropping, resizing or re-recording. So a strong signal is good evidence, and no signal proves nothing.
Check
Have a go
Check
3 questionsContent credentials sign a record of origin
Content credentials follow an open standard from the C2PA, an industry group. A tool writes a manifest saying who made the file and what was done to it. It binds the manifest to the content with a hash and signs it with a certificate.
A checker recomputes the hash and checks the signature. The lab's script uses a keyed seal from Python as a stand-in for that certificate signature.
Write the credentials checker
docker exec jupyter sh -c "printf '%s\n' 'import hashlib, hmac' 'key = b\"the maker key\"' 'def h(data):' ' return hashlib.sha256(data).hexdigest()' 'def seal_of(claim):' ' return hmac.new(key, claim.encode(), \"sha256\").hexdigest()' 'photo = bytes(range(256)) * 4' 'claim = \"made by camera app, captured, \" + h(photo)' 'seal = seal_of(claim)' 'def verify(name, data, claim, seal):' ' if claim is None:' ' print(name, \"no credentials: nothing either way\")' ' else:' ' print(name, \"seal valid:\", seal == seal_of(claim), \"content matches:\", claim.endswith(h(data)))' 'verify(\"original:\", photo, claim, seal)' 'edited = bytearray(photo)' 'edited[100] = 0' 'verify(\"one byte edited:\", bytes(edited), claim, seal)' 'verify(\"claim changed:\", photo, claim.replace(\"camera app\", \"news agency\"), seal)' 'verify(\"stripped:\", photo, None, None)' > steps/cred.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Check a file four ways
docker exec jupyter python3 steps/cred.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
What cred.py printed
| File | Seal valid | Content matches | What it tells you |
|---|---|---|---|
| Original | True | True | This tool signed this exact content |
| One byte edited | True | False | Changed after signing |
| Claim changed to a news agency | False | True | The record was forged |
| Credentials stripped | Nothing either way |
The cells students fill in are left blank in this preview.
A common mistake
Warning
Many people think media with no credentials or watermark must be fake, or must be real. Most files carry neither, and both can be stripped. Missing provenance is no evidence either way, and a valid credential proves who signed, not that the content is true.
Check
Have a go
Check
3 questionsDeepfakes cause real harm
A deepfake puts a real person into generated media. The harms are concrete: sexual images made without consent, fraud by a cloned voice or face on a call, and invented clips before an election. Real recordings can also be dismissed as fakes.
Law is catching up. In the UK, sharing a sexually explicit deepfake of a real person without consent is a crime. The EU's AI Act requires deepfakes to be labelled as generated.
Detectors fail more often than they seem
A detector is a discriminative model trained on known fakes. A new generator can fool it, and compression or a re-recording can hide what it looks for.
Even a good detector misleads when fakes are rare. The base rate matters: a small share of false positives on many real items can outnumber every fake it catches.
Worked example: 100,000 videos, 100 fakes
| Flagged | Not flagged | |
|---|---|---|
| 100 fakes, 95% caught | 95 | 5 |
| 99,900 real, 5% wrongly flagged | 4,995 | 94,905 |
| Share of flagged that are fake | 95 / 5,090 = 0.019 |
The cells students fill in are left blank in this preview.
Try it: the base rate
# A deepfake detector on a site that gets 100,000 videos a day.
videos = 100000
fakes = 100 # 1 in 1,000 is a deepfake
catches = 0.95 # it flags 95% of the fakes
false_alarms = 0.05 # and wrongly flags 5% of the real videos
caught = fakes * catches
wrongly_flagged = (videos - fakes) * false_alarms
flagged = caught + wrongly_flagged
print("flagged:", flagged)
print("share of flagged that are fake:", round(caught / flagged, 3))
# Change fakes to 10000. What share of the flagged are fake now?
Make a free account to save your work and track your progress.
Check
Have a go
Check
3 questionsAssignment: check a watermark
Write a small watermark checker and the base-rate sum.
is_green(token, key) is True when (token * 31 + key) % 100 is below 50. green_count(tokens, key) counts the green tokens in a list. z_score(green, total) gives (green - 0.5 * total) / math.sqrt(0.25 * total) rounded to 2 places. verdict(tokens, key, threshold) gives "watermarked" when the z-score of the tokens is at least threshold, and "no evidence" otherwise: never "human", because no signal proves nothing. flagged_fake(items, fake_share, catch_rate, false_rate) gives the share of flagged items that are really fake, rounded to 3 places.
import math
def is_green(token, key):
return False
def green_count(tokens, key):
return 0
def z_score(green, total):
return 0.0
def verdict(tokens, key, threshold):
return "no evidence"
def flagged_fake(items, fake_share, catch_rate, false_rate):
return 0.0
Make a free account to save your work and track your progress.
Exit quiz
Have a go