Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jquery-ecdsa

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery-ecdsa

ecdsa jquery plugin for the browser using the webcrypto api

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

jquery-ecdsa

ecdsa jquery plugin for the browser using the webcrypto api

Demo: https://angeal185.github.io/jquery-ecdsa

Installation

npm

$ npm install jquery-ecdsa --save

bower

$ bower install jquery-ecdsa

git

$ git clone git@github.com:angeal185/jquery-ecdsa.git
browser
<script src="./dist/jq-ecdsa.min.js"></script>
API

/**
 *  generate ecdsa keypair
 *  @param {string} curve ~ '256'/'384'/'521'
 *  @param {function} cb ~ callback function(err,res)
 **/

$.ecGen(curve, cb)


/**
 *  create signature
 *  @param {string} key ~ valid jwk
 *  @param {string} data ~ data to be signed
 *  @param {string} hash ~ '128'/'256'/'512'
 *  @param {string} digest ~ 'hex'/'base64'/'Uint8'
 *  @param {function} cb ~ callback function(err,res)
 **/

$.ecSign(key, data, hash, digest, cb)


/**
 *  verify signature
 *  @param {string} key ~ valid jwk
 *  @param {string} sig ~ valid signature
 *  @param {string} data ~ data to verify
 *  @param {string} hash ~ '128'/'256'/'512'
 *  @param {string} digest ~ 'hex'/'base64'/'Uint8'
 *  @param {function} cb ~ callback function(err,res)
 **/

$.ecVerify(key, sig, data, hash, digest, cb)

/**
 *  create signature
 *  @param {string} ele ~ location of data to sign
 *  @param {string} key ~ valid jwk
 *  @param {string} hash ~ '128'/'256'/'512'
 *  @param {string} digest ~ 'hex'/'base64'/'Uint8'
 *  @param {function} cb ~ callback function(err,res)
 **/

$(ele).ecSign(key, hash, digest, cb)


/**
 *  verify signature
 *  @param {string} ele ~ location of data to verify
 *  @param {string} key ~ valid jwk
 *  @param {string} sig ~ valid signature
 *  @param {string} hash ~ '128'/'256'/'512'
 *  @param {string} digest ~ 'hex'/'base64'/'Uint8'
 *  @param {function} cb ~ callback function(err,res)
 **/

$(ele).ecVerify(key, sig, hash, digest, cb)



//demo

const config = {
  curve: '521', // P-521
  hash: '512', // SHA-512
  degest: 'hex', // hexadecimal
  data: 'test'
}

//generate p-521 ecdsa keypair
$.ecGen(config.curve, function(err, gen){
  if(err){return console.log(err)}
  console.log(gen)

  //sign some data
  $.ecSign(gen.private, config.data, config.hash, config.digest, function(err, sig){
    if(err){return console.log(err)}
    console.log(res)

    //verify signature
    $.ecVerify(gen.public, sig, config.data, config.hash, config.digest, function(err, res){
      if(err){return console.log(err)}
      if(res){
        return console.log('ecdsa test pass')
      }
      return console.log('ecdsa test fail')
    })
  })


  //sign some data
  $('#data-to-sign').ecSign(gen.private, config.hash, config.digest, function(err, sig){
    if(err){return console.log(err)}
    console.log(res)

    //verify signature
    $('.data-to-verify').ecVerify(gen.public, sig, config.hash, config.digest, function(err, res){
      if(err){return console.log(err)}
      if(res){
        return console.log('ecdsa test pass')
      }
      return console.log('ecdsa test fail')
    })
  })


})




Keywords

FAQs

Package last updated on 15 May 2019

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