Page 34 - MSDN Magazine, September 2019
P. 34
QUANTUM COMPUTING
Quantum Messaging
with Q# and Blazor
Daniel Vaughan
In this article I explore quantum messaging, leveraging the remarkable phenomenon of quantum entanglement to instantly transfer half a message across potentially vast distances, eliminating the risk of eavesdropping. I’ll look at implementing a quantum algorithm for superdense coding in Q#, Microsoft’s new quantum programming language; how to entangle qubits using quantum gates; and how to encode ASCII messages as qubits. Then I’ll build a Web-based Blazor-powered UI that leverages the quantum algo- rithm and simulates sending quantum particles to different parties. I’ll show you how to consume a Q# library in a Blazor server application and how to launch and coordinate multiple browser windows. You’ll also learn how to employ Model-View-ViewModel (MVVM) in a Blazor application.
There’s quite a bit of quantum theory used in this article. If you’re new to quantum computing, I advise reading my “Quantum Com- putation Primer.” You’ll find the first part at tinyurl.com/quantumprimer1.
Let’s begin by taking a look at superdense coding.
Understanding Superdense Coding
Superdense coding leverages the phenomenon of quantum entangle- ment, where one particle from an entangled pair can affect the shared state of both, despite being separated across potentially vast distances.
To understand the superdense coding protocol, let’s say you have three actors: Alice, Bob and Charlie (A, B and C). Charlie creates an entangled pair of qubits and sends one to Alice and one to Bob. When Alice wants to send a 2-bit message to Bob, all she has to do is manipulate her own qubit—which influences the quantum state of the pair—and then send her single qubit to Bob. Bob then mea- sures both Alice’s qubit and his own to receive the 2-bit message.
The important point is that there’s no way to encode more than one bit of information into a single qubit—yet only one qubit changes hands to deliver a 2-bit message. Despite any distance between the qubits, the shared state of the entangled qubits allows the entire 2-bit message to be encoded using just one of the qubits.
Moreover, when Alice sends Bob a message, a long time may have passed since Charlie sent them each an entangled qubit. You can think of entangled qubits in this way as a resource, waiting to be consumed as part of the communication process.
The pre-sharing of qubits also brings an important security benefit: Anyone who wants to decode the message needs to be in possession of both Alice’s and Bob’s qubits. Intercepting just Alice’s qubit isn’t enough to decode the message, and as the entan- gled qubits are pre-shared, the risk of eavesdropping is eliminated.
If you’re skeptical about the physics underpinning superdense coding—and that’s a not a bad thing—the phenomenon has been experimentally validated (tinyurl.com/75entanglement), even with sat- ellites and lasers (tinyurl.com/spookyrecord).
This article discusses:
• Implementing the superdense coding protocol with Q# • Implementing MVVM in Blazor with Codon
• Calling Q# APIs with C#
• Launching multiple browser windows in Blazor
Technologies discussed:
Q#, Blazor, JavaScript, C#, Visual Studio 2019 16.2 Preview 1.0
Code download available at:
msdn.com/magazine/0919magcode
26 msdn magazine