Skip to content

z0d1ak ctf 2026

siren

crypto challenge from z0d1ak ctf 2026

challenge description

The Siren will sing any sailor's words back to him, sealed in her own hand. There is only one phrase she will never voice: the phrase that lifts the tide gate over her hoard.

Give her enough verses and the silence in every breath spells her name.

writeup

The server gives a pubkey command and a sign command

The only message it will not sign is

text

unlock:release-the-tide

The goal is to make a valid signature for that message anyway

nonce leak

First thing i checked was how the nonce gets made

Python

def public_pitch(msg):
    material = (SONG_ID + ":" + msg).encode()
    h = int.from_bytes(hashlib.sha256(material).digest(), "big")
    return h >> (256 - PITCH_BITS)


def shaped_nonce(msg):
    prefix = public_pitch(msg) << SUFFIX_BITS
    while True:
        k = prefix | (rng_below(SUFFIX_BOUND) - 1)
        if 1 <= k < N:
            return k

PITCH_BITS is 10

So the top 10 bits of every nonce are known from the message and the public song_id

Only the lower 246 bits are random

text

k = pitch(msg) << 246 | x
0 <= x < 2^246

That is enough for a partial nonce attack

The server is leaking 10 bits for every signature tbh

ecdsa equation

For ecdsa

text

s k = z + r d mod n

d is the private key and z is the message hash

For each message i write the nonce as

text

k_i = a_i + x_i

where a_i is the known prefix and x_i is the unknown suffix

Rearranging gives

text

x_i = alpha_i d + beta_i mod n

with

text

alpha_i = r_i s_i^-1 mod n
beta_i  = (z_i - s_i a_i) s_i^-1 mod n

Every signature gives one equation with the same unknown d

The x_i values are bounded to 246 bits so this is a Hidden Number Problem

lll

I collected 50 signatures using different messages

Then i built the usual HNP lattice

I used X = 2^10 to balance the small suffixes against the 256 bit private key

The useful short vector looks like this

text

[ X(alpha_i d + beta_i + n q_i) , d , W ]
= [ X x_i , d , W ]

The correct key makes the first values small because they are the leaked nonce suffixes

LLL finds that vector

Python

from fpylll import IntegerMatrix, LLL

m = len(vals)
X = 1 << 10
W = n

M = IntegerMatrix(m + 2, m + 2)

for i in range(m):
    M[i, i] = n * X

for i, row in enumerate(vals):
    M[m, i] = X * row["alpha"]
M[m, m] = 1

for i, row in enumerate(vals):
    M[m + 1, i] = X * row["beta"]
M[m + 1, m + 1] = W

LLL.reduction(M, delta=0.99)

I checked every row with an embedding coordinate of +W or -W

For each candidate key i recomputed every nonce and checked that its top 10 bits matched the pitch

The recovered private key was

text

0xb1fcd439a96aa11e45021cd15b23f7ec9abbe81d80f949ce123592481af4868c

forge

Now the blocked message is not a problem

I can sign it locally with the recovered key

I used k = 1 because it makes the calculation simple

Python

from ecdsa import SECP256k1
import hashlib

G = SECP256k1.generator
n = SECP256k1.order

d = 0xb1fcd439a96aa11e45021cd15b23f7ec9abbe81d80f949ce123592481af4868c
msg = "unlock:release-the-tide"
z = int.from_bytes(hashlib.sha256(msg.encode()).digest(), "big") % n

k = 1
R = k * G
r = R.x() % n
s = (pow(k, -1, n) * (z + r * d)) % n

print(hex(r))
print(hex(s))

This gave

text

r = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
s = 0x64ef74d7cb8f18fe3272c96339d0ead662acac9fa2ec8b34ae1d37ed21454d7c

I sent those values to unlock

JSON

{"cmd":"unlock","r":"0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","s":"0x64ef74d7cb8f18fe3272c96339d0ead662acac9fa2ec8b34ae1d37ed21454d7c"}

The server accepted it

and traaaaaaaaa

flag

text

zdk{a_F3w_blt5_PEr_s16n4tur3_51nK5_7HE_kEy}

Discussion

Loading discussion…

Related solves

Keep reading

Complete archive