Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: RentGPU on September 17, 2017, 05:03:40 PM



Title: Compressed and uncompressed
Post by: RentGPU on September 17, 2017, 05:03:40 PM
Sorry for my newbie question , actually there is 2 questions.
First, does the prefix (02 or 03) of the compressed publickey point refer to it's position of the x-axis up or down ,postive or negative?

Second, can i get the compressed publickey point from an uncompressed publickey point without knowing it's private key, if yes is there a site or software can do this for me?....thx alot.


Title: Re: Compressed and uncompressed
Post by: achow101 on September 17, 2017, 05:35:09 PM
Sorry for my newbie question , actually there is 2 questions.
First, does the prefix (02 or 03) of the compressed publickey point refer to it's position of the x-axis up or down ,postive or negative?
It refers to the position on the y-axis. Specifically 0x02 is used to indicate that the y value is even and 0x03 is used to indicate that it is odd.

Second, can i get the compressed publickey point from an uncompressed publickey point without knowing it's private key, if yes is there a site or software can do this for me?....thx alot.
Yes, you can. In fact all compressed public keys are actually computed from the uncompressed public key as the uncompressed public key is the one that is actually derived.

What kind of software are you looking for?


Title: Re: Compressed and uncompressed
Post by: RentGPU on September 17, 2017, 05:37:54 PM
Sorry for my newbie question , actually there is 2 questions.
First, does the prefix (02 or 03) of the compressed publickey point refer to it's position of the x-axis up or down ,postive or negative?
It refers to the position on the y-axis. Specifically 0x02 is used to indicate that the y value is even and 0x03 is used to indicate that it is odd.

Second, can i get the compressed publickey point from an uncompressed publickey point without knowing it's private key, if yes is there a site or software can do this for me?....thx alot.
Yes, you can. In fact all compressed public keys are actually computed from the uncompressed public key as the uncompressed public key is the one that is actually derived.

What kind of software are you looking for?
An online site that can convert uncompressed point to it's compressed one , script or something


Title: Re: Compressed and uncompressed
Post by: DannyHamilton on September 17, 2017, 06:16:26 PM
An online site that can convert uncompressed point to it's compressed one , script or something

There really isn't any "conversion" to do.

An uncompressed point has an x-coordinate and a y-coordinate. To get the compressed value, just throw away the y-coordinate, and add the appropriate (02 or 03) prefix.


Title: Re: Compressed and uncompressed
Post by: RentGPU on September 17, 2017, 07:08:40 PM
An online site that can convert uncompressed point to it's compressed one , script or something

There really isn't any "conversion" to do.

An uncompressed point has an x-coordinate and a y-coordinate. To get the compressed value, just throw away the y-coordinate, and add the appropriate (02 or 03) prefix.
Thats in order to convert uncompressed to compressed what i need is the opposite , or in other words how i know the right prefix 02 or 03


Title: Re: Compressed and uncompressed
Post by: achow101 on September 17, 2017, 07:30:45 PM
Thats in order to convert uncompressed to compressed what i need is the opposite , or in other words how i know the right prefix 02 or 03
No, that's exactly what you asked, to convert uncompressed pubkey to compressed one. Just look at the last digit of the y value (last 32 bytes of pubkey) and see if that is an even or odd digit. If it is even, the prefix byte is 0x02. If it is odd, the prefix byte is 0x03.


Title: Re: Compressed and uncompressed
Post by: DannyHamilton on September 17, 2017, 07:38:00 PM
how i know the right prefix 02 or 03

If you know the uncompressed?

Look at the value of the y-coordinate.  If the last digit is an odd number (1, 3, 5, 7, 9) then use a prefix of "03". If it is not an odd number (0, 2, 4, 6, 8 ) then use a prefix of "02"

Here's an example:

Uncompressed public key (prefix in black, x-value in blue, y-value in red):
04890821F2C9C8A01DDD5C019E75FD6D46D41D4575047CDEDD7946AA56EAE01A80FCA0ABC7E90526EB41EA6A9E4C6FA0A9FCED8DCF7E25FCD46509FFF2BD5088B8

Notice that the final digit of the red portion (y-value) is 8. So, we throw away that red portion, and change the prefix from 04 (uncompressed) to 02 (compressed/even):
02890821F2C9C8A01DDD5C019E75FD6D46D41D4575047CDEDD7946AA56EAE01A80



Here's another example:

Uncompressed public key (prefix in black, x-value in blue, y-value in red):
041C2E319C3F82FE654A77B6DF323166E1D771974B64CEF70F5AB97EAC9DA1A7CCDC44D9E9E893B53C9968C3D41EF20356484243530027456BFCF1AD97AC223839

Notice that the final digit of the red portion (y-value) is 9. So, we throw away that red portion, and change the prefix from 04 (uncompressed) to 03 (compressed/odd):
031C2E319C3F82FE654A77B6DF323166E1D771974B64CEF70F5AB97EAC9DA1A7CC


There really isn't any "conversion" to do.

An uncompressed point has an x-coordinate and a y-coordinate. To get the compressed value, just throw away the y-coordinate, and add the appropriate (02 or 03) prefix.
Thats in order to convert from uncompressed to compressed

Correct.  That's what you asked for, twice.

See here:

can i get the compressed publickey point from an uncompressed publickey point without knowing it's private key

An online site that can convert uncompressed point to it's compressed one


Title: Re: Compressed and uncompressed
Post by: RentGPU on September 17, 2017, 07:53:38 PM
how i know the right prefix 02 or 03

If you know the uncompressed?

Look at the value of the y-coordinate.  If the last digit is an odd number (1, 3, 5, 7, 9) then use a prefix of "03". If it is not an odd number (0, 2, 4, 6, 8 ) then use a prefix of "02"

Here's an example:

Uncompressed public key (prefix in black, x-value in blue, y-value in red):
04890821F2C9C8A01DDD5C019E75FD6D46D41D4575047CDEDD7946AA56EAE01A80FCA0ABC7E90526EB41EA6A9E4C6FA0A9FCED8DCF7E25FCD46509FFF2BD5088B8

Notice that the final digit of the red portion (y-value) is 8. So, we throw away that red portion, and change the prefix from 04 (uncompressed) to 02 (compressed/even):
02890821F2C9C8A01DDD5C019E75FD6D46D41D4575047CDEDD7946AA56EAE01A80



Here's another example:

Uncompressed public key (prefix in black, x-value in blue, y-value in red):
041C2E319C3F82FE654A77B6DF323166E1D771974B64CEF70F5AB97EAC9DA1A7CCDC44D9E9E893B53C9968C3D41EF20356484243530027456BFCF1AD97AC223839

Notice that the final digit of the red portion (y-value) is 9. So, we throw away that red portion, and change the prefix from 04 (uncompressed) to 03 (compressed/odd):
031C2E319C3F82FE654A77B6DF323166E1D771974B64CEF70F5AB97EAC9DA1A7CC


There really isn't any "conversion" to do.

An uncompressed point has an x-coordinate and a y-coordinate. To get the compressed value, just throw away the y-coordinate, and add the appropriate (02 or 03) prefix.
Thats in order to convert from uncompressed to compressed

Correct.  That's what you asked for, twice.

See here:

can i get the compressed publickey point from an uncompressed publickey point without knowing it's private key

An online site that can convert uncompressed point to it's compressed one
I got it now thanks alot for the detailed answer.