Bitcoin Forum
May 07, 2024, 03:51:25 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Calculationg public key from coordinates  (Read 223 times)
fenidik (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
July 03, 2018, 09:46:41 AM
 #1

Could anyone help me to realize how to get valid pub key from elliptic curve coordinates?

I get public key coordinates (secp256k1) from hsm device, but I dont understand how to convert these coordinates to pair of  32 hex characters.

"x": "2MDjyVEULe+IJaALKcF1Hon+wbJn7bgklVQq+7Y5WY8=",
"y": "VPdchhpNDZ3efVNVfVpzwn1/FRju4+tjBTWTdOMiXZ0="
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715097085
Hero Member
*
Offline Offline

Posts: 1715097085

View Profile Personal Message (Offline)

Ignore
1715097085
Reply with quote  #2

1715097085
Report to moderator
1715097085
Hero Member
*
Offline Offline

Posts: 1715097085

View Profile Personal Message (Offline)

Ignore
1715097085
Reply with quote  #2

1715097085
Report to moderator
1715097085
Hero Member
*
Offline Offline

Posts: 1715097085

View Profile Personal Message (Offline)

Ignore
1715097085
Reply with quote  #2

1715097085
Report to moderator
fenidik (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
July 03, 2018, 01:12:25 PM
 #2

to start the discussion I want to add some thoughts

this HSM coordinates otput is a part of JSON Web Key (https://tools.ietf.org/html/rfc7517)

Link below describes that "integers are represented using the base64url encoding of their big-endian representations"

But it's confusing. Cause "2MDjyVEULe+IJaALKcF1Hon+wbJn7bgklVQq+7Y5WY8=" looks like base64, not base64url.
fenidik (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
July 03, 2018, 01:54:52 PM
 #3

twimc

I just made base64 decode and encode to hex.  Seems correct

Code:
import base64

x='taf/47/9zBBq1OV+VjtCM3koD0Mav3hrrP0K8ux9Gjk='
y='dg4pB3+BrqyiFQ5HKVBUDw/lcQPrsZ3/ecLvO2dpckc='
print('04'+str(base64.b64decode(x).encode("hex"))+str(base64.b64decode(y).encode("hex")))

output: 04b5a7ffe3bffdcc106ad4e57e563b423379280f431abf786bacfd0af2ec7d1a39760e29077f81a eaca2150e472950540f0fe57103ebb19dff79c2ef3b67697247
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!