Debian Codegraph @

hashcash.txt

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