{
    "allowed_reference_expressions_for_hint": [
        {
            "allowed_expressions": [
                {
                    "expr": "[cast(ap + (-2), felt*)]",
                    "name": "blake2s.finalize_blake2s.__fp__"
                },
                {
                    "expr": "[cast(fp + (-5), starkware.cairo.common.cairo_builtins.BitwiseBuiltin**)]",
                    "name": "blake2s.finalize_blake2s.bitwise_ptr"
                },
                {
                    "expr": "[cast(fp + (-3), felt**)]",
                    "name": "blake2s.finalize_blake2s.blake2s_ptr_end"
                },
                {
                    "expr": "[cast(fp + (-4), felt**)]",
                    "name": "blake2s.finalize_blake2s.blake2s_ptr_start"
                },
                {
                    "expr": "[cast(ap + (-1), felt*)]",
                    "name": "blake2s.finalize_blake2s.n"
                },
                {
                    "expr": "[cast(fp + (-6), felt*)]",
                    "name": "blake2s.finalize_blake2s.range_check_ptr"
                },
                {
                    "expr": "[cast(ap + (-1), felt**)]",
                    "name": "blake2s.finalize_blake2s.sigma"
                }
            ],
            "hint_lines": [
                "# Add dummy pairs of input and output.",
                "from starkware.cairo.common.cairo_blake2s.blake2s_utils import IV, blake2s_compress",
                "",
                "_n_packed_instances = int(ids.N_PACKED_INSTANCES)",
                "assert 0 <= _n_packed_instances < 20",
                "_blake2s_input_chunk_size_felts = int(ids.BLAKE2S_INPUT_CHUNK_SIZE_FELTS)",
                "assert 0 <= _blake2s_input_chunk_size_felts < 100",
                "",
                "message = [0] * _blake2s_input_chunk_size_felts",
                "modified_iv = [IV[0] ^ 0x01010020] + IV[1:]",
                "output = blake2s_compress(",
                "    message=message,",
                "    h=modified_iv,",
                "    t0=0,",
                "    t1=0,",
                "    f0=0xffffffff,",
                "    f1=0,",
                ")",
                "padding = (message + modified_iv + [0, 0xffffffff] + output) * (_n_packed_instances - 1)",
                "segments.write_arg(ids.blake2s_ptr_end, padding)"
            ]
        },
        {
            "allowed_expressions": [
                {
                    "expr": "cast([ap + (-10)] + 10, felt*)",
                    "name": "blake2s.blake2s.blake2s_ptr"
                },
                {
                    "expr": "[cast(fp + (-5), felt**)]",
                    "name": "blake2s.blake2s.blake2s_start"
                },
                {
                    "expr": "[cast(fp + (-4), felt**)]",
                    "name": "blake2s.blake2s.input"
                },
                {
                    "expr": "[cast(fp + (-3), felt*)]",
                    "name": "blake2s.blake2s.n_bytes"
                },
                {
                    "expr": "cast([ap + (-10)] + 10, felt*)",
                    "name": "blake2s.blake2s.output"
                },
                {
                    "expr": "[cast(ap + (-2), felt*)]",
                    "name": "blake2s.blake2s.range_check_ptr"
                }
            ],
            "hint_lines": [
                "from starkware.cairo.common.cairo_blake2s.blake2s_utils import IV, blake2s_compress",
                "",
                "_blake2s_input_chunk_size_felts = int(ids.BLAKE2S_INPUT_CHUNK_SIZE_FELTS)",
                "assert 0 <= _blake2s_input_chunk_size_felts < 100",
                "",
                "new_state = blake2s_compress(",
                "    message=memory.get_range(ids.blake2s_start, _blake2s_input_chunk_size_felts),",
                "    h=[IV[0] ^ 0x01010020] + IV[1:],",
                "    t0=ids.n_bytes,",
                "    t1=0,",
                "    f0=0xffffffff,",
                "    f1=0,",
                ")",
                "",
                "segments.write_arg(ids.output, new_state)"
            ]
        },
        {
            "allowed_expressions": [
                {
                    "expr": "[cast(fp + (-6), felt**)]",
                    "name": "blake2s._blake2s_input.blake2s_ptr"
                },
                {
                    "expr": "[cast(fp, felt*)]",
                    "name": "blake2s._blake2s_input.full_word"
                },
                {
                    "expr": "[cast(fp + (-5), felt**)]",
                    "name": "blake2s._blake2s_input.input"
                },
                {
                    "expr": "[cast(fp + (-4), felt*)]",
                    "name": "blake2s._blake2s_input.n_bytes"
                },
                {
                    "expr": "[cast(fp + (-3), felt*)]",
                    "name": "blake2s._blake2s_input.n_words"
                },
                {
                    "expr": "[cast(fp + (-7), felt*)]",
                    "name": "blake2s._blake2s_input.range_check_ptr"
                }
            ],
            "hint_lines": [
                "ids.full_word = int(ids.n_bytes >= 4)"
            ]
        }
    ]
}
