INNER CODE UNIT · Python

bech32_hrp_expand

bee-san/pyWhat · pywhat/bitcoin.py:67

def bech32_hrp_expand(hrp: str) -> List[int]:
    """The human-readable part of Bech32 text, as checksummed (BIP 173)."""
    return [ord(char) >> 5 for char in hrp] + [0] + [ord(char) & 31 for char in hrp]


def convert_bits(
    data: Sequence[int], from_bits: int, to_bits: int
) -> Optional[List[int]]:
    """
    Regroup data, a sequence of from_bits-bit integers, into to_bits-bit
    integers. None if what is left over is not a zero padding of less than
    from_bits bits (BIP 173).
    """
    accumulator = 0
    bits = 0
    result = []
    max_value = (1 << to_bits) - 1
    max_accumulator = (1 << (from_bits + to_bits - 1)) - 1

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…