def send_classical_bits(self, string): if not isinstance(string, str): raise qobjecterror("argument must be string") try: self.socket.send(string) except socket.error: raise qsocketerror("not connected to any channel")
def send_photon_pulse(self, pulse): if not isinstance(pulse, list): raise qobjecterror("argument must be list") try: self.socket.send("qpulse:{0}".format(len(pulse))) self.socket.send("~" * len(pulse)) except socket.error: raise qsocketerror("not connected to any channel")
def create_shared_key(self, basis, other_basis): if len(basis) != len(other_basis): raise qobjecterror("both pulses must contain the same amount of photons") else: i = 0 while i != len(basis): if basis[i] == other_basis[i]: if basis[i] == 0: self.shared_key.append(0) elif basis[i] == 90: self.shared_key.append(1) elif basis[i] == 45: self.shared_key.append(0) elif basis[i] == 135: self.shared_key.append(1) i += 1
def verify(self): if len(self.shared_key) == 0 or len(self.sub_shared_key) == 0: raise qobjecterror("key is not defined") else: pass