Installations
npm install eosjs-ecc
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
10.0.0
NPM Version
6.4.1
Score
93.1
Supply Chain
98.6
Quality
80.8
Maintenance
100
Vulnerability
99.3
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (96.09%)
Shell (3.91%)
Developer
EOSIO
Download Statistics
Total Downloads
8,186,827
Last Day
1,486
Last Week
20,522
Last Month
96,768
Last Year
906,395
GitHub Statistics
288 Stars
131 Commits
120 Forks
53 Watching
22 Branches
10 Contributors
Package Meta Information
Latest Version
4.0.7
Package Id
eosjs-ecc@4.0.7
Size
310.27 kB
NPM Version
6.4.1
Node Version
10.0.0
Publised On
23 Sept 2019
Total Downloads
Cumulative downloads
Total Downloads
8,186,827
Last day
-71.5%
1,486
Compared to previous day
Last week
-25.6%
20,522
Compared to previous week
Last month
-28.3%
96,768
Compared to previous month
Last year
0.1%
906,395
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Elliptic curve cryptography functions (ECC)
Private Key, Public Key, Signature, AES, Encryption / Decryption
Import
1import ecc from 'eosjs-ecc' 2// or 3const ecc = require('eosjs-ecc')
Include
- Install with:
yarn add eosjs-ecc
- Html script tag, see releases for the correct version and its matching script integrity hash.
1<html> 2<head> 3 <meta charset="utf-8"> 4 <!-- 5 sha512-cL+IQQaQ586s9DrXfGtDheRpj5iDKh2M+xlpfwbhNjRIp4BGQ1fkM/vB4Ta8mc+f51YBW9sJiPcyMDIreJe6gQ== lib/eosjs-ecc.js 6 sha512-dYFDmK/d9r3/NCp6toLtfkwOjSMRBaEzaGAx1tfRItC0nsI0hVLERk05iNBQR7uDNI7ludYhcBI4vUiFHdjsTQ== lib/eosjs-ecc.min.js 7 sha512-eq1SCoSe38uR1UVuQMwR73VgY8qKTBDc87n2nIiC5WLhn1o2y1U6c5wY8lrigVX7INM8fM0PxDlMX5WvpghKig== lib/eosjs-ecc.min.js.map 8 --> 9 <script src="https://cdn.jsdelivr.net/npm/eosjs-ecc@4.0.4/lib/eosjs-ecc.min.js" 10 integrity="sha512-dYFDmK/d9r3/NCp6toLtfkwOjSMRBaEzaGAx1tfRItC0nsI0hVLERk05iNBQR7uDNI7ludYhcBI4vUiFHdjsTQ==" 11 crossorigin="anonymous"></script> 12 13</head> 14<body> 15 See console object: eosjs_ecc 16</body> 17</html>
Common API
Table of Contents
- wif
- ecc
- pubkey
wif
Type: string
ecc
initialize
Initialize by running some self-checking code. This should take a second to gather additional CPU entropy used during private key generation.
Initialization happens once even if called multiple times.
Returns Promise
unsafeRandomKey
Does not pause to gather CPU entropy.
Returns Promise<PrivateKey> test key
randomKey
Parameters
cpuEntropyBits
number gather additional entropy from a CPU mining algorithm. This will already happen once by default. (optional, default0
)
Examples
1ecc.randomKey().then(privateKey => { 2console.log('Private Key:\t', privateKey) // wif 3console.log('Public Key:\t', ecc.privateToPublic(privateKey)) // EOSkey... 4})
seedPrivate
Parameters
seed
string any length string. This is private. The same seed produces the same private key every time. At least 128 random bits should be used to produce a good private key.
Examples
1ecc.seedPrivate('secret') === wif
Returns wif
privateToPublic
Parameters
Examples
1ecc.privateToPublic(wif) === pubkey
Returns pubkey
isValidPublic
Parameters
Examples
1ecc.isValidPublic(pubkey) === true
Returns boolean valid
isValidPrivate
Parameters
wif
wif
Examples
1ecc.isValidPrivate(wif) === true
Returns boolean valid
sign
Create a signature using data or a hash.
Parameters
data
(string | Buffer)privateKey
(wif | PrivateKey)encoding
String data encoding (if string) (optional, default'utf8'
)
Examples
1ecc.sign('I am alive', wif)
Returns string string signature
signHash
Parameters
dataSha256
(String | Buffer) sha256 hash 32 byte buffer or stringprivateKey
(wif | PrivateKey)encoding
String dataSha256 encoding (if string) (optional, default'hex'
)
Returns string string signature
verify
Verify signed data.
Parameters
signature
(string | Buffer) buffer or hex stringdata
(string | Buffer)pubkey
(pubkey | PublicKey)encoding
(optional, default'utf8'
)hashData
boolean sha256 hash data before verify (optional, defaulttrue
)
Examples
1ecc.verify(signature, 'I am alive', pubkey) === true
Returns boolean
recover
Recover the public key used to create the signature.
Parameters
signature
(String | Buffer) (EOSbase58sig.., Hex, Buffer)data
(String | Buffer) full dataencoding
String data encoding (if data is a string) (optional, default'utf8'
)
Examples
1ecc.recover(signature, 'I am alive') === pubkey
Returns pubkey
recoverHash
Parameters
signature
(String | Buffer) (EOSbase58sig.., Hex, Buffer)dataSha256
(String | Buffer) sha256 hash 32 byte buffer or hex stringencoding
String dataSha256 encoding (if dataSha256 is a string) (optional, default'hex'
)
Returns PublicKey
sha256
Parameters
data
(string | Buffer) always binary, you may need Buffer.from(data, 'hex')resultEncoding
(optional, default'hex'
)encoding
string result encoding 'hex', 'binary' or 'base64' (optional, default'hex'
)
Examples
1ecc.sha256('hashme') === '02208b..'
1ecc.sha256(Buffer.from('02208b', 'hex')) === '29a23..'
Returns (string | Buffer) Buffer when encoding is null, or string
pubkey
EOSKey..
Type: string
Usage (Object API)
1let {PrivateKey, PublicKey, Signature, Aes, key_utils, config} = require('eosjs-ecc')
2
3// Create a new random private key
4let privateWif
5PrivateKey.randomKey().then(privateKey => privateWif = privateKey.toWif())
6
7// Convert to a public key
8pubkey = PrivateKey.fromString(privateWif).toPublic().toString()
Browser
1git clone https://github.com/EOSIO/eosjs-ecc.git 2cd eosjs-ecc 3yarn 4yarn build_browser 5# builds: ./dist/eosjs-ecc.js 6# Verify release hash
1<script src=eosjs-ecc.js></script>
1var ecc = eosjs_ecc 2 3ecc.randomKey().then(privateWif => { 4 var pubkey = ecc.privateToPublic(privateWif) 5 console.log(pubkey) 6})
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 8/14 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: npmCommand not pinned by hash: dist/run_tests.sh:5
- Warn: npmCommand not pinned by hash: scripts/publish-edge.sh:16
- Info: 0 out of 2 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 25 are checked with a SAST tool
Reason
60 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-whgm-jr23-g3j9
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-wg6g-ppvx-927h
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2
- Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-vfrc-7r7c-w9mx
- Warn: Project is vulnerable to: GHSA-7wwv-vh3v-89cq
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-3j8f-xvm3-ffx4
- Warn: Project is vulnerable to: GHSA-4p35-cfcx-8653
- Warn: Project is vulnerable to: GHSA-7f3x-x4pr-wqhj
- Warn: Project is vulnerable to: GHSA-jpp7-7chh-cf67
- Warn: Project is vulnerable to: GHSA-q6wq-5p59-983w
- Warn: Project is vulnerable to: GHSA-j9fq-vwqv-2fm2
- Warn: Project is vulnerable to: GHSA-pqw5-jmp5-px4v
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-9q5w-79cv-947m
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
- Warn: Project is vulnerable to: GHSA-g78m-2chm-r7qv
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
1.8
/10
Last Scanned on 2024-12-23
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