# Does the bit generated password using QKD protocols need to be converted to another base?

I am currently implementing some QKD protocols using Qiskit and I came up with the following question: After the protocol is finished, a true random password is generated using 0s and 1s, however, and here my question, do these passwords need to be converted to another base? Maybe hexadecimal? Or are they used as they are?

When I mean by used is to using them, for instance, as a key for the one time pad.

• Err, what do you mean by "When I mean by used is to using them, for instance, as a key for the one time pad?" Password $\ne$ cryptographic key. Are you simply thinking of generating OTP material and are using the term 'key' loosely? A lot of people use the term one time pad interchangeably with stream ciphers and pseudo randomness. Jun 17 at 17:32
• Qiskit is software. What's the hardware? Jun 17 at 18:15
• Sorry for the late reply. The hardware is the IBM quantum computers. This is not a real product, I am writing my thesis and I just implement them for educational purposes. Regarding the other question, to my understanding, the QKD serves as a mean to distribute a key securely, or as you said "cryptographic key". Meaning that once you obtain that key, you can use it to encrypt and decrypt information, for instance using the one time pad as cypher method. Your are in fact correct, I should have said key and not password.
– Rafa
Jun 17 at 19:56
• My question is, once you obtain the key, in the industry, do they convert it to other bases, or do they just use it as it is (with only 1s and 0s)
– Rafa
Jun 17 at 19:57

Do the bits generated password using QKD protocols need to be converted to another base before being used as a key for the one time pad?

No, if the OTP encrypts symbols that are bits, as does the most usual OTP.

Yes, in all the other cases. One simple method is rejection sampling: if symbols can take $$n$$ values, we group input QKD bits by blocks of $$b=\left\lceil\,\log_2 n\right\rceil$$, convert a block to integer $$i$$ with $$0\le i<2^b$$ per e.g. big-endian convention, reject the block if $$i\ge n$$ (note: which won't happen when $$n$$ is a power of two), and otherwise use $$i$$. Among several ways, the OTP can proceed by adding $$i$$ modulo $$n$$ for encryption, and subtracting $$i$$ modulo $$n$$ for decryption.

But that's arguably the easiest part in QKD. For the difficult ones, see this.

• "No, if the OTP encrypts symbols that are bits, as does the most usual OTP." or symmetric cipher... Jun 18 at 15:19

As you know, most computers talk in binary " (with only 1s and 0s)". So $$E_K(P) = C$$ in any base as long as encryption function $$E$$ is a bijection. Therefore $$E'_{K}(C) = P$$ reveals the original message. As long as $$E$$ is deterministic and bijective, the numeric base is kinda irrelevant, but computers do love their octets. [This is not the quantum notation down the fibre optic.]

For example, the following is a cardboard base encoding (and probably before XOR/ASCII was invented):-

59 1 62 62 64. Does this help:-

Notice that (whist preferable) a true one time pad is not required. Conventional symmetrical encryption can be used with regularly changed keys that come through the fibre. So that $$|K| \ne |P|$$. This greatly helped with throughput but QKDNs are getting pretty fast nowadays.

Is there any chance that you're conflating polarization bases with numeric bases?

• Comment on the cardboard shown: that "TAPIR" table was used to convert text into decimal digits and back, with approximately uniform distribution. It's an auxiliary to an encryption convention using a base-10 OTP, see this. This OTP is one that would need the base conversion asked in the question.
– fgrieu
Jun 18 at 15:52
• @fgrieu I'm really struggling with TAPIR. How do we encrypt "A" modulo 10 and differentiate between "A" and "0"? Unless we do modulo 100, isn't the cipher leaking information as some letters are encoded to single numerals? That then facilitates frequency analysis (assuming AEINR are Russian vowels). Should this be new question? Jun 18 at 17:38
• Apparently, sequence of digits are introduced by a 82 and ended with 81. Looks suboptimal. But I'm not an authority in this. Perhaps it would make a nice Q.
– fgrieu
Jun 18 at 18:21

At this step, you can use your key to generate a one-time-pad key with a cryptographic pseudo-random-generator. This functionality takes a fixed-length key as input and output as many bits as you need (if you use it recursively):

https://crypto.stanford.edu/pbc/notes/crypto/prng.html

Then you would use this one-time-pad key by xoring it with a plaintext message of same length. Then you can send classically the ciphertext computed.

Another possibility (more general) is also to use symmetric encryption with the secret key computed by the quantum protocol to encrypt the plaintext message :

https://en.wikipedia.org/wiki/Symmetric-key_algorithm

In any case, you have to be sure than the key length is enough big.

• A lot of people use the term one time pad interchangeably with stream ciphers and pseudo randomness. Jun 18 at 13:02