def unscramble_taxon(taxon: int, token_seq: int) -> int:
    """
    Unscrambles or rescrambles a taxon in an NFTokenID.

    An issuer may issue several NFTs with the same taxon; to ensure that NFTs
    are spread across multiple pages we lightly mix the taxon up by using the
    sequence (which is not under the issuer's direct control) as the seed for
    a simple linear congruential generator.

    From the Hull-Dobell theorem we know that f(x)=(m*x+c) mod n will yield a
    permutation of [0, n) when n is a power of 2 if m is congruent to 1 mod 4
    and c is odd. By doing a bitwise XOR with this permutation we can
    scramble/unscramble the taxon.

    The XLS-20d proposal fixes m = 384160001 and c = 2459.
    We then take the modulus of 2^32 which is 4294967296.

    Args:
        taxon: The scrambled or unscrambled taxon (The XOR is both the
                encoding and decoding)
        token_seq: The account sequence when the token was minted. Used as a
                psuedorandom seed.

    Returns:
        The opposite taxon. If the taxon was scrambled it becomes unscrambled,
        and vice versa.
    """
    return (taxon ^ (384160001 * token_seq + 2459)) % 4294967296