JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 335
  • Score
    100M100P100Q85261F

Elliptical Curve Cryptography Digital Signing

Package Exports

  • ecdsa

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 (ecdsa) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ecdsa

JavaScript component to Elliptical Curve Cryptography signing and verify.

See this article for more details: bitcoin address.

Install

Node.js/Browserify

npm install --save ecdsa

Component

component install cryptocoinjs/ecdsa

Bower

bower install ecdsa

Script

<script src="/path/to/ecdsa.js"></script>

Example

var ecdsa = require('../lib/ecdsa')
  , sha256 = require('sha256')
  , secureRandom = require('secure-random')
  , ecparams = require('ecurve-names')('secp256k1')
  , BigInteger = require('cryptocoin-bigint')

var randArr = secureRandom(32, {array: true})
var privKey = BigInteger.fromByteArrayUnsigned(randArr)
//var privKey = ecdsa.getBigRandom(ecparams.getN())
var pubPoint = ecparams.getG().multiply(privKey)
var pubKey = pubPoint.getEncoded(false) //true => compressed, fails though, must investigate
var msg = "hello world!"
var shaMsg = sha256(msg)
var signature = ecdsa.sign(shaMsg, privKey)
var isValid = ecdsa.verify(shaMsg, signature, pubKey)
console.log(isValid) //true

Credits

It's not clear to me if this is based upon Tom Wu's work or Stefen Thomas.