A key register is a quantum register whose computational-basis value identifies the input key in an encoded key–value pair. Together with a value register, it represents function inputs and corresponding outputs: measuring the combined state returns a key paired with its value. With n key qubits, the register represents integer keys from 0 through 2^n − 1. section 10.1 section 10.4
Figure 10.2 An example measurement outcome of a quantum state with n = 3 key qubits and m = 3 value qubits and an encoded function f representing the input–output pair (2, 4)
A measurement diagram makes the key–value layout concrete: three key qubits and three value qubits can represent the input–output pair (2, 4). section 10.1
A key register participates in function encoding through this implementation pattern:
- Create key and value registers with enough qubits for the input and output ranges. section 10.1
- Place both registers in equal superposition so every input key participates in the encoded state. section 10.1.1
- Apply phase rotations to the value register, controlled by key-register qubits; binary decomposition lets individual 1 digits contribute to the encoded output. section 10.1.1
- Apply the inverse quantum Fourier transform to the value register to recover output values on measurement. section 10.1.1 section 10.4
Counting the key's binary digits
For a three-qubit key register, key 011 represents integer 3. A two-qubit value register can encode its digit sum, producing the pair (3, 2). The complete mapping assigns values 0, 1, 1, 2, 1, 2, 2, and 3 to keys 0 through 7. section 10.1.1
The same register pattern supports polynomial functions after integer inputs are expanded into binary variables. Terms use controlled phase gates on the relevant key qubits, while constants use uncontrolled phase gates; negative values use two's complement. section 10.1.3 section 10.4
