Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: da2ce7 on March 21, 2011, 01:00:29 AM



Title: [RFC] Short Block and Address Reference
Post by: da2ce7 on March 21, 2011, 01:00:29 AM
This is a draft specification for a short bitcoin block and bitcoin address lookup system.

This system will allow the reference of any of the addresses in the block chain with 100% accuracy.

Format:

2 xxxx Yyyy

Prefix: '2'
This is to signify that it is NOT a bitcoin address, as bitcoin addresses start with a '1'

xxxx
Base 58 encoded block number.  such as 1112  (for Block #1) or 1zzz (for Block #195111).  4 characters should last us for at least 150years.

Yyyy
the start of the bitcoin address, until it is the only address that fits, with the '1' removed.
for the bitcoin address: 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX (picked randomly from the block explorer) it would be '2' as no other address in that particular block starts with '12'
for example the address on block 1 will would have the code: 211122

Address 1NA4tpWBG4RZGeTj9RjaUhDQd6QsrCz4Si (http://blockexplorer.com/address/1NA4tpWBG4RZGeTj9RjaUhDQd6QsrCz4Si)  would be 21Zz8N

This would be much easier to quote over the phone or write or type by hand!

Edit!  I hope I have the maths right now!


Title: Re: [RFC] Short Block and Address Reference
Post by: theymos on March 21, 2011, 01:16:06 AM
The block at a certain number can change, which might cause you to point to the wrong address.


Title: Re: [RFC] Short Block and Address Reference
Post by: Gavin Andresen on March 21, 2011, 01:19:21 AM
Neat idea!

As theymos says, this will only work 100% reliably for addresses buried "deep enough" in the block chain that the likelihood of a block-chain-re-org is vanishingly small.


Title: Re: [RFC] Short Block and Address Reference
Post by: Pieter Wuille on March 21, 2011, 01:24:48 AM
I believe this is a useful idea, but I would define it on the level below the base58 encoding.

So, an address currently is a base58-transformed sequence of bytes:
  • A version byte (0)
  • The pubkey hash (160 bit, 20 bytes)
  • A 32-bit (4 byte) checksum

It's not that hard to define a similar format for shortened addresses, but I would suggest not requiring lookup code to parse full blocks when looking for an address - they could become quite big in the future. Rather, what about this:

A base58-transformation of:
  • A version byte (1)
  • A BER-encoded block number
  • A BER-encoded tx number
  • A BER-encoded txout number
  • A 8-bit (1 byte) checksum
(BER encoding: in every byte, bits 0-6 contain data, bit 7 signifies if another data byte follows, like UTF-8 for unicode)

Up to block number 2113663, and as long as less than 128 transactions and less than 128 outputs per txout are used, this results in 7 bytes, or 10 base58-encoded characters. An alternative (if it's meant for typing over, instead of automated handling), would be to use base36 (case-insensitive alphanumeric) resulting in 11 characters.