2
base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,176);

I need prefix L , but i cannot find how do this, please do not post link to prefix list bitcoin , it's only for address prefix.

i search all google end find noting.

2
  • Are you creating your own currency, or are you trying to find the value for an existing one? In the former case, set it to whatever you like. Sep 24, 2017 at 23:32
  • did you ever figure this out?
    – tofutim
    Apr 5, 2018 at 21:33

2 Answers 2

2

Addresses and private keys are encoded using Base58Check Encoding. The prefix bytes are chosen such that once whatever you are encoding is actual encoded with Base58Check Encoding, you will end up with a string that has the intended prefix character.

The process of creating a Base58Check encoded string is described on the bitcoin wiki:

A Base58Check string is created from a version/application byte and payload as follows.

  1. Take the version byte and payload bytes, and concatenate them together (bytewise).
  2. Take the first four bytes of SHA256(SHA256(results of step 1)) 3.Concatenate the results of step 1 and the results of step 2 together (bytewise).
  3. Treating the results of step 3 - a series of bytes - as a single big-endian bignumber, convert to base-58 using normal mathematical steps (bignumber division) and the base-58 alphabet described below. The result should be normalized to not have any leading base-58 zeroes (character '1').
  4. The leading character '1', which has a value of zero in base58, is reserved for representing an entire leading zero byte, as when it is in a leading position, has no value as a base-58 symbol. There can be one or more leading '1's when necessary to represent one or more leading zero bytes. Count the number of leading zero bytes that were the result of step 3 (for old Bitcoin addresses, there will always be at least one for the version/application byte; for new addresses, there will never be any). Each leading zero byte shall be represented by its own character '1' in the final result.
  5. Concatenate the 1's from step 5 with the results of step 4. This is the Base58Check result.

The resulting prefix character is also dependent on the size of the data being encoded.

The only way to get a prefix byte that you want to use that has a specific character is to guess and check. The data you are encoding must be of a fixed length, and even when it is, you may still end up with multiple possible prefix characters for a given prefix byte.

A list of prefix values and the characters they produce for 20 byte values are also available on the bitcoin wiki

0
1

hmm, not sure what you are asking. Normally you have a private key in hex chars. When you do a base58 encoding, you use hex 0x80 as prefix, which results in "K" or "L" at the beginning of the so called WIF compressed key (wallet interchange format). It would be "5" for a normal WIF key. If this is what you are looking for, you may read up (online available) the chapter http://chimera.labs.oreilly.com/books/1234000001802/ch04.html#private_public_keys from Andreas' book "Mastering Bitcoin".

1
  • 2
    litecoin have 176 but how they get this, a ask where find the list of prefix for this key , or how convert L to hex end to decimal for find what value need :/ all altcoin have different privat key prefixes... But how create it no explaining , not list of baseprefix how for address.
    – tseries
    Jul 26, 2017 at 18:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.