feat: Allow creation of secret key from bytes (#224)

This commit is contained in:
cameron1024 2023-02-09 20:44:37 +00:00 committed by GitHub
parent a81fc101fe
commit 9fd00a9e5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -311,6 +311,30 @@ impl From<[u8; Self::SIZE]> for Signature {
}
}
impl From<[u8; Self::SIZE]> for SecretKey {
fn from(bytes: [u8; Self::SIZE]) -> Self {
Self(bytes)
}
}
impl From<SecretKey> for [u8; SecretKey::SIZE] {
fn from(sk: SecretKey) -> Self {
sk.0
}
}
impl From<[u8; Self::SIZE]> for SecretKeyExtended {
fn from(bytes: [u8; Self::SIZE]) -> Self {
Self(bytes)
}
}
impl From<SecretKeyExtended> for [u8; SecretKeyExtended::SIZE] {
fn from(ske: SecretKeyExtended) -> Self {
ske.0
}
}
impl<'a> TryFrom<&'a [u8]> for PublicKey {
type Error = TryFromPublicKeyError;
fn try_from(value: &'a [u8]) -> Result<Self, Self::Error> {