Skip to content
Adam Omar Saleh

TVX CTF 2026 placeholder badge (unofficial)TVX CTF 2026Cryptography

ender chest

Two AES-CBC ciphertexts are given. One is keyed with a public curve coordinate and opens immediately to a decoy. The real one is keyed with the secret scalar of an elliptic-curve point.

Competition
TVX CTF 2026 placeholder badge (unofficial)TVX CTF 2026
Category
CryptographyMedium · estimated
Source status
Flag recovered locally · platform unverified
Document
PDF edition5 min read

Brief

The challenge

Competition
TVX CTF 2026
Category
Cryptography (platform category: Crypto)
Difficulty
Medium — estimated, not an official rating
Points
100
Solves
85 on the challenge card when captured
Challenge author
gl1tt3rpuff0
Verification
Flag recovered locally; platform acceptance not documented

Difficulty: Medium (estimated). TVX CTF 2026 did not publish difficulty ratings; the challenge cards show only points and solve counts. It requires recognising a custom elliptic curve with a smooth group order and solving the discrete log with Pohlig–Hellman, plus avoiding a decoy that decrypts to a fake flag. The card showed 85 solves when captured.

01

Overview

No description.

Challenge page
Challenge page

Two AES-CBC ciphertexts are given. One is keyed with a public curve coordinate and opens immediately to a decoy. The real one is keyed with the secret scalar of an elliptic-curve point.

Solution path in brief

Two AES-CBC ciphertexts are given. The "shulker box" is keyed with Q.x, which is printed in the output, so it opens immediately. It's the trap: a TNT-themed decoy flag. The "ender chest" is keyed with the secret scalar d where Q = d·G. The custom 112-bit curve has a smooth group order, so Pohlig-Hellman solves the discrete log in about a second:

Text
#E smooth → Pohlig-Hellman → d → sha256(str(d)) → AES-CBC decrypt → flag

02

Initial investigation

The challenge ships its generator (chall.py) and output, so the investigation started by reading exactly how each key is derived.

Reading the source

Python
Q = d * Gender_chest = chest(FLAG,  str(d).encode())     # opens with the world seedshulker_box = chest(REALFLAG, str(Q[0]).encode()) # opens with the x coordinate

chest() uses sha256(key_src) as an AES-256-CBC key and puts the random IV in front of the ciphertext. output.txt gives p, a, b, G, Q and both ciphertexts.

03

Tools used

  • Python 3

  • PARI/GP through cypari2 (ellcard, ellorder, elllog)

  • PyCryptodome (AES-CBC, unpad)

04

Step-by-step process

Step 1: The shulker box (decoy)

Q is public, so sha256(str(Q.x)) gives the key directly:

Text
TVX{tNt_g035_B00m_C0ngr4t5}

The source calls this one REALFLAG, but the content says "TNT goes boom". In Minecraft, TNT is a trap. The challenge is named after the ender chest, and its comment hints that the curve is the weak point, so the real target is d.

Step 2: Inspecting the curve

  • p is a 112-bit prime, and both G and Q are on the curve.

  • The discriminant is non-zero, so the curve is not singular.

  • p·G ≠ O and (p+1)·G ≠ O, so it's neither anomalous (Smart's attack) nor supersingular (MOV).

Counting points with PARI (ellcard) shows the weakness:

Text
#E = ord(G) = 4724861355973759917094976238449899            = 11 · 367 · 13399 · 58453 · 484079 · 40128631 · 76927309

The largest prime factor is only about 27 bits. Pohlig-Hellman splits the discrete log into small subgroups, solves each with baby-step giant-step, and combines the results with CRT.

Step 3: Recovering d

PARI's elllog runs Pohlig-Hellman internally (recover_d.py, run in WSL with cypari2):

Text
d = 2327569722739447708246377569803395

Step 4: Opening the ender chest

sha256(str(d)) gives the AES key (solve.py):

Text
shulker_box: TVX{tNt_g035_B00m_C0ngr4t5}ender_chest: TVX{D1dn5_F4lL_4_7h3_7r4p_7h15_t1me}

The ender chest flag reads "didn't fall for the trap this time", which confirms it's the intended answer.

05

Commands and code

Solve scripts

recover_d.py:

Python
import cypari2pari = cypari2.Pari()​E = pari.ellinit([a, b], p)g = [pari.Mod(G[0], p), pari.Mod(G[1], p)]q = [pari.Mod(Q[0], p), pari.Mod(Q[1], p)]o = pari.ellorder(E, g)          # smoothd = pari.elllog(E, q, g, o)      # Pohlig-Hellman

solve.py:

Python
def open_chest(ct_hex, key_src):    raw = bytes.fromhex(ct_hex)    key = hashlib.sha256(key_src).digest()    pt = AES.new(key, AES.MODE_CBC, raw[:16]).decrypt(raw[16:])    return unpad(pt, 16).decode()​print("ender_chest:", open_chest(ender_chest, str(d).encode()))

Full source: recover_d.py: Pohlig–Hellman via PARI

Python
import cypari2​pari = cypari2.Pari()pari.allocatemem(2 * 10**9)​p = 4724861355973759862466485852137759a = 927566916496059264792326746507264b = 4715968330470840770745781630703560G = (3675942204092047283238136253093045, 3544727085494657603430718404172845)Q = (3869418175838450319054504785525959, 1429060253338888234770668216689896)​E = pari.ellinit([a, b], p)n = pari.ellcard(E)print("#E =", n)print("factors =", pari.factor(n))g, q = [pari.Mod(G[0], p), pari.Mod(G[1], p)], [pari.Mod(Q[0], p), pari.Mod(Q[1], p)]o = pari.ellorder(E, g)print("ord(G) =", o, pari.factor(o))d = pari.elllog(E, q, g, o)print("d =", d)

Full source: solve.py: open both chests

Python
import hashlibfrom Crypto.Cipher import AESfrom Crypto.Util.Padding import unpad​p = 4724861355973759862466485852137759a = 927566916496059264792326746507264b = 4715968330470840770745781630703560G = (3675942204092047283238136253093045, 3544727085494657603430718404172845)Q = (3869418175838450319054504785525959, 1429060253338888234770668216689896)ender_chest = '46e14511e959705d1fe179ab3a4c2c40f5db5273f61faa0e319096122ccc59f812a0f0591c193aab914bda09c9f609413398a9c3e8c8e602fc356ff3ea5a7583'shulker_box = 'db755bc9df9ca0eb13611170fceaf940a9395f71ac25050188701bf0b7c7fcb4954519578e377ed12f027388d3d63c8f'​​def open_chest(ct_hex, key_src):    raw = bytes.fromhex(ct_hex)    key = hashlib.sha256(key_src).digest()    pt = AES.new(key, AES.MODE_CBC, raw[:16]).decrypt(raw[16:])    return unpad(pt, 16).decode()​​# d from recover_d.py (Pohlig-Hellman, #E is smooth)d = 2327569722739447708246377569803395​if __name__ == "__main__":    print("shulker_box:", open_chest(shulker_box, str(Q[0]).encode()))    print("ender_chest:", open_chest(ender_chest, str(d).encode()))

06

Technical explanation

The elliptic-curve discrete log problem is only hard when the group order has a large prime factor. Here the order of the 112-bit curve is smooth (a product of small primes), so Pohlig–Hellman splits the problem into small discrete logs in each prime-power subgroup and recombines them with the Chinese Remainder Theorem. PARI's elllog does this automatically once the order is known.

Key lessons

  • ECC is only as strong as the largest prime factor of the subgroup order. Always factor #E for a custom curve.

  • Before reaching for heavier attacks, check the curve for anomalous (#E = p), supersingular, and singular cases.

  • When a challenge hands you an easy flag, check whether it's the intended one.

07

Flag

Flag

TVX{D1dn5_F4lL_4_7h3_7r4p_7h15_t1me}

Flag recovered locally · platform unverified

08

Verification status

Status: Flag recovered locally; platform acceptance not documented.

AES-CBC decryption with the key derived from the recovered scalar d produces valid PKCS#7 padding and readable plaintext; a wrong key would almost certainly fail the padding check. The decoy flag from the shulker box is identified as such. Platform acceptance is not documented.

Source evidence in the archive: WRITEUP.md, chall.py, output.txt, recover_d.py, solve.py, images/00_challenge.png.

09

Conclusion

The challenge pairs a real cryptographic weakness with a psychological trap. The first flag that decrypts is not the answer, and checking the curve order is what leads to the real one.

Prepared by Adam Omar Saleh from the archived solve notes in ender_chest/. Commands, code, output and screenshots are reproduced from the source; no results were added. Difficulty is an estimate.

PDF edition

Writeup PDF

Formatted edition of this walkthrough, built from my source notes · 5 pages.