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.
@blocksoft-ltd/cryptomate
Advanced tools
Ergonomic, zero-dependency crypto module wrapper for ECDSA and EdDSA signatures.
Key features of the module include:
To install cryptomate
, use the following npm command:
npm i --save cryptomate
Here is an example demonstrating the use of the ECDSA functionality provided by this module:
const {ECDSA, EC_CURVE, Key, SignatureEncoding} = require('cryptomate');
// Generate an ECDSA key pair.
const ecdsa = ECDSA.withCurve(EC_CURVE.secp256k1).genKeyPair();
// Sign a message.
let message = "Hello, World!";
let signature = ecdsa.sign(message, SignatureEncoding.HEX);
// Verify the signature.
console.log(ecdsa.verify(message, signature)); // Outputs: true
// Export keys in PEM format.
let privateKeyPEM = ecdsa.toPEM(Key.privateKey);
let publicKeyPEM = ecdsa.toPEM(Key.publicKey);
// Import keys from PEM format.
let importedECDSA = ECDSA.withCurve(EC_CURVE.secp256k1).fromPEM(privateKeyPEM, Key.privateKey);
A factory method to construct an ECDSA object with a given elliptic curve.
curve
- The elliptic curve to use. This can be one of the following values:
EC_CURVE.P_256
- NIST P-256 curve.EC_CURVE.P_384
- NIST P-384 curve.EC_CURVE.P_521
- NIST P-521 curve.EC_CURVE.SECP256K1
- SECP256K1 curve.EC_CURVE.SECP256R1
- SECP256R1 curve.EC_CURVE.SECP384R1
- SECP384R1 curve.EC_CURVE.SECP521R1
- SECP521R1 curve.An ECDSA object with the given elliptic curve.
Generates a new ECDSA key pair.
An ECDSA object with a newly generated key pair.
Constructs an ECDSA object from a given PEM string.
pem
- The PEM string to construct the ECDSA object from.keyType
- The type of key to construct. This can be one of the following values:
Key.privateKey
- Private key.Key.publicKey
- Public key.An ECDSA object with the given PEM string.
Converts the ECDSA object to a PEM string.
keyType
- The type of key to convert. This can be one of the following values:
Key.privateKey
- Private key.Key.publicKey
- Public key.A PEM string representing the ECDSA object.
Extracts the public key from the ECDSA object.
A Buffer object containing the public key.
Signs a message using the ECDSA object.
message
- The message to sign.encoding
- The encoding of the message. This can be one of the following values:
SignatureEncoding.HEX
- The message is encoded in hexadecimal format.SignatureEncoding.BASE64
- The message is encoded in Base64 format.SignatureEncoding.UTF8
- The message is encoded in UTF-8 format.A Buffer object containing the signature.
Verifies a signature using the ECDSA object.
message
- The message to verify.signature
- The signature to verify.encoding
- The encoding of the message. This can be one of the following values:
SignatureEncoding.HEX
- The message is encoded in hexadecimal format.SignatureEncoding.BASE64
- The message is encoded in Base64 format.SignatureEncoding.UTF8
- The message is encoded in UTF-8 format.A boolean value indicating whether the signature is valid.
Please note that the EdDSA class shares similar method names and functionalities to the ECDSA class for key pair generation, signing and verifying messages, and importing/exporting keys in various formats. Refer to the ECDSA API documentation provided above for further details.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
NodeJS crypto module wrapper for humans
The npm package @blocksoft-ltd/cryptomate receives a total of 2 weekly downloads. As such, @blocksoft-ltd/cryptomate popularity was classified as not popular.
We found that @blocksoft-ltd/cryptomate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.