Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Make signature sign and verify take impl AsRef<[u8]> instead of `&[…
Browse files Browse the repository at this point in the history
…u8]`
  • Loading branch information
soerenmeier committed Nov 26, 2021
1 parent 0f486f6 commit b9674f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "fire-crypto"
description = "Crypto library providing encryption and signing."
version = "0.3.2"
version = "0.3.3"
authors = ["Sören Meier <[email protected]>"]
repository = "https://github.com/fire-lib/fire-crypto"
homepage = "https://fire-lib.com/"
Expand Down
6 changes: 3 additions & 3 deletions src/signature/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ impl Keypair {
&self.public
}

pub fn sign(&self, msg: &[u8]) -> Signature {
pub fn sign(&self, msg: impl AsRef<[u8]>) -> Signature {
let expanded: ed::ExpandedSecretKey = (&self.secret).into();
let sign = expanded.sign(msg, self.public().inner());
let sign = expanded.sign(msg.as_ref(), self.public().inner());
Signature::from_sign(sign)
}

pub fn verify(&self, msg: &[u8], signature: &Signature) -> bool {
pub fn verify(&self, msg: impl AsRef<[u8]>, signature: &Signature) -> bool {
self.public.verify(msg, signature)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/signature/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ impl PublicKey {
self.inner.to_bytes()
}

pub fn verify(&self, msg: &[u8], signature: &Signature) -> bool {
self.inner.verify_strict(msg, signature.inner()).is_ok()
pub fn verify(&self, msg: impl AsRef<[u8]>, signature: &Signature) -> bool {
self.inner.verify_strict(msg.as_ref(), signature.inner()).is_ok()
}
}

Expand Down

0 comments on commit b9674f3

Please sign in to comment.