


import numpy as np
import qiskit



def 			lowerCAmelCase (		lowerCAmelCase_ = 8 ,   lowerCAmelCase_ = None )-> List[Any]:
				lowerCAmelCase_ :      Optional[Any]    				=				np.random.default_rng(seed=_lowerCamelCase )

				# Roughly 25% of the qubits will contribute to the key.
				# So we take more than we need.
				lowerCAmelCase_ :      Optional[Any]    				=				6 * key_len
				# Measurement basis for Alice's qubits.
				lowerCAmelCase_ :      List[str]    				=				rng.integers(2 ,   size=_lowerCamelCase )
				# The set of states Alice will prepare.
				lowerCAmelCase_ :      str    				=				rng.integers(2 ,   size=_lowerCamelCase )
				# Measurement basis for Bob's qubits.
				lowerCAmelCase_ :      List[str]    				=				rng.integers(2 ,   size=_lowerCamelCase )

				# Quantum Circuit to simulate BB84
				lowerCAmelCase_ :      Tuple    				=				qiskit.QuantumCircuit(_lowerCamelCase ,   name='''BB84''' )

				# Alice prepares her qubits according to rules above.
				for index, _ in enumerate(_lowerCamelCase ):
								if alice_state[index] == 1:
												bbaa_circ.x(_lowerCamelCase )
								if alice_basis[index] == 1:
												bbaa_circ.h(_lowerCamelCase )
				bbaa_circ.barrier()

				# Bob measures the received qubits according to rules above.
				for index, _ in enumerate(_lowerCamelCase ):
								if bob_basis[index] == 1:
												bbaa_circ.h(_lowerCamelCase )

				bbaa_circ.barrier()
				bbaa_circ.measure_all()

				# Simulate the quantum circuit.
				lowerCAmelCase_ :      Optional[Any]    				=				qiskit.Aer.get_backend('''aer_simulator''' )
				# We only need to run one shot because the key is unique.
				# Multiple shots will produce the same key.
				lowerCAmelCase_ :      Tuple    				=				qiskit.execute(_lowerCamelCase ,   _lowerCamelCase ,   shots=1 ,   seed_simulator=_lowerCamelCase )
				# Returns the result of measurement.
				lowerCAmelCase_ :      Optional[int]    				=				job.result().get_counts(_lowerCamelCase ).most_frequent()

				# Extracting the generated key from the simulation results.
				# Only keep measurement results where Alice and Bob chose the same basis.
				lowerCAmelCase_ :      Any    				=				"".join(
				    [
				        result_bit
				        for alice_basis_bit, bob_basis_bit, result_bit in zip(
				            _lowerCamelCase ,   _lowerCamelCase ,   _lowerCamelCase )
				        if alice_basis_bit == bob_basis_bit
				    ] )

				# Get final key. Pad with 0 if too short, otherwise truncate.
				lowerCAmelCase_ :      Optional[int]    				=				gen_key[:key_len] if len(_lowerCamelCase ) >= key_len else gen_key.ljust(_lowerCamelCase ,   '''0''' )
				return key


if __name__ == "__main__":
						print(f"""The generated key is : {bbaa(8, seed=0)}""")
						from doctest import testmod

						testmod()



import re



def 			lowerCAmelCase (		lowerCAmelCase_ )-> bool:
				lowerCAmelCase_ :      Tuple    				=				re.compile(r'''^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$''' )
				if match := re.search(lowerCAmelCase_ ,   lowerCAmelCase_ ):
								return match.string == phone
				return False


if __name__ == "__main__":
						print(indian_phone_validator("""+918827897895"""))