Skip to content

Commit

Permalink
Merge pull request #10 from spruceid/feat/sig-bytes
Browse files Browse the repository at this point in the history
Constrain signature to bytes
  • Loading branch information
chunningham authored Mar 29, 2022
2 parents fdae05e + f13bd04 commit c48b68f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,23 @@ pub enum VerificationError {
NotCurrentlyValid,
}

pub struct BasicSignature<S> {
pub struct BasicSignature<S: AsRef<[u8]> + TryFrom<Vec<u8>>> {
pub s: S,
}

impl<S: AsRef<[u8]> + TryFrom<Vec<u8>>> AsRef<[u8]> for BasicSignature<S> {
fn as_ref(&self) -> &[u8] {
self.s.as_ref()
}
}

impl<S: AsRef<[u8]> + TryFrom<Vec<u8>>> TryFrom<Vec<u8>> for BasicSignature<S> {
type Error = <S as TryFrom<Vec<u8>>>::Error;
fn try_from(s: Vec<u8>) -> Result<Self, Self::Error> {
Ok(Self { s: s.try_into()? })
}
}

#[derive(Copy, Clone)]
pub enum Version {
V1 = 1,
Expand Down

0 comments on commit c48b68f

Please sign in to comment.