# Representing a point

We call a `Point` an element of the elliptic curve group, which we can represent with its coordinates. Let's define a `Point` class to encapsulate the $$x$$ and $$y$$ coordinates in the generalised curve equation of $$y^2 = x^3 + ax + b$$**.**

```python
from typing import Optional

@dataclass
class Point:
    x: Optional[int]
    y: Optional[int]

    curve: EllipticCurve

    def __post_init__(self):
        # Ignore validation for I
        if self.x is None and self.y is None:
            return

        # Encapsulate int coordinates in FieldElement
        self.x = FieldElement(self.x, self.curve.field)
        self.y = FieldElement(self.y, self.curve.field)

        # Verify if the point satisfies the curve equation
        if self not in self.curve:
            raise ValueError
```

{% hint style="info" %}
**Point-compression:** To reduce the storage size for a curve point, one can also store a sign and the`x` coordinate. It is then possible to  reconstruct the `y` by calculating `sign * sqrt(x^3+a*x+b).`

Ref: <https://bitcoin.stackexchange.com/a/29905>
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://onyb.gitbook.io/roll-your-own-crypto/representing-a-point.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
