Asymmetric key echange
This package was designed as a placeholder for a future quantum-resistant key exchange algorithm once that is proven-secure.
npm install
First we'll need to import the package
import {KeyPair} from 'asymmetric-diffie-hellman';
Let's generate a key pair for the sender (alice) and the receiver (bob)
const Alice = new KeyPair();
const Bob = new KeyPair();
const AlicePublic = Alice.pubkey;
const BobPublic = Bob.pubkey;
When transmitting a message from Alice to Bob, Alice will need to include the new key generated in a non-encrypted manner. Using this new key, Bob can generate the same secret as Alice had when encrypting the message.
const AliceTx = Alice.keyExchange(BobPublic);
// Include AliceTx.key in the non-encrypted part of your message
// Use AliceTx.secret to generate the encryption key for your symmetric encryption algorithm
const BobRx = Bob.keyExchange(AliceTx.key);
// Use BobRx.secret to generate the encryption key for your symmetric encryption algorith