PrimeForYou

How Decoding Works (Backwards Magic)

Given a prime and a tiny key, we can recover the original name. Here is the step-by-step tour of how the puzzle unscrambles in reverse.

Prefer the story before the schematics? Start with Your Name Is in the Number — then come back here for the full reverse walkthrough.

In traditional cryptography, taking something apart is usually either impossible (like a one-way cryptographic hash) or requires enormous 256-bit military-grade keys and heavy mathematics.

The reversible algorithm (a3.0 and a3.1) takes a different approach: it turns your prime number into an elegant, reversible puzzle. If you have your prime number and the matching 3-character key, you can run the entire machine in reverse and recover your original name.

No servers, no hidden databases, no secret lookups. Everything required to reconstruct the name lives inside the digits of the prime itself.

Here is the step-by-step mechanics of how that backwards trip works.


What Lives Inside Your Prime

To understand how decoding works, it helps to look at how the bits were arranged before the prime was minted. Every candidate number starts as a single binary block divided into four distinct regions:

┌─────────┬──────────────────┬─────────────────────────────┬──────────────────┐
│ Pin (1) │ 6-bit Length (N) │   Huffman Bitstream (Name)  │    Nonce Bits    │
│  1 bit  │      6 bits      │       Variable length       │  Remaining bits  │
└─────────┴──────────────────┴─────────────────────────────┴──────────────────┘
  1. The Pin Bit (1): Guarantees the number stays within its designated block size.
  2. The 6-Bit Length Header: Stores the exact character count of your name (from 1 to 63).
  3. The Huffman Bitstream: Your name squeezed into variable-length binary codewords.
  4. The Nonce: Free “wiggle-room” bits adjusted during the prime hunt until the number is prime.

When you ask our Decode Tool to solve your prime, it carries out five sequential steps to extract your name.


Step 1: Measuring the Box (The Pin Bit)

Before the decoder can do anything, it has to know which size box it is opening. Our algorithm supports three block sizes:

  • 64 bits (up to ~19 decimal digits)
  • 96 bits (up to ~29 decimal digits)
  • 128 bits (up to ~39 decimal digits)

How does the decoder know which one it is looking at without asking a database?

It checks the prime’s bit length. Because our encoder forces the very highest bit of every block to be 1 (the block-size pin), a 96-bit prime will always have 96 bits—it can never accidentally look like a 64-bit number with leading zeros.

A simple, deliberate rule that prevents any ambiguity at the boundary.


Step 2: Undoing the Scramble (The Feistel Network)

Now that the decoder knows the block size, it encounters the scrambled ciphertext.

To lock the name into the prime, we use a Feistel network—a classic cipher structure designed by Horst Feistel at IBM in the 1970s. Feistel ciphers have a remarkable mathematical property: the exact same machinery runs both forwards and backwards.

    ENCRYPT (Forward)                     DECRYPT (Reverse)
┌───────────────────────┐             ┌───────────────────────┐
│ Left (L)    Right (R) │             │ Left (L)    Right (R) │
└───────┬───────────┬───┘             └───────┬───────────┬───┘
        ▼           ▼                         ▼           ▼
   [Round Function + Key]                [Round Function + Key]
        ▼           ▼                         ▼           ▼
   [Swap halves (L ↔ R) ]                [Swap halves (L ↔ R) ]
        ▼           ▼                         ▼           ▼
┌───────────────────────┐             ┌───────────────────────┐
│   Scrambled Output    │             │   Plaintext Block     │
└───────────────────────┘             └───────────────────────┘

When you enter your 3-character key, the decoder feeds the key into the Feistel network and runs the rounds in reverse. The scrambled digits unravel cleanly into the original plaintext block.

What happens with a wrong key? A single wrong letter in your key triggers the avalanche effect: every bit gets scrambled into pseudorandom noise. When the decoder tries to read a nonsense block, it immediately spots that the character count is invalid or that the Huffman path hits a dead end. Wrong keys don’t give you someone else’s name; they give you a polite warning.

(Read more in Your Tiny Key and the Number Lock.)


Step 3: Reading the Length Header

Once the block is unscrambled, the decoder does not immediately start guessing letters.

It first reads the fixed 6-bit length prefix right after the pin bit. Six binary bits can represent any integer from 0 to 63. If your name was "ALICE", this header reads 000101 (binary for 5).

This number tells the decoder: “Expect exactly 5 characters from the Huffman tree, then stop immediately.”

Without this fixed count, the decoder would not know where your name ends and where the leftover prime-hunting bits begin.


Step 4: Walking the Huffman Tree

With the count in hand, the decoder begins reading the variable-length Huffman bitstream.

Instead of wasting 8 bits per character (standard ASCII), our algorithm uses a static Huffman codebook tuned to the letter frequencies of names. Common letters get short bitstrings, while rare letters get longer ones:

CharacterExample Huffman CodewordBit Length
E0103 bits
A1003 bits
S11014 bits
Q1111111109 bits

The decoder reads the bitstream bit-by-bit, walking down a binary tree:

  1. Start at the root of the Huffman tree.
  2. Read a bit from the block: if 0, take the left branch; if 1, take the right branch.
  3. Keep following branches until you hit a leaf node containing a letter.
  4. Emit that letter.
  5. Jump back to the root and repeat for the next letter.
                  [Root]
                 /      \
               (0)      (1)
              /   \        \
            'E'   'A'      ...

Once the decoder has emitted exactly N characters (as dictated by the length prefix in Step 3), it halts the tree walk.

Why Huffman coding is the secret hero: Without Huffman compression, full names would not fit inside the compact 64-bit and 96-bit primes people love to collect. Squeezing names down to 3–4 bits per character leaves plenty of room for the prime hunt to succeed.

(For the full story and mathematical proof, explore How We Pack Your Name Into Fewer Bits and Huffman Coding: Squeezing Names into Fewer Bits.)


Step 5: Ignoring the Nonce & Outputting the Name

After reading N characters, any remaining bits in the block are the nonce—the random wiggle bits that allowed our prime search to land on an authentic prime number.

The decoder simply discards these extra bits.

What emerges is your clean, uppercase, normalized name—the exact canonical text that was prepared in Step 1: Tidying Your Name.

Prime Number + Key
   │
   ▼
[ 1. Bit Length Check ] ──▶ 96-bit Block
   │
   ▼
[ 2. Reverse Feistel ]  ──▶ Unscrambled Plaintext Block
   │
   ▼
[ 3. Read 6-bit Count ] ──▶ N = 7 characters
   │
   ▼
[ 4. Walk Huffman Tree ] ──▶ Recover "ELEANOR"
   │
   ▼
[ 5. Drop Nonce ]       ──▶ Finished!

Try It in Real Time

You don’t have to take our word for it. If you own an a3.0 or a3.1 prime (or want to try one of our sample numbers), head over to the live decoder:

👉 Launch the Interactive Prime Decoder

Enter your prime, paste your 3-character key, pick the matching algorithm version, and watch the reverse rounds unscramble your name in milliseconds.


The “From Name to Prime & Back” Series

Follow the complete journey of how a name transforms into a prime number and back:

  1. First, We Tidy Your Name — Standardizing characters, accents, and spaces.
  2. Packing Your Name Into Fewer Bits — How Huffman compression makes the puzzle fit.
  3. Your Tiny Key and the Number Lock — Feistel ciphers and why 3-character keys are fun.
  4. Prime Hunting With Tiny Tweaks — Wiggling nonces and the Miller–Rabin primality test.
  5. How Decoding Works (Backwards Magic) — (You are here) Running the pipeline in reverse.
  6. Share the Prime, Protect the Key — Keeping your name private until you choose to reveal it.

Companion Deep Dives:

Ready to claim your own piece of the number line?

Every prime number is a unique and eternal gift. Get you or your loved one a personalized prime today.

Visibility:

Bulk orders ·