Socket
Socket
Sign inDemoInstall

@types/elliptic

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/elliptic

TypeScript definitions for elliptic


Version published
Weekly downloads
92K
decreased by-14.81%
Maintainers
1
Weekly downloads
 
Created

What is @types/elliptic?

@types/elliptic provides TypeScript type definitions for the elliptic library, which is a JavaScript implementation of elliptic curve cryptography. This package allows developers to use elliptic with TypeScript, ensuring type safety and better development experience.

What are @types/elliptic's main functionalities?

Elliptic Curve Key Generation

This feature allows you to generate a new elliptic curve key pair using the secp256k1 curve. The code sample demonstrates how to create a key pair and extract the public and private keys in hexadecimal format.

const elliptic = require('elliptic');
const EC = new elliptic.ec('secp256k1');
const keyPair = EC.genKeyPair();
const publicKey = keyPair.getPublic('hex');
const privateKey = keyPair.getPrivate('hex');
console.log('Public Key:', publicKey);
console.log('Private Key:', privateKey);

Signing a Message

This feature allows you to sign a message using an elliptic curve key pair. The code sample demonstrates how to hash a message and sign it using the private key, then output the signature in DER format.

const elliptic = require('elliptic');
const EC = new elliptic.ec('secp256k1');
const keyPair = EC.genKeyPair();
const msg = 'Hello, world!';
const msgHash = EC.hash().update(msg).digest();
const signature = keyPair.sign(msgHash);
console.log('Signature:', signature.toDER('hex'));

Verifying a Signature

This feature allows you to verify a signature using an elliptic curve public key. The code sample demonstrates how to hash a message, sign it, and then verify the signature using the public key.

const elliptic = require('elliptic');
const EC = new elliptic.ec('secp256k1');
const keyPair = EC.genKeyPair();
const msg = 'Hello, world!';
const msgHash = EC.hash().update(msg).digest();
const signature = keyPair.sign(msgHash);
const isValid = keyPair.verify(msgHash, signature);
console.log('Signature valid:', isValid);

Other packages similar to @types/elliptic

FAQs

Package last updated on 21 Nov 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc