The header line looks something like this: X-Hashcash: 1:20:1303030600:adam@cypherspace.org::McMybZIhxKXu57jd:ckvi The header contains: •
ver: Hashcash format version, 1 (which supersedes version 0). •
bits: Number of "partial pre-image" (zero) bits in the hashed code. •
date: The time that the message was sent, in the format . •
resource: Resource data string being transmitted, e.g., an IP address or
email address. •
ext: Extension (optional; ignored in version 1). •
rand: String of random characters, encoded in
base-64 format. •
counter: Binary counter, encoded in base-64 format. The header contains the recipient's email address, the date of the message, and information proving that the required computation has been performed. The presence of the recipient's email address requires that a different header be computed for each recipient. The date allows the recipient to record headers received recently and to ensure that the header is unique to the email message.
Sender's side The sender prepares a header and appends a counter value initialized to a random number. It then computes the 160-bit
SHA-1 hash of the header. If the first 20 bits (i.e. the 5 most significant hex digits) of the hash are all zeros, then this is an acceptable header. If not, then the sender increments the counter and tries the hash again. Out of 2160 possible hash values, there are 2140 hash values that satisfy this criterion. Thus the chance of randomly selecting a header that will have 20 zeros as the beginning of the hash is 1 in 220 (approx. 106, or about one in a million). The number of times that the sender needs to try to get a valid hash value is modeled by
geometric distribution. Hence the sender will on average have to try 220 values to find a valid header. Given reasonable estimates of the time needed to compute the hash, this would take about one second to find. No more efficient method than this brute force approach is known to find a valid header. A normal user on a desktop PC would not be significantly inconvenienced by the processing time required to generate the Hashcash string. However, spammers would suffer significantly due to the large number of spam messages sent by them.
Recipient's side Technically the system is implemented with the following steps: • The recipient's computer calculates the 160-bit
SHA-1 hash of the entire string (e.g., ). This takes about two microseconds on a 1 GHz machine, far less time than the time it takes for the rest of the e-mail to be received. If the first 20 bits are not all zero, the hash is invalid. (Later versions may require more bits to be zero as machine processing speeds increase.) • The recipient's computer checks the date in the header (e.g., , which represents the date 8 Apr 2006). If it is not within two days of the current date, it is invalid. (The two-day window compensates for
clock skew and network routing time between different systems.) • The recipient's computer checks whether the e-mail address in the hash string matches any of the valid e-mail addresses registered by the recipient, or matches any of the mailing lists to which the recipient is subscribed. If a match is not found, the hash string is invalid. • The recipient's computer inserts the hash string into a database. If the string is already in the database (indicating that an attempt is being made to re-use the hash string), it is invalid. If the hash string passes all of these tests, it is considered a valid hash string. All of these tests take far less time and disk space than receiving the body content of the e-mail.
Required effort The time needed to compute such a hash partial preimage is
exponential with the number of zero bits. So additional zero bits can be added (doubling the amount of time needed to compute a hash with each additional zero bit) until it is too expensive for spammers to generate valid header lines. Confirming that the header is valid is much faster and always takes the same amount of time, no matter how many zero bits are required for a valid header, since this requires only a single hashing operation. ==Advantages and disadvantages==