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

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to