22import cbor2
33import logging
44
5- from pycose .keys import CoseKey
5+ from pycose .keys import CoseKey , EC2Key
66from typing import Union
77
88from pymdoccbor .mso .issuer import MsoIssuer
@@ -16,7 +16,7 @@ class MdocCborIssuer:
1616 MdocCborIssuer helper class to create a new mdoc
1717 """
1818
19- def __init__ (self , private_key : Union [dict , CoseKey ]):
19+ def __init__ (self , private_key : Union [dict , EC2Key , CoseKey ]):
2020 """
2121 Create a new MdocCborIssuer instance
2222
@@ -28,11 +28,17 @@ def __init__(self, private_key: Union[dict, CoseKey]):
2828 self .version : str = '1.0'
2929 self .status : int = 0
3030
31- if not private_key :
31+ if isinstance (private_key , dict ):
32+ self .private_key = CoseKey .from_dict (private_key )
33+ elif isinstance (private_key , EC2Key ):
34+ ec2_encoded = private_key .encode ()
35+ ec2_decoded = CoseKey .decode (ec2_encoded )
36+ self .private_key = ec2_decoded
37+ elif isinstance (private_key , CoseKey ):
38+ self .private_key = private_key
39+ else :
3240 raise MissingPrivateKey ("You must provide a private key" )
3341
34- if private_key and isinstance (private_key , dict ):
35- self .private_key = CoseKey .from_dict (private_key )
3642
3743 self .signed :dict = {}
3844
0 commit comments