Skip to content
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

awkward api due to code duplication between EphemeralSecret and StaticSecret #56

Closed
benma opened this issue Apr 7, 2020 · 3 comments
Closed

Comments

@benma
Copy link

benma commented Apr 7, 2020

new(), diffie_hellman(), pubkey computation etc. are all the same. This leads to a bit of an awkward use of the API downstream, as e.g. noise-rust-crypto is basically picking one of the two types arbitrarily to perform diffie hellman, or to compute a pubkey.

It would be great to have a `SecretKey`` that implements all those things, and have the two special secret types just wrap it.

@hdevalence
Copy link
Contributor

Hmm, an EphemeralSecret is just a StaticSecret where the compiler enforces at compile-time that the key is only used once. If you don't want to have two code paths, this means that you're OK with relaxing this compile-time verification. So it seems like an alternate solution would be to do

type SecretKey = x25519_dalek::StaticSecret;

and use that SecretKey type for both static and ephemeral keys. Would that work?

@benma
Copy link
Author

benma commented Apr 7, 2020

where the compiler enforces at compile-time that the key is only used once.

I see, so maybe it's better for the downstream library to also do that.

Thanks for the clarification.

@benma benma closed this as completed Apr 7, 2020
@hdevalence
Copy link
Contributor

Maybe, maybe not! I think that for a known protocol like Noise that already handles the static/ephemeral distinction, it may not be helpful to have two code paths with two different types. If it's not, you can use the type alias as above, but if it is, you can have two code paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants