JSPM

  • Created
  • Published
  • Downloads 1864454
  • Score
    100M100P100Q229208F
  • License MIT

This module provides native bindings to ecdsa secp256k1 functions

Package Exports

  • secp256k1
  • secp256k1/bindings
  • secp256k1/bindings.js
  • secp256k1/elliptic
  • secp256k1/js
  • secp256k1/js.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (secp256k1) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 git@github.com: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.