feat: expand onion service api
This commit is contained in:
parent
c1b385ed99
commit
e5976c4739
11 changed files with 646 additions and 348 deletions
|
@ -1,5 +1,6 @@
|
|||
import base64
|
||||
import hashlib
|
||||
from typing import Tuple, Optional, List, Dict
|
||||
|
||||
|
||||
def onion_hostname(onion_public_key: bytes) -> str:
|
||||
|
@ -17,3 +18,13 @@ def onion_hostname(onion_public_key: bytes) -> str:
|
|||
|
||||
onion = base64.b32encode(result).decode("utf-8").strip("=")
|
||||
return onion.lower()
|
||||
|
||||
|
||||
def decode_onion_keys(onion_private_key_base64: str, onion_public_key_base64: str) -> Tuple[
|
||||
Optional[bytes], Optional[bytes], List[Dict[str, str]]]:
|
||||
try:
|
||||
onion_private_key = base64.b64decode(onion_private_key_base64)
|
||||
onion_public_key = base64.b64decode(onion_public_key_base64)
|
||||
return onion_private_key, onion_public_key, []
|
||||
except ValueError as e:
|
||||
return None, None, [{"Error": "invalid_onion_key", "Message": str(e)}]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue