Photo by Matt Palme

The Wizardry of Elliptic Curve Cryptography

--

The flexibility of Elliptic Curve Cryptography (ECC) just seems endless. In places, it almost feels like wizardry. So let’s look at the wizardry involved in ElGamal encryption matched to ECC.

First Alice creates her key pair (a and aP), and where a (her private key) is a scalar, and P is a point on the elliptic curve.

a := suite.Scalar().Pick(suite.RandomStream()) 
A := suite.Point().Mul(a, nil)

Her pubic key is the point P, added to itself a times. She passes her public key to Bob (aP). He first takes the message and converts it into a byte array, and matches it to an elliptic curve point:

M := group.Point().Embed(message, random.New())

And then, as if by magic, he uses some randomization and creates a new elliptic curve point (k), and creates two cipher element (K and C):

k := group.Scalar().Pick(random.New()) 
K= group.Point().Mul(k, nil)
S := group.Point().Mul(k, pubkey)
C = S.Add(S, M)

Bob then pass that back to Alice. She uses her private key (a) to decipher the message and pluck it back off the elliptic curve (with the Data() method):

S := group.Point().Mul(prikey, K) 
M := group.Point().Sub(C, S)
message, err = M.Data()

--

--

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.