Bitcoin Forum
November 15, 2024, 03:16:51 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Calculationg public key from coordinates  (Read 233 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="
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!