Implementing Elliptic Curves

close button

Part III

Affine ↔ Jacobian Coordinates

We only have to implement 2 more functions for ObsidianGates to work. The contract accepts a signature (rx,ry,s)(rx, ry, s), where (rx, ry) is an affine point. Key holders are also represented as a mapping of affine points.

Hence, our elliptic curve library must support the conversion of points between the affine space and Jacobian space. We wish to implement the following 2 functions.



affineToJac(Felt, Felt) → JacPoint

Projects an affine point into the Jacobian space.

jacToAffine(JacPoint) → (Felt, Felt)

Converts a Jacobian point back into the affine space.

Your Task

In contracts/EllipticCurve.sol, implement the logic for affineToJac and jacToAffine. These functions must be implemented efficiently.

After that, the ObsidianGates should open to the city's key bearers again!

Run tests in Questplay

Submit work in Questplay

You are nearly there. The door begins to glow with fresh runes. Now to complete your task...