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: Encrypting a message with multiple people using publicKeys #282

Open
0xlue opened this issue May 6, 2022 · 0 comments
Open

ECDH: Encrypting a message with multiple people using publicKeys #282

0xlue opened this issue May 6, 2022 · 0 comments

Comments

@0xlue
Copy link

0xlue commented May 6, 2022

In this example, this only works if each user has the others private key? Lets say person A is initiating the group chat with B and C. User A would only have access to the public keys of the other users and not the private keys, so I'm not sure how the shared keys can be created securely like this.

My goal here is for the initiator of a group chat to send an encrypted message to the other parties, where those people can decrypt the message.

Sidenote: Would user A have to send the shared key to the rest of the party or can the others compute the shared key locally?

var EC = require('elliptic').ec;
var ec = new EC('curve25519');

var A = ec.genKeyPair();
var B = ec.genKeyPair();
var C = ec.genKeyPair();

var AB = A.getPublic().mul(B.getPrivate())
var BC = B.getPublic().mul(C.getPrivate())
var CA = C.getPublic().mul(A.getPrivate())

var ABC = AB.mul(C.getPrivate())
var BCA = BC.mul(A.getPrivate())
var CAB = CA.mul(B.getPrivate())

console.log(ABC.getX().toString(16))
console.log(BCA.getX().toString(16))
console.log(CAB.getX().toString(16))
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

1 participant