Gathering detailed insights and metrics for elliptic
Gathering detailed insights and metrics for elliptic
Gathering detailed insights and metrics for elliptic
Gathering detailed insights and metrics for elliptic
npm install elliptic
99.1
Supply Chain
100
Quality
85.2
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,705 Stars
342 Commits
397 Forks
52 Watching
9 Branches
27 Contributors
Updated on 28 Nov 2024
JavaScript (99.29%)
HTML (0.71%)
Cumulative downloads
Total Downloads
Last day
-9.2%
2,224,817
Compared to previous day
Last week
2.5%
13,361,820
Compared to previous week
Last month
19.4%
53,701,497
Compared to previous month
Last year
-8.8%
535,664,138
Compared to previous year
Fast elliptic-curve cryptography in a plain javascript implementation.
NOTE: Please take a look at http://safecurves.cr.yp.to/ before choosing a curve for your cryptography operations.
ECC is much slower than regular RSA cryptography, the JS implementations are even more slower.
1$ node benchmarks/index.js 2Benchmarking: sign 3elliptic#sign x 262 ops/sec ±0.51% (177 runs sampled) 4eccjs#sign x 55.91 ops/sec ±0.90% (144 runs sampled) 5------------------------ 6Fastest is elliptic#sign 7======================== 8Benchmarking: verify 9elliptic#verify x 113 ops/sec ±0.50% (166 runs sampled) 10eccjs#verify x 48.56 ops/sec ±0.36% (125 runs sampled) 11------------------------ 12Fastest is elliptic#verify 13======================== 14Benchmarking: gen 15elliptic#gen x 294 ops/sec ±0.43% (176 runs sampled) 16eccjs#gen x 62.25 ops/sec ±0.63% (129 runs sampled) 17------------------------ 18Fastest is elliptic#gen 19======================== 20Benchmarking: ecdh 21elliptic#ecdh x 136 ops/sec ±0.85% (156 runs sampled) 22------------------------ 23Fastest is elliptic#ecdh 24========================
1var EC = require('elliptic').ec; 2 3// Create and initialize EC context 4// (better do it once and reuse it) 5var ec = new EC('secp256k1'); 6 7// Generate keys 8var key = ec.genKeyPair(); 9 10// Sign the message's hash (input must be an array, or a hex-string) 11var msgHash = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; 12var signature = key.sign(msgHash); 13 14// Export DER encoded signature in Array 15var derSign = signature.toDER(); 16 17// Verify signature 18console.log(key.verify(msgHash, derSign)); 19 20// CHECK WITH NO PRIVATE KEY 21 22var pubPoint = key.getPublic(); 23var x = pubPoint.getX(); 24var y = pubPoint.getY(); 25 26// Public Key MUST be either: 27// 1) '04' + hex string of x + hex string of y; or 28// 2) object with two hex string properties (x and y); or 29// 3) object with two buffer properties (x and y) 30var pub = pubPoint.encode('hex'); // case 1 31var pub = { x: x.toString('hex'), y: y.toString('hex') }; // case 2 32var pub = { x: x.toBuffer(), y: y.toBuffer() }; // case 3 33var pub = { x: x.toArrayLike(Buffer), y: y.toArrayLike(Buffer) }; // case 3 34 35// Import public key 36var key = ec.keyFromPublic(pub, 'hex'); 37 38// Signature MUST be either: 39// 1) DER-encoded signature as hex-string; or 40// 2) DER-encoded signature as buffer; or 41// 3) object with two hex-string properties (r and s); or 42// 4) object with two buffer properties (r and s) 43 44var signature = '3046022100...'; // case 1 45var signature = new Buffer('...'); // case 2 46var signature = { r: 'b1fc...', s: '9c42...' }; // case 3 47 48// Verify signature 49console.log(key.verify(msgHash, signature));
1var EdDSA = require('elliptic').eddsa; 2 3// Create and initialize EdDSA context 4// (better do it once and reuse it) 5var ec = new EdDSA('ed25519'); 6 7// Create key pair from secret 8var key = ec.keyFromSecret('693e3c...'); // hex string, array or Buffer 9 10// Sign the message's hash (input must be an array, or a hex-string) 11var msgHash = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; 12var signature = key.sign(msgHash).toHex(); 13 14// Verify signature 15console.log(key.verify(msgHash, signature)); 16 17// CHECK WITH NO PRIVATE KEY 18 19// Import public key 20var pub = '0a1af638...'; 21var key = ec.keyFromPublic(pub, 'hex'); 22 23// Verify signature 24var signature = '70bed1...'; 25console.log(key.verify(msgHash, signature));
1var EC = require('elliptic').ec; 2var ec = new EC('curve25519'); 3 4// Generate keys 5var key1 = ec.genKeyPair(); 6var key2 = ec.genKeyPair(); 7 8var shared1 = key1.derive(key2.getPublic()); 9var shared2 = key2.derive(key1.getPublic()); 10 11console.log('Both shared secrets are BN instances'); 12console.log(shared1.toString(16)); 13console.log(shared2.toString(16));
three and more members:
1var EC = require('elliptic').ec; 2var ec = new EC('curve25519'); 3 4var A = ec.genKeyPair(); 5var B = ec.genKeyPair(); 6var C = ec.genKeyPair(); 7 8var AB = A.getPublic().mul(B.getPrivate()) 9var BC = B.getPublic().mul(C.getPrivate()) 10var CA = C.getPublic().mul(A.getPrivate()) 11 12var ABC = AB.mul(C.getPrivate()) 13var BCA = BC.mul(A.getPrivate()) 14var CAB = CA.mul(B.getPrivate()) 15 16console.log(ABC.getX().toString(16)) 17console.log(BCA.getX().toString(16)) 18console.log(CAB.getX().toString(16))
NOTE: .derive()
returns a BN instance.
Elliptic.js support following curve types:
Following curve 'presets' are embedded into the library:
secp256k1
p192
p224
p256
p384
p521
curve25519
ed25519
NOTE: That curve25519
could not be used for ECDSA, use ed25519
instead.
ECDSA is using deterministic k
value generation as per RFC6979. Most of
the curve operations are performed on non-affine coordinates (either projective
or extended), various windowing techniques are used for different cases.
All operations are performed in reduction context using bn.js, hashing is provided by hash.js
elliptic
for browser and secp256k1-node for
node)This software is licensed under the MIT License.
Copyright Fedor Indutny, 2014.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The latest stable version of the package.
Stable Version
1
7.7/10
Summary
Signature Malleabillity in elliptic
Affected Versions
< 6.5.3
Patched Versions
6.5.3
1
6.8/10
Summary
Elliptic Uses a Broken or Risky Cryptographic Algorithm
Affected Versions
< 6.5.4
Patched Versions
6.5.4
5
4.8/10
Summary
Valid ECDSA signatures erroneously rejected in Elliptic
Affected Versions
< 6.6.0
Patched Versions
6.6.0
5.3/10
Summary
Elliptic's verify function omits uniqueness validation
Affected Versions
< 6.5.6
Patched Versions
6.5.6
5.3/10
Summary
Elliptic's EDDSA missing signature length check
Affected Versions
>= 4.0.0, <= 6.5.6
Patched Versions
6.5.7
5.3/10
Summary
Elliptic's ECDSA missing check for whether leading bit of r and s is zero
Affected Versions
>= 2.0.0, <= 6.5.6
Patched Versions
6.5.7
5.3/10
Summary
Elliptic allows BER-encoded signatures
Affected Versions
>= 5.2.1, <= 6.5.6
Patched Versions
6.5.7
Reason
no binaries found in the repo
Reason
4 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 3
Reason
Found 4/29 approved changesets -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
44 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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