Function verify_message_signature
pub fn verify_message_signature(
address: &str,
message: &str,
signature: &str,
) -> Result<bool, Error>Expand description
Verifies a message signature against a given address.
This function performs cryptographic verification of a message signature using IOTA’s signature verification system. It rebuilds the PersonalMessage intent message, hashes its BCS encoding with blake2b256, and checks that the signature over that digest was produced by the private key corresponding to the given address.
§Arguments
address- The IOTA address string that should have signed the messagemessage- The original message that was signedsignature- The base64-encoded signature to verify
§Returns
Ok(true)- The signature is valid for the given address and messageErr(_)- Verification failed due to invalid signature, address format, or cryptographic mismatch
§Security
This function uses IOTA’s secure verification with PersonalMessage intent, which helps prevent signature replay attacks across different contexts.
§Examples
use crypto::{Signer, verify_message_signature};
let signer: Signer = "iotaprivkey1qrsd2u9ztqr6z2y78sp2ch8kcyak9cx3ezphkpp4acqaqruajxr6qye2645".into();
let address = signer.address();
let message = "Hello, world!";
let signature = signer.sign_message(message);
// Verify the signature
assert!(verify_message_signature(&address, message, &signature).is_ok());
// Wrong message should fail
assert!(verify_message_signature(&address, "Wrong message", &signature).is_err());§Errors
This function will return an error if:
- The address string is not a valid IOTA address format
- The signature string is not valid base64 or not a valid IOTA signature
- The signature uses a scheme other than Ed25519 (secp256k1 and secp256r1 are rejected)
- The signature was not created by the private key corresponding to the address
- The message doesn’t match what was originally signed