9

Does the second letter of the public address having any meaning since it only appears to be one of four characters?

All accounts that I've looked at start with either GA, GB, GC or GD. Is there some special meaning to the character in the second position? Why is that position limited to four choices where the other positions can have up to 32 different values?

3 Answers 3

13

No special meaning, it's just a side effect of base32 encoding:

  • the first byte (8 bits) that is encoded contains the type of the string. A public key has prefix "G" for example. You can see the others there.
  • when converting into base32 the data is consumed 5 bits at a time, so the first 5 bits of the 8 bits version end up being the first character. The second character is therefore the remaining 3 bits from the version byte (but they are all 0s), plus the first 2 bits of the actual data. 2 bits of data give you the characters A through D.
5

Firstly check these posts to see how the public address is constructed :-

Which cryptographic algorithm is used to generate the secret and public keys?

How can I decode Ed25519 addresses to the regular 56 letters format?

Now use a Base32 calculator (eg this one :- Perl CPAN module "Karel Miko > CryptX-0.057 > Crypt::Misc" function encode_b32r, or this :- http://tomeko.net/online_tools/hex_to_base32.php?lang=en) to calculate the Base32 encodings in the following :-

Stellar Lumens Public Key
=========================

30 (1 byte prefix)
0000000000000000000000000000000000000000000000000000000000000000 (32 bytes, min value)
0000 (2 bytes CRC16-XModem, min value)

3000000000000000000000000000000000000000000000000000000000000000000000 (concatenate, 35 bytes)
GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA (Base32 encoding, 56 characters, min value)


30 (1 byte prefix)
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF (32 bytes, max value)
FFFF (2 bytes CRC16-XModem, max value)

30FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF (concatenate)
GD777777777777777777777777777777777777777777777777777777 (Base32 encoding, 56 characters, max value)

From the minimum and maximum possible values of the Base32 encoding, as a base 32 integer, ie

GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
GD777777777777777777777777777777777777777777777777777777

we see the range of all possible public keys (or 'public addresses') that can occur. Each public key in that range is 56 'digits' long (ie in the number base 32), and as we run through that range the first digit is always 'G', and the second digit ranges from A through to D. We can do similar calculations with Bitcoin's Base58 to see why private keys always start with K, L, or 5, and why BIP38 encrypted private keys always start with 6PY or 6PR.

0

The top three bits of the second character in base 32 correspond to the low three bits of the version byte. These have been reserved in SEP-0023 for use as an algorithm specifier. There is currently only one signature scheme (Ed25519) and one hash (SHA256), both of which have been assigned the value zero. That leaves only four possible values of the second character, depending on the top two bits of the first byte after the version byte.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.