onionr/src/streamfill/extracted25519.py

14 lines
437 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(
2020-10-25 04:12:42 +00:00
address: 'OnionAddressString') -> 'Ed25519PublicKeyBytes':
2020-10-24 08:07:54 +00:00
address = str_to_bytes(address).replace(b'.onion', b'').upper()
ed25519 = b32decode(address)[:-3]
return ed25519