Posted to tcl by mookie at Tue Nov 24 01:33:03 GMT 2026view raw
- # GoldenTunnel v6.1: The Badge Check (Teddy Bear Guide)
-
- ---
-
- ## 🧸 The Teddy Bear Analogy
-
- Imagine you are a Teddy Bear living in the Crystal Forest. You have a Secret Treehouse where you keep all your honey and treasures. You want your friend, the Badger, to visit, but you live in a big, dangerous forest filled with "Wet Teabags" (naughty raccoons who want to steal honey).
-
- How do you know the Badger knocking on your door is real, and not a raccoon in a badger suit?
-
- You use a **Badge Check**.
-
- ### 1. The Badge (The Public Key)
-
- Every Teddy Bear has a **Badge**. It's a shiny, golden pin that says "THIS IS ME."
-
- * **In Computer Terms:** This is the **Server Public Key**. It's a unique digital ID generated by the Server.
- * **Teddy Terms:** A shiny pin on your chest.
-
- ### 2. The Pinning (The Safe List)
-
- The Badger has a notebook. In that notebook, he wrote down exactly what your Badge looks like.
-
- * **In Computer Terms:** The Client has a "Pinned Key" saved in its code.
- * **Teddy Terms:** The Badger's "Safe List."
-
- ### 3. The Knock (The Handshake)
-
- The Badger knocks on the door.
- The Teddy Bear opens a little window and shows her Badge.
-
- * **In Computer Terms:** The Server sends its Public Key to the Client during the connection (Handshake).
- * **Teddy Terms:** Showing the pin through the peephole.
-
- ### 4. The Check (Verification)
-
- The Badger looks at the Badge, then looks at his notebook.
- "Does this Badge match the one I wrote down?"
-
- * **YES:** It's the real Teddy Bear! Come in! (Connection Allowed)
- * **NO:** This is a raccoon! Go away! (Connection Rejected)
-
- * **In Computer Terms:** The Client compares the Server Key with the Pinned Key. If they match, the connection is secure. If not, it's a "Man-in-the-Middle Attack" (a raccoon).
- * **Teddy Terms:** Checking the Safe List.
-
- ---
-
- ## 🛠 How It Works (The "Magic")
-
- ### Step 1: The Setup (Generating the Badge)
-
- When the Teddy Bear (Server) is born, she creates a special pair of magic keys:
- * **The Secret Key:** She keeps this hidden. (Private Key)
- * **The Badge (Public Key):** She shows this to everyone.
-
- She saves these keys in a special box (the `./keys/` folder).
-
- ### Step 2: The First Visit (Pinning)
-
- The first time the Badger (Client) visits, he doesn't know the Teddy Bear yet.
- 1. He knocks.
- 2. She shows her Badge.
- 3. He writes the Badge down in his notebook.
- 4. **IMPORTANT:** He goes home and types that Badge into his computer (the `SERVER_PUBLIC_KEY_PINNED` array in `crystal_push.c`).
-
- Now he knows what the real Badge looks like forever.
-
- ### Step 3: Future Visits (The Badge Check)
-
- The next time he visits:
- 1. He knocks.
- 2. She shows her Badge.
- 3. He checks his notebook.
- 4. **MATCH!** It's really her.
-
- But if a Raccoon tries to trick him:
- 1. Raccoon knocks.
- 2. Raccoon shows a fake Badge (a piece of foil).
- 3. He checks his notebook.
- 4. **NO MATCH!** The real Badge is gold, this one is foil.
- 5. **ALARM!** He slams the door. (Security Alert)
-
- ---
-
- ## 🐛 The Glitch (What We Fixed)
-
- Sometimes, the Magic gets messy. We found three big bugs in the v6.1 Badge Check:
-
- ### Bug #1: The Lost Badge Box (Directory Mismatch)
-
- * **The Problem:** The Teddy Bear put her Badge in a box named `./keys`, but when she wanted to show it, she looked in a box named `./keys_public.key` (which didn't exist).
- * **The Fix:** We taught her to always use the `./keys` folder and name the Badge `keys_public.key`.
-
- ### Bug #2: The Vanishing Badge (Memory Allocation)
-
- * **The Problem:** The Badger tried to write the Badge in his notebook, but he used a tiny scrap of paper (Stack Memory) that was too small. The Badge fell off!
- * **The Fix:** We gave him a big, fresh sheet of paper (Heap Memory) so the Badge fits perfectly.
-
- ### Bug #3: The Confusing Ink (Sign Extension)
-
- * **The Problem:** When we looked at the Badge with our "Debug Goggles," the ink looked weird (`FFFFFF95` instead of `95`). It made us think the Badge was broken, but it was just the goggles confusing us.
- * **The Fix:** We adjusted the goggles to read the ink correctly. The Badge was fine all along!
-
- ---
-
- ## 📝 How to Use It (For the Architect)
-
- 1. **Run the Server:** Start the Teddy Bear. She will print her Badge in the terminal (`SERVER_PUBLIC_KEY_HEX`).
- 2. **Copy the Badge:** Copy that long string of numbers and letters.
- 3. **Paste in Client:** Open `crystal_push.c`, find the `SERVER_PUBLIC_KEY_PINNED` list, and paste the Badge there.
- 4. **Compile:** Build the Client.
- 5. **Connect:** The Badger will now only talk to the Teddy Bear with that specific Badge.
-
Add a comment