pub fn verify(&self, msg: &[u8], signature: &Signature) -> Result<(), Error> {
        let current_keynum = self.keynum();
        let expected_keynum = signature.keynum;

        if expected_keynum != current_keynum {
            return Err(Error::MismatchedKey {
                expected: expected_keynum,
                found: current_keynum,
            });
        }

        // Both the key data and signature data are not verified yet,
        // so the ed25519 math can still go wrong.
        // In that case all we need to communicate is that it was a bad signature.

        let public_key =
            ed25519_dalek::PublicKey::from_bytes(&self.key()).map_err(|_| Error::BadSignature)?;
        let signature = ed25519_dalek::Signature::from_bytes(&signature.signature())
            .map_err(|_| Error::BadSignature)?;

        public_key
            .verify(msg, &signature)
            .map_err(|_| Error::BadSignature)
    }
/// Use this key to verify that the provided signature for the given message
/// is authentic.
///
/// # Errors
///
/// This method errors if this key's number didn't match the ID of the key
/// which created the signature or if the signature couldn't be verified.
Use this key to verify that the provided signature for the given message
is authentic.
Use this key to verify that the provided signature for the given message is authentic .
pub fn verify(&self, msg: &[u8], signature: &Signature) -> Result<(), Error> {
        let current_keynum = self.keynum();
        let expected_keynum = signature.keynum;
        if expected_keynum != current_keynum {
            return Err(Error::MismatchedKey {
                expected: expected_keynum,
                found: current_keynum,
            });
        }
        // Both the key data and signature data are not verified yet,
        // so the ed25519 math can still go wrong.
        // In that case all we need to communicate is that it was a bad signature.
        let public_key =
            ed25519_dalek::PublicKey::from_bytes(&self.key()).map_err(|_| Error::BadSignature)?;
        let signature = ed25519_dalek::Signature::from_bytes(&signature.signature())
            .map_err(|_| Error::BadSignature)?;
        public_key
            .verify(msg, &signature)
            .map_err(|_| Error::BadSignature)
    }
pub fn verify ( & self , msg : & [ u8 ] , signature : & Signature ) -> Result < ( ) , Error > { let current_keynum = self . keynum ( ) ; let expected_keynum = signature . keynum ; if expected_keynum != current_keynum { return Err ( Error :: MismatchedKey { expected : expected_keynum , found : current_keynum , } ) ; } // Both the key data and signature data are not verified yet, // so the ed25519 math can still go wrong. // In that case all we need to communicate is that it was a bad signature. let public_key = ed25519_dalek :: PublicKey :: from_bytes ( & self . key ( ) ) . map_err ( | _ | Error :: BadSignature ) ? ; let signature = ed25519_dalek :: Signature :: from_bytes ( & signature . signature ( ) ) . map_err ( | _ | Error :: BadSignature ) ? ; public_key . verify ( msg , & signature ) . map_err ( | _ | Error :: BadSignature ) }
Use this key to verify that the provided signature for the given message
is authentic.
Use this key to verify that the provided signature for the given message is authentic .
&self
msg
&[u8]
signature
&Signature
&self
msg
&[u8]
signature
&Signature
errors
This method errors if this key's number didn't match the ID of the key
which created the signature or if the signature couldn't be verified.
This method errors if this key ' s number didn ' t match the ID of the key which created the signature or if the signature couldn ' t be verified .