thoughtpolice / salt

Fast cryptographic networking for Haskell
http://thoughtpolice.github.com/salt
MIT License
24 stars 1 forks source link

Simplified module structure #26

Open tel opened 11 years ago

tel commented 11 years ago

Right now in order to, say, create a key and use secret key encryption you currently have to import

import Crypto.NaCl.Encrypt.SecretKey
import Crypto.NaCl.Keys
import Crypto.NaCl.Random

which is a bit much, I feel. I'd much prefer to simply want to "do encryption" and therefore import

import Crypto.NaCl

or do public key encryption and do

import Crypto.NaCl.PublicKey

and get access to Key and maybe even randomBytes (or a generalized randomKey) immediately.

This feels somewhat like a cry for a typeclass containing (encrypt, decrypt, randomKey) but that might be a bad solution.

thoughtpolice commented 11 years ago

In general I don't necessarily think typeclassing is the answer here. I type-classified parts of the API before (and although I certainly could have done it wrong) I don't think this small of an API deserves such overkill.

I think we should try and resolve some of the naming ambiguities and have Crypto.NaCl import everything. This is minimal work but maximally useful to users, and I think it's reasonable to believe we can find some good names that are obvious.

tel commented 11 years ago

It comes to mind purely because "encryptWithSecretKey" "encryptStream" "encryptPrivateKey" "decryptStream" "decryptWithSecretKey" &c. are sort of a bear. It's probably not really worth worrying over, though.