# AES × KKP-R · Native and Quantum Simulator Sources

This directory is the existing live Mathematical City AES Constraint Spectrum instrument. No new app or repository is required.

## Run

- `make test` — compile `aes.c` under C99 with strict warnings and check the NIST AES-128 single-block known-answer vector and round-trip decryption.
- `cmake -S . -B build && cmake --build build && ctest --test-dir build --output-on-failure` — independent native build interface.
- `python verify.py aes_parity.qasm` — independently compute GF(2^8) AES S-box; simulate the reversible 16-qubit XOR oracle as a full 65,536-entry complex statevector; reconstruct all 39 phase-oracle constraints and diagonal Hamiltonian energies; check exact solution graph, gap, eigenvalue maximum, unitarity and optimal contraction.
- `python aes_spectrum.py` — dependency-free 65,536-state diagonal-spectrum enumeration from `aes_sbox_mq.txt`.
- `python verify_native.py` — isolated native GCC + CMake test, used in the existing validator workflow.

## Exact mathematical properties

`H_Q=Σ_i(𝕀−Z_i)/2`, `Z_i|z⟩=(−1)^{q_i(z)}|z⟩`.
`ker H_Q=span{|x,S_AES(x)⟩:x∈𝔽₂⁸}`, dimension 256.
`σ(H_Q)={0} ∪ {7,…,34}`. `P=∏_{k=7}^{34}(𝕀−H_Q/k)`.
With `Γ=𝕀−2H_Q/41`, `‖Γⁿ−P‖₂=(27/41)ⁿ`.
The 39-equation nonzero spectrum and gap are **specific to this selected constraint basis**; the kernel graph equivalence is invariant under alternate generating systems for the same zero set.

## Existing-city links

- [Live AES spectrum and browser byte/constraint tester](./)
- [THE MATRIX quantum simulator](../matrix/)
- [Entangle quantum state runtime](../entangle/)
- [Quantum circuit atlas](../qsvt-phi4-circuit/)
- [E₄₇ quantum error correction](../e47-qec/)
- [E₄₇ quantum energy](../e47-quantum-energy/)
- [Identity formal archive](https://github.com/nicholaskouns-create/Identity/tree/main/leri/universal-invariant)
- [All 256 graph rows](https://github.com/nicholaskouns-create/Identity/blob/main/leri/universal-invariant/finite_field_39_points.csv)

## QASM source versions

The current Pages copy is **OpenQASM 3** and uses `gphase(pi)` for the 20 constant-one quadrics. The archived Identity version is **OpenQASM 2** and records those constants using `// global phase -1 omitted` comments. The Python and browser parsers explicitly accept both encodings; dropping these constants changes the solution set.

## Engineering scope

The C program is an educational **AES-128 single-block reference**, not authenticated file encryption, nor a production constant-time AES. For real confidential storage use a standard audited AES-256-GCM implementation. The QASM contains diagonal phase-oracle circuits; the Python program simulates quantum basis permutations and statevectors classically. No QPU execution or performance advantage is asserted. The 125→47 E₄₇ projector and 65,536→256 AES projector are independent models of the same general finite spectral-projection construction; they have not been physically coupled.
