| 1 |
NAME |
| 2 |
hashcash - hashcash anti-spam / denial of service counter-measure tool |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
Mint (create) stamps: |
| 6 |
hashcash *-m* [ [ *options* ] [ *resource* ... ] ... ] |
| 7 |
|
| 8 |
Check stamps: |
| 9 |
hashcash *-c* [ [ *options* ] *-r resource* ... ] [ *stamp* ... ] |
| 10 |
|
| 11 |
Speed estimates: |
| 12 |
hashcash *-s* [ *options* ] [ *-b bits* ] |
| 13 |
|
| 14 |
Purge database: |
| 15 |
hashcash *-p now* [ *-j resource* ] [ *-k* ] [ *-t time* ] [ *-u* ] |
| 16 |
|
| 17 |
Count partial preimage bits: |
| 18 |
hashcash *-w* [ *options* ] [ *stamp* ... ] |
| 19 |
|
| 20 |
Get resource name: |
| 21 |
hashcash *-n* [ *options* ] [ *stamp* ... ] |
| 22 |
|
| 23 |
Get time remaining until expiry |
| 24 |
hashcash *-l* [ *options* ] *-e period* [ *stamp* ... ] |
| 25 |
|
| 26 |
DESCRIPTION |
| 27 |
Hashcash is a denial-of-service counter measure tool. Its main current |
| 28 |
use is to help hashcash users avoid losing email due to content based |
| 29 |
and blacklist based anti-spam systems. |
| 30 |
|
| 31 |
The hashcash tool allows you to create hashcash stamps to attach to |
| 32 |
emails you send, and to verify hashcash stamps attached to emails you |
| 33 |
receive. Email senders attach hashcash stamps with the X-Hashcash: |
| 34 |
header. Vendors and authors of anti-spam tools are encouraged to exempt |
| 35 |
mail sent with hashcash from their blacklists and content based |
| 36 |
filtering rules. |
| 37 |
|
| 38 |
A hashcash stamp constitutes a proof-of-work which takes a |
| 39 |
parameterizable amount of work to compute for the sender. The recipient |
| •40 |
can verify received stamps efficiently. |
| 41 |
|
| 42 |
The hashcash proof-of-work function is to compute partial hash preimages |
| 43 |
(the SHA1 hash function is used). By choosing the number of bits of the |
| 44 |
preimage that are equal to 0, the work required to compute a partial |
| 45 |
preimage can be made arbitrarily expensive -- from fractions of a second |
| 46 |
to minutes or hours. The verification is efficient requiring the same |
| 47 |
small cost whatever the preimage size. |
| 48 |
|
| 49 |
For more detailed discussion of other applications hashcash has been |
| 50 |
used for see http://www.hashcash.org/ |
| 51 |
|
| 52 |
USAGE NOTES |
| 53 |
In this man page a resource name is the name of the service or address |
| 54 |
the stamp is created for. In the case of email, the resource name is the |
| 55 |
recipient's email address in the form [email protected]. |
| 56 |
|
| 57 |
Minting stamps |
| 58 |
The *-m* flag must be given to mint a stamp. |
| 59 |
|
| 60 |
The resource name (recipient's email address) to mint the stamp against |
| 61 |
can be passed as an argument, or if omitted is read from stdin. If stdin |
| 62 |
is a tty the user is prompted, if stdin is a pipe the resource name is |
| 63 |
just silently read. The desired preimage size can be specified with the |
| 64 |
-b option. If no preimage size is specified, the default is 20 bits. See |
| 65 |
also the *-b default* option. |
| 66 |
|
| 67 |
Checking stamps |
| 68 |
The *-c* flag must be given to check a stamps expiry. The stamp to check |
| 69 |
can be given as an argument to "hashcash". If no stamp is given the |
| 70 |
stamp is read from stdin. If stdin is a tty the user will be prompted, |
| 71 |
if stdin is a pipe the stamp is just silently read. A resource name (the |
| 72 |
recipient's email address) can be given with the *-r* option. If a |
| 73 |
resource name is given the resource name is compared to the resource |
| 74 |
name in the stamp, if they do not match, the stamp is rejected. |
| 75 |
|
| 76 |
Note: if no resource name is given the stamp is anyway checked to see if |
| 77 |
it is otherwise valid, but it could be minted for a different resource, |
| 78 |
which would allow stamps to be reused across different resources, so |
| 79 |
hashcash will return unchecked exit code on exit. |
| 80 |
|
| 81 |
Stamps are by default considered to be valid for 28 days. The validity |
| 82 |
period can be changed using the *-e* flag. |
| 83 |
|
| 84 |
If the stamp has expired or has a date in the future the stamp is |
| 85 |
rejected and the program exits immediately. |
| 86 |
|
| 87 |
If a required preimage size is given with the *-b* flag, the stamps |
| 88 |
value is computed and compared, if the stamp has insufficent value it is |
| 89 |
rejected, and the program exits immediately. If the *-b* flag is not |
| 90 |
given, the stamp is checked to see if it is otherwise valid, but |
| 91 |
hashcash will return unchecked exit code on exit. |
| 92 |
|
| 93 |
If the stamp is double spent the stamp is rejected. Double spending |
| 94 |
protection is discussed in more detail below in "Double Spending |
| 95 |
Protection". If double spending protection is not enabled, the stamp |
| 96 |
could be double spent, so hashcash will return unchecked exit code (exit |
| 97 |
code 2) on exit. |
| 98 |
|
| 99 |
The *-w* flag can be used to request that the number of bits of the |
| 100 |
preimage are counted and displayed. The *-n* flag can be used to request |
| 101 |
that the resource name in the stamp is parsed out and displayed. The |
| 102 |
*-l* flag can be used to request the number of seconds until expiry of |
| 103 |
the stamp is output. |
| 104 |
|
| 105 |
The program will only return exit codes valid or invalid if the *-c* |
| 106 |
flag is used, the *-b* flag is used, *-d*, *-r resource* are used. These |
| 107 |
are the minimum set of options necessary to fully check the validty of a |
| 108 |
stamp. If these criteria are not met, the program will return exit code |
| 109 |
unchecked (exit code 2) on exit. (See also the *-y* flag.) |
| 110 |
|
| 111 |
Double Spending Protection |
| 112 |
If the *-d* flag is used when checking stamps, a database of spent |
| 113 |
stamps is kept. |
| 114 |
|
| 115 |
By default stamps expire after 28 days, without expiry the database |
| 116 |
would grow indefinately. You can specify an alternate expiry period with |
| 117 |
the *-e* flag. The recommended (and default) expiry period for email is |
| 118 |
28 days. After the expiry period amount of time, the stamp is anyway |
| 119 |
considered expired and may be purged from the database to save space. |
| 120 |
(See "Purging Periodically vs on Next Access" for how to purge stamps.) |
| 121 |
|
| 122 |
For efficiency reasons a stamp is verified before it is checked in the |
| 123 |
database; if it is otherwise invalid no database activity will occur. |
| 124 |
|
| 125 |
Note: The decision about how long the stamp should be considered valid |
| 126 |
is up to the verifier. If it is too short it is possible for some |
| 127 |
applications that the stamp will expire before arriving at the recipient |
| 128 |
(eg with email.) The suggested value of 28 days should be safe for |
| 129 |
normal email delivery delays. The choice is a trade-off between database |
| 130 |
size and risk of expiry prior to arrival, and depends on the |
| 131 |
application. |
| 132 |
|
| 133 |
Note: Different stamps in the same database can have different validity |
| 134 |
periods, so for example stamps for different resources with different |
| 135 |
validity periods can be stored in the same database, or the recipient |
| 136 |
may change the validity period for future stamps without affecting the |
| 137 |
validity of old stamps. |
| 138 |
|
| 139 |
Purging Periodically vs on Next Access |
| 140 |
To purge old stamps periodically while checking stamps use the *-p |
| 141 |
period* option to purge no sooner than the given time period since the |
| 142 |
last purge. Purging can be used with the *-k* option to purge unexpired |
| 143 |
stamps also, and with the *-j resource* flag to purge only stamps for |
| 144 |
the given resource. |
| 145 |
|
| 146 |
There are circumstances where it may be inconvenient to purge stamps on |
| 147 |
the next access, for example if there is a large double spend database |
| 148 |
which takes some time to purge, and the response time of the hashcash |
| 149 |
checker is important. To avoid this problem, purging can be done |
| 150 |
separately using just the *-p now* option to request just the purge |
| 151 |
operation. On unix for example you could call "hashcash -p now" in a |
| 152 |
cron job once per day, or on demand when disk was running low. |
| 153 |
|
| 154 |
Speed Estimates |
| 155 |
The *-s* flag requests measurement of how many preimage can be tested |
| 156 |
per second. No stamp is minted, or verified. |
| 157 |
|
| 158 |
If the *-b* flag is used with this option, instead an estimate of how |
| 159 |
many seconds it would take to mint a stamp of the given size in bits is |
| 160 |
computed. To find out how much time it will take to mint a default sized |
| 161 |
stamp use *-s -b default*. |
| 162 |
|
| 163 |
Notes |
| 164 |
All informational output is printed on stderr. Minted stamps, and |
| 165 |
results of stamp verification and timing are printed on stdout. The |
| 166 |
quiet flag *-q* suppresses all informational output. The *-v* flag |
| 167 |
requests more informational output. The requested output, which is the |
| 168 |
only information that is output in quiet mode (when *-q* is specified) |
| 169 |
is printed on standard output. If stdout is a pipe, or when quiet mode |
| 170 |
is in effect the output is printed without description (ie just bits, |
| 171 |
just seconds, just resource). |
| 172 |
|
| 173 |
OPTIONS |
| 174 |
*-c* |
| 175 |
Check the expiry information of stamps given as an argument or on |
| 176 |
stdin. (Use with *-b*, *-d* and *-r resource* to fully check |
| 177 |
stamps). |
| 178 |
|
| 179 |
*-m* |
| 180 |
Mint stamps with the resources given as arguments or on stdin. |
| 181 |
|
| 182 |
*-b bits* |
| 183 |
When minting a stamp, create a preimage of at least this many bits. |
| 184 |
When verifying a stamp require that it have a preimage of at minimum |
| 185 |
this many bits, otherwise reject it. If omitted the default is used. |
| 186 |
|
| 187 |
When checking stamps, require that the stamps have this many bits. |
| 188 |
|
| 189 |
The default number of bits can be specified with *-b default*. Bits |
| 190 |
relative to the default can also be specified with *-b +n* for n |
| 191 |
bits more than the default and *-b -n* for n bits less than the |
| 192 |
default. |
| 193 |
|
| 194 |
*-b default*, *-b +0* and *-b -0* are all equivalent. |
| 195 |
|
| 196 |
When doing the speed test *-s*, can to measure speed of default |
| 197 |
token with *-s -b default*. |
| 198 |
|
| 199 |
*-r resource* |
| 200 |
When minting stamps, the resource name (recipient's email address) |
| 201 |
to mint the stamp against can be given either with *-r resource* or |
| 202 |
as an argument to "hashcash". |
| 203 |
|
| 204 |
When checking stamps, the resource name (your own email address) is |
| 205 |
given with the *-r* option. If the resource name is given it is |
| 206 |
checked against the resource name in the stamp, and if they do not |
| 207 |
match the stamp is rejected. Note if the resource name is not given, |
| 208 |
stamps for other resources would be accepted, and therefore hashcash |
| 209 |
returns exit code unchecked (exit code 2) on exit. |
| 210 |
|
| 211 |
*-o* |
| 212 |
When verifying stamps multiple resources can be given. By default |
| 213 |
the resources are just checked one by one until a matching valid |
| 214 |
resource is found. However when you use wildcards or regular |
| 215 |
expressions (see *-E*), it is useful to be able to specify that one |
| 216 |
resource overrides another. For example this: *-b15 -r [email protected] |
| 217 |
-o -b10 *@dev.null* states that mail to address *[email protected]* |
| 218 |
requires 15 bits, but mail to **@dev.null* requires only 10 bits. If |
| 219 |
we omitted the *-o* override relationship between the two resources, |
| 220 |
a stamp of 10 bits would be accepted for address *[email protected]* |
| 221 |
because while it would be rejected as having insufficient bits under |
| 222 |
the first rule, it would be accepted under the 2nd rule. The *-o* |
| 223 |
option allows you avoid this problem. |
| 224 |
|
| 225 |
*-e time* |
| 226 |
Expiry period for spent stamps. While checking stamps (using the |
| 227 |
*-c* flag), if the stamp was minted more than the specified amount |
| 228 |
of time ago, it is considered expired. If this option is not used, |
| 229 |
by default stamps expire after 28 days. The expiry period is given |
| 230 |
in seconds by default (an argument of 0 means forever). A single |
| 231 |
character suffix can be used to specify alternate units (m = |
| 232 |
minutes, h = hours, d = days, M = months, y = Y = years, and s = |
| 233 |
seconds). |
| 234 |
|
| 235 |
If used with the *-d* option, the spent stamp and its expiry period |
| 236 |
is recorded in the database. See the *-p* option for description of |
| 237 |
how to purge stamps from the database. |
| 238 |
|
| 239 |
While minting stamps, the *-e* flag can have an effect on the |
| 240 |
resolution of time created in the stamp. Without the *-e* option, |
| 241 |
the default resolution is days (time format: YYMMDD). Alternate |
| 242 |
formats based on range of expiry period are as follows: |
| 243 |
|
| 244 |
While minting you can also given an explicit time width with the |
| 245 |
*-z* option instead. (*-z* overrides *-e* if both are given. If |
| 246 |
neither are given the default is 6 chars (time format: YYMMDD)). |
| 247 |
|
| 248 |
The rules for automatically determining appropriate time width from |
| 249 |
*-e* if no *-z* option is given are: |
| 250 |
|
| 251 |
* period >= 2 years then time format YY is used rounded down to the |
| 252 |
nearest year start; |
| 253 |
* 2 years < period <= 2 months then time format YYMM is used rounded |
| 254 |
down to the nearest month start; |
| 255 |
* 2 months < period <= 2 days then time format YYMMDD is used |
| 256 |
rounded down to the begining of the nearest day; |
| 257 |
* 2 days < period <= 2 minutes then time format YYMMDDhhmm is used |
| 258 |
rounded down to the begining of the nearest minute; |
| 259 |
* period < 2 minutes then time format YYMMDDhhmmss is used in |
| 260 |
seconds. |
| 261 |
|
| 262 |
Note the rounding down is based on UTC time, not local time. This |
| 263 |
can lead to initially suprising results when rounding down to eg |
| 264 |
days in time zones other than GMT (UTC = GMT). It may be clearer to |
| 265 |
understand if you use the *-u* option. |
| 266 |
|
| 267 |
*-z width* |
| 268 |
The *-z* option is for use during minting and allows user choice of |
| 269 |
width of time width field. See also the *-e* option given in |
| 270 |
combination with *-m* to specify an implicit time field width under |
| 271 |
the description of the *-e* flag. Valid widths are 6,10 or 12 chars |
| 272 |
corresponding respectively to: YYMMDD, YYMMDDhhmm, and YYMMDDhhmmss |
| 273 |
rounded down to the nearest day, or minute respectively. |
| 274 |
|
| 275 |
Note the rounding down is based on UTC time, not local time. This |
| 276 |
can lead to initially suprising results when rounding down to eg |
| 277 |
days in time zones other than GMT (UTC = GMT). It may be clearer to |
| 278 |
understand if you use the *-u* option. |
| 279 |
|
| 280 |
*-g period* |
| 281 |
The *-g* option is for use when checking hashcash stamps with the |
| 282 |
*-c* option and specifies a grace period for clock skew, ie if a |
| 283 |
hashcash stamp arrives with a date in the future or in the past it |
| 284 |
will not be rejected as having a futuristic date (or as being |
| 285 |
expired) unless it is more futuristic (or has been expired for |
| 286 |
longer) than this period. The default is 2 days, which means as long |
| 287 |
as the sending system's clock is no more than 2 days ahead (or 2 |
| 288 |
days behind) of the receiving system's clock, the hashcash stamp |
| 289 |
will still be accepted. |
| 290 |
|
| 291 |
The default units for grace period are seconds. A single character |
| 292 |
suffix can be used to specify alternate units (m = minutes, h = |
| 293 |
hours, d = days, M = months, y = Y = years, and s = seconds). |
| 294 |
|
| 295 |
*-d* |
| 296 |
Store stamps in a double spend database. If stamp has been seen |
| 297 |
before it will be rejected even if it is otherwise valid. The |
| 298 |
default database file is database.sdb in the current directory. Only |
| 299 |
otherwise valid stamps will be stored in the database. Only fully |
| 300 |
validated stamps will be stored in the database, unless the *-y* |
| 301 |
option is given. |
| 302 |
|
| 303 |
*-f dbname* |
| 304 |
Use dbname instead of default filename for double spend database. |
| 305 |
|
| 306 |
*-p period* |
| 307 |
Purges the database of expired stamps if the given time period has |
| 308 |
passed since the last time it was purged. As a convenience *-p now* |
| 309 |
is equivalent to *-p 0* both of which mean purge now, regardless of |
| 310 |
when the database was last purged. |
| 311 |
|
| 312 |
If used in combination with *-j resource* only the stamps minted for |
| 313 |
the given resource are purged. |
| 314 |
|
| 315 |
If used in combination with *-k* all stamps even un-expired stamps |
| 316 |
are purged. Can be used in combination with *-t time* to expire as |
| 317 |
if the current time were the given time. |
| 318 |
|
| 319 |
*-k* |
| 320 |
Use with option *-p* to request all stamps are purged rather than |
| 321 |
just expired ones. |
| 322 |
|
| 323 |
*-j resource* |
| 324 |
Use with option *-p* to request that just stamps matching the given |
| 325 |
resource name are to be purged, rather than the default which is to |
| 326 |
purge all expired stamps. If the resource name is the empty string, |
| 327 |
all stamps are matched (this is equivalent to omitting the *-j* |
| 328 |
option). |
| 329 |
|
| 330 |
Note the *-E*, *-M* and *-S* type of match flags also apply to |
| 331 |
resources given with the *-j resource* flag. |
| 332 |
|
| 333 |
*-s* |
| 334 |
Print timing information only, and don't proceed to create a stamp. |
| 335 |
If combined with *-b bits* flag print estimate of how long the |
| 336 |
requested preimage size would take to compute, if *-s* given by |
| 337 |
itself, just prints speed of the preimage finder. To print an |
| 338 |
estimate of how long the default number of bits would take use *-b |
| 339 |
default*. |
| 340 |
|
| 341 |
*-h* |
| 342 |
Print short usage information. |
| 343 |
|
| 344 |
*-v* |
| 345 |
Print more verbose informational output about the stamp minting or |
| 346 |
verification. (If -v is the only argument, prints the tool version |
| 347 |
number.) |
| 348 |
|
| 349 |
*-V* |
| 350 |
Prints tool version number. |
| 351 |
|
| 352 |
*-q* |
| 353 |
Batch mode. Prints no information other than output. This option |
| 354 |
overrides the *-v* option. |
| 355 |
|
| 356 |
*-X* |
| 357 |
When minting, prints the hashcash email X-header 'X-Hashcash: ' |
| 358 |
before the stamp. Without this option just the bare stamp is |
| 359 |
printed. |
| 360 |
|
| 361 |
When checking, after scanning stamps given as arguments, scans stdin |
| 362 |
for lines starting with the string 'X-Hashcash:', and uses the rest |
| 363 |
of the matching line as the stamp. Only the lines up to and ending |
| 364 |
at the first blank line are scanned (see also *-i* flag which can be |
| 365 |
used to override this). A blank line is the separator used to |
| 366 |
separate the headers from the body of a mail message or USENET |
| 367 |
article. This is meant to make it convenient to pipe a mail message |
| 368 |
or USENET article to hashcash on stdin. |
| 369 |
|
| 370 |
*-x extension* |
| 371 |
An extension string composed of name value sets. The extension |
| 372 |
format is described below in the section on the hashcash stamp |
| 373 |
format. This allows users to define their own stamp extensions which |
| 374 |
are hashed into the stamp, verified by recipients that support them, |
| 375 |
and ignored by recipients that don't support them. Note the |
| 376 |
extension hook mechanism has not yet been implemented. This will |
| 377 |
come in a subsequent release. |
| 378 |
|
| 379 |
*-i* |
| 380 |
When checking and using the *-X* flag, ignore the blank line |
| 381 |
boundary between headers and body of the message, and check for |
| 382 |
stamps in the body too if one is not found in the headers. |
| 383 |
|
| 384 |
*-t time* |
| 385 |
Pretend the current time is the time given for purposes of minting |
| 386 |
stamps, verifying stamps and purging old stamps from the database. |
| 387 |
Time is given in a format based on UTCTIME format YYMMDD[hhmm[ss]]. |
| 388 |
|
| 389 |
Time is expressed in local time by default. Use with *-u* flag to |
| 390 |
give time in UTC (GMT). |
| 391 |
|
| 392 |
You can also give time relative to the current time by prefixing the |
| 393 |
argument with + or -. The default units for relative time are |
| 394 |
seconds. A single character suffix can be used to specify alternate |
| 395 |
units (m = minutes, h = hours, d = days, M = months, y = Y = years, |
| 396 |
and s = seconds). |
| 397 |
|
| 398 |
Note: when time is expressed in local time, if there is daylight |
| 399 |
savings in your timezone, there are one or two ambiguous hours per |
| 400 |
year at the time of change from daylight savings time to normal |
| 401 |
time. |
| 402 |
|
| 403 |
*-u* |
| 404 |
Input and output absolute times in UTC (GMT) instead of local time. |
| 405 |
|
| 406 |
*-a period* |
| 407 |
Add (or subtract if number is negative) a random value from the |
| 408 |
current time before minting the stamp. This hides the time the stamp |
| 409 |
was created, which may be useful for anonymous users. Note adding |
| 410 |
(rather than subtracting) a random time may be risky if the stamp |
| 411 |
takes less than the added time to arrive as the recipient will |
| 412 |
reject stamps with time stamps in the future. |
| 413 |
|
| 414 |
*-n* |
| 415 |
Print resource name parsed from stamp being verified. Returns exit |
| 416 |
code unchecked on exit. |
| 417 |
|
| 418 |
*-l* |
| 419 |
Print number of seconds left before stamp expires. Returns exit code |
| 420 |
unchecked on exit. |
| 421 |
|
| 422 |
Note: the calculation includes the grace period, so can be up to 2 |
| 423 |
times grace period longer than you might otherwise expect (clock |
| 424 |
fast but system has to presume it could be slow). If you want to |
| 425 |
exclude the grace period add *-g0* to set grace period to 0 for the |
| 426 |
calculation. |
| 427 |
|
| 428 |
*-w* |
| 429 |
Print number of bits of preimage of stamp. Returns exit code |
| 430 |
unchecked on exit. |
| 431 |
|
| 432 |
*-y* |
| 433 |
Returns success if the stamp is valid even if it is not fully |
| 434 |
checked. Use with *-c* where not all of *-d*, *-r* are specified to |
| 435 |
get success exit code on valid but partially checked stamp. |
| 436 |
Similarly can use with *-n*, *-l*, *-w* with same effect. |
| 437 |
|
| 438 |
*-M* |
| 439 |
When checking stamps, allow wildcard *** matching in the resource |
| 440 |
name to make it simpler to specify multiple email addresses and to |
| 441 |
allow matching catch-all addresses and addresses including |
| 442 |
subdomains. This is the default. See also *-S*, *-E* and *-C* |
| 443 |
|
| 444 |
*-S* |
| 445 |
When checking stamps use simple text compare to compare resource |
| 446 |
names to those in stamps. See also *-M*, *-E* and *-C*. |
| 447 |
|
| 448 |
*-E* |
| 449 |
When checking stamps use regular expressions to specify resource |
| 450 |
names to make it simpler to specify multiple email addresses, |
| 451 |
catch-all addresses, classes of extension addresses and addresses |
| 452 |
including subdomains. Note regular expression syntax is POSIX style: |
| 453 |
special characters do not need to be quoted to have their special |
| 454 |
meaning; but they do have to be quoted with \ to that character in |
| 455 |
the searched string. The regular expression automatically has ^ |
| 456 |
added at the beginning and $ added at the end, if they are not |
| 457 |
specified. The special characters ^ matches the beginning of the |
| 458 |
resouce, and $ matches the end of resource. |
| 459 |
|
| 460 |
(Note even if compiled with BSD regular expressions, POSIX style |
| 461 |
syntax is used; also note BSD regular expressions do not support |
| 462 |
ranges {}.) |
| 463 |
|
| 464 |
*-C* |
| 465 |
By default resources are canonicalized to lower case on minting and |
| 466 |
on checking. The *-C* flag overrides this so that resources are |
| 467 |
treated as case sensitive on checking, and not canonizalized on |
| 468 |
minting. |
| 469 |
|
| 470 |
*-P* |
| 471 |
Print progress info (number of iterations, expected iterations, |
| 472 |
percentage done, best stamp size found so far). |
| 473 |
|
| 474 |
*-O core* |
| 475 |
Select hashcash core with that number. Currently 0-9 are valid |
| 476 |
cores. Not all cores work on all architectures. Eg some are x86 |
| 477 |
specific assembler, others PPC specific assembler. If a core is not |
| 478 |
valid hashcash returns failure and explains what happened. |
| 479 |
|
| 480 |
*-Z n* |
| 481 |
Compress the stamp. This is a time vs space trade off. Larger stamps |
| 482 |
are faster, but arguably slightly ugly. For fastest stamps (the |
| 483 |
default) use -Z 0; for partly compressed stamps use -Z 1; for very |
| 484 |
compressed, but somewhat slow stamps use -Z 2. (Note: due to a late |
| 485 |
discovered bug, -Z2 is the same as -Z1 for now until I can fix |
| 486 |
that.) |
| 487 |
|
| 488 |
EXAMPLES |
| 489 |
Creating stamps |
| 490 |
"hashcash -s" |
| 491 |
Print timing information about how many preimages the machine can |
| 492 |
try per second. |
| 493 |
|
| 494 |
"hashcash -sv" |
| 495 |
More accurate but quite slow benchmarking of different processor |
| 496 |
specific minting cores. |
| 497 |
|
| 498 |
"hashcash -s -b default" |
| 499 |
Print how long it would take the machine to compute a default sized |
| 500 |
preimage (but don't actually compute a preimage). |
| 501 |
|
| 502 |
"hashcash -s -b 32" |
| 503 |
Print how long it would take the machine to compute a 32 bit |
| 504 |
preimage (but don't actually compute a preimage). |
| 505 |
|
| 506 |
"hashcash -m" |
| 507 |
Mint a stamp. Will prompt for resource name and mint with default |
| 508 |
value (number of preimage bits). |
| 509 |
|
| 510 |
"hashcash -m foo" |
| 511 |
Compute preimage on resource foo. Will mint with default value |
| 512 |
(number of preimage bits). |
| 513 |
|
| 514 |
"hashcash -m foo -b 10" |
| 515 |
Compute 10 bit preimage on resource foo. |
| 516 |
|
| 517 |
"hashcash -a -3d" |
| 518 |
Subtract a random time of between 0 days and 3 days from the stamp's |
| 519 |
creation time. This is the same fuzz factor used by mixmaster to |
| 520 |
reduce risk of timing-correlations. |
| 521 |
|
| 522 |
Examining Stamps |
| 523 |
"hashcash -w 1:24:040806:foo::511801694b4cd6b0:1e7297a" |
| 524 |
Report the value of the stamp (how many bits of preimage) there are. |
| 525 |
The example is a 24 bit preimage, which takes on average 25 seconds |
| 526 |
to create on a 3Ghz P4. |
| 527 |
|
| 528 |
"hashcash -mq -b 10 foo | hashcash -w" |
| 529 |
Create a stamp in batch mode, pass to hashcash on stdin to verify, |
| 530 |
have it print how many bits there were. |
| 531 |
|
| 532 |
"hashcash -n 1:24:040806:foo::511801694b4cd6b0:1e7297a" |
| 533 |
Report the resource name from the stamp. The resource name in the |
| 534 |
example is foo. |
| 535 |
|
| 536 |
"hashcash -l -e 30y 1:24:040806:foo::511801694b4cd6b0:1e7297a" |
| 537 |
Report how long until the stamp expires if it expires in 30 years |
| 538 |
from its creation date. (Note dates too far into the future run into |
| 539 |
the 2038 end of Epoch, which is the unix time analog of the y2k |
| 540 |
bug). |
| 541 |
|
| 542 |
Verifying Stamps |
| 543 |
"hashcash -c 1:24:040806:foo::511801694b4cd6b0:1e7297a" |
| 544 |
Check if the stamp is valid. Note as we are not checking the stamp |
| 545 |
in a double spend database, and did not specify a resource name or |
| 546 |
required number of bits of preimage and hashcash will consider the |
| 547 |
stamp not fully checked, and it will report it as valid but not |
| 548 |
fully unchecked, or as invalid if there is any problem with the |
| 549 |
stamp. |
| 550 |
|
| 551 |
"hashcash -c -b24 1:24:040806:foo::511801694b4cd6b0:1e7297a" |
| 552 |
Check that the value of the stamp is greater or equal to 24 bits. |
| 553 |
This example has 24 bit value. If you increase the requested number |
| 554 |
of bits or replace the stamp with one with less than 24 bit preimage |
| 555 |
the stamp will be rejected. |
| 556 |
|
| 557 |
"hashcash -c -b24 -r foo 1:24:040806:foo::511801694b4cd6b0:1e7297a" |
| 558 |
As above check if the stamp has sufficient value, but in addition |
| 559 |
check that the resource name given matches the resource name in the |
| 560 |
stamp. |
| 561 |
|
| 562 |
Double Spending Prevention |
| 563 |
The examples given in "Verifying Stamps" can be modified to keep a |
| 564 |
double spend database so that the same stamp will not be accepted twice. |
| 565 |
Note a stamp will only be checked in and added to the database if it is |
| 566 |
otherwise valid and fully checked (a required number of bits of preimage |
| 567 |
has been specified and a resource has been specified). |
| 568 |
|
| 569 |
"hashcash -cd -b 10 -r foo 1:24:040806:foo::511801694b4cd6b0:1e7297a" |
| 570 |
Check the stamp and add to double spent database if it's valid (has |
| 571 |
correct resource name and sufficient value). |
| 572 |
|
| 573 |
"hashcash -cd -b 10 -r foo 1:24:040806:foo::511801694b4cd6b0:1e7297a" |
| 574 |
Try to double spend the stamp. It will be rejected as double spent. |
| 575 |
|
| 576 |
Stamp Expiry |
| 577 |
To prevent the double spend database growing indefinately, the recipient |
| 578 |
can request that stamps be no older than a specified period. After |
| 579 |
expiry old stamps can dropped from the double spend database as they |
| 580 |
will no longer be needed -- expired stamps can be rejected based purely |
| 581 |
on their old date, so the space taken by expired stamps in the double |
| 582 |
spend database can be saved without risk of accepting an expired though |
| 583 |
otherwise valid stamp. |
| 584 |
|
| 585 |
The third field of the stamp is the UTC time since 1st January 1970. The |
| 586 |
default time format is YYMMDD, time rounded down to the nearest day. The |
| 587 |
default validity period is 28 days. |
| 588 |
|
| 589 |
You can provide an alternative validity period with the *-e* option. |
| 590 |
|
| 591 |
"hashcash -cd -b 10 -e 2d -r foo |
| 592 |
1:24:040806:foo::511801694b4cd6b0:1e7297a" |
| 593 |
Try verifying an old stamp, the above stamp was created 11 Aug 2002. |
| 594 |
|
| 595 |
We gave option *-e 2d* so the stamps expiry date is 2 days after |
| 596 |
creation, which is now in the past. |
| 597 |
|
| 598 |
Note: if the creation time is expressed in the stamp in days, the |
| 599 |
precise creation date is the begining of the specified day in UTC |
| 600 |
time (similarly for alternate units the creation time is rounded |
| 601 |
down to the begining of the unit it is expressed in). For units in |
| 602 |
days, for example, this may mean depending on your time zone that |
| 603 |
the stamp appears to be considered invalid in under the specified |
| 604 |
expiry period in days relative to your relative view of what day it |
| 605 |
is, as the calculation is based on current time in UTC, and the |
| 606 |
creation time of the stamp is expressed in UTC time. |
| 607 |
|
| 608 |
"hashcash -cd -b 10 -r foo 1:24:040806:foo::511801694b4cd6b0:1e7297a" |
| 609 |
Test whether the stamp is otherwise valid, apart from having |
| 610 |
expired. Omitting the *-e* tells hashcash that the stamp will never |
| 611 |
expire. An expiry period of forever can also be given explitly like |
| 612 |
this: *-e 0*, where an expiry period of 0 means forever. |
| 613 |
|
| 614 |
Purging old stamps |
| 615 |
If the *-c*, *-d* options are used together, each time a stamp is |
| 616 |
checked, if it is valid and all of the mandatory aspects of the stamp |
| 617 |
are verified (preimage bits check, resource name check) then the stamp |
| 618 |
and its expiry period is written to the database file. The default |
| 619 |
expiry period if an expiry period is not given explicitly with the *-e* |
| 620 |
option is 28 days (ie stamps expire after 4 weeks). |
| 621 |
|
| 622 |
First mint and then add a stamp: |
| 623 |
|
| 624 |
"hashcash -m -b 10 foo -e 1m > stamp" |
| 625 |
Note: we specified an expiry on minting in this example, to ensure |
| 626 |
that the stamp creation time is given in high enough resolution in |
| 627 |
the stamp that the stamp will not be considered expired at time of |
| 628 |
creation. (Recall the default resolution is in days, a stamp created |
| 629 |
with a creation time rounded down to the beginging of the day is |
| 630 |
unlikely to be considered valid 1 minute later unless you mint it at |
| 631 |
midnight UTC time.) |
| 632 |
|
| 633 |
"hashcash -cd -e 1m -b 10 -r foo < stamp" |
| 634 |
The stamp expires in 1 minute. Wait 1 minute and then explicitly |
| 635 |
request that expired stamps be purged: |
| 636 |
|
| 637 |
"hashcash -p now" |
| 638 |
Then try resubmitting the same stamp: |
| 639 |
|
| 640 |
"hashcash -cd -e 1m -b 10 -r foo < stamp" |
| 641 |
and the stamp will be rejected anyway as it has expired, |
| 642 |
illustrating why it was not necessary to keep this stamp in the |
| 643 |
database. |
| 644 |
|
| 645 |
With the default database (the sdb format) the database contents are |
| 646 |
human readable, so you can view their contents by cating them to the |
| 647 |
terminal: |
| 648 |
|
| 649 |
"cat hashcash.sdb" |
| 650 |
to see that the stamp really is added and then after puring |
| 651 |
subsequently purged due to expiry. |
| 652 |
|
| 653 |
Purging old stamps on Demand |
| 654 |
As a convenience you can purge at the same time as checking stamps by |
| 655 |
using the *-p* option with the *-c* option. |
| 656 |
|
| 657 |
"hashcash -m -b 10 foo > stamp" |
| 658 |
"hashcash -cd -p now -e 1 -b 10 -r foo < stamp" |
| 659 |
It may be inefficient to purge stamps on every use as the entire |
| 660 |
database has to be scanned for expired stamps. By giving a time |
| 661 |
period to the *-p* option, you can tell "hashcash" to purge no more |
| 662 |
frequently than that time period since the previous purge. |
| 663 |
|
| 664 |
For example: |
| 665 |
|
| 666 |
"hashcash -cd -p 1d -e 1 -b 10 -r foo < stamp" |
| 667 |
tells "hashcash" to purge any expired stamps no more than once per |
| 668 |
day. |
| 669 |
|
| 670 |
"hashcash -p 1M -j foo" |
| 671 |
tells "hashcash" to purge only expired stamps matching resource foo |
| 672 |
once per month. |
| 673 |
|
| 674 |
"hashcash -p now -k" |
| 675 |
tells "hashcash" to purge all stamps (expired and unexpired) now. |
| 676 |
|
| 677 |
stamp format (version 1) |
| 678 |
The current stamp format is version 1. This tool can verify hashcash |
| 679 |
version 0 stamps also, but version 0 stamps are no longer created as |
| 680 |
they are being phased out in favor of the more extensible v1 stamp |
| 681 |
format. |
| 682 |
|
| 683 |
*ver*:*bits*:*date*:*resource*:[*ext*]:*rand*:*counter* |
| 684 |
|
| 685 |
where |
| 686 |
|
| 687 |
*ver* = 1 |
| 688 |
*bits* = how many bits of partial-preimage the stamp is claimed to have |
| 689 |
*date* = YYMMDD[hhmm[ss]] |
| 690 |
*resource* = resource string (eg IP address, email address) |
| 691 |
*ext* = extension -- ignored in the current version |
| 692 |
Format of extension: |
| 693 |
|
| 694 |
[name1[=val1[,val2...]];[name2[=val1[,val2...]]...]] |
| 695 |
Note the value can also contain =. Example extension (not a real |
| 696 |
one): |
| 697 |
|
| 698 |
name1=2,3;name2;name3=var1=2,var2=3,2,val |
| 699 |
|
| 700 |
Which would be extension name1 has values 2 and 3; extension |
| 701 |
name2 has no values; extension name3 has 3 values "var1=2", |
| 702 |
"var2=3", "2" and "val". The hashcash extension may interpret |
| 703 |
the values as it sees fit eg "var1=2" could be the value of an |
| 704 |
option to the extension name3. |
| 705 |
|
| 706 |
*rand* = string of random characters from alphabet a-zA-Z0-9+/= to avoid |
| 707 |
preimage with other sender's stamps |
| 708 |
*counter* = to find a stamp with the desired number of preimage bits |
| 709 |
need to try lots of different strings this counter is incremented on |
| 710 |
each try. The Counter is also composed of characters from the alphabet |
| 711 |
a-zA-Z0-9+/=. (Note an implementation is not required to count |
| 712 |
sequentially). |
| 713 |
|
| 714 |
FILES |
| 715 |
hashcash.sdb |
| 716 |
default double spend database |
| 717 |
|
| 718 |
EXIT STATUS |
| 719 |
"hashcash" returns success (exit code 0) after successfully minting a |
| 720 |
stamp, after fully checking a stamp and finding it valid, and after a |
| 721 |
timing test. |
| 722 |
|
| 723 |
If when checking a stamp it is found to be invalid (due to being |
| 724 |
malformed, being expired, having insufficient value, having a date in |
| 725 |
the future, or being double spent), "hashcash" returns failure (exit |
| 726 |
code 1). |
| 727 |
|
| 728 |
If insufficient options are given to fully check a stamp, if the stamp |
| 729 |
is otherwise valid return unchecked (exit code 2). If the *-y* flag is |
| 730 |
given and hashcash would normally return unchecked, exit code success is |
| 731 |
returned instead. |
| 732 |
|
| 733 |
If any exception occurs (file read failure for database checking or |
| 734 |
corrupted database contents) an exit status of 3 is returned. |
| 735 |
|
| 736 |
AUTHOR |
| 737 |
Written by Adam Back <[email protected]> |
| 738 |
|
| 739 |
SEE ALSO |
| •740 |
sha1sum(1), sha1(1), http://www.hashcash.org/ |
| 741 |
|