| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 |
<head> |
| 4 |
<title>hashcash</title> |
| 5 |
<link rev="made" href="mailto:root@localhost" /> |
| 6 |
</head> |
| 7 |
|
| 8 |
<body style="background-color: white"> |
| 9 |
|
| 10 |
<p><a name="__index__"></a></p> |
| 11 |
|
| 12 |
|
| 13 |
<ul> |
| 14 |
|
| 15 |
<li><a href="#name">NAME</a></li> |
| 16 |
<li><a href="#synopsis">SYNOPSIS</a></li> |
| 17 |
<ul> |
| 18 |
|
| 19 |
<li><a href="#mint__create__stamps_">Mint (create) stamps:</a></li> |
| 20 |
<li><a href="#check_stamps_">Check stamps:</a></li> |
| 21 |
<li><a href="#speed_estimates_">Speed estimates:</a></li> |
| 22 |
<li><a href="#purge_database_">Purge database:</a></li> |
| 23 |
<li><a href="#count_partial_preimage_bits_">Count partial preimage bits:</a></li> |
| 24 |
<li><a href="#get_resource_name_">Get resource name:</a></li> |
| 25 |
<li><a href="#get_time_remaining_until_expiry">Get time remaining until expiry</a></li> |
| 26 |
</ul> |
| 27 |
|
| 28 |
<li><a href="#description">DESCRIPTION</a></li> |
| 29 |
<li><a href="#usage_notes">USAGE NOTES</a></li> |
| 30 |
<ul> |
| 31 |
|
| 32 |
<li><a href="#minting_stamps">Minting stamps</a></li> |
| 33 |
<li><a href="#checking_stamps">Checking stamps</a></li> |
| 34 |
<li><a href="#double_spending_protection">Double Spending Protection</a></li> |
| 35 |
<li><a href="#purging_periodically_vs_on_next_access">Purging Periodically vs on Next Access</a></li> |
| 36 |
<li><a href="#speed_estimates">Speed Estimates</a></li> |
| 37 |
<li><a href="#notes">Notes</a></li> |
| 38 |
</ul> |
| 39 |
|
| 40 |
<li><a href="#options">OPTIONS</a></li> |
| 41 |
<li><a href="#examples">EXAMPLES</a></li> |
| 42 |
<ul> |
| 43 |
|
| 44 |
<li><a href="#creating_stamps">Creating stamps</a></li> |
| 45 |
<li><a href="#examining_stamps">Examining Stamps</a></li> |
| 46 |
<li><a href="#verifying_stamps">Verifying Stamps</a></li> |
| 47 |
<li><a href="#double_spending_prevention">Double Spending Prevention</a></li> |
| 48 |
<li><a href="#stamp_expiry">Stamp Expiry</a></li> |
| 49 |
<li><a href="#purging_old_stamps">Purging old stamps</a></li> |
| 50 |
<li><a href="#purging_old_stamps_on_demand">Purging old stamps on Demand</a></li> |
| 51 |
</ul> |
| 52 |
|
| 53 |
<li><a href="#stamp_format__version_1_">stamp format (version 1)</a></li> |
| 54 |
<li><a href="#files">FILES</a></li> |
| 55 |
<li><a href="#exit_status">EXIT STATUS</a></li> |
| 56 |
<li><a href="#author">AUTHOR</a></li> |
| 57 |
<li><a href="#see_also">SEE ALSO</a></li> |
| 58 |
</ul> |
| 59 |
|
| 60 |
|
| 61 |
<hr /> |
| 62 |
<p> |
| 63 |
</p> |
| 64 |
<h1><a name="name">NAME</a></h1> |
| 65 |
<p>hashcash - hashcash anti-spam / denial of service counter-measure tool</p> |
| 66 |
<p> |
| 67 |
</p> |
| 68 |
<hr /> |
| 69 |
<h1><a name="synopsis">SYNOPSIS</a></h1> |
| 70 |
<p> |
| 71 |
</p> |
| 72 |
<h2><a name="mint__create__stamps_">Mint (create) stamps:</a></h2> |
| 73 |
<p><strong>hashcash</strong> <em>-m</em> [ [ <em>options</em> ] [ <em>resource</em> ... ] ... ]</p> |
| 74 |
<p> |
| 75 |
</p> |
| 76 |
<h2><a name="check_stamps_">Check stamps:</a></h2> |
| 77 |
<p><strong>hashcash</strong> <em>-c</em> [ [ <em>options</em> ] <em>-r resource</em> ... ] [ <em>stamp</em> ... ]</p> |
| 78 |
<p> |
| 79 |
</p> |
| 80 |
<h2><a name="speed_estimates_">Speed estimates:</a></h2> |
| 81 |
<p><strong>hashcash</strong> <em>-s</em> [ <em>options</em> ] [ <em>-b bits</em> ]</p> |
| 82 |
<p> |
| 83 |
</p> |
| 84 |
<h2><a name="purge_database_">Purge database:</a></h2> |
| 85 |
<p><strong>hashcash</strong> <em>-p now</em> [ <em>-j resource</em> ] [ <em>-k</em> ] [ <em>-t time</em> ] [ <em>-u</em> ]</p> |
| 86 |
<p> |
| 87 |
</p> |
| 88 |
<h2><a name="count_partial_preimage_bits_">Count partial preimage bits:</a></h2> |
| 89 |
<p><strong>hashcash</strong> <em>-w</em> [ <em>options</em> ] [ <em>stamp</em> ... ]</p> |
| 90 |
<p> |
| 91 |
</p> |
| 92 |
<h2><a name="get_resource_name_">Get resource name:</a></h2> |
| 93 |
<p><strong>hashcash</strong> <em>-n</em> [ <em>options</em> ] [ <em>stamp</em> ... ]</p> |
| 94 |
<p> |
| 95 |
</p> |
| 96 |
<h2><a name="get_time_remaining_until_expiry">Get time remaining until expiry</a></h2> |
| 97 |
<p><strong>hashcash</strong> <em>-l</em> [ <em>options</em> ] <em>-e period</em> [ <em>stamp</em> ... ]</p> |
| 98 |
<p> |
| 99 |
</p> |
| 100 |
<hr /> |
| 101 |
<h1><a name="description">DESCRIPTION</a></h1> |
| 102 |
<p>Hashcash is a denial-of-service counter measure tool. Its main |
| 103 |
current use is to help hashcash users avoid losing email due to |
| 104 |
content based and blacklist based anti-spam systems.</p> |
| 105 |
<p>The hashcash tool allows you to create hashcash stamps to attach to |
| 106 |
emails you send, and to verify hashcash stamps attached to emails you |
| 107 |
receive. Email senders attach hashcash stamps with the X-Hashcash: |
| 108 |
header. Vendors and authors of anti-spam tools are encouraged to |
| 109 |
exempt mail sent with hashcash from their blacklists and content based |
| 110 |
filtering rules.</p> |
| 111 |
<p>A hashcash stamp constitutes a proof-of-work which takes a |
| 112 |
parameterizable amount of work to compute for the sender. The |
| •113 |
recipient can verify received stamps efficiently.</p> |
| 114 |
<p>The hashcash proof-of-work function is to compute partial hash |
| 115 |
preimages (the SHA1 hash function is used). By choosing the number of |
| 116 |
bits of the preimage that are equal to 0, the work required to compute |
| 117 |
a partial preimage can be made arbitrarily expensive -- from fractions |
| 118 |
of a second to minutes or hours. The verification is efficient |
| 119 |
requiring the same small cost whatever the preimage size.</p> |
| 120 |
<p>For more detailed discussion of other applications hashcash has been |
| 121 |
used for see <a href="http://www.hashcash.org/">http://www.hashcash.org/</a></p> |
| 122 |
<p> |
| 123 |
</p> |
| 124 |
<hr /> |
| 125 |
<h1><a name="usage_notes">USAGE NOTES</a></h1> |
| 126 |
<p>In this man page a resource name is the name of the service or address |
| 127 |
the stamp is created for. In the case of email, the resource name is |
| 128 |
the recipient's email address in the form <a href="mailto:[email protected].">[email protected].</a></p> |
| 129 |
<p> |
| 130 |
</p> |
| 131 |
<h2><a name="minting_stamps">Minting stamps</a></h2> |
| 132 |
<p>The <em>-m</em> flag must be given to mint a stamp.</p> |
| 133 |
<p>The resource name (recipient's email address) to mint the stamp |
| 134 |
against can be passed as an argument, or if omitted is read from |
| 135 |
stdin. If stdin is a tty the user is prompted, if stdin is a pipe the |
| 136 |
resource name is just silently read. The desired preimage size can |
| 137 |
be specified with the -b option. If no preimage size is specified, |
| 138 |
the default is 20 bits. See also the <em>-b default</em> option.</p> |
| 139 |
<p> |
| 140 |
</p> |
| 141 |
<h2><a name="checking_stamps">Checking stamps</a></h2> |
| 142 |
<p>The <em>-c</em> flag must be given to check a stamps expiry. The stamp to |
| 143 |
check can be given as an argument to <code>hashcash</code>. If no stamp is |
| 144 |
given the stamp is read from stdin. If stdin is a tty the user will |
| 145 |
be prompted, if stdin is a pipe the stamp is just silently read. A |
| 146 |
resource name (the recipient's email address) can be given with the |
| 147 |
<em>-r</em> option. If a resource name is given the resource name is |
| 148 |
compared to the resource name in the stamp, if they do not match, the |
| 149 |
stamp is rejected.</p> |
| 150 |
<p>Note: if no resource name is given the stamp is anyway checked to see |
| 151 |
if it is otherwise valid, but it could be minted for a different |
| 152 |
resource, which would allow stamps to be reused across different |
| 153 |
resources, so hashcash will return unchecked exit code on exit.</p> |
| 154 |
<p>Stamps are by default considered to be valid for 28 days. The validity |
| 155 |
period can be changed using the <em>-e</em> flag.</p> |
| 156 |
<p>If the stamp has expired or has a date in the future the stamp is |
| 157 |
rejected and the program exits immediately.</p> |
| 158 |
<p>If a required preimage size is given with the <em>-b</em> flag, the stamps value |
| 159 |
is computed and compared, if the stamp has insufficent value it is rejected, |
| 160 |
and the program exits immediately. If the <em>-b</em> flag is not given, the |
| 161 |
stamp is checked to see if it is otherwise valid, but hashcash will return |
| 162 |
unchecked exit code on exit.</p> |
| 163 |
<p>If the stamp is double spent the stamp is rejected. Double spending |
| 164 |
protection is discussed in more detail below in |
| 165 |
<a href="#double_spending_protection">Double Spending Protection</a>. If double spending protection is not |
| 166 |
enabled, the stamp could be double spent, so hashcash will return |
| 167 |
unchecked exit code (exit code 2) on exit.</p> |
| 168 |
<p>The <em>-w</em> flag can be used to request that the number of bits of the |
| 169 |
preimage are counted and displayed. The <em>-n</em> flag can be used to |
| 170 |
request that the resource name in the stamp is parsed out and |
| 171 |
displayed. The <em>-l</em> flag can be used to request the number of |
| 172 |
seconds until expiry of the stamp is output.</p> |
| 173 |
<p>The program will only return exit codes valid or invalid if the <em>-c</em> |
| 174 |
flag is used, the <em>-b</em> flag is used, <em>-d</em>, <em>-r resource</em> are used. |
| 175 |
These are the minimum set of options necessary to fully check the |
| 176 |
validty of a stamp. If these criteria are not met, the program will |
| 177 |
return exit code unchecked (exit code 2) on exit. (See also the <em>-y</em> |
| 178 |
flag.)</p> |
| 179 |
<p> |
| 180 |
</p> |
| 181 |
<h2><a name="double_spending_protection">Double Spending Protection</a></h2> |
| 182 |
<p>If the <em>-d</em> flag is used when checking stamps, a database of spent |
| 183 |
stamps is kept.</p> |
| 184 |
<p>By default stamps expire after 28 days, without expiry the database |
| 185 |
would grow indefinately. You can specify an alternate expiry period |
| 186 |
with the <em>-e</em> flag. The recommended (and default) expiry period for |
| 187 |
email is 28 days. After the expiry period amount of time, the stamp |
| 188 |
is anyway considered expired and may be purged from the database to |
| 189 |
save space. (See <a href="#purging_periodically_vs_on_next_access">Purging Periodically vs on Next Access</a> for how to |
| 190 |
purge stamps.)</p> |
| 191 |
<p>For efficiency reasons a stamp is verified before it is checked in the |
| 192 |
database; if it is otherwise invalid no database activity will occur.</p> |
| 193 |
<p>Note: The decision about how long the stamp should be considered valid |
| 194 |
is up to the verifier. If it is too short it is possible for some |
| 195 |
applications that the stamp will expire before arriving at the |
| 196 |
recipient (eg with email.) The suggested value of 28 days should be |
| 197 |
safe for normal email delivery delays. The choice is a trade-off |
| 198 |
between database size and risk of expiry prior to arrival, and depends |
| 199 |
on the application.</p> |
| 200 |
<p>Note: Different stamps in the same database can have different |
| 201 |
validity periods, so for example stamps for different resources with |
| 202 |
different validity periods can be stored in the same database, or the |
| 203 |
recipient may change the validity period for future stamps without |
| 204 |
affecting the validity of old stamps.</p> |
| 205 |
<p> |
| 206 |
</p> |
| 207 |
<h2><a name="purging_periodically_vs_on_next_access">Purging Periodically vs on Next Access</a></h2> |
| 208 |
<p>To purge old stamps periodically while checking stamps use the <em>-p |
| 209 |
period</em> option to purge no sooner than the given time period since the |
| 210 |
last purge. Purging can be used with the <em>-k</em> option to purge |
| 211 |
unexpired stamps also, and with the <em>-j resource</em> flag to purge only |
| 212 |
stamps for the given resource.</p> |
| 213 |
<p>There are circumstances where it may be inconvenient to purge stamps |
| 214 |
on the next access, for example if there is a large double spend |
| 215 |
database which takes some time to purge, and the response time of the |
| 216 |
hashcash checker is important. To avoid this problem, purging can be |
| 217 |
done separately using just the <em>-p now</em> option to request just the |
| 218 |
purge operation. On unix for example you could call <a href="#item_hashcash__2dp_now"><code>hashcash -p |
| 219 |
now</code></a> in a cron job once per day, or on demand when disk was running |
| 220 |
low.</p> |
| 221 |
<p> |
| 222 |
</p> |
| 223 |
<h2><a name="speed_estimates">Speed Estimates</a></h2> |
| 224 |
<p>The <em>-s</em> flag requests measurement of how many preimage can be |
| 225 |
tested per second. No stamp is minted, or verified.</p> |
| 226 |
<p>If the <em>-b</em> flag is used with this option, instead an estimate of how |
| 227 |
many seconds it would take to mint a stamp of the given size in bits |
| 228 |
is computed. To find out how much time it will take to mint a default |
| 229 |
sized stamp use <em>-s -b default</em>.</p> |
| 230 |
<p> |
| 231 |
</p> |
| 232 |
<h2><a name="notes">Notes</a></h2> |
| 233 |
<p>All informational output is printed on stderr. Minted stamps, and |
| 234 |
results of stamp verification and timing are printed on stdout. The |
| 235 |
quiet flag <em>-q</em> suppresses all informational output. The <em>-v</em> flag |
| 236 |
requests more informational output. The requested output, which is |
| 237 |
the only information that is output in quiet mode (when <em>-q</em> is |
| 238 |
specified) is printed on standard output. If stdout is a pipe, or |
| 239 |
when quiet mode is in effect the output is printed without description |
| 240 |
(ie just bits, just seconds, just resource).</p> |
| 241 |
<p> |
| 242 |
</p> |
| 243 |
<hr /> |
| 244 |
<h1><a name="options">OPTIONS</a></h1> |
| 245 |
<dl> |
| 246 |
<dt><strong><a name="item__2dc"><em>-c</em></a></strong><br /> |
| 247 |
</dt> |
| 248 |
<dd> |
| 249 |
Check the expiry information of stamps given as an argument or on |
| 250 |
stdin. (Use with <em>-b</em>, <em>-d</em> and <em>-r resource</em> to fully check |
| 251 |
stamps). |
| 252 |
</dd> |
| 253 |
<p></p> |
| 254 |
<dt><strong><a name="item__2dm"><em>-m</em></a></strong><br /> |
| 255 |
</dt> |
| 256 |
<dd> |
| 257 |
Mint stamps with the resources given as arguments or on stdin. |
| 258 |
</dd> |
| 259 |
<p></p> |
| 260 |
<dt><strong><a name="item__2db_bits"><em>-b bits</em></a></strong><br /> |
| 261 |
</dt> |
| 262 |
<dd> |
| 263 |
When minting a stamp, create a preimage of at least this many bits. |
| 264 |
When verifying a stamp require that it have a preimage of at minimum |
| 265 |
this many bits, otherwise reject it. If omitted the default is used. |
| 266 |
</dd> |
| 267 |
<dd> |
| 268 |
<p>When checking stamps, require that the stamps have this many bits.</p> |
| 269 |
</dd> |
| 270 |
<dd> |
| 271 |
<p>The default number of bits can be specified with <em>-b default</em>. Bits |
| 272 |
relative to the default can also be specified with <em>-b +n</em> for n bits |
| 273 |
more than the default and <em>-b -n</em> for n bits less than the default.</p> |
| 274 |
</dd> |
| 275 |
<dd> |
| 276 |
<p><em>-b default</em>, <em>-b +0</em> and <em>-b -0</em> are all equivalent.</p> |
| 277 |
</dd> |
| 278 |
<dd> |
| 279 |
<p>When doing the speed test <em>-s</em>, can to measure speed of default |
| 280 |
token with <em>-s -b default</em>.</p> |
| 281 |
</dd> |
| 282 |
<p></p> |
| 283 |
<dt><strong><a name="item__2dr_resource"><em>-r resource</em></a></strong><br /> |
| 284 |
</dt> |
| 285 |
<dd> |
| 286 |
When minting stamps, the resource name (recipient's email address) to |
| 287 |
mint the stamp against can be given either with <em>-r resource</em> or as |
| 288 |
an argument to <code>hashcash</code>. |
| 289 |
</dd> |
| 290 |
<dd> |
| 291 |
<p>When checking stamps, the resource name (your own email address) is |
| 292 |
given with the <em>-r</em> option. If the resource name is given it is |
| 293 |
checked against the resource name in the stamp, and if they do not |
| 294 |
match the stamp is rejected. Note if the resource name is not given, |
| 295 |
stamps for other resources would be accepted, and therefore hashcash |
| 296 |
returns exit code unchecked (exit code 2) on exit.</p> |
| 297 |
</dd> |
| 298 |
<p></p> |
| 299 |
<dt><strong><a name="item__2do"><em>-o</em></a></strong><br /> |
| 300 |
</dt> |
| 301 |
<dd> |
| 302 |
When verifying stamps multiple resources can be given. By default the |
| 303 |
resources are just checked one by one until a matching valid resource is |
| 304 |
found. However when you use wildcards or regular expressions (see <em>-E</em>), |
| 305 |
it is useful to be able to specify that one resource overrides another. For |
| 306 |
example this: <em>-b15 -r <a href="mailto:[email protected]">[email protected]</a> -o -b10 *@dev.null</em> states that mail |
| 307 |
to address <em><a href="mailto:[email protected]">[email protected]</a></em> requires 15 bits, but mail to <em>*@dev.null</em> |
| 308 |
requires only 10 bits. If we omitted the <em>-o</em> override relationship |
| 309 |
between the two resources, a stamp of 10 bits would be accepted for address |
| 310 |
<em><a href="mailto:[email protected]">[email protected]</a></em> because while it would be rejected as having insufficient |
| 311 |
bits under the first rule, it would be accepted under the 2nd rule. The |
| 312 |
<em>-o</em> option allows you avoid this problem. |
| 313 |
</dd> |
| 314 |
<p></p> |
| 315 |
<dt><strong><a name="item__2de_time"><em>-e time</em></a></strong><br /> |
| 316 |
</dt> |
| 317 |
<dd> |
| 318 |
Expiry period for spent stamps. While checking stamps (using the <em>-c</em> |
| 319 |
flag), if the stamp was minted more than the specified amount of time ago, |
| 320 |
it is considered expired. If this option is not used, by default stamps |
| 321 |
expire after 28 days. The expiry period is given in seconds by default (an |
| 322 |
argument of 0 means forever). A single character suffix can be used to |
| 323 |
specify alternate units (m = minutes, h = hours, d = days, M = months, y = Y |
| 324 |
= years, and s = seconds). |
| 325 |
</dd> |
| 326 |
<dd> |
| 327 |
<p>If used with the <em>-d</em> option, the spent stamp and its expiry period |
| 328 |
is recorded in the database. See the <em>-p</em> option for description of |
| 329 |
how to purge stamps from the database.</p> |
| 330 |
</dd> |
| 331 |
<dd> |
| 332 |
<p>While minting stamps, the <em>-e</em> flag can have an effect on the |
| 333 |
resolution of time created in the stamp. Without the <em>-e</em> option, |
| 334 |
the default resolution is days (time format: YYMMDD). Alternate |
| 335 |
formats based on range of expiry period are as follows:</p> |
| 336 |
</dd> |
| 337 |
<dd> |
| 338 |
<p>While minting you can also given an explicit time width with the <em>-z</em> |
| 339 |
option instead. (<em>-z</em> overrides <em>-e</em> if both are given. If neither |
| 340 |
are given the default is 6 chars (time format: YYMMDD)).</p> |
| 341 |
</dd> |
| 342 |
<dd> |
| 343 |
<p>The rules for automatically determining appropriate time width from |
| 344 |
<em>-e</em> if no <em>-z</em> option is given are:</p> |
| 345 |
</dd> |
| 346 |
<ul> |
| 347 |
<li><strong><a name="item_period__3e_3d_2_years_then_time_format_yy_is_used_">period >= 2 years then time format YY is used rounded down |
| 348 |
to the nearest year start;</a></strong><br /> |
| 349 |
</li> |
| 350 |
<li><strong><a name="item_2_years__3c_period__3c_3d_2_months_then_time_forma">2 years < period <= 2 months then time format YYMM is |
| 351 |
used rounded down to the nearest month start;</a></strong><br /> |
| 352 |
</li> |
| 353 |
<li><strong><a name="item_2_months__3c_period__3c_3d_2_days_then_time_format">2 months < period <= 2 days then time format YYMMDD is |
| 354 |
used rounded down to the begining of the nearest day;</a></strong><br /> |
| 355 |
</li> |
| 356 |
<li><strong><a name="item_2_days__3c_period__3c_3d_2_minutes_then_time_forma">2 days < period <= 2 minutes then time format |
| 357 |
YYMMDDhhmm is used rounded down to the begining of the nearest minute;</a></strong><br /> |
| 358 |
</li> |
| 359 |
<li><strong><a name="item_period__3c_2_minutes_then_time_format_yymmddhhmmss">period < 2 minutes then time format YYMMDDhhmmss is used in |
| 360 |
seconds.</a></strong><br /> |
| 361 |
</li> |
| 362 |
</ul> |
| 363 |
<p>Note the rounding down is based on UTC time, not local time. This can |
| 364 |
lead to initially suprising results when rounding down to eg days in |
| 365 |
time zones other than GMT (UTC = GMT). It may be clearer to |
| 366 |
understand if you use the <em>-u</em> option.</p> |
| 367 |
<dt><strong><a name="item__2dz_width"><em>-z width</em></a></strong><br /> |
| 368 |
</dt> |
| 369 |
<dd> |
| 370 |
The <em>-z</em> option is for use during minting and allows user choice of |
| 371 |
width of time width field. See also the <em>-e</em> option given in |
| 372 |
combination with <em>-m</em> to specify an implicit time field width under |
| 373 |
the description of the <em>-e</em> flag. Valid widths are 6,10 or 12 chars |
| 374 |
corresponding respectively to: YYMMDD, YYMMDDhhmm, and YYMMDDhhmmss |
| 375 |
rounded down to the nearest day, or minute respectively. |
| 376 |
</dd> |
| 377 |
<dd> |
| 378 |
<p>Note the rounding down is based on UTC time, not local time. This can |
| 379 |
lead to initially suprising results when rounding down to eg days in |
| 380 |
time zones other than GMT (UTC = GMT). It may be clearer to |
| 381 |
understand if you use the <em>-u</em> option.</p> |
| 382 |
</dd> |
| 383 |
<p></p> |
| 384 |
<dt><strong><a name="item__2dg_period"><em>-g period</em></a></strong><br /> |
| 385 |
</dt> |
| 386 |
<dd> |
| 387 |
The <em>-g</em> option is for use when checking hashcash stamps with the |
| 388 |
<em>-c</em> option and specifies a grace period for clock skew, ie if a |
| 389 |
hashcash stamp arrives with a date in the future or in the past it |
| 390 |
will not be rejected as having a futuristic date (or as being expired) |
| 391 |
unless it is more futuristic (or has been expired for longer) than |
| 392 |
this period. The default is 2 days, which means as long as the |
| 393 |
sending system's clock is no more than 2 days ahead (or 2 days behind) |
| 394 |
of the receiving system's clock, the hashcash stamp will still be |
| 395 |
accepted. |
| 396 |
</dd> |
| 397 |
<dd> |
| 398 |
<p>The default units for grace period are seconds. A single character |
| 399 |
suffix can be used to specify alternate units (m = minutes, h = hours, |
| 400 |
d = days, M = months, y = Y = years, and s = seconds).</p> |
| 401 |
</dd> |
| 402 |
<p></p> |
| 403 |
<dt><strong><a name="item__2dd"><em>-d</em></a></strong><br /> |
| 404 |
</dt> |
| 405 |
<dd> |
| 406 |
Store stamps in a double spend database. If stamp has been seen |
| 407 |
before it will be rejected even if it is otherwise valid. The default |
| 408 |
database file is <em>database.sdb</em> in the current directory. Only |
| 409 |
otherwise valid stamps will be stored in the database. Only fully |
| 410 |
validated stamps will be stored in the database, unless the <em>-y</em> |
| 411 |
option is given. |
| 412 |
</dd> |
| 413 |
<p></p> |
| 414 |
<dt><strong><a name="item__2df_dbname"><em>-f dbname</em></a></strong><br /> |
| 415 |
</dt> |
| 416 |
<dd> |
| 417 |
Use <em>dbname</em> instead of default filename for double spend database. |
| 418 |
</dd> |
| 419 |
<p></p> |
| 420 |
<dt><strong><a name="item__2dp_period"><em>-p period</em></a></strong><br /> |
| 421 |
</dt> |
| 422 |
<dd> |
| 423 |
Purges the database of expired stamps if the given time period has |
| 424 |
passed since the last time it was purged. As a convenience <em>-p now</em> |
| 425 |
is equivalent to <em>-p 0</em> both of which mean purge now, regardless of |
| 426 |
when the database was last purged. |
| 427 |
</dd> |
| 428 |
<dd> |
| 429 |
<p>If used in combination with <em>-j resource</em> only the stamps minted for |
| 430 |
the given resource are purged.</p> |
| 431 |
</dd> |
| 432 |
<dd> |
| 433 |
<p>If used in combination with <em>-k</em> all stamps even un-expired stamps |
| 434 |
are purged. Can be used in combination with <em>-t time</em> to expire as |
| 435 |
if the current time were the given time.</p> |
| 436 |
</dd> |
| 437 |
<p></p> |
| 438 |
<dt><strong><a name="item__2dk"><em>-k</em></a></strong><br /> |
| 439 |
</dt> |
| 440 |
<dd> |
| 441 |
Use with option <em>-p</em> to request all stamps are purged rather than |
| 442 |
just expired ones. |
| 443 |
</dd> |
| 444 |
<p></p> |
| 445 |
<dt><strong><a name="item__2dj_resource"><em>-j resource</em></a></strong><br /> |
| 446 |
</dt> |
| 447 |
<dd> |
| 448 |
Use with option <em>-p</em> to request that just stamps matching the given |
| 449 |
resource name are to be purged, rather than the default which is to |
| 450 |
purge all expired stamps. If the resource name is the empty string, |
| 451 |
all stamps are matched (this is equivalent to omitting the <em>-j</em> |
| 452 |
option). |
| 453 |
</dd> |
| 454 |
<dd> |
| 455 |
<p>Note the <em>-E</em>, <em>-M</em> and <em>-S</em> type of match flags also apply to |
| 456 |
resources given with the <em>-j resource</em> flag.</p> |
| 457 |
</dd> |
| 458 |
<p></p> |
| 459 |
<dt><strong><a name="item__2ds"><em>-s</em></a></strong><br /> |
| 460 |
</dt> |
| 461 |
<dd> |
| 462 |
Print timing information only, and don't proceed to create a stamp. |
| 463 |
If combined with <em>-b bits</em> flag print estimate of how long the |
| 464 |
requested preimage size would take to compute, if <em>-s</em> given by |
| 465 |
itself, just prints speed of the preimage finder. To print an |
| 466 |
estimate of how long the default number of bits would take use <em>-b |
| 467 |
default</em>. |
| 468 |
</dd> |
| 469 |
<p></p> |
| 470 |
<dt><strong><a name="item__2dh"><em>-h</em></a></strong><br /> |
| 471 |
</dt> |
| 472 |
<dd> |
| 473 |
Print short usage information. |
| 474 |
</dd> |
| 475 |
<p></p> |
| 476 |
<dt><strong><a name="item__2dv"><em>-v</em></a></strong><br /> |
| 477 |
</dt> |
| 478 |
<dd> |
| 479 |
Print more verbose informational output about the stamp minting or |
| 480 |
verification. (If -v is the only argument, prints the tool version |
| 481 |
number.) |
| 482 |
</dd> |
| 483 |
<p></p> |
| 484 |
<dt><strong><a name="item__2dv"><em>-V</em></a></strong><br /> |
| 485 |
</dt> |
| 486 |
<dd> |
| 487 |
Prints tool version number. |
| 488 |
</dd> |
| 489 |
<p></p> |
| 490 |
<dt><strong><a name="item__2dq"><em>-q</em></a></strong><br /> |
| 491 |
</dt> |
| 492 |
<dd> |
| 493 |
Batch mode. Prints no information other than output. This option |
| 494 |
overrides the <em>-v</em> option. |
| 495 |
</dd> |
| 496 |
<p></p> |
| 497 |
<dt><strong><a name="item__2dx"><em>-X</em></a></strong><br /> |
| 498 |
</dt> |
| 499 |
<dd> |
| 500 |
When minting, prints the hashcash email X-header 'X-Hashcash: ' before |
| 501 |
the stamp. Without this option just the bare stamp is printed. |
| 502 |
</dd> |
| 503 |
<dd> |
| 504 |
<p>When checking, after scanning stamps given as arguments, scans stdin |
| 505 |
for lines starting with the string 'X-Hashcash:', and uses the rest of |
| 506 |
the matching line as the stamp. Only the lines up to and ending at |
| 507 |
the first blank line are scanned (see also <em>-i</em> flag which can be |
| 508 |
used to override this). A blank line is the separator used to |
| 509 |
separate the headers from the body of a mail message or USENET |
| 510 |
article. This is meant to make it convenient to pipe a mail message |
| 511 |
or USENET article to hashcash on stdin.</p> |
| 512 |
</dd> |
| 513 |
<p></p> |
| 514 |
<dt><strong><a name="item__2dx_extension"><em>-x extension</em></a></strong><br /> |
| 515 |
</dt> |
| 516 |
<dd> |
| 517 |
An extension string composed of name value sets. The extension format |
| 518 |
is described below in the section on the hashcash stamp format. This |
| 519 |
allows users to define their own stamp extensions which are hashed |
| 520 |
into the stamp, verified by recipients that support them, and ignored |
| 521 |
by recipients that don't support them. Note the extension hook |
| 522 |
mechanism has not yet been implemented. This will come in a |
| 523 |
subsequent release. |
| 524 |
</dd> |
| 525 |
<p></p> |
| 526 |
<dt><strong><a name="item__2di"><em>-i</em></a></strong><br /> |
| 527 |
</dt> |
| 528 |
<dd> |
| 529 |
When checking and using the <em>-X</em> flag, ignore the blank line |
| 530 |
boundary between headers and body of the message, and check for |
| 531 |
stamps in the body too if one is not found in the headers. |
| 532 |
</dd> |
| 533 |
<p></p> |
| 534 |
<dt><strong><a name="item__2dt_time"><em>-t time</em></a></strong><br /> |
| 535 |
</dt> |
| 536 |
<dd> |
| 537 |
Pretend the current time is the time given for purposes of minting |
| 538 |
stamps, verifying stamps and purging old stamps from the database. |
| 539 |
Time is given in a format based on UTCTIME format |
| 540 |
YYMMDD[hhmm[ss]]. |
| 541 |
</dd> |
| 542 |
<dd> |
| 543 |
<p>Time is expressed in local time by default. Use with <em>-u</em> flag to |
| 544 |
give time in UTC (GMT).</p> |
| 545 |
</dd> |
| 546 |
<dd> |
| 547 |
<p>You can also give time relative to the current time by prefixing the |
| 548 |
argument with + or -. The default units for relative time are |
| 549 |
seconds. A single character suffix can be used to specify alternate |
| 550 |
units (m = minutes, h = hours, d = days, M = months, y = Y = years, |
| 551 |
and s = seconds).</p> |
| 552 |
</dd> |
| 553 |
<dd> |
| 554 |
<p>Note: when time is expressed in local time, if there is daylight |
| 555 |
savings in your timezone, there are one or two ambiguous hours per |
| 556 |
year at the time of change from daylight savings time to normal time.</p> |
| 557 |
</dd> |
| 558 |
<p></p> |
| 559 |
<dt><strong><a name="item__2du"><em>-u</em></a></strong><br /> |
| 560 |
</dt> |
| 561 |
<dd> |
| 562 |
Input and output absolute times in UTC (GMT) instead of local time. |
| 563 |
</dd> |
| 564 |
<p></p> |
| 565 |
<dt><strong><a name="item__2da_period"><em>-a period</em></a></strong><br /> |
| 566 |
</dt> |
| 567 |
<dd> |
| 568 |
Add (or subtract if number is negative) a random value from the |
| 569 |
current time before minting the stamp. This hides the time the stamp |
| 570 |
was created, which may be useful for anonymous users. Note adding |
| 571 |
(rather than subtracting) a random time may be risky if the stamp |
| 572 |
takes less than the added time to arrive as the recipient will reject |
| 573 |
stamps with time stamps in the future. |
| 574 |
</dd> |
| 575 |
<p></p> |
| 576 |
<dt><strong><a name="item__2dn"><em>-n</em></a></strong><br /> |
| 577 |
</dt> |
| 578 |
<dd> |
| 579 |
Print resource name parsed from stamp being verified. Returns exit |
| 580 |
code unchecked on exit. |
| 581 |
</dd> |
| 582 |
<p></p> |
| 583 |
<dt><strong><a name="item__2dl"><em>-l</em></a></strong><br /> |
| 584 |
</dt> |
| 585 |
<dd> |
| 586 |
Print number of seconds left before stamp expires. Returns exit code |
| 587 |
unchecked on exit. |
| 588 |
</dd> |
| 589 |
<dd> |
| 590 |
<p>Note: the calculation includes the grace period, so can be up to 2 |
| 591 |
times grace period longer than you might otherwise expect (clock fast |
| 592 |
but system has to presume it could be slow). If you want to exclude |
| 593 |
the grace period add <em>-g0</em> to set grace period to 0 for the |
| 594 |
calculation.</p> |
| 595 |
</dd> |
| 596 |
<p></p> |
| 597 |
<dt><strong><a name="item__2dw"><em>-w</em></a></strong><br /> |
| 598 |
</dt> |
| 599 |
<dd> |
| 600 |
Print number of bits of preimage of stamp. Returns exit code |
| 601 |
unchecked on exit. |
| 602 |
</dd> |
| 603 |
<p></p> |
| 604 |
<dt><strong><a name="item__2dy"><em>-y</em></a></strong><br /> |
| 605 |
</dt> |
| 606 |
<dd> |
| 607 |
Returns success if the stamp is valid even if it is not fully checked. |
| 608 |
Use with <em>-c</em> where not all of <em>-d</em>, <em>-r</em> are specified to get |
| 609 |
success exit code on valid but partially checked stamp. Similarly can |
| 610 |
use with <em>-n</em>, <em>-l</em>, <em>-w</em> with same effect. |
| 611 |
</dd> |
| 612 |
<p></p> |
| 613 |
<dt><strong><a name="item__2dm"><em>-M</em></a></strong><br /> |
| 614 |
</dt> |
| 615 |
<dd> |
| 616 |
When checking stamps, allow wildcard <em>*</em> matching in the resource |
| 617 |
name to make it simpler to specify multiple email addresses and to |
| 618 |
allow matching catch-all addresses and addresses including subdomains. |
| 619 |
This is the default. See also <em>-S</em>, <em>-E</em> and <em>-C</em> |
| 620 |
</dd> |
| 621 |
<p></p> |
| 622 |
<dt><strong><a name="item__2ds"><em>-S</em></a></strong><br /> |
| 623 |
</dt> |
| 624 |
<dd> |
| 625 |
When checking stamps use simple text compare to compare resource names |
| 626 |
to those in stamps. See also <em>-M</em>, <em>-E</em> and <em>-C</em>. |
| 627 |
</dd> |
| 628 |
<p></p> |
| 629 |
<dt><strong><a name="item__2de"><em>-E</em></a></strong><br /> |
| 630 |
</dt> |
| 631 |
<dd> |
| 632 |
When checking stamps use regular expressions to specify resource names |
| 633 |
to make it simpler to specify multiple email addresses, catch-all |
| 634 |
addresses, classes of extension addresses and addresses including |
| 635 |
subdomains. Note regular expression syntax is POSIX style: special |
| 636 |
characters do not need to be quoted to have their special meaning; but |
| 637 |
they do have to be quoted with \ to that character in the searched |
| 638 |
string. The regular expression automatically has ^ added at the |
| 639 |
beginning and $ added at the end, if they are not specified. The |
| 640 |
special characters ^ matches the beginning of the resouce, and $ |
| 641 |
matches the end of resource. |
| 642 |
</dd> |
| 643 |
<dd> |
| 644 |
<p>(Note even if compiled with BSD regular expressions, POSIX style |
| 645 |
syntax is used; also note BSD regular expressions do not support |
| 646 |
ranges {}.)</p> |
| 647 |
</dd> |
| 648 |
<p></p> |
| 649 |
<dt><strong><a name="item__2dc"><em>-C</em></a></strong><br /> |
| 650 |
</dt> |
| 651 |
<dd> |
| 652 |
By default resources are canonicalized to lower case on minting and on |
| 653 |
checking. The <em>-C</em> flag overrides this so that resources are treated |
| 654 |
as case sensitive on checking, and not canonizalized on minting. |
| 655 |
</dd> |
| 656 |
<p></p> |
| 657 |
<dt><strong><a name="item__2dp"><em>-P</em></a></strong><br /> |
| 658 |
</dt> |
| 659 |
<dd> |
| 660 |
Print progress info (number of iterations, expected iterations, |
| 661 |
percentage done, best stamp size found so far). |
| 662 |
</dd> |
| 663 |
<p></p> |
| 664 |
<dt><strong><a name="item__2do_core"><em>-O core</em></a></strong><br /> |
| 665 |
</dt> |
| 666 |
<dd> |
| 667 |
Select hashcash core with that number. Currently 0-9 are valid cores. |
| 668 |
Not all cores work on all architectures. Eg some are x86 specific |
| 669 |
assembler, others PPC specific assembler. If a core is not valid |
| 670 |
hashcash returns failure and explains what happened. |
| 671 |
</dd> |
| 672 |
<p></p> |
| 673 |
<dt><strong><a name="item__2dz_n"><em>-Z n</em></a></strong><br /> |
| 674 |
</dt> |
| 675 |
<dd> |
| 676 |
Compress the stamp. This is a time vs space trade off. Larger stamps |
| 677 |
are faster, but arguably slightly ugly. For fastest stamps (the |
| 678 |
default) use -Z 0; for partly compressed stamps use -Z 1; for very |
| 679 |
compressed, but somewhat slow stamps use -Z 2. (Note: due to a late |
| 680 |
discovered bug, -Z2 is the same as -Z1 for now until I can fix that.) |
| 681 |
</dd> |
| 682 |
<p></p></dl> |
| 683 |
<p> |
| 684 |
</p> |
| 685 |
<hr /> |
| 686 |
<h1><a name="examples">EXAMPLES</a></h1> |
| 687 |
<p> |
| 688 |
</p> |
| 689 |
<h2><a name="creating_stamps">Creating stamps</a></h2> |
| 690 |
<dl> |
| 691 |
<dt><strong><a name="item_hashcash__2ds"><code>hashcash -s</code></a></strong><br /> |
| 692 |
</dt> |
| 693 |
<dd> |
| 694 |
Print timing information about how many preimages the machine can try |
| 695 |
per second. |
| 696 |
</dd> |
| 697 |
<p></p> |
| 698 |
<dt><strong><a name="item_hashcash__2dsv"><code>hashcash -sv</code></a></strong><br /> |
| 699 |
</dt> |
| 700 |
<dd> |
| 701 |
More accurate but quite slow benchmarking of different processor |
| 702 |
specific minting cores. |
| 703 |
</dd> |
| 704 |
<p></p> |
| 705 |
<dt><strong><a name="item_hashcash__2ds__2db_default"><code>hashcash -s -b default</code></a></strong><br /> |
| 706 |
</dt> |
| 707 |
<dd> |
| 708 |
Print how long it would take the machine to compute a default sized |
| 709 |
preimage (but don't actually compute a preimage). |
| 710 |
</dd> |
| 711 |
<p></p> |
| 712 |
<dt><strong><a name="item_hashcash__2ds__2db_32"><code>hashcash -s -b 32</code></a></strong><br /> |
| 713 |
</dt> |
| 714 |
<dd> |
| 715 |
Print how long it would take the machine to compute a 32 bit preimage |
| 716 |
(but don't actually compute a preimage). |
| 717 |
</dd> |
| 718 |
<p></p> |
| 719 |
<dt><strong><a name="item_hashcash__2dm"><code>hashcash -m</code></a></strong><br /> |
| 720 |
</dt> |
| 721 |
<dd> |
| 722 |
Mint a stamp. Will prompt for resource name and mint with default |
| 723 |
value (number of preimage bits). |
| 724 |
</dd> |
| 725 |
<p></p> |
| 726 |
<dt><strong><a name="item_hashcash__2dm_foo"><code>hashcash -m foo</code></a></strong><br /> |
| 727 |
</dt> |
| 728 |
<dd> |
| 729 |
Compute preimage on resource foo. Will mint with default value |
| 730 |
(number of preimage bits). |
| 731 |
</dd> |
| 732 |
<p></p> |
| 733 |
<dt><strong><a name="item_hashcash__2dm_foo__2db_10"><code>hashcash -m foo -b 10</code></a></strong><br /> |
| 734 |
</dt> |
| 735 |
<dd> |
| 736 |
Compute 10 bit preimage on resource foo. |
| 737 |
</dd> |
| 738 |
<p></p> |
| 739 |
<dt><strong><a name="item_hashcash__2da__2d3d"><code>hashcash -a -3d</code></a></strong><br /> |
| 740 |
</dt> |
| 741 |
<dd> |
| 742 |
Subtract a random time of between 0 days and 3 days from the stamp's |
| 743 |
creation time. This is the same fuzz factor used by mixmaster to |
| 744 |
reduce risk of timing-correlations. |
| 745 |
</dd> |
| 746 |
<p></p></dl> |
| 747 |
<p> |
| 748 |
</p> |
| 749 |
<h2><a name="examining_stamps">Examining Stamps</a></h2> |
| 750 |
<dl> |
| 751 |
<dt><strong><a name="item_hashcash__2dw_1_3a24_3a040806_3afoo_3a_3a511801694"><code>hashcash -w 1:24:040806:foo::511801694b4cd6b0:1e7297a</code></a></strong><br /> |
| 752 |
</dt> |
| 753 |
<dd> |
| 754 |
Report the value of the stamp (how many bits of preimage) there are. |
| 755 |
The example is a 24 bit preimage, which takes on average 25 seconds |
| 756 |
to create on a 3Ghz P4. |
| 757 |
</dd> |
| 758 |
<p></p> |
| 759 |
<dt><strong><a name="item_hashcash__2dmq__2db_10_foo__7c_hashcash__2dw"><code>hashcash -mq -b 10 foo | hashcash -w</code></a></strong><br /> |
| 760 |
</dt> |
| 761 |
<dd> |
| 762 |
Create a stamp in batch mode, pass to hashcash on stdin to verify, |
| 763 |
have it print how many bits there were. |
| 764 |
</dd> |
| 765 |
<p></p> |
| 766 |
<dt><strong><a name="item_hashcash__2dn_1_3a24_3a040806_3afoo_3a_3a511801694"><code>hashcash -n 1:24:040806:foo::511801694b4cd6b0:1e7297a</code></a></strong><br /> |
| 767 |
</dt> |
| 768 |
<dd> |
| 769 |
Report the resource name from the stamp. The resource name in the |
| 770 |
example is foo. |
| 771 |
</dd> |
| 772 |
<p></p> |
| 773 |
<dt><strong><a name="item_hashcash__2dl__2de_30y_1_3a24_3a040806_3afoo_3a_3a"><code>hashcash -l -e 30y 1:24:040806:foo::511801694b4cd6b0:1e7297a</code></a></strong><br /> |
| 774 |
</dt> |
| 775 |
<dd> |
| 776 |
Report how long until the stamp expires if it expires in 30 years from |
| 777 |
its creation date. (Note dates too far into the future run into the |
| 778 |
2038 end of Epoch, which is the unix time analog of the y2k bug). |
| 779 |
</dd> |
| 780 |
<p></p></dl> |
| 781 |
<p> |
| 782 |
</p> |
| 783 |
<h2><a name="verifying_stamps">Verifying Stamps</a></h2> |
| 784 |
<dl> |
| 785 |
<dt><strong><a name="item_hashcash__2dc_1_3a24_3a040806_3afoo_3a_3a511801694"><code>hashcash -c 1:24:040806:foo::511801694b4cd6b0:1e7297a</code></a></strong><br /> |
| 786 |
</dt> |
| 787 |
<dd> |
| 788 |
Check if the stamp is valid. Note as we are not checking the stamp in |
| 789 |
a double spend database, and did not specify a resource name or |
| 790 |
required number of bits of preimage and hashcash will consider the |
| 791 |
stamp not fully checked, and it will report it as valid but not fully |
| 792 |
unchecked, or as invalid if there is any problem with the stamp. |
| 793 |
</dd> |
| 794 |
<p></p> |
| 795 |
<dt><strong><a name="item_hashcash__2dc__2db24_1_3a24_3a040806_3afoo_3a_3a51"><code>hashcash -c -b24 1:24:040806:foo::511801694b4cd6b0:1e7297a</code></a></strong><br /> |
| 796 |
</dt> |
| 797 |
<dd> |
| 798 |
Check that the value of the stamp is greater or equal to 24 bits. |
| 799 |
This example has 24 bit value. If you increase the requested number |
| 800 |
of bits or replace the stamp with one with less than 24 bit preimage |
| 801 |
the stamp will be rejected. |
| 802 |
</dd> |
| 803 |
<p></p> |
| 804 |
<dt><strong><a name="item_hashcash__2dc__2db24__2dr_foo_1_3a24_3a040806_3afo"><code>hashcash -c -b24 -r foo 1:24:040806:foo::511801694b4cd6b0:1e7297a</code></a></strong><br /> |
| 805 |
</dt> |
| 806 |
<dd> |
| 807 |
As above check if the stamp has sufficient value, but in addition |
| 808 |
check that the resource name given matches the resource name in the |
| 809 |
stamp. |
| 810 |
</dd> |
| 811 |
<p></p></dl> |
| 812 |
<p> |
| 813 |
</p> |
| 814 |
<h2><a name="double_spending_prevention">Double Spending Prevention</a></h2> |
| 815 |
<p>The examples given in <a href="#verifying_stamps">Verifying Stamps</a> can be modified to keep a |
| 816 |
double spend database so that the same stamp will not be accepted |
| 817 |
twice. Note a stamp will only be checked in and added to the database |
| 818 |
if it is otherwise valid and fully checked (a required number of bits |
| 819 |
of preimage has been specified and a resource has been specified).</p> |
| 820 |
<dl> |
| 821 |
<dt><strong><a name="item_hashcash__2dcd__2db_10__2dr_foo_1_3a24_3a040806_3a"><code>hashcash -cd -b 10 -r foo 1:24:040806:foo::511801694b4cd6b0:1e7297a</code></a></strong><br /> |
| 822 |
</dt> |
| 823 |
<dd> |
| 824 |
Check the stamp and add to double spent database if it's valid (has |
| 825 |
correct resource name and sufficient value). |
| 826 |
</dd> |
| 827 |
<p></p> |
| 828 |
<dt><strong><code>hashcash -cd -b 10 -r foo 1:24:040806:foo::511801694b4cd6b0:1e7297a</code></strong><br /> |
| 829 |
</dt> |
| 830 |
<dd> |
| 831 |
Try to double spend the stamp. It will be rejected as double spent. |
| 832 |
</dd> |
| 833 |
<p></p></dl> |
| 834 |
<p> |
| 835 |
</p> |
| 836 |
<h2><a name="stamp_expiry">Stamp Expiry</a></h2> |
| 837 |
<p>To prevent the double spend database growing indefinately, the |
| 838 |
recipient can request that stamps be no older than a specified period. |
| 839 |
After expiry old stamps can dropped from the double spend database as |
| 840 |
they will no longer be needed -- expired stamps can be rejected based |
| 841 |
purely on their old date, so the space taken by expired stamps in the |
| 842 |
double spend database can be saved without risk of accepting an |
| 843 |
expired though otherwise valid stamp.</p> |
| 844 |
<p>The third field of the stamp is the UTC time since 1st January 1970. |
| 845 |
The default time format is YYMMDD, time rounded down to the nearest |
| 846 |
day. The default validity period is 28 days.</p> |
| 847 |
<p>You can provide an alternative validity period with the <em>-e</em> option.</p> |
| 848 |
<dl> |
| 849 |
<dt><strong><a name="item_hashcash__2dcd__2db_10__2de_2d__2dr_foo_1_3a24_3a0"><code>hashcash -cd -b 10 -e 2d -r foo 1:24:040806:foo::511801694b4cd6b0:1e7297a</code></a></strong><br /> |
| 850 |
</dt> |
| 851 |
<dd> |
| 852 |
Try verifying an old stamp, the above stamp was created 11 Aug 2002. |
| 853 |
</dd> |
| 854 |
<dd> |
| 855 |
<p>We gave option <em>-e 2d</em> so the stamps expiry date is 2 days after |
| 856 |
creation, which is now in the past.</p> |
| 857 |
</dd> |
| 858 |
<dd> |
| 859 |
<p>Note: if the creation time is expressed in the stamp in days, the |
| 860 |
precise creation date is the begining of the specified day in UTC time |
| 861 |
(similarly for alternate units the creation time is rounded down to |
| 862 |
the begining of the unit it is expressed in). For units in days, for |
| 863 |
example, this may mean depending on your time zone that the stamp |
| 864 |
appears to be considered invalid in under the specified expiry period |
| 865 |
in days relative to your relative view of what day it is, as the |
| 866 |
calculation is based on current time in UTC, and the creation time of |
| 867 |
the stamp is expressed in UTC time.</p> |
| 868 |
</dd> |
| 869 |
<p></p> |
| 870 |
<dt><strong><code>hashcash -cd -b 10 -r foo 1:24:040806:foo::511801694b4cd6b0:1e7297a</code></strong><br /> |
| 871 |
</dt> |
| 872 |
<dd> |
| 873 |
Test whether the stamp is otherwise valid, apart from having expired. |
| 874 |
Omitting the <em>-e</em> tells hashcash that the stamp will never expire. |
| 875 |
An expiry period of forever can also be given explitly like this: <em>-e |
| 876 |
0</em>, where an expiry period of 0 means forever. |
| 877 |
</dd> |
| 878 |
<p></p></dl> |
| 879 |
<p> |
| 880 |
</p> |
| 881 |
<h2><a name="purging_old_stamps">Purging old stamps</a></h2> |
| 882 |
<p>If the <em>-c</em>, <em>-d</em> options are used together, each time a stamp is |
| 883 |
checked, if it is valid and all of the mandatory aspects of the stamp |
| 884 |
are verified (preimage bits check, resource name check) then the |
| 885 |
stamp and its expiry period is written to the database file. The |
| 886 |
default expiry period if an expiry period is not given explicitly with |
| 887 |
the <em>-e</em> option is 28 days (ie stamps expire after 4 weeks).</p> |
| 888 |
<p>First mint and then add a stamp:</p> |
| 889 |
<dl> |
| 890 |
<dt><strong><a name="item_hashcash__2dm__2db_10_foo__2de_1m__3e_stamp"><code>hashcash -m -b 10 foo -e 1m > stamp</code></a></strong><br /> |
| 891 |
</dt> |
| 892 |
<dd> |
| 893 |
Note: we specified an expiry on minting in this example, to ensure |
| 894 |
that the stamp creation time is given in high enough resolution in the |
| 895 |
stamp that the stamp will not be considered expired at time of |
| 896 |
creation. (Recall the default resolution is in days, a stamp created |
| 897 |
with a creation time rounded down to the beginging of the day is |
| 898 |
unlikely to be considered valid 1 minute later unless you mint it at |
| 899 |
midnight UTC time.) |
| 900 |
</dd> |
| 901 |
<p></p> |
| 902 |
<dt><strong><a name="item_hashcash__2dcd__2de_1m__2db_10__2dr_foo__3c_stamp"><code>hashcash -cd -e 1m -b 10 -r foo < stamp</code></a></strong><br /> |
| 903 |
</dt> |
| 904 |
<dd> |
| 905 |
The stamp expires in 1 minute. Wait 1 minute and then explicitly |
| 906 |
request that expired stamps be purged: |
| 907 |
</dd> |
| 908 |
<p></p> |
| 909 |
<dt><strong><a name="item_hashcash__2dp_now"><code>hashcash -p now</code></a></strong><br /> |
| 910 |
</dt> |
| 911 |
<dd> |
| 912 |
Then try resubmitting the same stamp: |
| 913 |
</dd> |
| 914 |
<p></p> |
| 915 |
<dt><strong><code>hashcash -cd -e 1m -b 10 -r foo < stamp</code></strong><br /> |
| 916 |
</dt> |
| 917 |
<dd> |
| 918 |
and the stamp will be rejected anyway as it has expired, illustrating |
| 919 |
why it was not necessary to keep this stamp in the database. |
| 920 |
</dd> |
| 921 |
<dd> |
| 922 |
<p>With the default database (the sdb format) the database contents are |
| 923 |
human readable, so you can view their contents by cating them to the |
| 924 |
terminal:</p> |
| 925 |
</dd> |
| 926 |
<p></p> |
| 927 |
<dt><strong><a name="item_cat_hashcash_2esdb"><code>cat hashcash.sdb</code></a></strong><br /> |
| 928 |
</dt> |
| 929 |
<dd> |
| 930 |
to see that the stamp really is added and then after puring |
| 931 |
subsequently purged due to expiry. |
| 932 |
</dd> |
| 933 |
<p></p></dl> |
| 934 |
<p> |
| 935 |
</p> |
| 936 |
<h2><a name="purging_old_stamps_on_demand">Purging old stamps on Demand</a></h2> |
| 937 |
<p>As a convenience you can purge at the same time as checking stamps by |
| 938 |
using the <em>-p</em> option with the <em>-c</em> option.</p> |
| 939 |
<dl> |
| 940 |
<dt><strong><a name="item_hashcash__2dm__2db_10_foo__3e_stamp"><code>hashcash -m -b 10 foo > stamp</code></a></strong><br /> |
| 941 |
</dt> |
| 942 |
<dt><strong><a name="item_hashcash__2dcd__2dp_now__2de_1__2db_10__2dr_foo__3"><code>hashcash -cd -p now -e 1 -b 10 -r foo < stamp</code></a></strong><br /> |
| 943 |
</dt> |
| 944 |
<dd> |
| 945 |
It may be inefficient to purge stamps on every use as the entire |
| 946 |
database has to be scanned for expired stamps. By giving a time |
| 947 |
period to the <em>-p</em> option, you can tell <code>hashcash</code> to purge no more |
| 948 |
frequently than that time period since the previous purge. |
| 949 |
</dd> |
| 950 |
<dd> |
| 951 |
<p>For example:</p> |
| 952 |
</dd> |
| 953 |
<p></p> |
| 954 |
<dt><strong><a name="item_hashcash__2dcd__2dp_1d__2de_1__2db_10__2dr_foo__3c"><code>hashcash -cd -p 1d -e 1 -b 10 -r foo < stamp</code></a></strong><br /> |
| 955 |
</dt> |
| 956 |
<dd> |
| 957 |
tells <code>hashcash</code> to purge any expired stamps no more than once per |
| 958 |
day. |
| 959 |
</dd> |
| 960 |
<p></p> |
| 961 |
<dt><strong><a name="item_hashcash__2dp_1m__2dj_foo"><code>hashcash -p 1M -j foo</code></a></strong><br /> |
| 962 |
</dt> |
| 963 |
<dd> |
| 964 |
tells <code>hashcash</code> to purge only expired stamps matching resource foo |
| 965 |
once per month. |
| 966 |
</dd> |
| 967 |
<p></p> |
| 968 |
<dt><strong><a name="item_hashcash__2dp_now__2dk"><code>hashcash -p now -k</code></a></strong><br /> |
| 969 |
</dt> |
| 970 |
<dd> |
| 971 |
tells <code>hashcash</code> to purge all stamps (expired and unexpired) now. |
| 972 |
</dd> |
| 973 |
<p></p></dl> |
| 974 |
<p> |
| 975 |
</p> |
| 976 |
<hr /> |
| 977 |
<h1><a name="stamp_format__version_1_">stamp format (version 1)</a></h1> |
| 978 |
<p>The current stamp format is version 1. This tool can verify hashcash |
| 979 |
version 0 stamps also, but version 0 stamps are no longer created as |
| 980 |
they are being phased out in favor of the more extensible v1 stamp |
| 981 |
format.</p> |
| 982 |
<dl> |
| 983 |
<dt><strong><a name="item_ver_3abits_3adate_3aresource_3a_5bext_5d_3arand_3a"><em>ver</em>:<em>bits</em>:<em>date</em>:<em>resource</em>:[<em>ext</em>]:<em>rand</em>:<em>counter</em></a></strong><br /> |
| 984 |
</dt> |
| 985 |
</dl> |
| 986 |
<p>where</p> |
| 987 |
<dl> |
| 988 |
<dt><strong><a name="item_ver__3d_1"><em>ver</em> = 1</a></strong><br /> |
| 989 |
</dt> |
| 990 |
<dt><strong><a name="item_bits__3d_how_many_bits_of_partial_2dpreimage_the_s"><em>bits</em> = how many bits of partial-preimage the stamp is claimed to have</a></strong><br /> |
| 991 |
</dt> |
| 992 |
<dt><strong><a name="item_date__3d_yymmdd_5bhhmm_5bss_5d_5d"><em>date</em> = YYMMDD[hhmm[ss]]</a></strong><br /> |
| 993 |
</dt> |
| 994 |
<dt><strong><a name="item_string"><em>resource</em> = resource string (eg IP address, email address)</a></strong><br /> |
| 995 |
</dt> |
| 996 |
<dt><strong><a name="item_ext__3d_extension__2d_2d_ignored_in_the_current_ve"><em>ext</em> = extension -- ignored in the current version</a></strong><br /> |
| 997 |
</dt> |
| 998 |
<dd> |
| 999 |
Format of extension: |
| 1000 |
</dd> |
| 1001 |
<dl> |
| 1002 |
<dt><strong><a name="item__5bname1_5b_3dval1_5b_2cval2_2e_2e_2e_5d_5d_3b_5bn">[name1[=val1[,val2...]];[name2[=val1[,val2...]]...]]</a></strong><br /> |
| 1003 |
</dt> |
| 1004 |
<dd> |
| 1005 |
Note the value can also contain =. Example extension (not a real one): |
| 1006 |
</dd> |
| 1007 |
<dd> |
| 1008 |
<pre> |
| 1009 |
name1=2,3;name2;name3=var1=2,var2=3,2,val</pre> |
| 1010 |
</dd> |
| 1011 |
<dd> |
| 1012 |
<p>Which would be extension name1 has values 2 and 3; extension name2 has |
| 1013 |
no values; extension name3 has 3 values ``var1=2'', ``var2=3'', ``2'' and |
| 1014 |
``val''. The hashcash extension may interpret the values as it sees fit |
| 1015 |
eg ``var1=2'' could be the value of an option to the extension name3.</p> |
| 1016 |
</dd> |
| 1017 |
<p></p></dl> |
| 1018 |
<dt><strong><a name="item_rand__3d_string_of_random_characters_from_alphabet"><em>rand</em> = string of random characters from alphabet |
| 1019 |
a-zA-Z0-9+/= to avoid preimage with other sender's |
| 1020 |
stamps</a></strong><br /> |
| 1021 |
</dt> |
| 1022 |
<dt><strong><a name="item_counter__3d_to_find_a_stamp_with_the_desired_numbe"><em>counter</em> = to find a stamp with the desired number of |
| 1023 |
preimage bits need to try lots of different strings |
| 1024 |
this counter is incremented on each try. |
| 1025 |
The Counter is also composed of characters from the |
| 1026 |
alphabet a-zA-Z0-9+/=. (Note an implementation is |
| 1027 |
not required to count sequentially).</a></strong><br /> |
| 1028 |
</dt> |
| 1029 |
</dl> |
| 1030 |
<p> |
| 1031 |
</p> |
| 1032 |
<hr /> |
| 1033 |
<h1><a name="files">FILES</a></h1> |
| 1034 |
<dl> |
| 1035 |
<dt><strong><a name="item_hashcash_2esdb"><em>hashcash.sdb</em></a></strong><br /> |
| 1036 |
</dt> |
| 1037 |
<dd> |
| 1038 |
default double spend database |
| 1039 |
</dd> |
| 1040 |
<p></p></dl> |
| 1041 |
<p> |
| 1042 |
</p> |
| 1043 |
<hr /> |
| 1044 |
<h1><a name="exit_status">EXIT STATUS</a></h1> |
| 1045 |
<p><code>hashcash</code> returns success (exit code 0) after successfully minting a |
| 1046 |
stamp, after fully checking a stamp and finding it valid, and after a |
| 1047 |
timing test.</p> |
| 1048 |
<p>If when checking a stamp it is found to be invalid (due to being |
| 1049 |
malformed, being expired, having insufficient value, having a date in |
| 1050 |
the future, or being double spent), <code>hashcash</code> returns failure (exit |
| 1051 |
code 1).</p> |
| 1052 |
<p>If insufficient options are given to fully check a stamp, if the stamp |
| 1053 |
is otherwise valid return unchecked (exit code 2). If the <em>-y</em> flag |
| 1054 |
is given and hashcash would normally return unchecked, exit code |
| 1055 |
success is returned instead.</p> |
| 1056 |
<p>If any exception occurs (file read failure for database checking or |
| 1057 |
corrupted database contents) an exit status of 3 is returned.</p> |
| 1058 |
<p> |
| 1059 |
</p> |
| 1060 |
<hr /> |
| 1061 |
<h1><a name="author">AUTHOR</a></h1> |
| 1062 |
<p>Written by Adam Back <<a href="mailto:[email protected]">[email protected]</a>></p> |
| 1063 |
<p> |
| 1064 |
</p> |
| 1065 |
<hr /> |
| 1066 |
<h1><a name="see_also">SEE ALSO</a></h1> |
| •1067 |
<p>sha1sum(1), sha1(1), <a href="http://www.hashcash.org/">http://www.hashcash.org/</a></p> |
| 1068 |
|
| 1069 |
</body> |
| 1070 |
|
| 1071 |
</html> |