Photo by Sixteen Miles Out on Unsplash

Rust and 3-way Diffie-Hellman

--

C is responsible for some many problems in Cybersecurity. So what’s the alterative? Well, we can use Python and Node.js, but they are generally slower than C and reveal their source code. We can then turn to Golang, but it is still a language in transistion, and the libraries are still not as extensive as Python and Node.js. But, for seriously secure code, the focus should be on Rust, and which makes sure that the code and the build process is done correctly. So let’s do a bit of 3-way Diffie-Hellman key exchange between Bob, Alice and Carol, using Rust.

Bob, Alice and Carol

Elliptic curves are used fairly extensively in public key encryption (such as in Bitcoin and Tor). A BN-curve (Barreto-Naehrig curve) defines an elliptic curve which can be used for pairings that allow for a high security and efficiency level. This page implements the tripartite Diffie-Hellman algorithm and where Bob, Alice and Carol can share a secret key. In this case we will not be using crypto pairing, but have two rounds of exchange. In this case we have a curve (G1) and a generator point (G), and Bob, Alice and Carol determine their private key value (a, b and c). Next they exchange their public key values of aG, bG and cG, and go through two rounds of exchange, to eventually end up with abcG.

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.