Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: streamplus on May 06, 2018, 06:05:22 PM



Title: How the Bitcoin Private pubkey prefix is generated ?
Post by: streamplus on May 06, 2018, 06:05:22 PM
Hi,

I noticied that bitcoin private contain two bytes !

Code:
        // guarantees the first 2 characters, when base58 encoded, are "b1"
        base58Prefixes[PUBKEY_ADDRESS]     = {0x13,0x25};
        // guarantees the first 2 characters, when base58 encoded, are "bx"
        base58Prefixes[SCRIPT_ADDRESS]     = {0x13,0xAF};
        // the first character, when base58 encoded, is "5" or "K" or "L" (as in Bitcoin)
        base58Prefixes[SECRET_KEY]         = {0x80};
        // do not rely on these BIP32 prefixes; they are not specified and may change
        base58Prefixes[EXT_PUBLIC_KEY]     = {0x04,0x88,0xB2,0x1E};
        base58Prefixes[EXT_SECRET_KEY]     = {0x04,0x88,0xAD,0xE4};
        // guarantees the first 2 characters, when base58 encoded, are "zk"
        base58Prefixes[ZCPAYMENT_ADDRRESS] = {0x16,0xA8};
        // guarantees the first 2 characters, when base58 encoded, are "SK"
        base58Prefixes[ZCSPENDING_KEY] = {0xAB,0x36};

How is that calculated ?

Thank you in advance.


Title: Re: How the Bitcoin Private pubkey prefix is generated ?
Post by: shahzadafzal on May 06, 2018, 07:19:33 PM
Public key prefix yes but are there prefixes for private key too? I don't think so.

1 prefix is public key hash
3 prefix is a script hash

For public key prefix you can get idea from below

Quote
Bitcoin address is a Base58Check representation of a Hash160 of a public key with a version byte 0x00 which maps to a prefix "1". Typically represented as text (ex. 1CBtcGivXmHQ8ZqdPgeMfcpQNJrqTrSAcG) or as a QR code.

A more recent variant of an address is a P2SH address: a hash of a spending script with a version byte 0x05 which maps to a prefix "3" (ex. 3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8).


Ref: https://github.com/oleganza/CoreBitcoin/blob/master/GLOSSARY.md

You check here list of address prefixes: https://en.bitcoin.it/wiki/List_of_address_prefixes



Title: Re: How the Bitcoin Private pubkey prefix is generated ?
Post by: nc50lc on May 07, 2018, 03:24:22 AM
-snip-
I'm pretty sure that the OP is talking about an Altcoin: Bitcoin Private (BTCP).
Its addresses starts with "b1" prefix.
Code:
        // guarantees the first 2 characters, when base58 encoded, are "b1"
        base58Prefixes[PUBKEY_ADDRESS]     = {0x13,0x25};

@streamplus
This forum is for Bitcoin development, you can move this to Altcoin Discussion to look for the accurate answers from BTCP users and developers.


Title: Re: How the Bitcoin Private pubkey prefix is generated ?
Post by: akaltcoins on December 11, 2020, 08:27:34 PM
I'm pretty sure that the OP is talking about an Altcoin: Bitcoin Private (BTCP).
Its addresses starts with "b1" prefix.
Code:
        // guarantees the first 2 characters, when base58 encoded, are "b1"
        base58Prefixes[PUBKEY_ADDRESS]     = {0x13,0x25};

@streamplus
This forum is for Bitcoin development, you can move this to Altcoin Discussion to look for the accurate answers from BTCP users and developers.


I know that this post has been dormant for a long time but I keep seeing references to the Wiki List of Prefixes but I can't find anywhere that actually spells out why "b1" = {0x13,0x25}.  From the table on that page I can see that 'b' corresponds to a decimal value of 84 or 85 and '1' has a decimal value of 0.  How does that become {0x13,0x25}?

Crown, for example, start with CRW and uses (0x01)(0x75)(0x07) in their chainparams to describe this I just can't figure out why the following is true:

C = (0x01)
R = (0x75)
W = (0x07)


Title: Re: How the Bitcoin Private pubkey prefix is generated ?
Post by: nc50lc on December 12, 2020, 08:14:31 AM
Honestly, I have no idea how that Altcoin derive an address from its public key. But it looks like they are using the same "base58 encoding" just like BTC.
So, in order to make the address start with "b1", a coin needs to add a prefix to whatever data was encoded.

Example: We want to derive an address from the "hash160" of a public key:
Code:
f54a5851e9372b87810a8e60cdd2e7cfd80b6e31
Now, those 0x13 & 0x25 need to be added as a prefix in order to get an address that starts with "b1":
Code:
1325f54a5851e9372b87810a8e60cdd2e7cfd80b6e31
skipping the other non-topic-related stuffs & to shorten the post, here it is with a checksum:
Code:
1325f54a5851e9372b87810a8e60cdd2e7cfd80b6e31c0fa2051
Lastly, encode it to Base58 (test it online (https://incoherency.co.uk/base58/)), you'll get: b1SqBHmTn3jUx5DdQgjNVmjqTy9GBiN6ABJ

Note: Better move this to Altcoin board for them (BTCP devs and experts) to provide the proper answers.