pub fn from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, HederaError> {
        let bytes = bytes.as_ref();

        if bytes.len() == ed25519_dalek::SECRET_KEY_LENGTH + ed25519_dalek::PUBLIC_KEY_LENGTH
            || bytes.len() == ed25519_dalek::SECRET_KEY_LENGTH
        {
            // If the buffer looks like a {secret}{public} byte string; just pull the secret
            // key bytes off of it
            return Ok(PrivateKey(ed25519_dalek::SecretKey::from_bytes(
                &bytes[..ed25519_dalek::SECRET_KEY_LENGTH],
            )?));
        }

        let info: PrivateKeyInfo = der_decode(&bytes)?;

        if info.algorithm.algorithm != *OID_ED25519 {
            return Err(HederaError::PkcsUnknownPublicKeyAlgorithm);
        }

        Ok(PrivateKey(ed25519_dalek::SecretKey::from_bytes(
            &info.private_key[2..],
        )?))
    }
/// Construct a `PrivateKey` from a slice of bytes.
/// Bytes are expected to be either a raw key or encoded in ASN.1.
Construct a `PrivateKey` from a slice of bytes.
Bytes are expected to be either a raw key or encoded in ASN.1.
Construct a ` PrivateKey ` from a slice of bytes . Bytes are expected to be either a raw key or encoded in ASN . 1 .
pub fn from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, HederaError> {
        let bytes = bytes.as_ref();
        if bytes.len() == ed25519_dalek::SECRET_KEY_LENGTH + ed25519_dalek::PUBLIC_KEY_LENGTH
            || bytes.len() == ed25519_dalek::SECRET_KEY_LENGTH
        {
            // If the buffer looks like a {secret}{public} byte string; just pull the secret
            // key bytes off of it
            return Ok(PrivateKey(ed25519_dalek::SecretKey::from_bytes(
                &bytes[..ed25519_dalek::SECRET_KEY_LENGTH],
            )?));
        }
        let info: PrivateKeyInfo = der_decode(&bytes)?;
        if info.algorithm.algorithm != *OID_ED25519 {
            return Err(HederaError::PkcsUnknownPublicKeyAlgorithm);
        }
        Ok(PrivateKey(ed25519_dalek::SecretKey::from_bytes(
            &info.private_key[2..],
        )?))
    }
pub fn from_bytes ( bytes : impl AsRef < [ u8 ] > ) -> Result < Self , HederaError > { let bytes = bytes . as_ref ( ) ; if bytes . len ( ) == ed25519_dalek :: SECRET_KEY_LENGTH + ed25519_dalek :: PUBLIC_KEY_LENGTH || bytes . len ( ) == ed25519_dalek :: SECRET_KEY_LENGTH { // If the buffer looks like a {secret}{public} byte string; just pull the secret // key bytes off of it return Ok ( PrivateKey ( ed25519_dalek :: SecretKey :: from_bytes ( & bytes [ .. ed25519_dalek :: SECRET_KEY_LENGTH ] , ) ? ) ) ; } let info : PrivateKeyInfo = der_decode ( & bytes ) ? ; if info . algorithm . algorithm != * OID_ED25519 { return Err ( HederaError :: PkcsUnknownPublicKeyAlgorithm ) ; } Ok ( PrivateKey ( ed25519_dalek :: SecretKey :: from_bytes ( & info . private_key [ 2 .. ] , ) ? ) ) }
Construct a `PrivateKey` from a slice of bytes.
Construct a ` PrivateKey ` from a slice of bytes .
bytes
impl AsRef<[u8]>
bytes
impl AsRef<[u8]>