Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including eris-keys with all npm packages installed. Try it out:

var erisKeys = require("eris-keys")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

eris-keys v0.6.1

a JavaScript client library for eris-keys

This is a JavaScript client library to facilitate interaction with an Eris Keys server.

Note: Eris Keys does not expose an interface to get private keys.

Installation

$ npm install eris-keys

Usage

First start a key server:

$ eris services start keys --publish

'use strict'

const assert = require('assert')
const keys = require('../../lib')

describe('a client for eris-keys', function () {
  it('generates a key, signs a message, and verifies the signature',
    function () {
      this.timeout(10 * 1000)

      // Connect to the key server.
      return keys.serviceUrl('services', 'keys', 4767).then((url) => {
        const server = keys.connect(url)

        // Generate a new key pair.
        return server.generateKeyPair().then((keyPairId) => {
          const message = 'a message in a bottle'

          return Promise.all([
            // Get the public key of the key pair.
            server.publicKeyFor(keyPairId),

            // Sign the message.
            server.sign(message, keyPairId)
          ]).then(([publicKey, signature]) =>
            server.verifySignature(message, signature, publicKey)
              .then((valid) => {
                assert(valid)
              })
          )
        })
      })
    })
})

Documentation

You can generate documentation in the doc subdirectory with the command npm run doc.

Copyright

Copyright 2016 Monax

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free