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

@tradle/kiki

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tradle/kiki

Wrappers for DSA, EC, Bitcoin and other keys to provide a common API for signing/verifying/importing/exporting

  • 1.1.8
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by150%
Maintainers
1
Weekly downloads
 
Created
Source

kiki

Wrappers for DSA, EC, Bitcoin and other keys to provide a common API for signing/verifying/importing/exporting

this module is used by Tradle

Usage

var kiki = require('kiki');
var Keys = kiki.Keys

// load ec public key
var ecPubKey = new Keys.EC({
  pub: '022ee9fefd1b275d4ee1e7c41157cd4753ad4cbd0cbfdc76eef85ebae230bf27ee'
})

// load ec private key
var ecPrivKey = new Keys.EC({
  priv: '01762d59097688a1f1cd241aadee4cb1bd3d37017f71501b28e85ecdab5349c2'
})

// new ec private key
var newECKey = Keys.EC.gen({
  curve: 'ed25519'
})

// new bitcoin key
var btcKey = Keys.Bitcoin.gen({
  networkName: 'bitcoin'
})

// new dsa key
var dsaKey = Keys.DSA.gen()

// keys with metadata
btcKey = Keys.Bitcoin.gen({
  networkName: 'testnet',
  // arbitrary metadata
  label: 'most excellent key',
  purpose: 'messaging'
})

sync API (may not be supported for some keys)

var sig = ecKey.signSync('hey ho') 
var verified = ecKey.verifySync('hey ho', sig)

async API (supported for all keys)

ecKey.sign('hey ho', function (err, sig) {
  // async is supported for all
  ecKey.verify('hey ho', function (err, verified) {
    // verified is a boolean
  })
})

export

var pub = ecKey.exportPublic()
var priv = ecKey.exportPrivate()

pub

{
  "curve": "ed25519",
  "fingerprint": "de26dffa5dc9e3866ea23d9120578b768b945b1385d8393d275d715470dd6056",
  "type": "ec",
  "value": "022ee9fefd1b275d4ee1e7c41157cd4753ad4cbd0cbfdc76eef85ebae230bf27ee",
  // whatever metadata you added
  "purpose": "sign",
  "label": "one key to rule them all"
}

priv

{
  "curve": "ed25519",
  "fingerprint": "de26dffa5dc9e3866ea23d9120578b768b945b1385d8393d275d715470dd6056",
  "priv": "01762d59097688a1f1cd241aadee4cb1bd3d37017f71501b28e85ecdab5349c2",
  "type": "ec",
  "value": "022ee9fefd1b275d4ee1e7c41157cd4753ad4cbd0cbfdc76eef85ebae230bf27ee",
  // whatever metadata you added
  "purpose": "sign",
  "label": "one key to rule them all"
}

import

// recover to typed instance (ECKey/DSAKey/etc.)
var ecKey = kiki.toKey(pub || priv) 

Key API

(static) gen(options)

Generate a new key. Different keys may have different required properties (this asymmetry can't be avoided.)

hasDeterministicSig()

Some keys have deterministic signatures - same outputs for the same inputs. Some don't.

parsePub(pubKeyString)

parsePriv(privKeyString)

fingerprint()

pubKeyString()

exportPublic()

exportPrivate()

mock "secure element" API

Simple mock for a "secure element" type API, where you don't have access to the private keys. Give it a public key, an operation and data, and it will perform signing, decrypting, etc.

var kiki = require('kiki').kiki
var secureEl = kiki(privKeys) // setup the mock secure element
secureEl.sign(pubKey, msg, callback)
secureEl.ecdh(ecPubKey1, ecPubKey2, callback)

FAQs

Package last updated on 21 Nov 2015

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