Why does the Node crypto library do Diffie Hellman this way? 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?
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.