# Compute EC_KEY starting from X or Y coordinate only

Luca Di Mauro luca.dimauro at cnit.it
Fri Oct 25 11:39:24 UTC 2019

```But the y bit is indicated by the foutth parameter of
'EC_POINT_set_compressed_coordinates_GFp' function.
previously?

Luca

Thulasi Goriparthi <thulasi.goriparthi at gmail.com> ha scritto:

> 02 indicates y bit is 0
> 03 indicates y bit is 1
>
>
>
> Thanks,
> Thulasi.
>
> On Fri, 25 Oct 2019 at 16:50, Luca Di Mauro <luca.dimauro at cnit.it> wrote:
>
>>
>> Mh, maybe I didn't understand.
>>
>> If I have an x-point which follows this representation
>> https://tools.ietf.org/id/draft-jivsov-ecc-compact-05.html (so it is
>> composed by 33 byte and first byte is '0x02') and I use
>> 'EC_POINT_set_compressed_coordinates_GFp' function, it will be
>> considered as compressed-y-0 or compressed-y-1? Or it is correctly
>> considered as the x coordinate?
>>
>> Luca
>>
>> Billy Brumley <bbrumley at gmail.com> ha scritto:
>>
>> >> Thank you! I thought they were the same.
>> >>
>> >> And given an x-only coordinate, how can I find the y coordinate? I
>> >> don't find the relative functions on the documentation.
>> >
>> > Well it depends on what you mean. Internally,
>> > EC_POINT_set_compressed_coordinates_GFp will internally automatically
>> > compute the y coordinate based on the y_bit argument.
>> >
>> > EC_POINT_set_compressed_coordinates_GFp(group, p, x, 0, ...
>> > EC_POINT_get_affine_coordinates_GFp(group, p, X0, Y0 ...
>> >
>> > That will get you one of the points in X0, Y0.
>> >
>> > EC_POINT_set_compressed_coordinates_GFp(group, p, x, 1, ...
>> > EC_POINT_get_affine_coordinates_GFp(group, p, X1, Y1 ...
>> >
>> > That will get you the other point in X1, Y1. (Where X0 = X1 = x.)
>> >
>> > (But you are probably looking to do something cryptographically
>> > interesting between set/get, which is application specific.)
>> >
>> > Generally, in addition to the man pages which you seem to have found,
>> > check the "tests" folder if you are looking for examples to get
>> > started.
>> >
>> > BBB
>>
>>
>>
>>

```