Gnus development mailing list
 help / color / mirror / Atom feed
From: Simon Josefsson <jas@extundo.com>
Cc: Paul Foley <mycroft@actrix.gen.nz>
Subject: Re: Hashcash
Date: Thu, 02 Jan 2003 19:33:28 +0100	[thread overview]
Message-ID: <iluwuln4d1j.fsf@latte.josefsson.org> (raw)
In-Reply-To: <m3wulsmk2o.fsf_-_@quimbies.gnus.org> (Lars Magne Ingebrigtsen's message of "Mon, 30 Dec 2002 01:22:55 +0100")

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> There doesn't seem to be any code in there to verify the hashcash
> payment.  Does anybody have anything for doing that?

I lobbied for this in SpamAssassin, and there are patches available,
but nothing seems to happen.  They seemed to want to wait for a
standard to emerge, which seemed very backwards to what SA is all
about to me, but anyway.

I noticed that Lars updated Gnus' hashcash.el from upstream that has
verify functions, but it seems XEmacs specific, and it didn't work in
incomming mail buffers with RFC 822 body separators.  Patch attached;
Paul do you think it is OK?

> Also, the posting code seems to be synchronous.  I think it would be
> nice to put the hashcash generation in the background, and postpone
> the sending until the message has been hashcashed.  Has anybody done
> any work in that area?  Could, perhaps, the delayed nndrafts code be
> used for that?

Sounds like a good idea.  We'd might as well write a complete elisp
implementation of it, since it justs loop over a SHA-1 computation.

--- hashcash.el.~1.6~	Thu Jan  2 17:52:32 2003
+++ hashcash.el	Thu Jan  2 19:28:44 2003
@@ -37,11 +37,19 @@
   "*The default minimum number of bits to accept on incoming payments."
   :type 'integer)
 
-(defcustom hashcash-accept-resources `((,(user-mail-address) nil))
+(defcustom hashcash-accept-resources `((,(if (fboundp 'user-mail-address)
+					     (user-mail-address)
+					   user-mail-address) . nil))
   "*An association list mapping hashcash resources to payment amounts.
 Resources named here are to be accepted in incoming payments.  If the
 corresponding AMOUNT is NIL, the value of `hashcash-default-accept-payment'
-is used instead.")
+is used instead."
+  :type '(repeat (cons (string)
+		       (choice (const :tag "Default" nil)
+			       (const :tag "20 bits" 20)
+			       (const :tag "25 bits" 25)
+			       (const :tag "30 bits" 30)
+			       (integer)))))
 
 (defcustom hashcash "/usr/local/bin/hashcash"
   "*The path to the hashcash binary.")
@@ -93,11 +101,19 @@
 
 (defun hashcash-check-payment (token str val)
   "Check the validity of a hashcash payment."
-  (zerop (call-process hashcash nil nil nil "-c"
+  (zerop (save-excursion
+	   (set-buffer (get-buffer-create " *hashcash verify*"))
+	   (erase-buffer)
+	   (insert (format "%s -c -d -f %s -b %s -r %s %s\n"
+			   hashcash hashcash-double-spend-database
+			   (number-to-string val) str token))
+	   ;; hashcash uses isatty() to set -quiet flag, so we don't
+	   ;; see anything. process-connection-type doesn't help.
+	   (call-process hashcash nil t nil "-c"
 		       "-d" "-f" hashcash-double-spend-database
 		       "-b" (number-to-string val)
 		       "-r" str
-		       token)))
+			 token))))
 
 ;;;###autoload
 (defun hashcash-insert-payment (arg)
@@ -112,14 +128,16 @@
 ;;;###autoload
 (defun hashcash-verify-payment (token &optional resource amount)
   "Verify a hashcash payment"
-  (let ((key (cadr (split-string-by-char token ?:))))
+  (let ((key (caddr (split-string token ":"))))
     (cond ((null resource)
 	   (let ((elt (assoc key hashcash-accept-resources)))
-	     (and elt (hashcash-check-payment token (car elt)
-			(or (cadr elt) hashcash-default-accept-payment)))))
+	     (and elt (hashcash-check-payment
+		       token (car elt)
+		       (or (cdr elt) hashcash-default-accept-payment)))))
 	  ((equal token key)
 	   (hashcash-check-payment token resource
-				(or amount hashcash-default-accept-payment)))
+				   (or amount
+				       hashcash-default-accept-payment)))
 	  (t nil))))
 
 ;;;###autoload
@@ -159,7 +177,8 @@
 					   hashcash-default-accept-payment)))
     (save-excursion
       (goto-char (point-min))
-      (search-forward mail-header-separator)
+      (or (search-forward (concat "\n" mail-header-separator "\n") nil t)
+	  (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t))
       (beginning-of-line)
       (let ((end (point))
 	    (ok nil))




  reply	other threads:[~2003-01-02 18:33 UTC|newest]

Thread overview: 174+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-31 19:24 new spam functionality added Ted Zlatanov
2002-07-31 19:54 ` Scott A Crosby
2002-07-31 20:07   ` Ted Zlatanov
2002-07-31 20:14   ` Simon Josefsson
2002-07-31 20:25     ` Josh Huber
2002-07-31 20:34       ` Scott A Crosby
2002-07-31 20:41         ` Josh Huber
2002-07-31 21:03           ` Stainless Steel Rat
2002-07-31 21:08             ` Stainless Steel Rat
2002-07-31 21:12             ` Josh Huber
2002-07-31 21:38               ` Paul Jarc
2002-07-31 23:19                 ` David Masterson
2002-07-31 23:08               ` Frank Schmitt
2002-08-01 17:03                 ` Josh Huber
2002-08-01 17:38                   ` Harry Putnam
2002-08-01 19:16                     ` Scott A Crosby
2002-08-01 22:43                       ` Harry Putnam
2002-08-05 17:16                       ` Per Abrahamsen
2002-08-01  1:25               ` Stainless Steel Rat
2002-08-01  1:33                 ` Scott A Crosby
2002-08-01  2:17                   ` Stainless Steel Rat
2002-08-01 19:20                     ` David Masterson
2002-08-01 20:00                       ` Stainless Steel Rat
2002-08-02 23:37                     ` Florian Weimer
2002-08-02 23:45                       ` Russ Allbery
2002-08-03 10:23                       ` Simon Josefsson
2002-08-03 13:47                         ` Stainless Steel Rat
2002-08-03 16:01                           ` hashcash (was Re: new spam functionality added) Simon Josefsson
2002-08-04  6:55                             ` Stainless Steel Rat
2002-08-01 19:17                 ` new spam functionality added David Masterson
2002-08-01 19:59                   ` Stainless Steel Rat
2002-07-31 21:07           ` Scott A Crosby
2002-07-31 21:35             ` Paul Jarc
2002-07-31 21:58               ` Josh Huber
2002-07-31 21:47             ` Josh Huber
2002-07-31 21:54               ` Paul Jarc
2002-07-31 22:05                 ` Josh Huber
2002-07-31 22:10                   ` Paul Jarc
2002-07-31 22:35               ` Scott A Crosby
2002-07-31 23:10                 ` Josh Huber
2002-08-01 16:56                   ` Paul Jarc
2002-07-31 23:30                 ` Alan Shutko
2002-08-01 19:25                   ` David Masterson
2002-08-01 19:33                     ` Josh Huber
2002-08-01 22:06                       ` Scott A Crosby
2002-08-01 22:13                         ` Paul Jarc
2002-08-01 22:18                           ` Jack Twilley
2002-08-01 22:23                             ` TMDA (was: new spam functionality added) Paul Jarc
2002-08-01 22:40                               ` Scott A Crosby
2002-08-01 23:29                                 ` Josh Huber
2002-08-02  2:11                                   ` Scott A Crosby
2002-08-01 19:34                     ` new spam functionality added Ted Zlatanov
2002-08-01 19:39                       ` Paul Jarc
2002-08-01 21:38                       ` Simon Josefsson
2002-08-23  1:50                         ` Ted Zlatanov
2002-08-23  2:42                           ` Katsumi Yamaoka
2002-08-23  3:10                             ` Ted Zlatanov
2002-12-30  0:10                           ` Lars Magne Ingebrigtsen
2002-12-30  2:31                             ` Ted Zlatanov
2002-12-30  2:52                               ` Lars Magne Ingebrigtsen
2002-12-30  3:13                                 ` Ted Zlatanov
2002-12-30  3:27                                   ` Lars Magne Ingebrigtsen
2002-12-30  3:44                                     ` Ted Zlatanov
2002-12-30  4:12                                       ` Lars Magne Ingebrigtsen
2002-12-30  4:48                                         ` Ted Zlatanov
2002-12-30  5:08                                           ` Lars Magne Ingebrigtsen
2002-12-30 19:03                                             ` spam.el now supports blackholes by default Ted Zlatanov
2002-12-30 21:41                                               ` Matt Armstrong
2002-12-30 22:42                                                 ` Ted Zlatanov
2002-12-30 23:38                                                   ` spam.el proposed group parameters Ted Zlatanov
2002-12-31  0:02                                                     ` Lars Magne Ingebrigtsen
2003-01-05 16:58                                                 ` spam.el now supports blackholes by default luis fernandes
2003-01-05 22:07                                                   ` Ted Zlatanov
2003-01-06  2:15                                                   ` Lars Magne Ingebrigtsen
2002-08-02  2:05             ` new spam functionality added Jason R. Mastaler
2002-08-02  3:43               ` Russ Allbery
2002-08-02  4:29                 ` Jason R. Mastaler
2002-08-02  4:34                   ` Russ Allbery
2002-08-02 16:17                     ` TMDA (was: new spam functionality added) Paul Jarc
2002-08-02 21:46                       ` Russ Allbery
2002-08-02 21:53                         ` Paul Jarc
2002-08-05 17:38                       ` Per Abrahamsen
2002-08-05 17:49                         ` Paul Jarc
2002-08-05 17:57                           ` Simon Josefsson
2002-08-05 20:18                             ` David Masterson
2002-08-05 20:46                               ` Stainless Steel Rat
2002-08-05 21:50                                 ` Russ Allbery
2002-08-06  0:43                                   ` Stainless Steel Rat
2002-08-06  3:04                                 ` David Masterson
2002-08-06 14:27                                   ` Stainless Steel Rat
2002-08-06 17:13                                     ` David Masterson
2002-08-06 17:26                                       ` David Masterson
2002-08-06 18:08                                         ` Stainless Steel Rat
2002-08-07 12:02                                           ` Lloyd Zusman
2002-12-30  0:22                                             ` Hashcash (was: TMDA) Lars Magne Ingebrigtsen
2003-01-02 18:33                                               ` Simon Josefsson [this message]
2003-01-02 19:25                                                 ` Hashcash Lars Magne Ingebrigtsen
2003-01-02 21:01                                                   ` Hashcash Simon Josefsson
2003-01-02 21:05                                                     ` Hashcash Lars Magne Ingebrigtsen
2002-08-05 18:30                           ` TMDA (was: new spam functionality added) Stainless Steel Rat
2002-08-05 20:46                             ` David Masterson
2002-08-05 21:33                               ` Stainless Steel Rat
2002-08-06  3:28                                 ` David Masterson
2002-08-06 16:02                                   ` Paul Jarc
2002-08-08  9:21                                     ` Steinar Bang
2002-08-08 15:34                                       ` Paul Jarc
2002-08-08 19:57                                         ` Steinar Bang
2002-08-08 20:17                                           ` Paul Jarc
2002-08-08 21:30                                             ` Steinar Bang
2002-08-08 21:35                                               ` Paul Jarc
2002-08-08 22:27                                                 ` Steinar Bang
2002-08-08 17:26                                       ` Matt Armstrong
2002-08-08 20:23                                         ` Steinar Bang
2002-08-09 19:32                                           ` Matt Armstrong
2002-08-10  9:23                                             ` Steinar Bang
2002-08-10 17:21                                               ` Paul Jarc
2002-08-11  8:41                                                 ` Steinar Bang
2002-08-11 14:58                                                   ` Steinar Bang
2002-08-11  8:47                                             ` Steinar Bang
2002-08-12 16:04                                               ` Paul Jarc
2002-08-12 21:38                                                 ` Steinar Bang
2002-08-12 22:40                                                   ` Paul Jarc
2002-08-13  9:21                                                     ` Steinar Bang
2002-08-05 20:11                         ` David Masterson
2002-08-06  2:15                         ` Scott A Crosby
2002-08-06 10:10                           ` Per Abrahamsen
2002-08-06 13:20                             ` Scott A Crosby
2002-08-06 16:13                               ` Per Abrahamsen
2002-08-16 14:23             ` new spam functionality added clemens fischer
2002-08-05 17:07         ` Per Abrahamsen
2002-07-31 20:46       ` Jack Twilley
2002-07-31 21:01         ` Josh Huber
2002-07-31 21:03         ` Simon Josefsson
2002-07-31 21:51           ` David Masterson
2002-07-31 21:08       ` Simon Josefsson
2002-07-31 22:05         ` David Masterson
2002-07-31 23:32           ` Alan Shutko
2002-08-01 17:00             ` Paul Jarc
2002-08-05 18:07           ` Simon Josefsson
2002-08-05 18:23             ` TMDA (was: new spam functionality added) Paul Jarc
2002-08-05 23:41               ` Simon Josefsson
2002-08-06 10:27                 ` Per Abrahamsen
2002-08-06 15:57                 ` Paul Jarc
2002-07-31 20:35     ` new spam functionality added Ted Zlatanov
2004-09-26 15:30 hashcash Adam Sjøgren
2004-09-26 17:36 ` hashcash Simon Josefsson
2004-09-26 20:59   ` hashcash Adam Sjøgren
2004-09-27  2:03     ` hashcash Paul Foley
2004-09-27 14:32       ` hashcash Simon Josefsson
2004-09-27 14:46         ` hashcash Adam Sjøgren
2004-09-29 14:37         ` hashcash Dan Christensen
2004-09-29 14:40           ` hashcash Ted Zlatanov
2004-09-29 19:11             ` hashcash Dan Christensen
2004-09-29 21:08               ` hashcash Magnus Henoch
2004-09-30 14:30                 ` hashcash Ted Zlatanov
2004-09-30 20:42                   ` hashcash Magnus Henoch
2004-09-27 14:45       ` hashcash Adam Sjøgren
2004-09-27 15:21         ` hashcash Simon Josefsson
2004-09-27 15:38           ` hashcash Adam Sjøgren
2004-09-27 17:13             ` hashcash Jesper Harder
2004-09-27 19:02               ` hashcash Adam Sjøgren
2004-09-27 19:38                 ` hashcash Simon Josefsson
2004-09-27 19:54                   ` hashcash Adam Sjøgren
2004-09-27 19:56                   ` hashcash Jesper Harder
2004-09-27 20:50                     ` hashcash Simon Josefsson
2004-09-28 14:08         ` hashcash Ted Zlatanov
2004-09-28 14:49           ` hashcash Simon Josefsson
2004-09-28 17:41             ` hashcash Ted Zlatanov
2004-09-30 20:50               ` hashcash Simon Josefsson
2004-10-04 17:06                 ` hashcash Ted Zlatanov
2004-10-04 19:36                   ` hashcash Simon Josefsson
2004-10-05  2:34                     ` hashcash Dan Christensen
2004-10-06 15:17                     ` hashcash Ted Zlatanov
2004-09-27 16:10 ` hashcash Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=iluwuln4d1j.fsf@latte.josefsson.org \
    --to=jas@extundo.com \
    --cc=mycroft@actrix.gen.nz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).