Skip to content

Node.js binding for an Optimized C library for EC operations on curve secp256k1

Notifications You must be signed in to change notification settings

claudiosdc/secp256k1-node

 
 

Repository files navigation

secp256k1-node

NPM Package Build Status Coverage Status

js-standard-style

This module provides native bindings to ecdsa secp256k1 functions. This library is experimental, so use at your own risk. Works on node version 0.10 or greater.

Installation

If you have gmp installed secp256k1 will use it. Otherwise it should fallback to openssl.

  • arch pacman -S gmp
  • ubuntu sudo apt-get install libgmp-dev
from npm

npm install secp256k1

from git
git clone [email protected]:wanderer/secp256k1-node.git
cd secp256k1-node
npm install

Usage

var crypto = require('crypto')
var secp256k1 = require('secp256k1')
// or require('secp256k1/js')
//   if you want to use pure js implementation in node (uses elliptic now)
// or require('secp256k1/elliptic')
//   if implementation that uses elliptic package

// generate message to sign
var msg = crypto.randomBytes(32)

// generate privKey
var privKey
do {
  privKey = crypto.randomBytes(32)
} while (!secp256k1.secretKeyVerify(privKey))

// get the public key in a compressed format
var pubKey = secp256k1.publicKeyCreate(privKey)

// sign the message
var sigObj = secp256k1.signSync(msg, privKey)

// verify the signature
console.log(secp256k1.verifySync(msg, sigObj.signature, pubKey))

LICENSE

This library is free and open-source software released under the MIT license.

About

Node.js binding for an Optimized C library for EC operations on curve secp256k1

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 62.4%
  • C++ 25.8%
  • C 8.2%
  • Python 3.1%
  • Shell 0.5%