Skip to content

Commit 611d01f

Browse files
committed
Add public key props
1 parent 7d20956 commit 611d01f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tesla_fleet_api/tesla/tesla.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,23 @@ async def get_private_key(
6262
def has_private_key(self) -> bool:
6363
"""Check if the private key has been set."""
6464
return self.private_key is not None
65+
66+
@property
67+
def public_pem(self) -> str:
68+
"""Get the public key in PEM format."""
69+
if self.private_key is None:
70+
raise ValueError("Private key is not set")
71+
return self.private_key.public_key().public_bytes(
72+
encoding=serialization.Encoding.PEM,
73+
format=serialization.PublicFormat.SubjectPublicKeyInfo,
74+
).decode('utf-8')
75+
76+
@property
77+
def public_uncompressed_point(self) -> str:
78+
"""Get the public key in uncompressed point format."""
79+
if self.private_key is None:
80+
raise ValueError("Private key is not set")
81+
return self.private_key.public_key().public_bytes(
82+
encoding=serialization.Encoding.X962,
83+
format=serialization.PublicFormat.UncompressedPoint,
84+
).hex()

0 commit comments

Comments
 (0)