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

'Secret' trait for unified DH #58

Closed
wants to merge 1 commit into from

Conversation

super-horst
Copy link

Introduced a Secret trait to encapsulate Diffie-Hellman functionality of both StaticSecret and EphemeralSecret.

Any overlaying logic would not care if it calculates DH on a static or ephemeral secret. This would enable to build generic interfaces using the trait as a DH mediator.

For example X3DH uses static and ephemeral keys during it's agreement calculation:
https://www.signal.org/docs/specifications/x3dh/#sending-the-initial-message

@hdevalence
Copy link
Contributor

I wrote a comment about a similar issue here that might be relevant: #56 (comment)

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?

@super-horst
Copy link
Author

Hmm, an EphemeralSecret is just a StaticSecret where the compiler enforces at compile-time that the key is only used once.

That is precisely where I stumbled too. IMHO it makes no sense to enforce that the EphemeralSecret is only used once. While it makes sure that no one does anything stupid, it also removes alot of flexibility.

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?

Dunno about this type definition though, I'm not that deep into rust to give a qualified opinion here.

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

Successfully merging this pull request may close these issues.

None yet

2 participants