```python
def mask_from_prefix(prefix: int) -> str:
    if not isinstance(prefix, int) or prefix < 0 or prefix > 32:
        raise ValueError("Prefix must be an integer from 0 to 32")
    
    return ".".join([str((1 << (32 - i)) - 1) for i in range(4)])


def prefix_from_mask(mask: str) -> int:
    if not isinstance(mask, str):
        raise ValueError("Mask must be a string")
    
    octets = mask.split(".")
    if len(octets) != 4:
        raise ValueError("Mask must have exactly four dot-separated fields")
    
    prefix = 0
    for octet in octets:
        if not octet.isdigit() or (octet[0] == '0' and octet != '0'):
            raise ValueError("Each field must be a decimal number without leading zeros except '0'")
        
        octet = int(octet)
        if octet < 0 or octet > 255:
            raise ValueError("Each field must hold a value between 0 and 255")
        
        prefix <<= 8
        prefix |= octet
    
    for i in range(31, -1, -1):
        if (prefix >> i) & 1 == 0 and (prefix >> (i + 1)) & 1 == 1:
            raise ValueError("One bits must be unbroken by zeros")
    
    return prefix.bit_length()
```