#[cfg(feature = "ecdsa")]
#[allow(unused_imports)]
use crate::ecdsa;
#[cfg(feature = "ed25519")]
use crate::ed25519;
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum KeyHandle {
#[cfg(feature = "nistp256")]
EcdsaNistP256(ecdsa::nistp256::VerifyingKey),
#[cfg(feature = "nistp384")]
EcdsaNistP384(ecdsa::nistp384::VerifyingKey),
#[cfg(feature = "secp256k1")]
EcdsaSecp256k1(ecdsa::secp256k1::VerifyingKey),
#[cfg(feature = "ed25519")]
Ed25519(ed25519::VerifyingKey),
}
impl KeyHandle {
#[cfg(feature = "nistp256")]
pub fn ecdsa_nistp256(&self) -> Option<ecdsa::nistp256::VerifyingKey> {
match self {
KeyHandle::EcdsaNistP256(pk) => Some(*pk),
#[allow(unreachable_patterns)]
_ => None,
}
}
#[cfg(feature = "nistp384")]
pub fn ecdsa_nistp384(&self) -> Option<ecdsa::nistp384::VerifyingKey> {
match self {
KeyHandle::EcdsaNistP384(pk) => Some(*pk),
#[allow(unreachable_patterns)]
_ => None,
}
}
#[cfg(feature = "secp256k1")]
pub fn ecdsa_secp256k1(&self) -> Option<ecdsa::secp256k1::VerifyingKey> {
match self {
KeyHandle::EcdsaSecp256k1(pk) => Some(*pk),
#[allow(unreachable_patterns)]
_ => None,
}
}
#[cfg(feature = "ed25519")]
pub fn ed25519(&self) -> Option<ed25519::VerifyingKey> {
match self {
KeyHandle::Ed25519(pk) => Some(*pk),
#[allow(unreachable_patterns)]
_ => None,
}
}
}