diff --git a/src/types/crypto/secp256r1.rs b/src/types/crypto/secp256r1.rs index cd4122708..0d2f5c085 100644 --- a/src/types/crypto/secp256r1.rs +++ b/src/types/crypto/secp256r1.rs @@ -64,6 +64,10 @@ impl Secp256r1PublicKey { pub const fn as_bytes(&self) -> &[u8] { &self.0 } + + pub fn from_bytes>(bytes: T) -> Result { + <[u8; Self::LENGTH]>::try_from(bytes.as_ref()).map(Self) + } } impl std::str::FromStr for Secp256r1PublicKey { @@ -158,6 +162,10 @@ impl Secp256r1Signature { pub const fn as_bytes(&self) -> &[u8] { &self.0 } + + pub fn from_bytes>(bytes: T) -> Result { + <[u8; Self::LENGTH]>::try_from(bytes.as_ref()).map(Self) + } } impl std::str::FromStr for Secp256r1Signature {