210 похожих чатов

Does anyone know how to convert base58 private key to

hex?

13 ответов

18 просмотров

To convert a base58 private key to hex, you can use the following steps: Identify the version byte. The first byte of a base58 private key is the version byte, which indicates the network that the key is for. For example, the version byte for the mainnet Bitcoin network is 0x80. Remove the version byte. Once you have identified the version byte, you can remove it from the base58 private key. Convert the remaining bytes to hex. The remaining bytes of the base58 private key can be converted to hex by using a hex converter. Append the checksum. Once you have converted the remaining bytes to hex, you need to append a checksum to the end of the string. The checksum is calculated by taking the SHA-256 hash of the hex string and then taking the first four bytes of the hash. The result is the hex private key. The result of these steps is the hex private key.

Base58 private key: 5J5PZqvCe1uThJ3FZeUUFLCh2FuK9pZhtEK4MzhNmugqTmxCdwE Version byte: 0x80 Remaining bytes: 224b2d71866c35d3701f0fcdd7871cb191c2ae25068602759fcb9b59d9100e00 Checksum: 7ac24c81 Hex private key: 80224b2d71866c35d3701f0fcdd7871cb191c2ae25068602759fcb9b59d9100e007ac24c81

-Лис Автор вопроса
Simon | TRONIC | 🇬🇧
Base58 private key: 5J5PZqvCe1uThJ3FZeUUFLCh2FuK9p...

I think I understood the idea, but: TRX Address: TXXXxBvcn9XM4DG7Bhy3qc4ASr5SEqyLpp TRX Privkey: 12WDeSKSficyViwQZ2ap4na1tLdUDBVUSxMM3m1pCM8KB5Qcxi8 TRX Address: TXXXGFPPqUHy6X4kcD6gcyAqtjyozYsgqa TRX Privkey: 1oqSVtJJBpWKpRwpqeuSKvb7v39RwJYCdZQj6Fuw2hkg9Xipek They should have prefix "65" I decode 1st one: c60a08ba8e4e801ef945a45d08fc72447e643230b29fc507932b9fa6d7fe4ec077a540f5 2nd: 6a585030c6165409ed892b47b7b1df6f025fa8a25c4d73b0c64b70e53a889271aaf048b1 I don't see the same 1st byte and it's strange. Tronlink doesn't accept this as private key. However private key always has "1" upfront

 Лис
I think I understood the idea, but: TRX Address: ...

Are you sure that your private keys are base58check-encoded? If yes, then converting them to hex is most likely one-step process - base58check decode.

-Лис Автор вопроса
 Лис
yes

Then use any working base58check decoder. You should get result of 32 bytes (64 hex characters).

-Лис Автор вопроса
-Лис Автор вопроса
 Лис
I think I understood the idea, but: TRX Address: ...

I think it's point on curve, need to be converted to hex somehow, but it's not really b58

 Лис
it gives 72

You used base58 decoder, so need to remove the checksum (last 8 hex characters) manually. Base58check decoder would remove it for you automatically.

-Лис Автор вопроса
Augustus
You used base58 decoder, so need to remove the che...

I tried to remove, but it was another wallet, so it seems broken

 Лис
I tried to remove, but it was another wallet, so i...

Where did you get those base58-encoded private keys from? Which wallet application exports tron private keys in this format?

-Лис Автор вопроса
Augustus
Where did you get those base58-encoded private key...

old version of one software it was fixed in new version like this if (strncmp(ticker, "TRX", 3) == 0) { // For tron, output hex string for private key char *buf = BN_bn2hex(EC_KEY_get0_private_key(pkey)); strcpy(privkey_buf, buf); if (buf) OPENSSL_free(buf); } However this format is absolutely good for btc/eth I guess. But not for tron.

 Лис
old version of one software it was fixed in new ve...

Tron simply doesn't use base58 for encoding of private keys. But some applications, like your example, may export tron private keys in base58, in which case they need to be converted to hex to be usable in Tronlink (which I assume only supports private keys in hex format).

Похожие вопросы

Обсуждают сегодня

Карта сайта