DawgCTF 2025 - Cantor's Pairadox

Published: April 22, 2025 | CTF: DawgCTF 2025
CTF Crypto Math

Cantor's Pairadox (CRYPTO)

Category Cryptography
Points 200
Difficulty Medium
Cantor's Pairadox Challenge Description

This challenge involves understanding and reversing a mathematical pairing function based on Georg Cantor's work. Let's look at what we were given:

Cantor's Pairadox Encryption Code

Challenge Analysis

  1. The original code encrypted the flag by:
    • Converting the flag to ASCII values
    • Padding the array to a power of 2 length
    • Applying a special pairing function 6 times, which combined pairs of numbers using triangular numbers
  2. To decrypt it, I needed to:
    • Implement the inverse of the pairing function (unpair)
    • Apply this inverse function 6 times to the encoded value
    • Convert the resulting ASCII values back to characters

The key to the decryption was understanding the mathematical "pairing function" used in the original code. This function maps pairs of non-negative integers to a single non-negative integer. To reverse it, I needed to compute the inverse function.

Solution Code

After implementing the inverse pairing function and applying it recursively to unwind the 6 rounds of encryption, I was able to recover the original ASCII values and convert them back to the flag.

FLAG: Dawg{1_pr3f3r_4ppl3s_t0_pa1rs_4nyw2y5}
Key Learning: This challenge demonstrated how mathematical functions like Cantor's pairing function can be used in cryptography, and the importance of understanding how to reverse mathematical transformations to decrypt data.