Skip to content

Commit

Permalink
badge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Aug 8, 2023
1 parent 21ef739 commit f49e24f
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# eccrypto [![Build Status](https://github.com/torusresearch/eccrypto/workflows/master/badge.svg)](https://github.com/torusresearch/eccrypto/actions)
# eccrypto

[![NPM](https://nodei.co/npm/eccrypto.png)](https://www.npmjs.com/package/eccrypto)
![Build Status](https://github.com/torusresearch/eccrypto/actions/workflows/master.yml/badge.svg)

[![npm downloads](https://img.shields.io/npm/dm/@toruslabs/eccrypto.svg?style=flat-square)](https://www.npmjs.com/package/@toruslabs/eccrypto)

[![NPM](https://nodei.co/npm/@toruslabs/eccrypto.png)](https://www.npmjs.com/package/@toruslabs/eccrypto)

JavaScript Elliptic curve cryptography library for both browserify and node.

Expand All @@ -12,11 +16,11 @@ There is currently no any isomorphic ECC library which provides ECDSA, ECDH and

With the help of browserify `eccrypto` provides different implementations for Browser and Node.js with the same API. Because WebCryptoAPI defines asynchronous promise-driven API, implementation for Node needs to use promises too.

* Use Node.js crypto module/library bindings where possible
* Use WebCryptoAPI where possible
* Promise-driven API
* Only secp256k1 curve, only SHA-512 (KDF), HMAC-SHA-256 (HMAC) and AES-256-CBC for ECIES
* Compressed key support
- Use Node.js crypto module/library bindings where possible
- Use WebCryptoAPI where possible
- Promise-driven API
- Only secp256k1 curve, only SHA-512 (KDF), HMAC-SHA-256 (HMAC) and AES-256-CBC for ECIES
- Compressed key support

### Native crypto API limitations

Expand All @@ -32,7 +36,7 @@ So we use [seck256k1](https://www.npmjs.com/package/secp256k1) library in Node f

## Possible future goals

* Support other curves/KDF/MAC/symmetric encryption schemes
- Support other curves/KDF/MAC/symmetric encryption schemes

## Usage

Expand All @@ -51,13 +55,16 @@ var str = "message to sign";
// Always hash you message to sign!
var msg = crypto.createHash("sha256").update(str).digest();

eccrypto.sign(privateKey, msg).then(function(sig) {
eccrypto.sign(privateKey, msg).then(function (sig) {
console.log("Signature in DER format:", sig);
eccrypto.verify(publicKey, msg, sig).then(function() {
console.log("Signature is OK");
}).catch(function() {
console.log("Signature is BAD");
});
eccrypto
.verify(publicKey, msg, sig)
.then(function () {
console.log("Signature is OK");
})
.catch(function () {
console.log("Signature is BAD");
});
});
```

Expand All @@ -71,8 +78,8 @@ var publicKeyA = eccrypto.getPublic(privateKeyA);
var privateKeyB = eccrypto.generatePrivate();
var publicKeyB = eccrypto.getPublic(privateKeyB);

eccrypto.derive(privateKeyA, publicKeyB).then(function(sharedKey1) {
eccrypto.derive(privateKeyB, publicKeyA).then(function(sharedKey2) {
eccrypto.derive(privateKeyA, publicKeyB).then(function (sharedKey1) {
eccrypto.derive(privateKeyB, publicKeyA).then(function (sharedKey2) {
console.log("Both shared keys are equal:", sharedKey1, sharedKey2);
});
});
Expand All @@ -89,17 +96,17 @@ var privateKeyB = eccrypto.generatePrivate();
var publicKeyB = eccrypto.getPublic(privateKeyB);

// Encrypting the message for B.
eccrypto.encrypt(publicKeyB, Buffer.from("msg to b")).then(function(encrypted) {
eccrypto.encrypt(publicKeyB, Buffer.from("msg to b")).then(function (encrypted) {
// B decrypting the message.
eccrypto.decrypt(privateKeyB, encrypted).then(function(plaintext) {
eccrypto.decrypt(privateKeyB, encrypted).then(function (plaintext) {
console.log("Message to part B:", plaintext.toString());
});
});

// Encrypting the message for A.
eccrypto.encrypt(publicKeyA, Buffer.from("msg to a")).then(function(encrypted) {
eccrypto.encrypt(publicKeyA, Buffer.from("msg to a")).then(function (encrypted) {
// A decrypting the message.
eccrypto.decrypt(privateKeyA, encrypted).then(function(plaintext) {
eccrypto.decrypt(privateKeyA, encrypted).then(function (plaintext) {
console.log("Message to part A:", plaintext.toString());
});
});
Expand Down

0 comments on commit f49e24f

Please sign in to comment.