Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eccrypto-js

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eccrypto-js

Pure JavaScript Elliptic curve cryptography library

  • 0.2.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
decreased by-36.57%
Maintainers
1
Weekly downloads
 
Created
Source

eccrypto-js npm version

Pure JavaScript Elliptic curve cryptography library

Description

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 hash = await eccryptoJS.sha256(str);
const msg = eccryptoJS.hexToBuffer(hash);

const sig = await eccryptoJS.sign(keyPair.privateKey, msg);

await eccryptoJS.verify(keyPair.publicKey, msg, sig);

// verify will throw if signature is BAD

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
);

// sharedKey1.toString('hex') === sharedKey2.toString('hex')

ECIES

import * as eccryptoJS from 'eccrypto-js';

const keyPair = eccryptoJS.generateKeyPair();

const str = 'message to sign';
const msg = eccryptoJS.utf8ToBuffer(str);

const encrypted = await eccryptoJS.encrypt(keyPairB.publicKey, msg);

const decrypted = await eccryptoJS.decrypt(keyPairB.privateKey, encrypted);

// decrypted.toString() === str

License

MIT License

Keywords

FAQs

Package last updated on 04 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc