![](https://cdn.nodeguardians.io/backend-production/solidity_bg_fc76a87eed/solidity_bg_fc76a87eed.webp)
Standalone
Implementing Elliptic Curves
![](https://cdn.nodeguardians.io/backend-production/Implementing_Elliptic_Curves_part2_38ead18abd/Implementing_Elliptic_Curves_part2_38ead18abd.webp)
Part II
Elliptic Curve Operations
With field arithmetic abstracted away, we can now implement our elliptic curve. For efficiency purposes, we want to implement the elliptic curve in the Jacobian space, where points are represented as .In contracts/EllipticCurve.sol
, we have defined a new struct JacPoint
to represent points on the curve.
struct JacPoint {
Felt x;
Felt y;
Felt z;
}
We want to implement functions to support point manipulation. Specifically, we wish to implement the following functions.
Function | Description |
| Adds 2 Jacobian points and returns the result. If the points are equivalent, then double the point instead. |
| Multiplies a Jacobian point with a scalar value and returns the result. |
| Multiplies the generator point with a scalar value and returns the result. |
In our implementation, we define the point at infinity to be any point with z-coordinate of value . For example, and are both the point at infinity.
Your Task
In contracts/EllipticCurve.sol
, implement the logic for jacAdd
, jacMul
, and generatePoint
. These functions must be implemented efficiently.
Run tests in Questplay
![](https://cdn.nodeguardians.io/backend-production/Implementing_Elliptic_Curves_part2_38ead18abd/Implementing_Elliptic_Curves_part2_38ead18abd.webp)
Having grasped the runic lexicon, you can now begin to enchant fresh power atop that with had begun to fade...