eccrypto-js
Description
Pure JavaScript Elliptic curve cryptography library
This library is a port from eccrypto using only pure javascript libraries from ethers.js version 5
NOTE: This library is still experimental and hasn't been thoroughly tested yet
Usage
ECDSA
import * as eccryptoJS from 'eccrypto-js';
const keyPair = eccryptoJS.generateKeyPair();
const str = 'message to sign';
const msg = eccryptoJS.sha256(str);
const sig = await eccryptoJS.sign(keyPair.privateKey, msg);
await eccryptoJS.verify(keyPair.publicKey, msg, sig);
ECDH
import * as eccryptoJS from 'eccrypto-js';
const keyPairA = eccryptoJS.generateKeyPair();
const keyPairB = eccryptoJS.generateKeyPair();
const sharedKey1 = await eccryptoJS.derive(
keyPairA.privateKey,
keyPairB.publicKey
);
const sharedKey2 = await eccryptoJS.derive(
keyPairB.privateKey,
keyPairA.publicKey
);
ECIES
import * as eccryptoJS from 'eccrypto-js';
const keyPair = eccryptoJS.generateKeyPair();
const str = 'message to sign';
const msg = Buffer.from(str);
const encrypted = await eccryptoJS.encrypt(keyPairB.publicKey, msg);
const decrypted = await eccryptoJS.decrypt(keyPairB.privateKey, encrypted);
License
MIT License