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

No Eq or PartialEq for SecretKey #280

Closed
ilya-bobyr opened this issue Feb 17, 2023 · 2 comments
Closed

No Eq or PartialEq for SecretKey #280

ilya-bobyr opened this issue Feb 17, 2023 · 2 comments

Comments

@ilya-bobyr
Copy link

It seems to be intentional that SecretKey does not have Eq defined for it.
But the reasoning is not part of the type documentation.
Nor was I able to find a discussion elsewhere.

This issue seems related: #52
It says:

There's functionality in the subtle crate for comparing the equality of two equally-sized byte arrays in constant time, if you need to check if two secret keys are the same.

Is it the case that nobody just connected the crates, to use subtle as an implementation of Eq for SecretKey?
Or is there more to it?

I think it would be nice to have an explanation. Either as an issue or directly in the doc-comment.
I would imagine, I might not be the only person looking for Eq.

@based-a-tron
Copy link

They return different types.
ConstantTimeEq's ct_eq returns a Choice, to prevent things like the following toy example from leaking timing information by short circuiting, or through other side channels
if (secret_key1 == key1) && (secret_key2 == key2) { ... }

@rozbb
Copy link
Contributor

rozbb commented Mar 7, 2023

SecretKey is just a 32-byte array in 2.0

@rozbb rozbb closed this as completed Mar 7, 2023
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

3 participants