pub fn verify(&self, msg: &[u8], signature: &Signature) -> Result<(), Error> {
        match self {
            PublicKey::Ed25519(pk) => {
                match ed25519_dalek::Signature::try_from(signature.as_bytes()) {
                    Ok(sig) => pk.verify(msg, &sig).map_err(|_| {
                        Error::signature_invalid(
                            "Ed25519 signature verification failed".to_string(),
                        )
                    }),
                    Err(e) => Err(Error::signature_invalid(format!(
                        "invalid Ed25519 signature: {}",
                        e
                    ))),
                }
            }
            #[cfg(feature = "secp256k1")]
            PublicKey::Secp256k1(pk) => {
                match k256::ecdsa::Signature::try_from(signature.as_bytes()) {
                    Ok(sig) => pk.verify(msg, &sig).map_err(|_| {
                        Error::signature_invalid(
                            "Secp256k1 signature verification failed".to_string(),
                        )
                    }),
                    Err(e) => Err(Error::signature_invalid(format!(
                        "invalid Secp256k1 signature: {}",
                        e
                    ))),
                }
            }
        }
    }
/// Verify the given [`Signature`] using this public key
Verify the given [`Signature`] using this public key
Verify the given [ ` Signature ` ] using this public key
pub fn verify(&self, msg: &[u8], signature: &Signature) -> Result<(), Error> {
        match self {
            PublicKey::Ed25519(pk) => {
                match ed25519_dalek::Signature::try_from(signature.as_bytes()) {
                    Ok(sig) => pk.verify(msg, &sig).map_err(|_| {
                        Error::signature_invalid(
                            "Ed25519 signature verification failed".to_string(),
                        )
                    }),
                    Err(e) => Err(Error::signature_invalid(format!(
                        "invalid Ed25519 signature: {}",
                        e
                    ))),
                }
            }
            #[cfg(feature = "secp256k1")]
            PublicKey::Secp256k1(pk) => {
                match k256::ecdsa::Signature::try_from(signature.as_bytes()) {
                    Ok(sig) => pk.verify(msg, &sig).map_err(|_| {
                        Error::signature_invalid(
                            "Secp256k1 signature verification failed".to_string(),
                        )
                    }),
                    Err(e) => Err(Error::signature_invalid(format!(
                        "invalid Secp256k1 signature: {}",
                        e
                    ))),
                }
            }
        }
    }
pub fn verify ( & self , msg : & [ u8 ] , signature : & Signature ) -> Result < ( ) , Error > { match self { PublicKey :: Ed25519 ( pk ) => { match ed25519_dalek :: Signature :: try_from ( signature . as_bytes ( ) ) { Ok ( sig ) => pk . verify ( msg , & sig ) . map_err ( | _ | { Error :: signature_invalid ( " " . to_string ( ) , ) } ) , Err ( e ) => Err ( Error :: signature_invalid ( format ! ( " " e ) ) ) , } } # [ cfg ( feature " " ) ] PublicKey :: Secp256k1 ( pk ) => { match k256 :: ecdsa :: Signature :: try_from ( signature . as_bytes ( ) ) { Ok ( sig ) => pk . verify ( msg , & sig ) . map_err ( | _ | { Error :: signature_invalid ( " " . to_string ( ) , ) } ) , Err ( e ) => Err ( Error :: signature_invalid ( format ! ( " " e ) ) ) , } } } }
Verify the given [`Signature`] using this public key
Verify the given [ ` Signature ` ] using this public key
&self
msg
&[u8]
signature
&Signature