Socket
Socket
Sign inDemoInstall

tiny-secp256k1

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-secp256k1

A tiny secp256k1 native/JS wrapper


Version published
Weekly downloads
173K
decreased by-11.9%
Maintainers
2
Weekly downloads
 
Created

What is tiny-secp256k1?

The tiny-secp256k1 npm package is a small, fast, and reliable library for elliptic curve cryptography using the secp256k1 curve. It is commonly used in blockchain and cryptocurrency applications, particularly for Bitcoin, to perform cryptographic operations such as key generation, signing, and verification.

What are tiny-secp256k1's main functionalities?

Key Generation

This feature allows you to generate a private key and derive the corresponding public key using the secp256k1 curve.

const secp256k1 = require('tiny-secp256k1');
const randomBytes = require('crypto').randomBytes;

const privateKey = randomBytes(32);
const publicKey = secp256k1.pointFromScalar(privateKey);
console.log('Private Key:', privateKey.toString('hex'));
console.log('Public Key:', publicKey.toString('hex'));

Signing a Message

This feature allows you to sign a message using a private key. The message is hashed using SHA-256 before signing.

const secp256k1 = require('tiny-secp256k1');
const randomBytes = require('crypto').randomBytes;
const createHash = require('crypto').createHash;

const privateKey = randomBytes(32);
const message = 'Hello, world!';
const messageHash = createHash('sha256').update(message).digest();
const signature = secp256k1.sign(messageHash, privateKey);
console.log('Signature:', signature.toString('hex'));

Verifying a Signature

This feature allows you to verify a signature using a public key. The message is hashed using SHA-256 before verification.

const secp256k1 = require('tiny-secp256k1');
const createHash = require('crypto').createHash;

const publicKey = Buffer.from('your-public-key-hex', 'hex');
const message = 'Hello, world!';
const messageHash = createHash('sha256').update(message).digest();
const signature = Buffer.from('your-signature-hex', 'hex');
const isValid = secp256k1.verify(messageHash, publicKey, signature);
console.log('Is the signature valid?', isValid);

Other packages similar to tiny-secp256k1

FAQs

Package last updated on 01 Dec 2020

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