address.rst
1 Address 2 ======= 3 4 Bitmessage adresses are Base58 encoded public key hashes. An address looks like 5 ``BM-BcbRqcFFSQUUmXFKsPJgVQPSiFA3Xash``. All Addresses start with ``BM-``, 6 however clients should accept addresses without the prefix. PyBitmessage does 7 this. The reason behind this idea is the fact, that when double clicking on an 8 address for copy and paste, the prefix is usually not selected due to the dash 9 being a common separator. 10 11 Public Key usage 12 ---------------- 13 14 Addresses may look complicated but they fulfill the purpose of verifying the 15 sender. A Message claiming to be from a specific address can simply be checked by 16 decoding a special field in the data packet with the public key, that represents 17 the address. If the decryption succeeds, the message is from the address it 18 claims to be. 19 20 Length 21 ------ 22 23 Without the ``BM-`` prefix, an address is usually 32-34 chars long. Since an 24 address is a hash it can be calculated by the client in a way, that the first 25 bytes are zero (``\0``) and bitmessage strips these. This causes the client to do 26 much more work to be lucky and find such an address. This is an optional checkbox 27 in address generation dialog. 28 29 Versions 30 -------- 31 32 * v1 addresses used a single RSA key pair 33 * v2 addresses use 2 ECC key pairs 34 * v3 addresses extends v2 addresses to allow specifying the proof of work 35 requirements. The pubkey object is signed to mitigate against 36 forgery/tampering. 37 * v4 addresses protect against harvesting addresses from getpubkey and pubkey 38 objects 39 40 Address Types 41 ------------- 42 43 There are two address types the user can generate in PyBitmessage. The resulting 44 addresses have no difference, but the method how they are created differs. 45 46 Random Address 47 ^^^^^^^^^^^^^^ 48 49 Random addresses are generated from a randomly chosen number. The resulting 50 address cannot be regenerated without knowledge of the number and therefore the 51 keys.dat should be backed up. Generating random addresses takes slightly longer 52 due to the POW required for the public key broadcast. 53 54 Usage 55 """"" 56 57 * Generate unique addresses 58 * Generate one time addresses. 59 60 61 Deterministic Address 62 ^^^^^^^^^^^^^^^^^^^^^ 63 64 For this type of Address a passphrase is required, that is used to seed the 65 random generator. Using the same passphrase creates the same addresses. 66 Using deterministic addresses should be done with caution, using a word from a 67 dictionary or a common number can lead to others generating the same address and 68 thus being able to receive messages not intended for them. Generating a 69 deterministic address will not publish the public key. The key is sent in case 70 somebody requests it. This saves :doc:`pow` time, when generating a bunch of 71 addresses. 72 73 Usage 74 """"" 75 76 * Create the same address on multiple systems without the need of copying 77 keys.dat or an Address Block. 78 * create a Channel. (Use the *Join/create chan* option in the file menu instead) 79 * Being able to restore the address in case of address database corruption or 80 deletation. 81 82 Address generation 83 ------------------ 84 85 1. Create a private and a public key for encryption and signing (resulting in 86 4 keys) 87 2. Merge the public part of the signing key and the encryption key together. 88 (encoded in uncompressed X9.62 format) (A) 89 3. Take the SHA512 hash of A. (B) 90 4. Take the RIPEMD160 of B. (C) 91 5. Repeat step 1-4 until you have a result that starts with a zero 92 (Or two zeros, if you want a short address). (D) 93 6. Remove the zeros at the beginning of D. (E) 94 7. Put the stream number (as a var_int) in front of E. (F) 95 8. Put the address version (as a var_int) in front of F. (G) 96 9. Take a double SHA512 (hash of a hash) of G and use the first four bytes as a 97 checksum, that you append to the end. (H) 98 10. base58 encode H. (J) 99 11. Put "BM-" in front J. (K) 100 101 K is your full address 102 103 .. note:: Bitmessage's base58 encoding uses the following sequence 104 (the same as Bitcoin's): 105 "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz". 106 Many existing libraries for base58 do not use this ordering.