1

I have a 32 byte hex private key: 081549973bafbba825b31bcc402a3c4ed8e3185c2f3a31c75e55f423e9629aa3

And I want to convert it to 32 byte hex Public Key according to https://learnmeabitcoin.com/technical/hd-wallets

To generate an Ethereum address, I need the Public Key code. enter image description here

I looked through all the Chilkat examples but couldn't find any code to convert it! But on the site https://lab.miguelmota.com/ethereum-private-key-to-public-key/example/ enter image description here

I was able to find that, unfortunately, it is written in Github with Json and I only know VB6: https://github.com/miguelmota/ethereum-private-key-to-public-key

Can you convert the code in GitHub to VB6 using Chilkat algorithms? And how can generate ethereum address from public key code?

thank you

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
M.A. ARD
  • 51
  • 4
  • For each elliptic curve you derive the public key from the private key by (scalar) multiplying with the base point G of the curve. Search for `scalar multiply secp256k1` in Chilkat documentation. Check out [this](https://www.vbforums.com/showthread.php?890063-VB6-secp256k1-library-generate-Bitcoin-keys) forum thread. – wqw Jul 14 '22 at 12:53
  • There is `PublicKeyFromPrivate` method in `CBTCGenerator.cls` which does exactly what you want to do in OP and the referenced project uses open source and popular `libsecp256k1` for the actual crypto not some bullsh*t components from Chilkat which will always remain closed source and unaudited. – wqw Jul 16 '22 at 11:20
  • This program does not work, for example, for the term secp256k1_pubkey, a function is not defined and unfortunately it is written completely incompletely . – M.A. ARD Jul 16 '22 at 11:26
  • You need to register `secp256k1vb.tlb` type library and place `libsecp256k1vb.dll` in the same folder as your executable or to use it from VB IDE place it in a folder from PATH (e.g. C:\Windows). Register `hashlibvb.tlb` too before opening the sample .vbp project file. Google "how to register typelib in VB6" if uncertain. – wqw Jul 16 '22 at 11:33
  • Dear friend I finally got it up and running but I'm having trouble with the "PublicKeyFromPrivate" function I want to convert a hex private key code to a hex public key, but the arguments of this function require 2 inputs, the first input is ByRef bPrivate() As Byte and the second input is ByRef bPublicOut() As Byte! As follows : Public Sub PublicKeyFromPrivate(ByRef bPrivate() As Byte, ByRef bPublicOut() As Byte) If I had the value of bPublicOut() As Byte, I would not seek to generate it! I just have the value of ByRef bPrivate() As Byte and I want to generate Public Key from it – M.A. ARD Jul 17 '22 at 05:37
  • 1
    There are FromRawHex/ToRawHex functions in the class which convert between byte-arrays and hex strings. You should prefer working with byte-arrays internally and convert to hex strings only for UI purposes i.e. display or input of keys to/from TextBox controls. – wqw Jul 17 '22 at 21:18

0 Answers0