Bitcoin Forum

Other => Beginners & Help => Topic started by: mikemm on May 31, 2013, 04:21:51 AM



Title: Transaction ID
Post by: mikemm on May 31, 2013, 04:21:51 AM
Maybe someone can answer a question for me.  Are transaction id's random or maybe a better question is how random are they?  I'm thinking of doing a promotion/lottery type giveaway and want to have the transaction id determine who the winner is.  That way it is provably fair.


Title: Re: Transaction ID
Post by: Foxpup on May 31, 2013, 06:13:16 AM
The transaction ID is a hash of the transaction. It is random, but it is possible to generate many variations of the same transaction (without actually sending them) until you get a transaction with a transaction ID that matches some criteria, and then only send that one. You should not use a transaction ID alone as a source of random data.

The correct way to do what you're trying to do is to generate a secret, then publish a hash of that secret. Add the secret to the transaction ID, then hash that, and use that hash to select the winner. When you announce the winner, reveal the secret at the same time. To verify that the winner was fairly chosen, anyone can hash the secret, verify that the hash matches the hash you published earlier (to prevent you from cheating by changing the secret), and then hash the secret+transaction ID to verify that you selected the winner correctly.


Title: Re: Transaction ID
Post by: mikemm on May 31, 2013, 10:42:18 PM
I see.  I wanted to do an auction for multiple items with a chance to get it for free and use for example the last digit of the transaction id as a determiner as to who gets it free.  I guess I can still do that with a hash of some sort of multiplier and reveal it afterwards and apply it to each incoming transaction id to see who won but it is a bit bulky and not easily explained to a regular user.