Closed benma closed 4 years ago
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?
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.
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.
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.