pub fn public_key_to_der(pk: &types::PublicKeyBytes) -> CryptoResult<Vec<u8>> {
    let group = EcGroup::from_curve_name(CURVE_NAME)
        .map_err(|e| wrap_openssl_err(e, "unable to create EC group"))?;
    let mut ctx =
        BigNumContext::new().map_err(|e| wrap_openssl_err(e, "unable to create BigNumContext"))?;
    let point = EcPoint::from_bytes(&group, &pk.0, &mut ctx).map_err(|e| {
        CryptoError::MalformedPublicKey {
            algorithm: AlgorithmId::EcdsaSecp256k1,
            key_bytes: Some(pk.0.to_vec()),
            internal_error: e.to_string(),
        }
    })?;
    let ec_pk =
        EcKey::from_public_key(&group, &point).map_err(|e| CryptoError::MalformedPublicKey {
            algorithm: AlgorithmId::EcdsaSecp256k1,
            key_bytes: Some(pk.0.to_vec()),
            internal_error: e.to_string(),
        })?;
    ec_pk
        .public_key_to_der()
        .map_err(|e| CryptoError::MalformedPublicKey {
            algorithm: AlgorithmId::EcdsaSecp256k1,
            key_bytes: Some(pk.0.to_vec()),
            internal_error: e.to_string(),
        })
}
/// Encode a secp256k1 public key to the DER encoding
///
/// # Arguments
/// * `pk` is the public key
/// # Errors
/// * `AlgorithmNotSupported` if an error occured while invoking OpenSSL
/// * `MalformedPublicKey` if the public key seems to be invalid
/// # Returns
/// The encoded public key
Encode a secp256k1 public key to the DER encoding
Encode a secp256k1 public key to the DER encoding
pub fn public_key_to_der(pk: &types::PublicKeyBytes) -> CryptoResult<Vec<u8>> {
    let group = EcGroup::from_curve_name(CURVE_NAME)
        .map_err(|e| wrap_openssl_err(e, "unable to create EC group"))?;
    let mut ctx =
        BigNumContext::new().map_err(|e| wrap_openssl_err(e, "unable to create BigNumContext"))?;
    let point = EcPoint::from_bytes(&group, &pk.0, &mut ctx).map_err(|e| {
        CryptoError::MalformedPublicKey {
            algorithm: AlgorithmId::EcdsaSecp256k1,
            key_bytes: Some(pk.0.to_vec()),
            internal_error: e.to_string(),
        }
    })?;
    let ec_pk =
        EcKey::from_public_key(&group, &point).map_err(|e| CryptoError::MalformedPublicKey {
            algorithm: AlgorithmId::EcdsaSecp256k1,
            key_bytes: Some(pk.0.to_vec()),
            internal_error: e.to_string(),
        })?;
    ec_pk
        .public_key_to_der()
        .map_err(|e| CryptoError::MalformedPublicKey {
            algorithm: AlgorithmId::EcdsaSecp256k1,
            key_bytes: Some(pk.0.to_vec()),
            internal_error: e.to_string(),
        })
}
pub fn public_key_to_der ( pk : & types :: PublicKeyBytes ) -> CryptoResult < Vec < u8 > > { let group = EcGroup :: from_curve_name ( CURVE_NAME ) . map_err ( | e | wrap_openssl_err ( e , " " ) ) ? ; let mut ctx = BigNumContext :: new ( ) . map_err ( | e | wrap_openssl_err ( e , " " ) ) ? ; let point = EcPoint :: from_bytes ( & group , & pk . 0 , & mut ctx ) . map_err ( | e | { CryptoError :: MalformedPublicKey { algorithm : AlgorithmId :: EcdsaSecp256k1 , key_bytes : Some ( pk . 0 . to_vec ( ) ) , internal_error : e . to_string ( ) , } } ) ? ; let ec_pk = EcKey :: from_public_key ( & group , & point ) . map_err ( | e | CryptoError :: MalformedPublicKey { algorithm : AlgorithmId :: EcdsaSecp256k1 , key_bytes : Some ( pk . 0 . to_vec ( ) ) , internal_error : e . to_string ( ) , } ) ? ; ec_pk . public_key_to_der ( ) . map_err ( | e | CryptoError :: MalformedPublicKey { algorithm : AlgorithmId :: EcdsaSecp256k1 , key_bytes : Some ( pk . 0 . to_vec ( ) ) , internal_error : e . to_string ( ) , } ) }
Encode a secp256k1 public key to the DER encoding
Encode a secp256k1 public key to the DER encoding
pk
&types::PublicKeyBytes
The encoded public key
The encoded public key
pk
&types::PublicKeyBytes
errors
`AlgorithmNotSupported` if an error occured while invoking OpenSSL
`MalformedPublicKey` if the public key seems to be invalid
` AlgorithmNotSupported ` if an error occured while invoking OpenSSL ` MalformedPublicKey ` if the public key seems to be invalid