Bitcoin Forum
July 03, 2024, 10:29:44 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How the Bitcoin Private pubkey prefix is generated ?  (Read 252 times)
streamplus (OP)
Newbie
*
Offline Offline

Activity: 107
Merit: 0


View Profile
May 06, 2018, 06:05:22 PM
 #1

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.
shahzadafzal
Copper Member
Legendary
*
Offline Offline

Activity: 1596
Merit: 2984



View Profile
May 06, 2018, 07:19:33 PM
 #2

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


█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
nc50lc
Legendary
*
Offline Offline

Activity: 2464
Merit: 5763


Self-proclaimed Genius


View Profile
May 07, 2018, 03:24:22 AM
Last edit: May 07, 2018, 06:24:43 AM by nc50lc
 #3

-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.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
akaltcoins
Newbie
*
Offline Offline

Activity: 18
Merit: 0


View Profile
December 11, 2020, 08:27:34 PM
 #4

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)
nc50lc
Legendary
*
Offline Offline

Activity: 2464
Merit: 5763


Self-proclaimed Genius


View Profile
December 12, 2020, 08:14:31 AM
Merited by ABCbits (1), NotATether (1)
 #5

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), you'll get: b1SqBHmTn3jUx5DdQgjNVmjqTy9GBiN6ABJ

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

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
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!