Gathering detailed insights and metrics for @toruslabs/eccrypto
Gathering detailed insights and metrics for @toruslabs/eccrypto
Gathering detailed insights and metrics for @toruslabs/eccrypto
Gathering detailed insights and metrics for @toruslabs/eccrypto
npm install @toruslabs/eccrypto
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
9 Stars
193 Commits
6 Forks
3 Watching
16 Branches
17 Contributors
Updated on 25 Nov 2024
Minified
Minified + Gzipped
TypeScript (97.32%)
JavaScript (1.55%)
HTML (1.13%)
Cumulative downloads
Total Downloads
Last day
0.3%
13,317
Compared to previous day
Last week
11.9%
68,371
Compared to previous week
Last month
4.2%
270,822
Compared to previous month
Last year
18.3%
3,329,624
Compared to previous year
1
26
JavaScript Elliptic curve cryptography library for both browserify and node.
There is currently no any isomorphic ECC library which provides ECDSA, ECDH and ECIES for both Node.js and Browser and uses the fastest implementation available (e.g. secp256k1-node is much faster than other libraries but can be used only on Node.js). So eccrypto
is an attempt to create one.
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.
ECDH only works in Node 0.11+ (see https://github.com/joyent/node/pull/5854), ECDSA only supports keys in PEM format (see https://github.com/joyent/node/issues/6904) and ECIES is not supported at all.
ECDSA and ECDH are supported in Chrome only on Windows (see also bug 338883), aren't supported by Firefox (fixed only in 36.0+, see bug 1034854; see also feature matrix) and ECIES is not defined at all in WebCryptoAPI draft. Also WebCryptoAPI currently defines only curves recommended by NIST meaning that secp256k1 (K-256) curve is not supported (see also: [1], [2]).
So we use seck256k1 library in Node for ECDSA, elliptic in Browser for ECDSA and ECDH and implement ECIES manually with the help of native crypto API.
1var crypto = require("crypto"); 2var eccrypto = require("eccrypto"); 3 4// A new random 32-byte private key. 5var privateKey = eccrypto.generatePrivate(); 6// Corresponding uncompressed (65-byte) public key. 7var publicKey = eccrypto.getPublic(privateKey); 8 9var str = "message to sign"; 10// Always hash you message to sign! 11var msg = crypto.createHash("sha256").update(str).digest(); 12 13eccrypto.sign(privateKey, msg).then(function (sig) { 14 console.log("Signature in DER format:", sig); 15 eccrypto 16 .verify(publicKey, msg, sig) 17 .then(function () { 18 console.log("Signature is OK"); 19 }) 20 .catch(function () { 21 console.log("Signature is BAD"); 22 }); 23});
1var eccrypto = require("eccrypto"); 2 3var privateKeyA = eccrypto.generatePrivate(); 4var publicKeyA = eccrypto.getPublic(privateKeyA); 5var privateKeyB = eccrypto.generatePrivate(); 6var publicKeyB = eccrypto.getPublic(privateKeyB); 7 8eccrypto.derive(privateKeyA, publicKeyB).then(function (sharedKey1) { 9 eccrypto.derive(privateKeyB, publicKeyA).then(function (sharedKey2) { 10 console.log("Both shared keys are equal:", sharedKey1, sharedKey2); 11 }); 12});
1var eccrypto = require("eccrypto"); 2 3var privateKeyA = eccrypto.generatePrivate(); 4var publicKeyA = eccrypto.getPublic(privateKeyA); 5var privateKeyB = eccrypto.generatePrivate(); 6var publicKeyB = eccrypto.getPublic(privateKeyB); 7 8// Encrypting the message for B. 9eccrypto.encrypt(publicKeyB, Buffer.from("msg to b")).then(function (encrypted) { 10 // B decrypting the message. 11 eccrypto.decrypt(privateKeyB, encrypted).then(function (plaintext) { 12 console.log("Message to part B:", plaintext.toString()); 13 }); 14}); 15 16// Encrypting the message for A. 17eccrypto.encrypt(publicKeyA, Buffer.from("msg to a")).then(function (encrypted) { 18 // A decrypting the message. 19 eccrypto.decrypt(privateKeyA, encrypted).then(function (plaintext) { 20 console.log("Message to part A:", plaintext.toString()); 21 }); 22});
eccrypto - JavaScript Elliptic curve cryptography library
Written in 2014-2015 by Kagami Hiiragi kagami@genshiken.org
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see http://creativecommons.org/publicdomain/zero/1.0/.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
8 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 6
Reason
Found 5/14 approved changesets -- score normalized to 3
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More