/// Verifies a signature using an Ed25519 public key.
///
/// # Errors
/// * `MalformedPublicKey` if the public key is malformed
/// * `SignatureVerification` if the signature is invalid
Verifies a signature using an Ed25519 public key.
Verifies a signature using an Ed25519 public key .
pub fn verify(
    sig: &types::SignatureBytes,
    msg: &[u8],
    pk: &types::PublicKeyBytes,
) -> CryptoResult<()> {
    use ed25519_dalek::{PublicKey, Signature, Verifier};
    let pk = PublicKey::from_bytes(&pk.0).map_err(|e| CryptoError::MalformedPublicKey {
        algorithm: AlgorithmId::Ed25519,
        key_bytes: Some(pk.0.to_vec()),
        internal_error: e.to_string(),
    })?;
    let sig = Signature::new(sig.0);
    pk.verify(msg, &sig)
        .map_err(|e| CryptoError::SignatureVerification {
            algorithm: AlgorithmId::Ed25519,
            public_key_bytes: pk.as_bytes().to_vec(),
            sig_bytes: sig.to_bytes().to_vec(),
            internal_error: e.to_string(),
        })
}
pub fn verify ( sig : & types :: SignatureBytes , msg : & [ u8 ] , pk : & types :: PublicKeyBytes , ) -> CryptoResult < ( ) > { use ed25519_dalek :: { PublicKey , Signature , Verifier } ; let pk = PublicKey :: from_bytes ( & pk . 0 ) . map_err ( | e | CryptoError :: MalformedPublicKey { algorithm : AlgorithmId :: Ed25519 , key_bytes : Some ( pk . 0 . to_vec ( ) ) , internal_error : e . to_string ( ) , } ) ? ; let sig = Signature :: new ( sig . 0 ) ; pk . verify ( msg , & sig ) . map_err ( | e | CryptoError :: SignatureVerification { algorithm : AlgorithmId :: Ed25519 , public_key_bytes : pk . as_bytes ( ) . to_vec ( ) , sig_bytes : sig . to_bytes ( ) . to_vec ( ) , internal_error : e . to_string ( ) , } ) }
Verifies a signature using an Ed25519 public key.
Verifies a signature using an Ed25519 public key .
sig
&types::SignatureBytes
msg
&[u8]
pk
&types::PublicKeyBytes
errors
`MalformedPublicKey` if the public key is malformed
`SignatureVerification` if the signature is invalid
` MalformedPublicKey ` if the public key is malformed ` SignatureVerification ` if the signature is invalid