[hashcash] about bits field (Re: Re: python hashcash status)

  • From: Adam Back <adam@xxxxxxxxxxxxxxx>
  • To: hashcash@xxxxxxxxxxxxx
  • Date: Thu, 12 Aug 2004 11:35:28 -0400

On Thu, Aug 12, 2004 at 08:39:17AM -0500, John Honan wrote:
> Sorry if this was covered in the docs, but I can't find it.

I think the FAQ is missing description if the ins and outs of the
bits field.  Will fix that.

> What is the purpose/advantage of the 'intended bit count' field? -
> As the stamp will have to be checked anyway to determine the actual
> bit count.

Well it serves a few different purposes:

1. makes the stamp value human readable (stamps with invalid bit
counts will be rare as any software will reject them)

2. makes things more deterministic (removes the previous issue where
if you looked at the value of a stamp intended to be a 20 bit stamp
1/2 time it would be > 20 bits, 1/4 time it would be > 21 bits etc.)

Determinism is useful to avoid complicating debugging of what filters
based on hashcash are doing.  eg. if a server required 20 bits and you
sent 18 bits but one in 4 msgs got delivered anyway, it would add to
confusion.

To go with this stamps are valued as described in:

        http://www.hashcash.org/dev/

like this:

| the v1 format has an explicit version field which I'll call
| $claimed_value. Then $measured_value is the number of leading 0 bits.
| 
| But the actual value used should be calculated based on those two
| inputs as follows:
| 
| $value = $measured_value >= $claimed_value ? $claimed_value : 0
| 
| ie you do not get lucky and get more than planned number of bits some
| of the time, if it has more than the required number of 0 bits it gets
| knocked back to the claimed bits. On the other hand if it has less
| bits than claimed it is worthless (0 value).


John also wrote:
> One other thing, on the http://www.hashcash.org/dev/ page, I think there
> might be a typo. There is an example section about halfway down;
> 
> "Taking the example stamp: 1:20:040806:foo::be1f404f77b928e2:2360d4 one
> could verify its collision using the following:
> 
> echo -n 1:20:040806:foo::65f460d0726f420d:13a6b8 | sha "
> 
> It appears you're using a different stamp in the command line than in the
> text above it?

Thanks for pointing that out.  I've fixed it now.  (I had tried it and
found it more than 20 bits, so rather than having a complicated stamp,
I generated another repeatedly until I got one exactly 20 bits, but I
forgot to update the example).

Adam

Other related posts:

  • » [hashcash] about bits field (Re: Re: python hashcash status)