[Haskell-cafe] Re: Crypto-API is stabilizing

geremy condra debatem1 at gmail.com
Fri Sep 3 01:06:09 EDT 2010


On Thu, Sep 2, 2010 at 3:07 PM, Sebastian Fischer
<sebf at informatik.uni-kiel.de> wrote:
>
> On Aug 27, 2010, at 11:12 AM, Heinrich Apfelmus wrote:
>
>> 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)
>
> In general, I like this approach, but what are
>
>    encrypt privateKey
>
> or
>
>    decrypt publicKey
>
> supposed to do? A type-class solution also does not *prevent* programmers to
> perform such non-sensical calls, but the data-type solution *forces*
> programmers to provide non-sensical encrypt and decrypt functions when
> creating the public and private keys.

Just thought I would mention, for RSA at least these operations are
identical modular exponentiation steps, differing only in the exponent
used.

Geremy Condra


More information about the Haskell-Cafe mailing list