[Haskell-cafe] Re: Crypto-API is stabilizing
Heinrich Apfelmus
apfelmus at quantentunnel.de
Fri Aug 27 05:12:56 EDT 2010
Thomas DuBuisson wrote:
>>> class (Binary p, Serialize p) => AsymCipher p where
>>> generateKeypair :: RandomGen g => g -> BitLength -> Maybe ((p,p),g)
>>> encryptAsym :: p -> B.ByteString -> B.ByteString
>>> decryptAsym :: p -> B.ByteString -> B.ByteString
>>> asymKeyLength :: p -> BitLength
Is it actually necessary to use a type class here? The situation is very
similar to
Luke Palmer. Haskell Antipattern: Existential Typeclass.
http://lukepalmer.wordpress.com/2010/01/24/
I suggest to use good old data types
data Key = Key {
encrypt :: B.ByteString -> B.ByteString,
decrypt :: B.ByteString -> B.ByteString,
keyLength :: BitLength,
serialize :: B.ByteString}
rsa :: RandomGen g => BitLength -> g -> ((Key,Key), g)
Regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
More information about the Haskell-Cafe
mailing list