pub struct Signature { /* private fields */ }
Expand description
A versionned signature. Can be used to validate if some data has been tampered.
Implementations§
Source§impl Signature
impl Signature
Sourcepub fn verify(&self, data: &[u8], public_key: &SigningPublicKey) -> bool
pub fn verify(&self, data: &[u8], public_key: &SigningPublicKey) -> bool
Verify if the signature matches with the specified data and key.
§Arguments
data
- The data that’s signed.public_key
- The public part of the keypair used to sign the data.
§Returns
Returns true if the signature is valid and false if it doesn’t.
§Example
use devolutions_crypto::signing_key::{generate_signing_keypair, SigningKeyVersion, SigningKeyPair};
use devolutions_crypto::signature::{sign, Signature, SignatureVersion};
let keypair: SigningKeyPair = generate_signing_keypair(SigningKeyVersion::Latest);
let signature: Signature = sign(b"this is some test data", &keypair, SignatureVersion::Latest);
assert!(signature.verify(b"this is some test data", &keypair.get_public_key()));
Trait Implementations§
Source§impl HeaderType for Signature
impl HeaderType for Signature
Auto Trait Implementations§
impl Freeze for Signature
impl RefUnwindSafe for Signature
impl Send for Signature
impl Sync for Signature
impl Unpin for Signature
impl UnwindSafe for Signature
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more