Artificial Intelligence & Data Science is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Image verification and authentication

Image verification and authentication: methods (cryptographic hashes, digital signatures), forensic detection (passive/statistical methods, active watermarking), quality metrics (MSE, PSNR), and practical workflows for verifying that an image is original and unmodified.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Digital images are used as evidence, in news, in social media and in technical systems. An engineer in digital forensics or cybersecurity uses image verification and authentication to decide whether an image is original, altered, or forged — for example when preparing evidence, investigating a cybercrime, or building an automated system that flags manipulated images.

Key ideas

Start from first principles and simple definitions.

  • Image: a two-dimensional array of pixel values. For a grayscale 8-bit image each pixel is an integer 0..255.

  • Authentication: the process of proving the origin of data (who created it) and that the data has not been altered since creation.

  • Verification: the act of checking if data (an image) meets some authenticity criteria set by the verifier.

  • Cryptographic hash function: a deterministic function H that maps arbitrary-length inputs to fixed-length outputs (hash values). Properties used in forensics: pre-image resistance (given y it is infeasible to find x with H(x)=y), second pre-image resistance (given x it is infeasible to find x'≠x with H(x)=H(x')), and collision resistance (it is infeasible to find any x≠x' with H(x)=H(x')). Avoid weak/broken hashes (e.g., MD5, SHA-1) for authenticity; prefer SHA-256 or SHA-3.

  • Digital signature: a cryptographic scheme where a signer uses a private key to produce a signature on a message (or on a hash of the message). Anyone with the signer’s public key can verify the signature and therefore verify authenticity and non-repudiation. In symmetric-key settings, use a Message Authentication Code (MAC), e.g., HMAC-SHA-256, for integrity and data-origin authentication; MACs are not publicly verifiable.

  • Active methods (watermarking / fingerprinting): deliberately embed additional data into the image at creation time so later checks can prove ownership or authenticity. Robust watermarking survives some processing (e.g. compression); fragile watermarking breaks on any modification and detects changes.

  • Passive methods (blind detection): do not require pre-embedded data. They look for statistical inconsistencies introduced by editing: noise patterns, compression artifacts, camera sensor patterns (CFA — color filter array), double JPEG compression signatures, or anomalies in metadata (e.g., EXIF).

  • Perceptual hash (pHash): a hash that captures perceptual content rather than bitwise content. Typical steps: resize to small fixed size, compute a transform (DCT), take low-frequency coefficients, threshold them (above/below median) to produce a binary fingerprint. Similar images have small Hamming distance between their perceptual hashes.

  • Error Level Analysis (ELA): for JPEG images, recompress the image at a known quality, subtract recompressed image from original, and inspect the difference: regions that were altered (and then recompressed) often show different error levels. ELA is a heuristic applicable only to lossy formats like JPEG; it can produce false positives/negatives and should not be used as sole proof of tampering.

  • How to draw the common diagrams an examiner might include in an answer: 1) flow for cryptographic verification: draw boxes left-to-right labeled Original Image -> Hashing -> Signature (private key) -> Store/Transmit; then Verify path: Received Image -> Hashing -> Compare to Signature Decrypted (public key). Label each arrow with data (image, H(image), signature). 2) ELA diagram: Original JPEG -> Recompress JPEG(95) -> Compute Difference -> Amplify difference -> Visual inspection.

  • Assumptions behind methods: cryptographic methods assume secure private key management and trusted initial capture; passive forensic methods assume editing leaves detectable statistical traces and that source camera pipeline leaves characteristic artifacts.

  • Derivation universities often ask for: why PSNR uses log10 and MAX^2. PSNR compares a signal power (MAX^2) to noise power (MSE). Power ratio in decibels is 10·log10(power_ratio); thus PSNR = 10·log10(MAX_I^2 / MSE). (Derivation shown in Formulas below.)

Formulas

MSE = (1/(M·N)) · Σ_{i=1..M} Σ_{j=1..N} (I(i,j) - K(i,j))^2 where I = original image, K = test image, M,N = image dimensions. Units: (intensity)^2. Applies to pixel-wise error measurement.

PSNR = 10 · log10(MAX_I^2 / MSE) where MAX_I is the maximum possible pixel value (for 8-bit images MAX_I = 255; for normalized images in [0,1], use MAX_I = 1). Units: decibels (dB). Applies when MSE > 0; if MSE = 0, PSNR = +∞.

HammingDistance(h1,h2) = number of bit positions where h1 and h2 differ where h1,h2 are binary fingerprints. Unitless. Applies to binary perceptual hashes.

For cryptographic operations, key steps (syntax-like):

  • Compute hash: h = H(image) (e.g., H = SHA-256)
  • Sign: signature = Sign_privatekey(h) (e.g., RSA, ECDSA)
  • Verify: h' = H(received_image); then either call Verify_publickey(signature, h') to get a true/false, or recover the signed digest as v = Recover_publickey(signature) and check v == h' (scheme-dependent).

Worked examples

  1. Numerical: compute MSE and PSNR for two 2×2 8-bit grayscale images. Let Original I = [[100, 102], [98, 101]] Test K = [[100, 103], [97, 100]] Step 1: differences: 0, -1, 1, 1 (pixel-wise I - K) Step 2: squares: 0, 1, 1, 1; sum = 3 Step 3: MSE = sum / (M·N) = 3 / 4 = 0.75 (intensity^2) Step 4: PSNR = 10·log10(MAX_I^2 / MSE). For 8-bit MAX_I = 255 so MAX_I^2 = 65025. PSNR = 10·log10(65025 / 0.75) = 10·log10(86700) ≈ 10·4.937 = 49.37 dB (Show units and rounding.)

  2. Algorithm trace: digital-signature verification (symbolic values)

  • Alice computes h = H(image) = 0xA1B2 (example hex). She computes signature s = Sign_private(h). She publishes image and s.
  • Bob receives image' and s. He computes h' = H(image'). He either calls Verify_public(image', s) which returns true/false, or he computes v = Recover_public(s) to obtain the signed hash value (after proper padding/format checks) and compares it to h'. If v == h' then signature verifies: image' is bitwise identical to the signed image and signed by Alice. If not equal, either image' changed or signature invalid. Step-by-step show data flow: Image -> H -> h; h + private key -> signature; on verify: signature + public key -> expected h; compare to H(received image).
  1. Perceptual-hash example (small 8-bit trace): Suppose pHash produces 8-bit fingerprints for teaching. Let ph1 = 11001010, ph2 = 11011011 Compare bit-by-bit: differences at positions 4 and 8 -> Hamming distance = 2. If threshold for “same” is ≤ 3 (heuristic), then ph1 and ph2 likely represent the same image with minor edits.

Common mistakes

  • Using visible watermarks for forensic proof — visible marks prove ownership but are easy to crop out; fragile/invisible watermarks are more useful for tamper detection.
  • Re-saving or re-compressing an evidence image before computing a verifying hash — recompression changes bits and will break bitwise hashes. Always preserve the original or compute and store a hash immediately at capture.
  • Misusing PSNR: high PSNR does not always mean perceptually identical; it measures average squared error and is less sensitive to structural differences (use SSIM or perceptual measures for perceptual quality).

For your exam

Kinds of questions you will see: definitions (define cryptographic hash, digital signature, watermarking), short notes (passive vs active methods, explain ELA), derivations (derive PSNR from MSE, explain why 10·log10 appears), numericals (compute MSE/PSNR for small matrices), algorithms (trace signature verification or perceptual-hash comparison), diagrams (draw signature flow or ELA pipeline), and case-based questions (given a scenario, which methods to use and why).

What a full-marks answer includes:

  • Clear definitions of terms (bold or underlined in notes), assumptions stated, and method limitations.
  • Step-by-step derivation when asked (e.g., PSNR derivation: power ratio -> dB conversion).
  • For practical questions, list exact workflow steps: acquisition → hashing/signing → storage and chain-of-custody → verification steps; mention non-technical controls (key management, timestamps).
  • When discussing detection, include at least one passive and one active method, explain how they detect tampering, and note false-positive/false-negative risks.

Quick check

  1. Define collision resistance in one sentence.
  2. Give the PSNR (approx) for MSE = 0.75 with 8-bit images.
  3. What does a Hamming distance of 0 between two perceptual hashes mean? Answers: 1) Collision resistance: it is infeasible to find two different inputs that give the same hash value. 2) ≈ 49.37 dB. 3) The two perceptual hashes are identical — images are likely perceptually identical (modulo hash limitations).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?