Home

Awesome

supercop.js

NOTE: A version compiled to WASM and maintained better can be found at nazar-pc/supercop.wasm. It probably works as opposed to this old code.

orlp/ed25519 compiled to pure javascript using Emscripten

example

signing and verifying stuff

var lib = require('supercop.js')

var seed = lib.createSeed()
var keys = lib.createKeyPair(seed)
var msg = new Buffer('hello there')
var sig = lib.sign(msg, keys.publicKey, keys.secretKey)
console.log(lib.verify(sig, msg, keys.publicKey)) // true

storing keypairs

var lib = require('supercop.js')
var fs = require('fs')

var seed = lib.createSeed()
var keys = lib.createKeyPair(seed)

fs.writeFileSync('keys.json', JSON.stringify({
  publicKey: keys.publicKey.toString('base64'),
  secretKey: keys.secretKey.toString('base64')
}))

loading keypairs

var fs = require('fs')

var keys = require('./keys.json')
keys = {
  publicKey: new Buffer(keys.publicKey, 'base64'),
  secretKey: new Buffer(keys.secretKey, 'base64')
}

api

var seed = lib.createSeed()

Generates a cryptographically-secure 32-byte seed.

var keys = lib.createKeyPair(seed)

Generates a keypair from the provided 32-byte seed with the following properties:

var sig = lib.sign(msg, publicKey, secretKey)

Signs a given message of any length.

var valid = lib.verify(sig, msg, publicKey)

Verifies a given signature goes with the message and key.