; Find 2 primes from length of their product and textually supplied entropy. (let* ((Do ((fileVal "Do") 'Do)) (e 17) (MR (((fileVal "Miller-Rabin") 'multi) 20)) (pl (list 3 5 7 11 13 17 19 23 29)) (pp (apply * pl))) (lambda (n seed) (let* ((state ((fileVal "RC4") seed)) (rbi (state 'rbi))) (let ((nb (state 'sb))) (Do 768 (lambda (i) (nb)))) (let ((G (lambda (st sz) (let ((sg (rbi (quotient sz 2))) (ost (if (odd? sz) sz (+ sz 1)))) (let pc () (let ((p (+ ost (* 2 (sg))))) (if (and (let ((md (modulo p pp))) (let dt ((pl pl)) (or (null? pl) (and (positive? (modulo md (car pl))) (dt (cdr pl)))))) (positive? (modulo (- p 1) e)) (MR p)) p (pc)))))))) (let* ((lim (expt 2 (quotient n 2))) (p (G (quotient (* 2 lim) 3) lim)) (q (let ((P (quotient (* lim lim) (* 2 p)))) (G P P)))) (list (* p q) e p q)))))) ; Tests ((fileVal "chRSA") 500 "zork") => (2088772682269626055814675188164220140153306033285004989651173866910793362220665331976177914420919915140617935795333510889913660028126229524877579898901 17 2168681558342580996112164137701913384909773475075589479783835808214588388847 963153245913141138732866521690546022251278619456208745635719829659897101883)