subtle
subtle copied to clipboard
Make `Choice` and `CtOption` be `Hash`
While rare, sometimes it is convenient to use CtOption in hashmaps/sets. This PR suggests adding Hash to CtOption and Choice to allow that use case, see e.g. crypto-bigint::Checked.
It also aligns with std::option::Option, which is also Hash.
One question I have is if making BlackBox be Hash as well is desirable?
What's the use case for Choice being Hash? You want to use a Choice as a key for a HashMap?
I think all of these types, including and especially BlackBox, deliberately keep their internals opaque and only allow access using very specific and deliberate methods. BlackBox for example is only intended to be accessed via its get method and a Hash impl would bypass that.
Choice being Hash is just a consequence of making CtOption Hash.