-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Place all classes in modules describing their primitives #74
Conversation
Thinking about this some more, I think this is the 'wrong way around'. The point of libsodium/NaCl is in the high level constructs it provides. I think that's actually more useful than the specific algorithmic choices it provides. The developer says "I want to exchange messages securely when I have public key pairs" and libsodium says "Here's a A construct focused layout would be better. |
What you're proposing, organizing everything by the construct, is what I originally set out to do. However, when I actually sat down and started doing it I realized something: What we're actually exposing are APIs which should be more or less identical for the given constructs provided they're used with the appropriate types. Thus what the end user ends up working with should be a Some of the algorithms (Curve25519 and Ed25519) have multiple classes we need to deal with and group in a logical manner. Hence: RbNaCl::Curve25519XSalsa20Poly1305::Box The class you're working with is named Box and exposes the Box API. It has two associated classes: public and private keys, which are named PublicKey and PrivateKey. We could, perhaps, go for a more NaCl like structure that does both. I'd imagine it would look like this (call this Alternative #1):
Or we could do something more like what I had originally planned (call this Alternative #2):
Or do you have a better suggestion? All in all, I think I would prefer the class names should reflect the constructs (e.g. |
@namelessjon any thoughts here? |
Alternative 2 is more or less what I'm doing in Sodium, although I'm honestly a fan of
et al (e.g., no need for plurals and separate namespaces) but that's mostly just an issue of taste. |
@stouset |
This change places all primitives into their own module. I have to say that by doing this, the organization of the source code seems much improved to me. The original API is preserved (with some changes) by aliasing shorthand class names to their algorithm-specific versions.
@namelessjon @stouset have a look at a381190 This places all primitives into modules/directories according to the construct name, not the underlying algorithm. I used the mapping I suggested before with the tweaks suggested by @stouset. I also decided to use I also used |
Noted by @CodesInChaos: perhaps |
Per @CodesInChaos's suggestion I've renamed @namelessjon look good now? |
Looks good. |
Place all classes in modules describing their primitives
cc @namelessjon @stouset
This change places all primitives into their own module. I have to say that by
doing this, the organization of the source code seems much improved to me.
The original API is preserved (with some changes) by aliasing shorthand class
names to their algorithm-specific versions.
The following name changes have been made:
RbNaCl::Box
=>RbNaCl::Curve25519XSalsa20Poly1305::Box
RbNaCl::PrivateKey
=>RbNaCl::Curve25519XSalsa20Poly1305::PrivateKey
RbNaCl::PublicKey
=>RbNaCl::Curve25519XSalsa20Poly1305::PublicKey
RbNaCl::SecretBox
=>RbNaCl::XSalsa20Poly1305::SecretBox
RbNaCl::SigningKey
=>RbNaCl::Ed25519::SigningKey
RbNaCl::VerifyKey
=>RbNaCl::Ed25519::VerifyKey
RbNaCl::Point
=>RbNaCl::Curve25519::Point
RbNaCl::Auth::OneTime
=>RbNaCl::Poly1305::OneTimeAuth
RbNaCl::Hash::Blake2b
=>RbNaCl::Blake2b::Hash
RbNaCl::HMAC::SHA256
=>RbNaCl::SHA256::HMAC
RbNaCl::HMAC::SHA512256
=>RbNaCl::SHA512256::HMAC