Home
Writeups Misc About
Ellipse Curve Cryptography

Ellipse Curve Cryptography

I did not know the way to solve the challenge after some naive idea of using Pohlig-Hellman on the smooth prime given. Nonetheless, it was a good try as after peeking at the solution, there is no shot that I can solve this without knowing some group theory of have acute observation of the number patterns.

The first way to solve this, and one can look up in this paper, about Genus 0 Curves. We are basically given a conic, or a hyperbola whose equation looks like:

x2dy2=1

over a prime finite field. Using some math on group theory (can read from the paper or read the excellent writeup from aloof), there exists a group isomorphism between the hyperbola H and Fp (under multiplication):

φ:HFp
(x,y)u=xdy

This only works (the mapping is well defined) if d is a square root. Hence with this knowledge, to solve the challenge, we need to map the point G and A given to the finite group under multiplication Fp

g=φ(G)
h=φ(A)

and the remaining task is to calculate the discrete log of h in base g, and then we have the value of n_a. We have this relation:

h=φ(A)=φ(naG)=φ(G)na=gna

Sage Implementation:

The second solution, which requires INSANE fuzzing to find some patterns, is to use the symbolic math functionality of Sage to hunt for some patterns. I did do this, but was not serious in my approach enough (and also I put D as a number - keep in mind not to do this next time). Kudos to Nightshade999 on Cryptohack for this creative solution.

Again, we can represent the coordinates of scalar multiplication between G and i as polynomials in coordinates of G. The following Sage script does so:

What the output look like is something very similar to some binomial expansion. We thus can try writing the polynomial in the binomial expansion form. We can notice that x is fairly well-behaved, it is just y that is causing us some issues.

The form that is returned back for y, after some great observation, is hinting at the fact that we can do a multiply of 23 on y. We eventually arrive at the general formula for this problem, for G×n=P and d=D

P.x+D×P.y=(G.x+D×G.y)n

What is left is just calculating discrete log on Fp again, and it should be easy given that p is smooth.

Sage Implementation (kudos to soon_haari)