qiskit_rng.GeneratorResult

class GeneratorResult(wsr: List[List[int]], raw_bits_list: List[List[int]], backend: qiskit.providers.basebackend.BaseBackend)[source]

Representation of random number sampling result.

GeneratorResult constructor.

Bell values are calculated based on the input parameters. The values include:

  • mermin_correlator: Mermin correlator value. The statistical value calculated from the probability distributions. This verifies quantum correlations when >2, as 2 is the maximal value possible in a classical setup.

  • winning_probability: Probability of “winning” each round in the Mermin quantum game. It is used to verify quantum correlations (the maximum probability in a classical implementation is 87.5%).

  • losing_probability: 1-winning_probability.

Parameters
  • wsr – WSR used to generate the circuits.

  • raw_bits_list – A list of formatted bits from job results.

  • backend – Backend used to generate the bits.

__init__(wsr: List[List[int]], raw_bits_list: List[List[int]], backend: qiskit.providers.basebackend.BaseBackend) → None[source]

GeneratorResult constructor.

Bell values are calculated based on the input parameters. The values include:

  • mermin_correlator: Mermin correlator value. The statistical value calculated from the probability distributions. This verifies quantum correlations when >2, as 2 is the maximal value possible in a classical setup.

  • winning_probability: Probability of “winning” each round in the Mermin quantum game. It is used to verify quantum correlations (the maximum probability in a classical implementation is 87.5%).

  • losing_probability: 1-winning_probability.

Parameters
  • wsr – WSR used to generate the circuits.

  • raw_bits_list – A list of formatted bits from job results.

  • backend – Backend used to generate the bits.

Methods

__init__(wsr, raw_bits_list, backend)

GeneratorResult constructor.

bell_values()

Return a tuple of the bell values.

extract([rate_sv, expected_correlator, …])

Invoke CQC extractor synchronously.

get_cqc_extractor_params([rate_sv, …])

Return parameters for the CQC extractors.

bell_values() → Tuple[float, float, float][source]

Return a tuple of the bell values.

Returns

The losing probability, winning probability, and Mermin correlator.

extract(rate_sv: float = 0.95, expected_correlator: Optional[float] = None, epsilon_sec: float = 1e-30, quantum_proof: bool = False, trusted_backend: bool = True, privacy: bool = False, wsr_generator: Optional[Callable] = None) → List[int][source]

Invoke CQC extractor synchronously.

Note

This method uses the CQC extractor service on IBM Quantum Experience and will raise an RNGNotAuthorizedError if you don’t have access to the service.

Parameters
  • rate_sv – Assumed randomness rate of the initial WSR as a Santha-Vazirani source.

  • expected_correlator – The expected correlator value. qiskit_rng.constants.EXPECTED_CORRELATOR contains known values for certain backends. If None, the observed value from the sampling output is used.

  • epsilon_sec – The distance to uniformity of the final bit string. When performing privacy amplification as well, this is the distance to a perfectly uniform and private string.

  • quantum_proof – Set to True for quantum-proof extraction in the Markov model (most secure), False for classical-proof extraction in the standard model. Note that setting this to True reduces the generation rates considerably.

  • trusted_backendTrue if the raw bits were generated by a trusted backend and communicated securely.

  • privacyTrue if privacy amplification is to be performed.

  • wsr_generator – Function used to generate WSR. It must take the number of bits as the input and a list of random bits (0s and 1s) as the output.

Returns

The extracted random bits.

Raises

RNGNotAuthorizedError – If you are not authorized to use the CQC extractor.

get_cqc_extractor_params(rate_sv: float = 0.95, expected_correlator: Optional[float] = None, epsilon_sec: float = 1e-30, quantum_proof: bool = False, trusted_backend: bool = True, privacy: bool = False, wsr_generator: Optional[Callable] = None) → qiskit_rng.model.CQCExtractorParams[source]

Return parameters for the CQC extractors.

Dodis is the first 2-source extractor that takes the Bell value and the WSR, in order to generate high-quality random bits.

Hayashi is the second extractor. It takes the output of the first extractor and another WSR string to increase the size of the final output string. The second extractor is only used if trusted_backend is True and privacy is False.

Parameters
  • rate_sv – Assumed randomness rate of the initial WSR as a Santha-Vazirani source.

  • expected_correlator – The expected correlator value. qiskit_rng.constants.EXPECTED_CORRELATOR contains known values for certain backends. If None, the observed value from the sampling output is used.

  • epsilon_sec – The distance to uniformity of the final bit string. When performing privacy amplification as well, this is the distance to a perfectly uniform and private string.

  • quantum_proof – Set to True for quantum-proof extraction in the Markov model (most secure), False for classical-proof extraction in the standard model. Note that setting this to True reduces the generation rates considerably.

  • trusted_backendTrue if the raw bits were generated by a trusted backend and communicated securely.

  • privacyTrue if privacy amplification is to be performed.

  • wsr_generator – Function used to generate WSR. It must take the number of bits as the input and a list of random bits (0s and 1s) as the output.

Returns

A CQCExtractorParams instance that contains all the parameters needed for the extractors.

Raises

ValueError – If an input argument is invalid.