Chapter 12 of 22 Part III: Cybersecurity and Privacy

Secrets Hidden in Plain Sight

Each project below is tailored to a specific algorithm and scientific question from Chapter 12, with concrete inputs, verifiable numerical outputs, boundary cases, and links to the related lab and pioneer.

Project 1 of 3 · v1-c12-p01 Foundational · ~25 min

Bit-Plane Visual Perception Experiment

Lab activity: A. Can you see the difference? · Related code: block-01.js · Pioneer: View profile

Real-World Problem: How much of a digital photograph's visual appearance lives in its high bits vs. its low bits?
Scientific Question: At which bit position (bit 0 through bit 7) do pixel modifications shift from visually imperceptible to clearly visible?

Objective: Toggle individual bit planes (0–7) of an RGB pixel grid and measure brightness deltas and visual artifacts.

Hypothesis to Test: Changing bit 0 shifts a channel by at most 1/255 (often visually imperceptible), whereas changing bit 6 or 7 causes dramatic 64–128 brightness jumps.

Step-by-Step Implementation

  1. Inspect a synthetic gradient image in Activity A of the Chapter 12 Lab.
  2. Modify only bit 0 (LSB) across pixels and compare side by side.
  3. Increase the modified bit plane to bits 3, 5, and 7 to watch quantization bands appear.
  4. Plot the bit-0 plane alone to see how statistical/visual inspection reveals hidden patterns.
Concrete Input: RGB pixel (120, 140, 160); flip bit 0 vs. bit 4 vs. bit 7.
Expected Output: Bit 0 flip -> (121, 140, 160) Δ=1; Bit 4 -> Δ=16; Bit 7 -> (248, 140, 160) Δ=128.

Test Cases: 120 ^ 1 = 121 (Δ=1); 120 ^ 128 = 248 (Δ=128).

Boundary Condition: Even-valued channels increase by +1 on LSB flip; odd-valued channels decrease by −1.

Common Mistake to Avoid: Claiming 1-bit LSB changes are strictly undetectable rather than often visually imperceptible to humans.

Interpreting Results: Human vision has limited contrast sensitivity, but computers inspecting the bit-0 plane detect LSB anomalies readily.

Show Hint, Extension Challenge & Reflection

Hint: Review the worked example and equation in Chapter 12 before testing the boundary case: Even-valued channels increase by +1 on LSB flip; odd-valued channels decrease by −1.

Extension Challenge: Write a bit-plane extractor that visualizes bit 0 of every pixel as pure black (0) or pure white (255).

Reflection Question: Why does Johannes Trithemius's concept of hidden writing differ fundamentally from modern encryption?

Project 2 of 3 · v1-c12-p02 Intermediate · ~30 min

Lossless RGB LSB Capacity & Extractor

Lab activity: B. Read the science-fair clue · Related code: block-02.js · Pioneer: View profile

Real-World Problem: Embedding a hidden note into a lossless PNG requires exact bit packing and a length header so the receiver knows where to stop.
Scientific Question: How many UTF-8 bytes fit inside a W×H lossless RGB image at 1 bit per channel?

Objective: Compute exact capacity floor((W × H × 3)/8), embed a length-prefixed UTF-8 message into pixel arrays, and decode it cleanly.

Hypothesis to Test: An 80×100 RGB image holds at most 3,000 raw bytes, and modifying even 1 pixel in the length header corrupts extraction.

Step-by-Step Implementation

  1. Calculate max capacity in bytes and reject messages exceeding capacity − 2 header bytes.
  2. Convert the 16-bit length header and UTF-8 bytes into a sequential bit stream.
  3. Replace each RGB channel's LSB using (channel & 0xFE) | bit.
  4. Extract the first 16 bits as length L, then read L*8 bits to reconstruct the exact text.
Concrete Input: 80×100 RGB array + message "MIRA-LAB-12" (11 bytes + 2-byte length header = 104 bits).
Expected Output: 104 channels updated (35 pixels); extracted UTF-8 matches "MIRA-LAB-12" identically.

Test Cases: Short ASCII -> exact round-trip; Oversized string -> rejected before writing.

Boundary Condition: Multi-byte UTF-8 characters (accented letters) take 2–4 bytes, not 1 byte per character.

Common Mistake to Avoid: Writing into the Alpha (transparency) channel in HTML Canvas where premultiplied alpha alters RGB values.

Interpreting Results: Exact bit-level framing and lossless formats (PNG) are required for LSB payloads to survive.

Show Hint, Extension Challenge & Reflection

Hint: Review the worked example and equation in Chapter 12 before testing the boundary case: Multi-byte UTF-8 characters (accented letters) take 2–4 bytes, not 1 byte per character.

Extension Challenge: Add a 1-bit error check (or encrypt the payload first) before embedding into the LSB plane.

Reflection Question: Why does re-saving an LSB-encoded PNG as a JPEG destroy the hidden bits?

Project 3 of 3 · v1-c12-p03 Applied · ~30 min

Statistical LSB Anomaly Detector

Lab activity: C. Sign your own picture · Related code: block-03.js · Pioneer: View profile

Real-World Problem: Security analysts need methods to test whether a lossless image carries suspicious LSB data.
Scientific Question: How does replacing LSBs with uniform random bits distort natural adjacent-value (2k, 2k+1) pixel histograms?

Objective: Compare pair-of-values (PoV) counts in a natural smooth gradient vs. an LSB-embedded image.

Hypothesis to Test: Random/encrypted LSB payloads equalize counts of adjacent even/odd pairs (2k and 2k+1), exposing embedding statistically.

Step-by-Step Implementation

  1. Count frequency of each 0–255 brightness value in a clean synthetic image.
  2. Embed a pseudorandom payload across all LSBs.
  3. Compare |count(2k) − count(2k+1)| across all 128 pairs before and after embedding.
  4. Summarize why steganography alone does not guarantee secrecy against statistical inspection.
Concrete Input: Smooth 64×64 grayscale gradient before and after 100% random LSB overwrite.
Expected Output: Original uneven even/odd counts equalize sharply (chi-squared drops toward uniform 50/50 within pairs).

Test Cases: Clean skewed gradient -> large pair imbalance; Full LSB overwrite -> balanced pairs.

Boundary Condition: Very low embedding rates (< 2% of pixels) are much harder to spot with simple pair counts.

Common Mistake to Avoid: Assuming human eyes are the only detector an analyst uses.

Interpreting Results: Steganography and steganalysis are a statistical arms race.

Show Hint, Extension Challenge & Reflection

Hint: Review the worked example and equation in Chapter 12 before testing the boundary case: Very low embedding rates (< 2% of pixels) are much harder to spot with simple pair counts.

Extension Challenge: Test 10%, 50%, and 100% embedding rates and record how pair-imbalance shrinks.

Reflection Question: When is visible watermarking more honest and robust than hidden steganography?