Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECDH usage #96

Closed
Rush opened this issue Sep 2, 2013 · 2 comments
Closed

ECDH usage #96

Rush opened this issue Sep 2, 2013 · 2 comments

Comments

@Rush
Copy link

Rush commented Sep 2, 2013

I am a bit baffled how to use your ECDH functionality, I would expect the following to log the same results. Follow the comments

  var keys1 = sjcl.ecc.elGamal.generateKeys(256); // peer1 generates keys 
  var keys2 = sjcl.ecc.elGamal.generateKeys(256); // peer2 generates keys
  var kem1 = keys2.pub.kem(0); // peer1 generates kem from peer2's public
  var kem2 = keys1.pub.kem(0); // peer2 generates kem from peer1's public
  console.log(keys1.sec.unkem(kem2.tag)); // peer1 calculates shared key
  console.log(keys2.sec.unkem(kem1.tag)); // peer2 calculates shared key

Unfortunately the above does not arrive at the same result. What am I missing? Thanks for the help.

@Nilos
Copy link
Collaborator

Nilos commented Sep 2, 2013

First: Do not add a 0 as the second parameter to kem. This is the paranoia. Zero means that you do not care at all whether the random generator is properly seeded or not.
Second: If you want Diffie-hellmann use the dh function of a secret key.
Code:

 var keys1 = sjcl.ecc.elGamal.generateKeys(256); // peer1 generates keys 
 var keys2 = sjcl.ecc.elGamal.generateKeys(256); // peer2 generates keys
console.log(keys1.sec.dh(keys2.pub))
console.log(keys2.sec.dh(keys1.pub))

@Nilos Nilos closed this as completed Sep 10, 2013
@Rush
Copy link
Author

Rush commented Sep 10, 2013

Forgot to thank you for the answer. ;) Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants