Base 58 Encoding

From Bitcoin Wiki
Revision as of 13:56, 30 June 2011 by TierNolan (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Base 58 Encoding

Base 58 encoding is used for encoding addresses.

Address = Base58Encode(RIPEMD160(SHA-256(public key))

The public key is expressed as an encoded point.

Code Character Code Character Code Character Code Character
0 1 1 2 2 3 3 4
4 5 5 6 6 7 7 8
8 9 9 A 10 B 11 C
12 D 13 E 14 F 15 G
16 H 17 J 18 K 19 L
20 M 21 N 22 P 23 Q
24 R 25 S 26 T 27 U
28 V 29 W 30 X 31 Y
32 Z 33 a 34 b 35 c
36 d 37 e 38 f 39 g
40 h 41 i 42 j 43 k
44 m 45 n 46 o 47 p
48 q 49 r 50 s 51 t
52 u 53 v 54 w 55 x
56 y 57 z

The algorithm for encoding is

   code_string = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
   x = convert_bytes_to_big_integer(hash_result)
   
   output_string = ""
   
   while(x > 0) 
       {
           (x, remainder) = divide(x, 58)
           output_string.append(output_string[remainder])
       }
   
   repeat(number_of_leading_zeros_in_hash)
       {
       output_string.append(output_string[0]);
       }
   
   output_string.reverse();

Source

https://github.com/bitcoin/bitcoin/blob/master/src/base58.h