A symbolic implementation of the quantum one-time pad
by José Manuel Rodríguez Caballero (University of Tartu)
by José Manuel Rodríguez Caballero (University of Tartu)
Abstract. We implement in the Wolfram Language the quantum one-time pad protocol [1, 2] using a symbolic representation of separable qubits prepared in the Z and X basis.
Update. December 1, 2020
Twitter: JosManu92295689
Symbolic quantum information
Symbolic quantum information
Symbolic quantum information theory is the study of discrete representations of quantum information, i.e., representations avoiding uncountable sets such that the real and complex numbers.
Basis for quantum measurement
Basis for quantum measurement
A basis for quantum measurement is a nonempty string consisting of characters from the alphabet {"X", "Z"}. Basis are defined by induction.
In[]:=
BX:=Basis["X"]BZ:=Basis["Z"]BB[Verbatim[Basis][a_],Verbatim[Basis][b_]]:=Basis[a<>b]
StrBasis[s] is the basis associated to the string s.
In[]:=
StrBasis[""]:=Failure;StrBasis["X"]:=BX;StrBasis["Z"]:=BZ;StrBasis[s_String]:=If[StringLength[s]==1,Failure,Function[{p,q},(*s=p::q*)If[p===Failure||q===Failure,Failure,BB[p,q]]][StrBasis[StringTake[s,1]],StrBasis[StringTake[s,{2,-1}]]]]
Separable qubits
Separable qubits
A symbolic separable qubit (SQ) is a bit r encoded in a basis s as SQ[r, s], where r is either 0 or 1, and s is either X or Z. Symbolic separable qubits are defined by induction.
In[]:=
A0X:=SQ["0","X"]A0Z:=SQ["0","Z"]A1X:=SQ["1","X"]A1Z:=SQ["1","Z"]AA[Verbatim[SQ][a_,x_],Verbatim[SQ][b_,y_]]:=SQ[a<>b,x<>y]
StrSQ[r, s] is the separable qubit associated to the sequence of bits r and the sequence of basis s.
In[]:=
StrSQ["",_]:=Failure;StrSQ[_,""]:=Failure;StrSQ["0","X"]:=A0X;StrSQ["0","Z"]:=A0Z;StrSQ["1","X"]:=A1X;StrSQ["1","Z"]:=A1Z;StrSQ[r_String,s_String]:=If[StringLength[r]≤1||StringLength[s]≤1,Failure,Function[{a,l,b,m},(*r=a::l,s=b::m*)If[l==""&&m=="",StrSQ[a,b],Function[{p,q},If[p===Failure||q===Failure,Failure,AA[p,q]]][StrSQ[a,b],StrSQ[l,m]]]][(*a=*)StringTake[r,1],(*l=*)StringTake[r,{2,-1}],(*b=*)StringTake[s,1],(*m=*)StringTake[s,{2,-1}]]]
Measurement
Measurement
The measurement of the separable qubit SQ[r,s] in the basis Basis[b] is defined by induction. In the present idealized case, we omit the errors of measurement. Indeed, the error in measurement can be corrected using error correcting codes.
In[]:=
Measure[Verbatim[SQ]["0","X"],Verbatim[Basis]["X"]]:="0";Measure[Verbatim[SQ]["1","X"],Verbatim[Basis]["X"]]:="1";Measure[Verbatim[SQ]["0","X"],Verbatim[Basis]["Z"]]:=RandomChoice[{"0","1"}];Measure[Verbatim[SQ]["1","X"],Verbatim[Basis]["Z"]]:=RandomChoice[{"0","1"}];Measure[Verbatim[SQ]["0","Z"],Verbatim[Basis]["X"]]:=RandomChoice[{"0","1"}];Measure[Verbatim[SQ]["1","Z"],Verbatim[Basis]["X"]]:=RandomChoice[{"0","1"}];Measure[Verbatim[SQ]["0","Z"],Verbatim[Basis]["Z"]]:="0";Measure[Verbatim[SQ]["1","Z"],Verbatim[Basis]["Z"]]:="1";Measure[Verbatim[SQ][r_String,s_String],Verbatim[Basis][b_String]]:=Measure[SQ[StringTake[r,1],StringTake[s,1]],Basis[StringTake[b,1]]]<>Measure[SQ[StringTake[r,{2,-1}],StringTake[s,{2,-1}]],Basis[StringTake[b,{2,-1}]]]
Encoding and decoding
Encoding and decoding
Given a string s, EncodeMessage[s] is the encoding of s as a sequence of bits (string).
EncodeMessage[s_String]:=StringJoin[IntegerString[#,2,8]&/@ToCharacterCode[s,"UTF8"]]
The function DecodeMessage satisfies DecodeMessage[ EncodeMessage[s] ] = s.
DecodeMessage[L_List]:=StringJoin[FromCharacterCode/@(FromDigits[#,2]&/@Table[StringTake[L,{8*k-7,8*k}],{k,1,StringLength[L]/8}])]
Example
Example
In[]:=
EncodeMessage["see you at 10pm near the bridge"]
Out[]=
01110011011001010110010100100000011110010110111101110101001000000110000101110100001000000011000100110000011100000110110100100000011011100110010101100001011100100010000001110100011010000110010100100000011000100111001001101001011001000110011101100101
In[]:=
DecodeMessage[EncodeMessage["see you at 10pm near the bridge"]]
Out[]=
see you at 10pm near the bridge
Cryptographic protocol
Cryptographic protocol
The message was not intercepted
The message was not intercepted
The message that Alice wants to send to Bob.
In[]:=
m=EncodeMessage["see you at 10pm near the bridge"]
Out[]=
01110011011001010110010100100000011110010110111101110101001000000110000101110100001000000011000100110000011100000110110100100000011011100110010101100001011100100010000001110100011010000110010100100000011000100111001001101001011001000110011101100101
Alice and Bob share a basis (common key) k.
In[]:=
k=StringJoin[Table[RandomChoice[{"X","Z"}],{StringLength[m]}]]
Out[]=
XZXZZXZZZZXXXXZZXXXZXZZZZXXZZXZXXXXXZZZXZXXXZXXXZXZZXZZZXZXZZXZZXZZXZXZXXZXZZXXXXZZXZZXZXXXXXZXXXZZZXXXXZZZXZXZXXXXXXXXZZZXZZZXXZXXZZZZZXZZXXZXZXXZXZXXZXXXXXZXZXZXZXZZZZZXXZZXXZZZXXXXXXZZZZXXZZXZXZXXZZXXZZZXXZZXZZXZZZXZXXXXZZXXXXZXXZXZZZXXZZZZZZZXX
Alice encodes her message m in the basis associated to the key k. She uses separable quantum states.
In[]:=
q=StrSQ[m,k]
Out[]=
SQ[01110011011001010110010100100000011110010110111101110101001000000110000101110100001000000011000100110000011100000110110100100000011011100110010101100001011100100010000001110100011010000110010100100000011000100111001001101001011001000110011101100101,XZXZZXZZZZXXXXZZXXXZXZZZZXXZZXZXXXXXZZZXZXXXZXXXZXZZXZZZXZXZZXZZXZZXZXZXXZXZZXXXXZZXZZXZXXXXXZXXXZZZXXXXZZZXZXZXXXXXXXXZZZXZZZXXZXXZZZZZXZZXXZXZXXZXZXXZXXXXXZXZXZXZXZZZZZXXZZXXZZZXXXXXXZZZZXXZZXZXZXXZZXXZZZXXZZXZZXZZZXZXXXXZZXXXXZXXZXZZZXXZZZZZZZXX]
Alice sends the separable quantum state q to Bob.
Bob measures q in the basis determined by the key k.
In[]:=
Measure[q,StrBasis[k]]//DecodeMessage
Out[]=
see you at 10pm near the bridge
The message was intercepted
The message was intercepted
Suppose that Eve intercepts the separable qubits q. Because she has not access to the key k, she cannot know the message. Indeed, using a random key, Eve obtains the following pseudorandom string.
In[]:=
Measure[q,StrBasis[StringJoin[Table[RandomChoice[{"X","Z"}],{StringLength[m]}]]]]//DecodeMessage
Out[]=
a=g(pL(,A5j³Àù\8/uaò|pt¢1`CeEå
References
References
[1] Course of Quantum Cryptography (TU Delft, OpenCourseWare), lectures:
https://ocw.tudelft.nl/course-lectures/1-3-1-encrypting-qubits-quantum-one-time-pad/
https://ocw.tudelft.nl/course-lectures/1-3-2-example-quantum-one-time-pad/
https://ocw.tudelft.nl/course-lectures/1-3-1-encrypting-qubits-quantum-one-time-pad/
https://ocw.tudelft.nl/course-lectures/1-3-2-example-quantum-one-time-pad/
[2] Deng, Fu-Guo, and Gui Lu Long. "Secure direct communication with a quantum one-time pad." Physical Review A 69.5 (2004): 052319.
[3] J. Gorard, “Some Quantum Mechanical Properties of the Wolfram Model,” Complex Systems, 29(2), 2020 pp. 537–598.
https://doi.org/10.25088/ComplexSystems.29.2.537
https://doi.org/10.25088/ComplexSystems.29.2.537
[4] Gorard, Jonathan, Manojna Namuduri, and Xerxes D. Arsiwalla. "ZX-Calculus and Extended Hypergraph Rewriting Systems I: A Multiway Approach to Categorical Quantum Information Theory." arXiv preprint arXiv:2010.02752 (2020).
[5] S. Wolfram, “A Class of Models with the Potential to Represent Fundamental Physics,” Complex Systems, 29(2), 2020 pp. 107–536.
https://doi.org/10.25088/ComplexSystems.29.2.107
https://doi.org/10.25088/ComplexSystems.29.2.107