; See ../../../MathPhys/Field/AGEC.html and ../../../Crypto/EC/DSA.html
(lambda (f sqrt) (apply [lambda (sg zer zer? one add neg mul inv)
(let* ((C2 (add one one)) (C3 (add one C2))
(C4 (add C2 C2)) (C27 (mul C3 (mul C3 C3))))
(and (not (or (zer? C2) (zer? (add one C2))))
(lambda (a b) (and (not (zer?
(add (mul C4 (mul a (mul a a))) (mul C27 (mul b b)))))
(letrec (
(pred (lambda (p) (or (and (pair? p) (let ((x (car p)) (y (cdr p)))
(zer? (add (neg (mul y y)) (add (mul x (mul x x))
(add (mul x a) b)))))) (eq? p 0))))
(pg (lambda () (let l () (let* ((x (sg))
(p (add (mul x (mul x x)) (add (mul x a) b)))
(y (sqrt p))) (or (and (eq? y 'none) (l)) (cons x y))))))
{padd (lambda (p q)
(if (eq? p 0) q (if (eq? q 0) p
(let ((xp (car p))(yp (cdr p))(xq (car q))(yq (cdr q)))
(let ((diff (add xp (neg xq))))
(if (zer? diff) (if (zer? (add yp yq)) 0 (let* (
(t (mul (add (mul C3 (mul xp xp)) a) (inv (mul C2 yp))))
(x3 (add (mul t t) (neg (mul C2 xp)))))
(cons x3 (add (mul t (add xp (neg x3))) (neg yp)))))
(let* ((s (mul (add (cdr p) (neg (cdr q))) (inv diff)))
(xr (add (mul s s) (neg (add (car p) (car q))))))
(cons xr (neg (add (cdr p)
(mul s (add xr (neg (car p))))))))))))))}
(pneg (lambda (a) (if (pair? a) (cons (car a) (neg (cdr a))) 0)))
(pmul (lambda (n p) (if (eq? p 0) 0 (if (< n 2)
(if (= n 0) 0 (if (< n 0) (pmul (- n) (pneg p)) p))
(let ((p2 (padd p p)))
(if (odd? n) (padd p (pmul (/ (- n 1) 2) p2))
(pmul (/ n 2) p2))))))))
(lambda (sy) (cdr (assq sy (list (cons 'add padd) (cons 'neg pneg)
(cons 'mul pmul) (cons 'pred pred)
(cons 'pg pg))))))))))] f))
; Limbo: ((fileVal "AGEC") ((fileVal "GFpq") 5 2 "goo"))