Bitcoin Forum
May 06, 2024, 05:53:07 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: shortening hashes as a shortcut  (Read 1128 times)
Nefario (OP)
Hero Member
*****
Offline Offline

Activity: 602
Merit: 512


GLBSE Support support@glbse.com


View Profile WWW
April 14, 2011, 04:51:34 PM
 #1

I'm using 512sha2 hashes as an id, however I would like to use a shorter string, what options are there available?

I'm thinking not using all the hash, say the first 50-100 characters to lookup the whole hash and get to work that way.

If there is a collision at say 50characters (2 hash id's have the same first 50 character) then what should I do?

Workable?

Is there a specific term for what I'm attempting to do?

PGP key id at pgp.mit.edu 0xA68F4B7C

To get help and support for GLBSE please email support@glbse.com
1715017987
Hero Member
*
Offline Offline

Posts: 1715017987

View Profile Personal Message (Offline)

Ignore
1715017987
Reply with quote  #2

1715017987
Report to moderator
1715017987
Hero Member
*
Offline Offline

Posts: 1715017987

View Profile Personal Message (Offline)

Ignore
1715017987
Reply with quote  #2

1715017987
Report to moderator
The grue lurks in the darkest places of the earth. Its favorite diet is adventurers, but its insatiable appetite is tempered by its fear of light. No grue has ever been seen by the light of day, and few have survived its fearsome jaws to tell the tale.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715017987
Hero Member
*
Offline Offline

Posts: 1715017987

View Profile Personal Message (Offline)

Ignore
1715017987
Reply with quote  #2

1715017987
Report to moderator
BitterTea
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250



View Profile
April 14, 2011, 05:27:09 PM
 #2

I'm using 512sha2 hashes as an id, however I would like to use a shorter string, what options are there available?

I'm thinking not using all the hash, say the first 50-100 characters to lookup the whole hash and get to work that way.

If there is a collision at say 50characters (2 hash id's have the same first 50 character) then what should I do?

Workable?

Is there a specific term for what I'm attempting to do?

Well, Bitcoin takes the SHA256 hash of the public key and turns it into an address by hashing with RipeMD-160 and then Base58 encoding the result (and some other stuff). Perhaps something like that?

Also, if you run Bitcoin in debug mode and double click on a txn, it will give you a very short (16 char?) string which BlockExplorer knows what to do with. Theymos might be able to tell you what exactly that string is.
theymos
Administrator
Legendary
*
Offline Offline

Activity: 5194
Merit: 12972


View Profile
April 14, 2011, 05:53:47 PM
 #3

Also, if you run Bitcoin in debug mode and double click on a txn, it will give you a very short (16 char?) string which BlockExplorer knows what to do with. Theymos might be able to tell you what exactly that string is.

It's the first part the hash. Even with these few characters, collisions are rare.

50 characters is probably overkill. That's more entropy than even Bitcoin addresses. I'd probably use 12-16 bytes of high-quality randomness concatenated with the UTC time of item creation, leaving out the last four digits of the time. Then base58-encode this.

It depends on the situation, though.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
yomi
Newbie
*
Offline Offline

Activity: 39
Merit: 0


View Profile
April 14, 2011, 08:18:38 PM
 #4

Nefario, check this:

http://blog.logeek.fr/2009/7/2/creating-small-unique-tokens-in-ruby

I found it pretty useful.
Nefario (OP)
Hero Member
*****
Offline Offline

Activity: 602
Merit: 512


GLBSE Support support@glbse.com


View Profile WWW
April 15, 2011, 01:58:08 AM
 #5

Thanks for the replies.

This is for the stock market, where shares that don't have a stock ticker use have a long hash id.

I'm planning to use twitter to feed post trades to, and with a character limit of 140 characters it's almost all used up just with the id. Letting twitter keep all trade records but giving users instant updates on the latest trades.

It'll also help users by having shorter strings to work with.

At least I hope it will.

PGP key id at pgp.mit.edu 0xA68F4B7C

To get help and support for GLBSE please email support@glbse.com
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!