# Scalar Multiplication using NAF method

I am learning about Elliptic curve scalar multiplications and I am on NAF, and I am trying to figure out the concept.

What I understand is if I have K=27 with using NAF the binary looks like this 100-10-1 then the scalar multiplication process like this: 2(2(2(2(2P))-P))-P which is 5DBL and 2ADD.

My questions is if want to scalar K=27 it means the steps like this:

1- 2P (0 bit)

2- 4P (0 bit)

3- 8P-P=7P (-1 bit)

4- 14P (0 bit)

5- 28P-P=27P (-1 bit)

My issue is how can I calculate 28P then minus one P and my group only 27P my group is like this:

 1     3    10
2     7    12
3    19     5
4    17     3
5     9    16
6    12     4
7    11     3
8    13    16
9     0     1
10     6     4
11    18    20
12     5     4
13     1     7
14     4     0
15     1    16
16     5    19
17    18     3
18     6    19
19     0    22
20    13     7
21    11    20
22    12    19
23     9     7
24    17    20
25    19    18
26     7    11
27     3    13




My issue is how can I calculate 28P then minus one P
The issue that appears to be confusing you is that the order of the curve you picked happens to be 28, and hence 28P happens to be the "point at infinity", which does not correspond to any specific $$(x, y)$$ coordinates.
In spite of that, it is a well defined 'point' (even if it's not a solution to the curve equation), with well defined addition and subtraction operations; if we designate $$I$$ as the point at infinity, then we have $$I+X = X+I = X-I = X$$ and $$I-X = -X$$, for any point $$X$$.
• Actually I modified a code in Matlab, but can i resolve it in matlab code if reached to Infinity then instead of 14P doubling then make 13P doubling = 26P+P=27P` ? What is EC library I can use it in matlab to resolve the issue? Apr 24, 2023 at 20:22