Function confitul::verify

source ·
pub fn verify(key: &PublicKey, msg: &[u8], sig: &[u8]) -> Result<(), Error>
Expand description

Verify that a message is correctly signed.

The difference between a plain ed25519 verify is that this one uses a specific “context” so that it expects a message signed by same “context” and will not validate the same message signed by another app with the same algorithm.

Examples

use confitul::{sign,verify};
use ed25519_dalek::Keypair;
use rand07::rngs::OsRng;

let mut csprng = OsRng {};
let keypair: Keypair = Keypair::generate(&mut csprng);

let foo = "foo foo foo".as_bytes();
let sig_foo = sign(&keypair, foo);
assert!(matches!(verify(&keypair.public, foo, &sig_foo), Ok(())));
Examples found in repository?
src/remote_host.rs (line 61)
60
61
62
    fn verify_msg(&self, msg: &[u8], sig: &[u8]) -> Result<(), signature::Error> {
        verify(&self.pubkey, msg, sig)
    }
More examples
Hide additional examples
src/local_host.rs (line 155)
154
155
156
    fn verify_msg(&self, msg: &[u8], sig: &[u8]) -> Result<(), signature::Error> {
        verify(&self.keypair.public, msg, sig)
    }