0
$\begingroup$

I was sifting through the Node Crytpo library and I came across their Diffie Hellman utility class. Their class implements a generateKeys function that, in their words,

Generates private and public Diffie-Hellman key values, and returns the public key in the specified encoding

My understanding of Diffie Hellman is that both parties only ever need to generate a single random number, not a public/private key. I suppose that you could call this random number a public key and that's what this function returns, but where does a private key come into this process?

I know that in Station to Station protocol a public/private key pair is used for signing. Is that what is happening here? Could this class be used for Station to Station protocol as is?

$\endgroup$
1
  • $\begingroup$ DH uses two keypairs, one for each party, each consisting of a private key and a public key, to derive a share secret. Generating a keypair consists of choosing the private key randomly (and secretly) and computing the public key, so yes each party only chooses one random (per instance) but they do more than just choose that one random. For STS each party needs a DH keypair and a signing keypair; that class could provide the former (only) and do part but not all of the protocol. $\endgroup$ Commented Nov 23, 2018 at 5:56

1 Answer 1

1
$\begingroup$

My understanding of Diffie Hellman is that both parties only ever need to generate a single random number, not a public/private key.

That is not correct.

Wikipedia’s entry covers it pretty well. Once two parties have agreed upon a domain (the (g, p) pair) each member generates their own private key. Their shared secret is equal to

(g ^ (a * b)) % p

where a is Alice’s private key and b is Bob’s. Of course, each side can do this calculation without the other party revealing their private key.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.