This repo is an implementation of Elliptic Curve Integrated Encryption Scheme (ECIES), a hybrid encryption method that combines the efficiency of symmetric encryption with the key exchange capabilities of asymmetric elliptic curve cryptography (ECDH). It uses an ephemeral key pair to establish a shared secret for encrypting a message with a symmetric cipher (AES-GCM), and it’s a versatile standard used for encrypting data and establishing secure communication channels.
To generate a public/private key pair for encryption and decryption, run the following script:
npm run generate-key-pairThis will create two files: privateJwk.json and publicJwk.json in the demo/ directory.
Share the public key (publicJwk.json) with anyone who needs to send you encrypted messages, while
keeping the private key (privateJwk.json) secure and confidential. Data encrypted with the public
key can only be decrypted with the corresponding private key.
To see a simple demonstration of encrypting and decrypting a message using the generated key pair, run:
npm run demoThis will generate a sample set of original JSON files, encrypt them using the public key, and then
decrypt them using the private key. The original, encrypted, and decrypted files will be stored in
the demo/data/ directory. Make sure to check that the decrypted files match the original files to
verify the correctness of the encryption and decryption process.