Onionr/src/streamfill/extracted25519.py

14 lines
433 B
Python
Raw Normal View History

2020-10-24 08:07:54 +00:00
from base64 import b32decode
from typing import TYPE_CHECKING
from onionrutils.bytesconverter import str_to_bytes
if TYPE_CHECKING:
from onionrtypes import Ed25519PublicKeyBytes, OnionAddressString
def extract_ed25519_from_onion_address(
address: OnionAddressString) -> Ed25519PublicKeyBytes:
address = str_to_bytes(address).replace(b'.onion', b'').upper()
ed25519 = b32decode(address)[:-3]
return ed25519