```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(255 if i < prefix // 8 else 0) 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 contain exactly four dot-separated fields")
    
    prefix = 0
    for octet in octets:
        if not octet.isdigit():
            raise ValueError("All fields must contain decimal digits")
        if octet[0] == '0' and len(octet) > 1:
            raise ValueError("Leading zero in a field other than '0' is invalid")
        octet_value = int(octet)
        if octet_value < 0 or octet_value > 255:
            raise ValueError("Octet must be between 0 and 255 inclusive")
        
        prefix <<= 8
        prefix += octet_value
    
    if not all(bit == '1' for bit in mask.split('.')[0].rstrip('0')):
        raise ValueError("Mask one bits must be unbroken by zeros")
    
    return prefix.bit_length()
```