Author

Topic: Base58 (Read 8196 times)

legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
August 08, 2011, 04:17:32 PM
#19
Yeah, because I have yet to find a way to convert it from base58 into a usable hex key like the ones stored in the wallet... At least to know what the result of such a conversion looks like, would already be a big help.

EDIT:
Code:
Hexprivkey: a7593394a809fe36b10fb3203480dd789fd12e771b07e3df50b37080714f1d2e

oh cool! are these two
6398247687543120230611217925528537819731860764507939242623555882076675375130382
and
a7593394a809fe36b10fb3203480dd789fd12e771b07e3df50b37080714f1d2e
the same?
I'm sure a7593394a809fe36b10fb3203480dd789fd12e771b07e3df50b37080714f1d2e is equivalent to 5K5zGnFRJAD3viw93hPQLq5Fa3xsLFGYC9yoGMcmVdS1CEaKYs7
If you are sure 5K5zGnFRJAD3viw93hPQLq5Fa3xsLFGYC9yoGMcmVdS1CEaKYs7 is equivalent to 6398247687543120230611217925528537819731860764507939242623555882076675375130382
Then yes they are the same

Allow me to inject some sanity into this adventure (although it is fun):

(1) An ECDSA private key is literally a random number, between 1 and slightly less than 2^256 (something like 0.999999999*(2^256))
(2) Any number greater than that range is identical to private key that is in in the range of (1)

Therefore, you can pick yourself a 4000-bit ECDSA key if you wanted, but there's an equivalent 256-bit key, and you might as well use that one because it's shorter.   

Speaking of this, I miscalculated in my previous post.  The maximum address size is actually 33 Base58 characters, so I shouldn't have given you a hard time about wanting to calculate 58^33.  Sorry!

-Eto


For those interested by the exact value: 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 is equivalent to 0, so [...]142 to 1, etc
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
August 08, 2011, 02:43:42 PM
#18
Allow me to inject some sanity into this adventure (although it is fun):

(1) An ECDSA private key is literally a random number, between 1 and slightly less than 2^256 (something like 0.999999999*(2^256))
(2) Any number greater than that range is identical to private key that is in in the range of (1)

Therefore, you can pick yourself a 4000-bit ECDSA key if you wanted, but there's an equivalent 256-bit key, and you might as well use that one because it's shorter.  

Speaking of this, I miscalculated in my previous post.  The maximum address size is actually 33 Base58 characters, so I shouldn't have given you a hard time about wanting to calculate 58^33.  Sorry!

-Eto

full member
Activity: 238
Merit: 100
August 08, 2011, 01:40:51 PM
#17
Yeah, because I have yet to find a way to convert it from base58 into a usable hex key like the ones stored in the wallet... At least to know what the result of such a conversion looks like, would already be a big help.

EDIT:
Code:
Hexprivkey: a7593394a809fe36b10fb3203480dd789fd12e771b07e3df50b37080714f1d2e

oh cool! are these two
6398247687543120230611217925528537819731860764507939242623555882076675375130382
and
a7593394a809fe36b10fb3203480dd789fd12e771b07e3df50b37080714f1d2e
the same?
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
August 08, 2011, 01:37:01 PM
#16
Pywallet says:
Code:
Address (Bitcoin): 1GPtKcQXVnayMz7fjyZnr89oVoFiCMTv2P
Privkey (Bitcoin): 5K5zGnFRJAD3viw93hPQLq5Fa3xsLFGYC9yoGMcmVdS1CEaKYs7
Hexprivkey: a7593394a809fe36b10fb3203480dd789fd12e771b07e3df50b37080714f1d2e

And Block Explorer says 'never used' Tongue
full member
Activity: 238
Merit: 100
August 08, 2011, 01:35:20 PM
#15
No! It's a real key, containing all my life savings (0).

5K5z GnFR JAD3 viw9 3hPQ Lq5F a3xs LFGY C9yo GMcm VdS1 CEaK Ys7

4 18 4 57-15 45 14 24-17 9 12 2-56 41 54 8-2 40 22 23-19 48 4 14-33 2 55 50-19 14 15 31-11 8 56 46-
15 20 35 44-28 36 25 0-11 13 33 18-31 50 6  

5935532256285717999993358604737352755352447108304822663869987597039882747861497 3660266496+
4605154336773401896546571331261739206738967584029603790933611066668874545754610 025365504+
1764426948955326397144280203548559083041750032195250494610578952746695228258471 2740864+
4335014486657482958501033258718442574714644475652124060034612082179380517704002 699264+
1966884975797406061025877159128149988527515642310401116168154302259247058849366 0160+
1017354297826244514323729565066284476824577056367448853190424639099610547680706 560+
5457072861903227279897399965872790297143325206568691166538676225055382248095744+
161292793947878638814701476823826314201280547977399738912473188917893071372288+
1969811420340471882076095622130062745274259565815945087293135209485763084288+
17980023106556031377976532047840329317919204961808829397199002926340636672+
413333864518529456964977748226214467078602412915145503383885124743462912+
1187740989995774301623499276512110537582190841710188228114612427423744+
573392202066925524921689305902398190556919716687677075641537033928704+
7238017329046781564590289883620174203458654059173263577987382509568+
164362041954804964040317768593561567277866828929922722124187828224+
419826416231941159745383827825189188449212845287158932628832256+
1809596621689401550626654430280987881246607091754995399262208+
623998835065310879526432562165857890085036928191377723883520+
5917230332515879029992032917090031716323626043194099105792+
106658540476383399443430060417767029369469748427479842816+
1519124639468729077530113304301029653688099865159008256+
66168768325316693032164644833438678200570593037778944+
95070069432926283092190581657239480173233610686464+
5736986948538655014183914410350658286315821334528+
233153410470167014123237900913265669271455793152+
243629478025252888321042738676348661725659136+
115513976649904386703942677820682555128545280+
1810563897333924556488129746405682682265600+
11862315189429160887336022476451024470016+
150700918921967561182127327287036608512+
2783883970233390908536834863676784640+
99195865606017377200737793993080832+
606871257878860483430542677377024+
7609670945189473146464484982784+
918408562350453655607782670336+
13007017816539676157006774272+
73127911262404476145090560+
1681101408331137382645760+
50722887320336041717760+
1099412336007283662848+
12062517793183363072+
267395714627217408+
3201577042950400+
0+
418755617984+
8532637984+
373444368+
3512016+
104284+
2900+
6

result: 6398247687543120230611217925528537819731860764507939242623555882076675375130382 4780494710

Now I only need to find a way to turn this into hex, and I'm done! YAY
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
August 08, 2011, 01:33:42 PM
#14
Btw, why do you need 58**33?  For bitcoin, most Base58 addresses are about 25 characters long.  This means, the biggest int you would need would be about 58**26

What do you mean? My favorite priv key, 5K5zGnFRJAD3viw93hPQLq5Fa3xsLFGYC9yoGMcmVdS1CEaKYs7, which I use everywhere, is 50 characters long! (more or less)
.
I bet it's a fake Grin
full member
Activity: 238
Merit: 100
August 08, 2011, 01:29:03 PM
#13
Btw, why do you need 58**33?  For bitcoin, most Base58 addresses are about 25 characters long.  This means, the biggest int you would need would be about 58**26

What do you mean? My favorite priv key, 5K5zGnFRJAD3viw93hPQLq5Fa3xsLFGYC9yoGMcmVdS1CEaKYs7, which I use everywhere, is 50 characters long! (more or less)
.
kjj
legendary
Activity: 1302
Merit: 1026
August 08, 2011, 09:51:27 AM
#12
lol! how am I supposed to calculate 51 * 58^33 ??

Use BC.

Code:
root@inana:~# bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
51 * 58^33
795598514708271371396201516761468809858422083444006597951488

It is in POSIX, so libraries can be found for just about any language or platform.  Here is a PHP example:

Code:
root@inana:~# cat b58.php
echo bcmul("51",bcpow("58","33"))."\n";
?>

root@inana:~# php -q b58.php
795598514708271371396201516761468809858422083444006597951488
root@inana:~#
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
August 08, 2011, 08:47:08 AM
#11
If you're doing it in Python, you just "58**33" since it can handle arbitrarily large integers.   If you're doing it in another language such as C++, there is no native integer representation larger than 64-bits, so you have need a special class.  I believe the OpenSSL C++ library uses a "bignum" class, or you can google for a open-source solutions, such as this one. There will be an option somewhere ,for just about every language...

Btw, why do you need 58**33?  For bitcoin, most Base58 addresses are about 25 characters long.  This means, the biggest int you would need would be about 58**26
full member
Activity: 238
Merit: 100
August 08, 2011, 08:23:11 AM
#10
lol! how am I supposed to calculate 51 * 58^33 ??
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
August 07, 2011, 02:11:01 PM
#9

46736 = index('E') * 58^2 + index('t') * 58 + index('o') = 13*58*58 + 51*58 + 46

Hope that helps!
-Eto


so, "test" would be
(51 * 58 * 58 * 58) + (37 * 58 * 58) + (50 * 58) + (51) which would be 10078131. Is this correct?
.
Yes
full member
Activity: 238
Merit: 100
August 07, 2011, 01:18:51 PM
#8

46736 = index('E') * 58^2 + index('t') * 58 + index('o') = 13*58*58 + 51*58 + 46

Hope that helps!
-Eto


so, "test" would be
(51 * 58 * 58 * 58) + (37 * 58 * 58) + (50 * 58) + (51) which would be 10078131. Is this correct?
.
member
Activity: 76
Merit: 12
August 07, 2011, 05:26:56 AM
#7
The problem is the lack of site-able references.  The bitcoin wiki article doesn't explain why it exists, so until there is an article somewhere that explains the logic of base58 I fear we will never see it at wikipedia.

newbie
Activity: 42
Merit: 0
July 17, 2011, 09:53:53 PM
#6
Who is "Cyde" to say that it is not worthy encyclopedic material.

It's not like we're making the wikipedia encyclopedia too heavy to ship or anything.

If somebody wants information on Base 58, they should be able to find it.

If they have no idea what Base 58 is, they shouldn't really mind that wikipedia has an article on it.
hero member
Activity: 812
Merit: 1022
No Maps for These Territories
July 17, 2011, 04:53:37 AM
#5
Sigh, more wikipedia delete-fetishism  Roll Eyes
legendary
Activity: 1092
Merit: 1001
July 16, 2011, 10:48:44 PM
#4
https://en.bitcoin.it/wiki/Base_58_Encoding

it is a character coding that reduces the chance of mistaking 1 for l or 0 for O if you re-type addresses, passwords or other information.

The same format is used for other things, like product keys etc. Google comes up with flickr URLs. There's enough reason for it to stay in wikipedia.

Except.. I gather that flickr uses a slightly different alphabet for their base58.
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
July 16, 2011, 03:24:55 PM
#3
Base58 is the same concept as Base64, but without the '/', '=', 'I', 'l', '0', and 'O' characters.  This guarantees that the address consists only of alphanumeric characters, and ones that are easily identifiable in any font.

Since python handles arbitrarily large integers, Base58 can be defined the "mathematical" way without having to worry about integer overflows.  The left-most digits are the most significant bits:

Code:
b58_digits = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'

def base58str_to_int(b58str):
   n = 0
   for s in b58str:
      n *= 58
      digit = b58_digits.index(s)
      n += digit
   return n

Then:
Code:
>>> base58Str_to_int('Eto') 
46736

Because:
46736 = index('E') * 58^2 + index('t') * 58 + index('o') = 13*58*58 + 51*58 + 46

Hope that helps!
-Eto



legendary
Activity: 1512
Merit: 1036
July 16, 2011, 02:15:30 PM
#2
https://en.bitcoin.it/wiki/Base_58_Encoding

it is a character coding that reduces the chance of mistaking 1 for l or 0 for O if you re-type addresses, passwords or other information.

The same format is used for other things, like product keys etc. Google comes up with flickr URLs. There's enough reason for it to stay in wikipedia.
member
Activity: 76
Merit: 12
July 15, 2011, 03:30:09 PM
#1
The base58 article is deleted. "(Non-notable ASCII encoding format, not a reference in sight, not a good candidate for an encyclopedia article.)"

http://en.wikipedia.org/wiki/Base58

What's up with that?  Can anyone help provide wikipedea with with some references (or me for that matter)?

Base58 seems odd vs. Base64

Jump to: