anchor.diff:  handle_pkcs_frame_error(_, _, Error) ->
       erlang:error(Error).
   
  -der_priv_key_decode({'PrivateKeyInfo', v1,
  -	{'PrivateKeyInfo_privateKeyAlgorithm', ?'id-ecPublicKey', {asn1_OPENTYPE, Parameters}}, PrivKey, _}) ->
  -	EcPrivKey = der_decode('ECPrivateKey', PrivKey),
  -	EcPrivKey#'ECPrivateKey'{parameters = der_decode('EcpkParameters', Parameters)};
  -der_priv_key_decode({'PrivateKeyInfo', v1,
  -                     {'PrivateKeyInfo_privateKeyAlgorithm', CurveOId, _}, PrivKey, _}) when
  +der_priv_key_decode(#'PrivateKeyInfo'{version = v1,
  +                                      privateKeyAlgorithm =
  +                                          #'PrivateKeyInfo_privateKeyAlgorithm'{algorithm = ?'id-ecPublicKey',
  +                                                                                parameters = {asn1_OPENTYPE, Parameters}},
  +                                      privateKey = PrivKey}) ->
  +    EcPrivKey = der_decode('ECPrivateKey', PrivKey),
  +    EcPrivKey#'ECPrivateKey'{parameters = der_decode('EcpkParameters', Parameters)};
  +der_priv_key_decode(#'PrivateKeyInfo'{version = v1,
  +                                      privateKeyAlgorithm =#'PrivateKeyInfo_privateKeyAlgorithm'{algorithm = CurveOId},
  +                                      privateKey = PrivKey}) when
         CurveOId == ?'id-Ed25519'orelse
         CurveOId == ?'id-Ed448' ->
       #'ECPrivateKey'{version = 1, parameters = {namedCurve, CurveOId}, privateKey = PrivKey};
  -der_priv_key_decode({'OneAsymmetricKey', _,
  -                     {'OneAsymmetricKey_privateKeyAlgorithm', CurveOId, _}, PrivKey, Attr, PubKey}) when
  +der_priv_key_decode(#'OneAsymmetricKey'{
  +                       privateKeyAlgorithm = #'OneAsymmetricKey_privateKeyAlgorithm'{algorithm = CurveOId},
  +                       privateKey = PrivKey,
  +                       attributes = Attr,
  +                       publicKey = PubKey}) when
         CurveOId == ?'id-Ed25519'orelse
         CurveOId == ?'id-Ed448' ->
       #'ECPrivateKey'{version = 2, parameters = {namedCurve, CurveOId}, privateKey = PrivKey,
  
positive.code: %% Description: Encodes a public key entity with asn1 DER encoding.
  %%--------------------------------------------------------------------
  der_encode('PrivateKeyInfo', #'DSAPrivateKey'{p=P, q=Q, g=G, x=X}) ->
      der_encode('PrivateKeyInfo',
                 {'PrivateKeyInfo', v1,
                  {'PrivateKeyInfo_privateKeyAlgorithm', ?'id-dsa',
                   {asn1_OPENTYPE, der_encode('Dss-Parms', #'Dss-Parms'{p=P, q=Q, g=G})}},
  		der_encode('Prime-p', X), asn1_NOVALUE});
  der_encode('PrivateKeyInfo', #'RSAPrivateKey'{} = PrivKey) ->
      der_encode('PrivateKeyInfo',
                 {'PrivateKeyInfo', v1,
                  {'PrivateKeyInfo_privateKeyAlgorithm', ?'rsaEncryption', 
                   {asn1_OPENTYPE, ?DER_NULL}},
                  der_encode('RSAPrivateKey', PrivKey), asn1_NOVALUE});
  der_encode('PrivateKeyInfo', {#'RSAPrivateKey'{} = PrivKey, Parameters}) ->
      der_encode('PrivateKeyInfo',
                 {'PrivateKeyInfo', v1,
                  {'PrivateKeyInfo_privateKeyAlgorithm', ?'id-RSASSA-PSS',
                   {asn1_OPENTYPE, der_encode('RSASSA-PSS-params', Parameters)}},
                  der_encode('RSAPrivateKey', PrivKey), asn1_NOVALUE});
  der_encode('PrivateKeyInfo', #'ECPrivateKey'{parameters = {namedCurve, CurveOId},
                                               privateKey = PrivKey}) when
        CurveOId == ?'id-Ed25519' orelse
        CurveOId == ?'id-Ed448' ->
      der_encode('PrivateKeyInfo',
                 {'PrivateKeyInfo', v1,
  		{'PrivateKeyInfo_privateKeyAlgorithm', CurveOId, asn1_NOVALUE},
                  PrivKey, asn1_NOVALUE});
  der_encode('PrivateKeyInfo', #'ECPrivateKey'{parameters = Parameters} = PrivKey) ->
      der_encode('PrivateKeyInfo',
                 {'PrivateKeyInfo', v1,
  		{'PrivateKeyInfo_privateKeyAlgorithm', ?'id-ecPublicKey',
                   {asn1_OPENTYPE, der_encode('EcpkParameters', Parameters)}},
                  der_encode('ECPrivateKey', PrivKey#'ECPrivateKey'{parameters = asn1_NOVALUE}), 
                  asn1_NOVALUE});
  der_encode('OneAsymmetricKey', #'ECPrivateKey'{parameters = {namedCurve, CurveOId},
                                                 privateKey = PrivKey,
                                                 attributes = Attr,
                                                 publicKey = PubKey}) ->
      der_encode('OneAsymmetricKey',
                 {'OneAsymmetricKey', 1,
  		{'OneAsymmetricKey_privateKeyAlgorithm', CurveOId, asn1_NOVALUE},
                  PrivKey,
                  Attr,
                  PubKey
                 });
  der_encode(Asn1Type, Entity) when (Asn1Type == 'PrivateKeyInfo') orelse
                                    (Asn1Type == 'OneAsymmetricKey') orelse
  				  (Asn1Type == 'EncryptedPrivateKeyInfo') ->
  
negative.code:     Key = der_decode('RSAPrivateKey', PrivKey),
      Params = der_decode('RSASSA-PSS-params', Parameters),
      {Key, Params};
  der_priv_key_decode(#'PrivateKeyInfo'{version = v1,
                                        privateKeyAlgorithm = #'PrivateKeyInfo_privateKeyAlgorithm'{algorithm = ?'id-dsa',
                                                                                                    parameters =
                                                                                                        {asn1_OPENTYPE, Parameters}},
                                        privateKey = PrivKey}) ->
      {params, #'Dss-Parms'{p=P, q=Q, g=G}} = der_decode('DSAParams', Parameters),
      X = der_decode('Prime-p', PrivKey),
      #'DSAPrivateKey'{p=P, q=Q, g=G, x=X};
  der_priv_key_decode(PKCS8Key) ->
      PKCS8Key.
  
  %%--------------------------------------------------------------------
  -spec der_encode(Asn1Type, Entity) -> Der when Asn1Type :: asn1_type(),
  