Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
universal-ecdsa
Advanced tools
A universal JavaScript Elliptic Curve Digital Signature Algorithm (ECDSA) for the Koblitz secp256k1 curve.
A Universal JavaScript Elliptic Curve Digital Signature Algorithm (ECDSA) for the Koblitz secp256k1 curve.
Info
The Web Assembly binary file esdsa.json
that is consumed by the JavaScript environments is compiled from C/C++, see cpp/readme.md.
npm i universal-ecdsa
^12.20.1 || >= 13.2
defaults, no IE 11
You will need Node +15 web crypto for passing test.
Generates a compressed public key for the secp256k1
curve.
Parameter | Type | Description |
---|---|---|
private_key | Uint8Array | secp256k1 valid private key. |
Returns: Uint8Array — Public key.
Ways to import
.
import { get_public_key } from 'universal-ecdsa'
Ways to require
.
const { get_public_key } = require('universal-ecdsa')
Usage get_public_key
.
const private_key = new Uint8Array([ 210, 101, 63, 247, 203, 178, 216, 255, 18, 154, 194, 126, 245, 120, 28, 230, 139, 37, 88, 196, 26, 116, 175, 31, 45, 220, 166, 53, 203, 238, 240, 125 ]) get_public_key(private_key).then(console.log) // compressed public key.
The logged output was [2, …, 207].
Universal sha256 message digest helper function.
Parameter | Type | Description |
---|---|---|
data | Uint8Array | Binary data to hash. |
Returns: Uint8Array — Message digest.
Ways to import
.
import { sha256 } from 'universal-ecdsa'
Ways to require
.
const { sha256 } = require('universal-ecdsa')
Usage sha256
in node.
const array = Uint8Array.from( Buffer.from('The quick brown fox jumped over the lazy dog') ) sha256(array).then(console.log)
The logged output is [215, …, 146 ]
Generates a digital signature on the secp256k1 Koblitz curve.
Parameter | Type | Description |
---|---|---|
Arg | object | Argument. |
Arg.private_key | Uin8Array | secp256k1 private key. |
Arg.data | Uin8Array | Data to sign. |
Returns: Signature — Digital signature object containing r
and s
values.
Ways to import
.
import { sign } from 'universal-ecdsa'
Ways to require
.
const { sign } = require('universal-ecdsa')
Usage sign
.
const private_key = new Uint8Array([ 210, 101, 63, 247, 203, 178, 216, 255, 18, 154, 194, 126, 245, 120, 28, 230, 139, 37, 88, 196, 26, 116, 175, 31, 45, 220, 166, 53, 203, 238, 240, 125 ]) const data = Uint8Array.from([104, 101, 108, 108, 111]) sign({ data, private_key }).then(console.log)
The logged output is { r: [23, …, 89], s: [111, …, 142] }
FAQs
A universal JavaScript Elliptic Curve Digital Signature Algorithm (ECDSA) for the Koblitz secp256k1 curve.
The npm package universal-ecdsa receives a total of 9 weekly downloads. As such, universal-ecdsa popularity was classified as not popular.
We found that universal-ecdsa demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.