FedericoCeratto / nim-libsodium

Nim wrapper for the libsodium library
Mozilla Public License 2.0
47 stars 13 forks source link

use compile-time sizes #4

Closed ehmry closed 7 years ago

ehmry commented 7 years ago

This is a dubious PR because it makes a lot of changes, but I've found that using typed arrays catches mistakes in passing arguments in the correct order.

I'm new at Nim so really let the criticism flow.

ehmry commented 7 years ago

Looking at the compiled C makes me think arrays are a bad idea now, would it be better to use distinct string types or ref array[...]?

FedericoCeratto commented 7 years ago

Thanks for the PR @ehmry As libsodium is loaded as a dynamic library, the input/output string sizes might be different from hardcoded values used at compile time. I briefly looked at some other wrappers (in Python) and they call the exposed functions as well. Those sizes might change very rarely, but it could happen. Any thoughts?

ehmry commented 7 years ago

I think the sizes can be safely assumed to be constant because changing a key size anywhere should cause total protocol or application breakage. I think I should close this and wait a bit until I have more experience with Nim memory.

ehmry commented 7 years ago

I will come back to this later.