# hxpCTF 2020 - Hyper writeup

## Server code

The server constructs the hyperelliptic curve over , where .

Then it considers three points with coordinates of , and constructs the divisors corresponding to them on the Jacobian of (i.e. ).

There are three random values , which we want to recover, that are used as multipliers during one round of the PRNG.

In particular, the PRNG works in the following way: in the -th round it computes the divisor ; then it computes the Mumford representation of , and outputs the coefficients of those polynomials encoded as bytes.

## Reconstruct the divisor

The first challenge, hyper, only asks us to recover by knowing : we have the first 24 bytes of both output and input, so we can recover the first 24 bytes of the PRNG, that are exactly the coefficients of .

To obtain , we look up the definition of Mumford representation, for example on “Handbook of Elliptic and Hyperelliptic Curves”.
Every divisor has a unique representation as , where and the following properties hold:

• is monic

The last condition tells us that if is a root of in some extension of , then , so that .

Since we know , we can compute its roots , and for each choice of signs we get a system of equations , which can be solved via Lagrange interpolation.

Running this we get two valid s, but only one which decodes to the correct flag:

## Get the next block

In the hyperhyper challenge, we can reconstruct as above the divisor ; but now we want to know the divisor , and the strategy is finding each individual .

The first things to notice is that ; this is not a completely random try, because for elliptic curves over the multiplication by can signal some special behaviour of the curve:

• if , then we probably are dealing with an anomalous curve
• if , then we probably are on a supersingular curve

This means that we are dealing with the supersingular analogous of hyperelliptic curves, so that we probably can apply the MOV attack on supersingular curves by extending the base field to and taking Weil pairings.

In particular, if is the Jacobian over , and is a random point, then we can compute Weil pairings with and find an equation in of the kind

Moreover, if we take the discrete logarithms , since has order , we get the equation .

This is where I stopped during the CTF, since I had no idea how to compute the different and I was running out of time. Then, after the CTF, I got the hint that the group is a product of many copies of , and that are not in the same cyclic subgroup of order , so using different random s should generate independent equations modulo !

I then tried this approach using MAGMA (since Sage refused to compute Weil pairings on hyperelliptic curves), and was able to generate three independent equations!

Having the three triples I got back to Sage, solved the linear system and decoded the flag:

This returns Hello! The flag is: hxp{n0w_c0m3th_th3_h4rD_P4rT__TsMXaeGJsTkdokHKhIjZDtAkc1NuiLP2__gOod_j0b}, which should be the flag.