<p><strong>First some background</strong></p>
<p>The X and Y coordinates of an elliptic curve are <em>not</em> integers. They are elements of a finite field. In secp256k1, that is the modulo <em>p = 2<sup>256</sup>-2<sup>32</sup>-977</em> field. In your example, that is the modulo <em>p = 11</em> field. Elliptic curves over different fields are also possible, including ones which don't even <em>look</em> like integers.</p>
<p>In these modulo fields, many standard arithmetic operations have a different meaning. Addition, subtraction, and multiplication are performed following a modulo <em>p</em> step. I think you understand this already, but miss that it also applies to constants. <em>-2</em> is the negation of <em>2</em>, which modulo <em>p = 11</em>, equals <em>9</em>. Thus, <em>(3, -2)</em> very much lies on your curve, as it's just another way of writing <em>(3, 9)</em>. Note that our choice of treating <em>[0, 1, ..., 10]</em> as the &quot;right&quot; way of representing these field elements is also just a convention - there is nothing special about this choice. All elliptic curve formulas work just fine with the other representations too.</p>
<p>It goes further, though. Division in the field modulo <em>p</em> isn't anything like integer division. Given the fact that for example <em>3×8 = 24 = 2 (mod 11)</em>, and division is the reverse operation of multiplication is division, it has to hold that <em>2/8 = 3 (mod 11)</em>, and <em>2/3 = 8 (mod 11)</em>, but from an integer perspective, <em>2</em> is clearly not divisible by <em>3</em>. The answer is that division modulo <em>p</em> is actually multiplication with the <a href="https://en.wikipedia.org/wiki/Modular_multiplicative_inverse" rel="nofollow noreferrer">modular inverse</a>. Similarly square roots are also nothing like normal square roots, but become <a href="https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm" rel="nofollow noreferrer">modular square roots</a> (the reverse operation of squaring).</p>
<p>Why do people use the same terms/symbols for things like negation, multiplication, division, square roots, if they're nothing like the &quot;normal&quot; ones? Because for abstract mathematics, it actually doesn't matter what field one works on, or what these exact operations correspond to. Elliptic curves can be defined over <em>any</em> field, and their equations, addition formulas, properties, ... generally hold over all or many of them. This abstraction means mathematicians can describe these curves just once, and then one can instantiate them for whatever field one likes, as long as one uses whatever these operations mean for the chosen field.</p>
<p><strong>So what do the terms &quot;positive&quot; and &quot;negative&quot; refer to?</strong></p>
<p>If <em>-2</em> and <em>9</em> are the same thing modulo 11, we clearly can't use this fact to call some numbers positive or negative. <em>Every</em> field element has both positive and negative integer representatives (infinitely many even, because <em>-2</em> is also equal to <em>-13</em>, <em>-24</em>, <em>-35</em>, or to <em>20</em>, <em>31</em>, <em>42</em>, ...).</p>
<p>The truth is, there just doesn't exist a well-defined &quot;positive&quot; and &quot;negative&quot; for modulo fields. However, it turns out that it's still useful to pick some definition, in analogy with integers or real numbers, so that one can make statements like &quot;for a given X coordinate on the curve there are two Y coordinates - one positive and one negative&quot;. The reality is that it doesn't really matter how one chooses this - it's just a convention - as long as it holds that negating a (nonzero) positive element gives a negative element, and vice versa.</p>
<p>There are many different possible choices for these, and all are used in some context(s):</p>
<ul>
<li>Call a field element positive, if when represented as an integer in range <em>[0, p-1]</em> it is smaller than <em>p/2</em>, and negative if above <em>p/2</em>.  Modulo <em>11</em> this means <em>[1, 2, 3, 4, 5]</em> are positive, and <em>[6, 7, 8, 9, 10]</em> are negative. This also means that <em>20 = 9 = -2 = -13</em> is negative, and <em>14 = 3 = -8 = -19</em> is positive.</li>
<li>Call a field element positive, if when represented as an integer in range <em>[0, p-1]</em> it is odd, and negative if even. Modulo <em>11</em> this means <em>[1, 3, 5, 7, 9]</em> are positive and <em>[2, 4, 6, 8, 10]</em> are negative. In this case, sign and parity are basically the same thing.</li>
<li>Call a field element positive if it has a square root, and negative if it doesn't. (this only works if <em>p mod 4 = 3</em>). Modulo <em>11</em> this means <em>[1, 3, 4, 5, 9]</em> are positive and <em>[2, 6, 7, 8, 10]</em> are negative.</li>
</ul>
<p>Picking a different definition will result in different field elements being called positive and negative, but for all of them, it will be the case that among the two Y coordinates for a given X coordinate on the curve, one will be positive and one will be negative.</p>
<p>So: pick whatever definition you like.</p>
<p><strong>Back to your questions</strong></p>
<blockquote>
<p>What is the relationship between parity and the signs of points on an elliptic curve?</p>
</blockquote>
<p>If you pick parity <em>as sign</em>, then they are the same thing. If you don't, they're really unrelated.</p>
<blockquote>
<p>Should I use the -Y point in the addition equation even if it is not part of the elliptic curve?</p>
</blockquote>
<p>It is part of the curve. If <em>(X, Y)</em> is on the curve, then so is <em>(X, -Y)</em>, if one takes into account that that negation sign is the field's negation operation, which isn't necessarily the same as integer negation. Specifically, for modulo <em>p</em> fields, <em>-Y = p-Y</em>.</p>
<blockquote>
<p>If we know that the public key is a result of adding G point to itself private key number of times, how is it possible to apply addition with a negative number, that is, in the example, to add G to itself -10 times?</p>
</blockquote>
<p>Adding <em>G</em> to itself -10 times is the same as adding <em>(-G)</em> to itself 10 times. Alternatively, you can compute it by first adding <em>G</em> to itself 10 times, and then negating the result. It's also equivalent to subtracting <em>G</em> 10 times from the point at infinity (where point subtraction is the same as point addition with negation of the operand).</p>
<p>There is a third option, by taking into account that G is a generator for the elliptic curve group, which has order <em>n</em> (for your small curve, <em>n=17</em>). This means that every 17 additions of <em>G</em> you loop around (or, put otherwise, <em>17×G = Inf</em>). This means that going backwards 10 times is the same as going forward 7 times, and <em>(-10)×G = 7×G</em>, or more generally, <em>(-a)×G = (n-a)×G</em>.</p>

CC BY-SA 4.0
2023-11-12T15:52:02.740Z
2023-11-12T19:15:19.497Z
2023-11-12T19:15:19.497Z
Pieter Wuille
<p>EDIT: I found out that the answer on the second question is just to do <code>10 * -G</code>, that is, <code>10 * G(X, -Y)</code> instead of <code>-10 * G</code>. However, I still do not understand relation between parity and the sign of the point.</p>
<p>I know that a private key is some random 256 bit number, which multiplied with G (generator point), gives a public key (a point on the curve). Multiplication denotes adding G point to itself private key number of times. For every X coordinate, 2 Y coos exist, <strong>EVEN</strong> and <strong>ODD</strong>. Also, these two point are negations of each other, so <code>(X, Yeven) + (X, Yodd) = Inf</code> and <code>(X, Yodd) + (X, Yeven) = Inf</code>.</p>
<p>For example, in the elliptic curve:</p>
<pre><code>a=2
b=4
p=11
G=(2, 4) 
</code></pre>
<p>... for the point <code>(3, 2)</code> the negation is <code>(3, 9)</code> and vice versa. Also, <code>(3, 2) + (3, 9) = Inf</code> and <code>(3, 9) + (3, 2)= Inf</code>.</p>
<p>This is completely clear to me because in the equation for adding two points of the elliptic curve, in this case we will get below <code>/</code> zero (0), so division will not be possible, and the result is <code>Inf</code>.</p>
<p>However, in many articles I see that they talk about <strong>POSITIVE</strong> and <strong>NEGATIVE</strong> Y coordinate, not even and odd.</p>
<p>According to them, there exists pair of points <code>(X, Y) (X, -Y)</code> and, from it, the equations <code>(X, Y) + (X, -Y) = Inf</code> and <code>(X, -Y) + (X, Y) = Inf</code>. That is, for every <code>(X, Y)</code> exist its negation <code>-(X,Y) = (X,Y)</code>.</p>
<p>So in the previous example, for the point <code>(3, 2)</code> exists <code>-(3, 2) = (3, -2)</code> and an equations <code>(3, 2) + (3, -2) = Inf</code> and <code>(3, -2) + (3, 2) = Inf</code>.</p>
<p>This makes no sense to me because the point (3, -2) is not part of the elliptic curve at all and elliptic curve is only &quot;in the context&quot; of the positive numbers.</p>
<p><strong>1. How is it possible? What is the relationship between parity and the signs of points on an elliptic curve? Should I use the -Y point in the addition equation even if it is not part of the elliptic curve?</strong></p>
<p>Also, all these articles says that we can get a negation of some point by doing <code>- private_key * G</code>. Since the private key for the <code>(3, 2)</code> is <code>10</code>, they say that we should just use <code>-10</code> and <code>-10 * (2, 4)</code> to get <code>(3, 9)</code>.</p>
<p><strong>2. If we know that the public key is a result of adding G point to itself private key number of times, how is it possible to apply addition with a negative number, that is, in the example, to add G to itself <code>-10</code> times?</strong></p>

<secp256k1><elliptic-curve>
What is the relationship between parity and the sign of the points on the elliptic curve?
LeaBit
# What is the relationship between parity and the sign of the points on the elliptic curve?

(Asked by: username_0 on 2023-11-12)

EDIT: I found out that the answer on the second question is just to do `10 * -G`, that is, `10 * G(X, -Y)` instead of `-10 * G`. However, I still do not understand relation between parity and the sign of the point.

I know that a private key is some random 256 bit number, which multiplied with G (generator point), gives a public key (a point on the curve). Multiplication denotes adding G point to itself private key number of times. For every X coordinate, 2 Y coos exist, **EVEN** and **ODD**. Also, these two point are negations of each other, so `(X, Yeven) + (X, Yodd) = Inf` and `(X, Yodd) + (X, Yeven) = Inf`.

For example, in the elliptic curve:

```
a=2
b=4
p=11
G=(2, 4) 

```

... for the point `(3, 2)` the negation is `(3, 9)` and vice versa. Also, `(3, 2) + (3, 9) = Inf` and `(3, 9) + (3, 2)= Inf`.

This is completely clear to me because in the equation for adding two points of the elliptic curve, in this case we will get below `/` zero (0), so division will not be possible, and the result is `Inf`.

However, in many articles I see that they talk about **POSITIVE** and **NEGATIVE** Y coordinate, not even and odd.

According to them, there exists pair of points `(X, Y) (X, -Y)` and, from it, the equations `(X, Y) + (X, -Y) = Inf` and `(X, -Y) + (X, Y) = Inf`. That is, for every `(X, Y)` exist its negation `-(X,Y) = (X,Y)`.

So in the previous example, for the point `(3, 2)` exists `-(3, 2) = (3, -2)` and an equations `(3, 2) + (3, -2) = Inf` and `(3, -2) + (3, 2) = Inf`.

This makes no sense to me because the point (3, -2) is not part of the elliptic curve at all and elliptic curve is only "in the context" of the positive numbers.

**1. How is it possible? What is the relationship between parity and the signs of points on an elliptic curve? Should I use the -Y point in the addition equation even if it is not part of the elliptic curve?**

Also, all these articles says that we can get a negation of some point by doing `- private_key * G`. Since the private key for the `(3, 2)` is `10`, they say that we should just use `-10` and `-10 * (2, 4)` to get `(3, 9)`.

**2. If we know that the public key is a result of adding G point to itself private key number of times, how is it possible to apply addition with a negative number, that is, in the example, to add G to itself `-10` times?**

**Tags:** secp256k1, elliptic-curve


---

## 1 answers

### Answer by username_1 on 2023-11-12. Score: 3 | Accepted answer

**First some background**

The X and Y coordinates of an elliptic curve are *not* integers. They are elements of a finite field. In secp256k1, that is the modulo *p = 2256-232-977* field. In your example, that is the modulo *p = 11* field. Elliptic curves over different fields are also possible, including ones which don't even *look* like integers.

In these modulo fields, many standard arithmetic operations have a different meaning. Addition, subtraction, and multiplication are performed following a modulo *p* step. I think you understand this already, but miss that it also applies to constants. *-2* is the negation of *2*, which modulo *p = 11*, equals *9*. Thus, *(3, -2)* very much lies on your curve, as it's just another way of writing *(3, 9)*. Note that our choice of treating *[0, 1, ..., 10]* as the "right" way of representing these field elements is also just a convention - there is nothing special about this choice. All elliptic curve formulas work just fine with the other representations too.

It goes further, though. Division in the field modulo *p* isn't anything like integer division. Given the fact that for example *3×8 = 24 = 2 (mod 11)*, and division is the reverse operation of multiplication is division, it has to hold that *2/8 = 3 (mod 11)*, and *2/3 = 8 (mod 11)*, but from an integer perspective, *2* is clearly not divisible by *3*. The answer is that division modulo *p* is actually multiplication with the [modular inverse](https://en.wikipedia.org/wiki/Modular_multiplicative_inverse). Similarly square roots are also nothing like normal square roots, but become [modular square roots](https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm) (the reverse operation of squaring).

Why do people use the same terms/symbols for things like negation, multiplication, division, square roots, if they're nothing like the "normal" ones? Because for abstract mathematics, it actually doesn't matter what field one works on, or what these exact operations correspond to. Elliptic curves can be defined over *any* field, and their equations, addition formulas, properties, ... generally hold over all or many of them. This abstraction means mathematicians can describe these curves just once, and then one can instantiate them for whatever field one likes, as long as one uses whatever these operations mean for the chosen field.

**So what do the terms "positive" and "negative" refer to?**

If *-2* and *9* are the same thing modulo 11, we clearly can't use this fact to call some numbers positive or negative. *Every* field element has both positive and negative integer representatives (infinitely many even, because *-2* is also equal to *-13*, *-24*, *-35*, or to *20*, *31*, *42*, ...).

The truth is, there just doesn't exist a well-defined "positive" and "negative" for modulo fields. However, it turns out that it's still useful to pick some definition, in analogy with integers or real numbers, so that one can make statements like "for a given X coordinate on the curve there are two Y coordinates - one positive and one negative". The reality is that it doesn't really matter how one chooses this - it's just a convention - as long as it holds that negating a (nonzero) positive element gives a negative element, and vice versa.

There are many different possible choices for these, and all are used in some context(s):

* Call a field element positive, if when represented as an integer in range *[0, p-1]* it is smaller than *p/2*, and negative if above *p/2*. Modulo *11* this means *[1, 2, 3, 4, 5]* are positive, and *[6, 7, 8, 9, 10]* are negative. This also means that *20 = 9 = -2 = -13* is negative, and *14 = 3 = -8 = -19* is positive.
* Call a field element positive, if when represented as an integer in range *[0, p-1]* it is odd, and negative if even. Modulo *11* this means *[1, 3, 5, 7, 9]* are positive and *[2, 4, 6, 8, 10]* are negative. In this case, sign and parity are basically the same thing.
* Call a field element positive if it has a square root, and negative if it doesn't. (this only works if *p mod 4 = 3*). Modulo *11* this means *[1, 3, 4, 5, 9]* are positive and *[2, 6, 7, 8, 10]* are negative.

Picking a different definition will result in different field elements being called positive and negative, but for all of them, it will be the case that among the two Y coordinates for a given X coordinate on the curve, one will be positive and one will be negative.

So: pick whatever definition you like.

**Back to your questions**

> What is the relationship between parity and the signs of points on an elliptic curve?

If you pick parity *as sign*, then they are the same thing. If you don't, they're really unrelated.

> Should I use the -Y point in the addition equation even if it is not part of the elliptic curve?

It is part of the curve. If *(X, Y)* is on the curve, then so is *(X, -Y)*, if one takes into account that that negation sign is the field's negation operation, which isn't necessarily the same as integer negation. Specifically, for modulo *p* fields, *-Y = p-Y*.

> If we know that the public key is a result of adding G point to itself private key number of times, how is it possible to apply addition with a negative number, that is, in the example, to add G to itself -10 times?

Adding *G* to itself -10 times is the same as adding *(-G)* to itself 10 times. Alternatively, you can compute it by first adding *G* to itself 10 times, and then negating the result. It's also equivalent to subtracting *G* 10 times from the point at infinity (where point subtraction is the same as point addition with negation of the operand).

There is a third option, by taking into account that G is a generator for the elliptic curve group, which has order *n* (for your small curve, *n=17*). This means that every 17 additions of *G* you loop around (or, put otherwise, *17×G = Inf*). This means that going backwards 10 times is the same as going forward 7 times, and *(-10)×G = 7×G*, or more generally, *(-a)×G = (n-a)×G*.


---

