cryptol/tests/issues/issue225.cry

23 lines
683 B
Plaintext
Raw Normal View History

2016-02-19 21:08:20 +03:00
module EnigmaBroke where
2014-04-18 02:34:25 +04:00
type Rotor = [26](Char, Bit)
mkRotor : {a} (fin a) => ([26]Char,[a]) -> Rotor
mkRotor (_,_) = zero
scramble : (Bit, Char, Rotor) -> (Bit, Char, Rotor)
scramble (_,_,_) = zero
joinRotors : {n} (fin n) => ([n]Rotor, Char) -> ([n]Rotor, Char)
joinRotors (rotors, inputChar) = (rotors', outputChar)
where
initRotor = mkRotor (['A' .. 'Z'], [])
// ncrs : [n+1](Bit, [8], Rotor)
ncrs = [(True, inputChar, initRotor)]
# [ scramble (notch, char, r)
| r <- rotors
| (notch, char, rotor') <- ncrs
]
rotors' = tail [ r | (_, _, r) <- ncrs ]
(_, outputChar, _) = ncrs ! 0