liveBook · Manning

Key register

As explained in Building Quantum Software with Python

A key register is a quantum register whose computational-basis value represents the key in an encoded key-value pair.

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)
figure

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

How Building Quantum Software with Python covers it

How deep it goes
Defines register sizing and traces superposition, controlled phases, and IQFT, but defers physical implementation details.
Examples
Uses a three-qubit digit-sum function and polynomial encodings including k² + 2 and k² − 5k + 7.
What it assumes
Assumes binary integers and quantum circuits while teaching register sizing, binary decomposition, and key-controlled output encoding.
What you can do after
Build it from scratch with quantum registers, controlled phase gates, binary-variable terms, and an inverse quantum Fourier transform.
How it connects
Connects key registers to value registers, quantum entanglement, phase rotations, inverse quantum Fourier transforms, and Grover's algorithm.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Quantum Software with Python. The section links point to the parts of the book it draws on.