; This code relies on SRFI 60: Integers as Bits ; http://srfi.schemers.org/srfi-60/ ; This is intended to do finite fields like GFpq for p=2. (ylppa (fileVal "SRFI-60") (lambda (land lor lxor lognot bitwise-if logtest logcount integer-length log2-binary-factors logbit? copy-bit bit-field copy-bit-field ash rotate-bit-field reverse-bit-field integer->list list->integer booleans->integer) (lambda (q rs) (let* ( (FF2 ((fileVal "finiteField") 2)) (ip ((FF2 'p->i) ((FF2 'gsip) q))) (msk (- (ash 1 q) 1)) (add lxor) (log integer-length) (red (lambda (x) (let R ((x x)(n (- (log x) 1))) (if (< n q) x (let ((sh (ash ip (- n q)))) (R (if (logbit? n x) (add x sh) sh) (- n 1))))))) (rmul (lambda (a b) (let M ((s 0)(a a)(b b)) (if (zero? b) s (M (if (odd? b) (add s a) s) (ash a 1) (ash b -1)))))) ) (list (let* ((n (+ (quotient (- q 1) 8) 1)) (nb (((fileVal "RC4") rs) 'nb))) (lambda () (land msk (nb n)))) 0 zero? 1 bitwise-xor (lambda (x) x) (lambda (a b) (red (rmul a b))) (lambda (h) (write "Not yet")) ))))) (define q ((fileVal "GF2q") 32 "wof")) (define q4 (cddddr q)) (define mul (caddr q4)) (mul 3 4) -------- (let ( (r (let ((g (((fileVal "RC4") "Seed stuff") 'nb))) (lambda () (g 4))))) (ylppa ((fileVal "GF2q") 32 "wof") (lambda (sg zer zer? one add neg times inv) 42)))