Z25377

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z25377"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z25376",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z610",
            "Z16K2": "def Z25376(Z25376K1, Z25376K2, Z25376K3):\n    def quater_round(a, b, c, d):\n        a = (a + b) % (1\u003C\u003C32)\n        d = d ^ a\n        d = ((d \u0026 0x0000ffff) \u003C\u003C 16) | ((d \u0026 0xffff0000) \u003E\u003E 16)\n        c = (c + d) % (1\u003C\u003C32)\n        b = b ^ c\n        b = ((b \u0026 0x000fffff) \u003C\u003C 12) | ((b \u0026 0xfff00000) \u003E\u003E 20)\n        a = (a + b) % (1\u003C\u003C32)\n        d = d ^ a\n        d = ((d \u0026 0x00ffffff) \u003C\u003C 8) | ((d \u0026 0xff000000) \u003E\u003E 24)\n        c = (c + d) % (1\u003C\u003C32)\n        b = b ^ c\n        b = ((b \u0026 0x01ffffff) \u003C\u003C 7) | ((b \u0026 0xffffff80) \u003E\u003E 25)\n\n        return a, b, c, d\n        \n    def compress(state):\n        old_state = state.copy()\n\n        for i in range(0, 10):\n            state[0], state[4], state[8], state[12] = quater_round(state[0], state[4], state[8], state[12])\n            state[1], state[5], state[9], state[13] = quater_round(state[1], state[5], state[9], state[13])\n            state[2], state[6], state[10], state[14] = quater_round(state[2], state[6], state[10], state[14])\n            state[3], state[7], state[11], state[15] = quater_round(state[3], state[7], state[11], state[15])\n            state[0], state[5], state[10], state[15] = quater_round(state[0], state[5], state[10], state[15])\n            state[1], state[6], state[11], state[12] = quater_round(state[1], state[6], state[11], state[12])\n            state[2], state[7], state[8], state[13] = quater_round(state[2], state[7], state[8], state[13])\n            state[3], state[4], state[9], state[14] = quater_round(state[3], state[4], state[9], state[14])\n            \n        for i in range(0, 16):\n            state[i] = (state[i] + old_state[i]) % (1\u003C\u003C32)\n\n    key = bytes.fromhex(Z25376K1)\n    counter = Z25376K2\n    nonce = Z25376K3\n    assert len(key) == 32\n    assert counter \u003E= 0 and counter \u003E\u003E 64 == 0\n    assert nonce \u003E= 0 and nonce \u003E\u003E 64 == 0\n    \n    state = [0x61707865, 0x3320646e, 0x79622d32, 0x6b206574, int.from_bytes(key[0:4], \"little\"), int.from_bytes(key[4:8], \"little\"), int.from_bytes(key[8:12], \"little\"), int.from_bytes(key[12:16], \"little\"), int.from_bytes(key[16:20], \"little\"), int.from_bytes(key[20:24], \"little\"), int.from_bytes(key[24:28], \"little\"), int.from_bytes(key[28:32], \"little\"), counter % (1 \u003C\u003C 32), counter \u003E\u003E 32, nonce % (1 \u003C\u003C 32), nonce \u003E\u003E 32]\n    compress(state)\n    \n    block = b\"\"\n    for i in state:\n        block += i.to_bytes(4, \"little\")\n        \n    return block.hex()"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "ChaCha20, python"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}