How do we calculate DHKey using A's public key and B's private key?

I have 2 set of public/private keys. I would like to know how I can calculate DHKey.

e.g:

P-192
Private A:   07915f86918ddc27005df1d6cf0c142b625ed2eff4a518ff
Private B:   1e636ca790b50f68f15d8dbe86244e309211d635de00e16d
Public A(x): 15207009984421a6586f9fc3fe7e4329d2809ea51125f8ed
Public A(y): b09d42b81bc5bd009f79e4b59dbbaa857fca856fb9f7ea25
DHKey:       fb3ba2012c7e62466e486e229290175b4afebc13fdccee46


These data have been extracted from the Bluetooth v4.2 Core Specification.

• Are you looking for a theoretical explanation or implementations? Commented Feb 25, 2016 at 13:12
• I am looking for an implementation. Commented Feb 25, 2016 at 13:20

Generally, the shared secret DHKey is the first coordinate of the $b$th multiple of the point $A$, denoted $[b]A$. Here, $b$ represents B's private key Private B and $A$ is A's public key Public A.

Using the computer algebra package sage, this can be computed as follows. First, we set up the NIST curve P-192 (the constants can be found online):

sage: p = 6277101735386680763835789423207666416083908700390324961279
sage: b = 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1
sage: E = EllipticCurve(Zmod(p), [0, 0, 0, -3, b])


Then, we plug in the given values and compute $Q:=[b]A$:

sage: b = 0x1e636ca790b50f68f15d8dbe86244e309211d635de00e16d
sage: Ax = 0x15207009984421a6586f9fc3fe7e4329d2809ea51125f8ed
sage: Ay = 0xb09d42b81bc5bd009f79e4b59dbbaa857fca856fb9f7ea25
sage: Q = b * E(Ax, Ay)


...yielding the desired value:

sage: hex(Integer(Q[0]))
'fb3ba2012c7e62466e486e229290175b4afebc13fdccee46'


If you want to perform this computation in a different environment (other programming languages, etc.), I am sure you will find plenty of implementations for point multiplication on P-192 using your favourite internet search engine.

• Exactly what I needed. It would have been even better if you provided command line tools, but that's not the point. Thank you. Commented Feb 25, 2016 at 13:40