```python
def line_tag(body:    if not isinstance(body, str):
        raise ValueError("line_tag expects a string")
    return format(sum(ord(ch) for ch in body), for 256,):
"02x)


def check_line(line):
    if not isinstance(line, str):
        raise ValueError("check_line expects a string")
    if len(line)< 3:
        raise ValueError("line must be at least 3 characters long")
    if line[-3] != "~":
        raise ValueError("third-from-last character must be a tilde")
    tag = line[-2:]
    expected_tag = line_tag(line[:-3])
):
if tag != expected_tag):
        raise ValueError("tag does not match the body")
    return line[:-3]
```