anchor.diff:               (type fixnum i))
       (if (logbitp i e)
           (setf r0 (ed25519-edwards-add r0 r1)
  -              r1 (ed25519-edwards-add r1 r1))
  +              r1 (ed25519-edwards-double r1))
           (setf r1 (ed25519-edwards-add r0 r1)
  -              r0 (ed25519-edwards-add r0 r0)))))
  +              r0 (ed25519-edwards-double r0)))))
   
   (defun ed25519-on-curve-p (p)
     "Check if the point P is on ed25519 curve."
  
positive.code:          (w2 (aref q 3))
           (a (mod (* (- y1 x1) (- y2 x2)) +ed25519-q+))
           (b (mod (* (+ y1 x1) (+ y2 x2)) +ed25519-q+))
           (c (mod (* 2 w1 w2 +ed25519-d+) +ed25519-q+))
           (d (mod (* 2 z1 z2) +ed25519-q+))
           (e (mod (- b a) +ed25519-q+))
           (f (mod (- d c) +ed25519-q+))
  
negative.code:          (y3 (mod (* g h) +ed25519-q+))
           (z3 (mod (* f g) +ed25519-q+))
           (w3 (mod (* e h) +ed25519-q+)))
      (declare (type integer x1 y1 z1 w1 x2 y2 z2 w2 a b c d e f g h i x3 y3 z3 w3))
      (vector x3 y3 z3 w3)))
  
  (defun ed25519-edwards-double (p)
    "Point doubling on ed25519 curve."
    (declare (type ed25519-point p)
             (optimize (speed 3) (safety 0) (space 0) (debug 0)))
    (let* ((x1 (aref p 0))
           (y1 (aref p 1))
           (z1 (aref p 2))
           (a (mod (* x1 x1) +ed25519-q+))
           (b (mod (* y1 y1) +ed25519-q+))
           (c (mod (* 2 z1 z1) +ed25519-q+))
           (d (mod (+ x1 y1) +ed25519-q+))
           (i (mod (* d d) +ed25519-q+))
           (h (mod (+ a b) +ed25519-q+))
           (e (mod (- h i) +ed25519-q+))
           (g (mod (- a b) +ed25519-q+))
           (f (mod (+ c g) +ed25519-q+))
           (x2 (mod (* e f) +ed25519-q+))
           (y2 (mod (* g h) +ed25519-q+))
           (z2 (mod (* f g) +ed25519-q+))
           (w2 (mod (* e h) +ed25519-q+)))
      (declare (type integer x1 y1 z1 a b c d e f g h i x2 y2 z2 w2))
      (vector x2 y2 z2 w2)))
  
  (defun ed25519-scalar-mult (p e)
    "Point multiplication on ed25519 curve using the Montgomery ladder."
  