Skip to content
This repository has been archived by the owner on Mar 13, 2020. It is now read-only.
/ iroha-ed25519.js Public archive

warchant/ed25519 compiled with Emscripten and wrapper for it.

License

Notifications You must be signed in to change notification settings

soramitsu/iroha-ed25519.js

Repository files navigation

ed25519.js npm version License

https://github.com/hyperledger/iroha-ed25519 compiled with Emscripten and wrapper for it.

Installation

Yarn: yarn add ed25519.js

NPM: npm install ed25519.js

After it, you can use it with require('ed25519.js')

Example

This library produces buffers of bytes and requires buffers as input

Generating keypair

var ed25519 = require('ed25519.js')

var keys = ed25519.createKeyPair() //Generate keypair
console.log(keys.publicKey) // Generated public key, stored as buffer
console.log(keys.privateKey) // Generated private key, stored as buffer

Deriving public key, signing and verifying message

var ed25519 = require('ed25519.js')

// Example private key, parsed from hex string as buffer
var privateKey = Buffer.from('9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60', 'hex')

// Derived public key, stored as buffer
var publicKey = ed25519.derivePublicKey(privateKey)

// Message, stored as buffer
var message = Buffer.from('Cool message', 'utf8')

// Signing message
var signature = ed25519.sign(message, publicKey, privateKey)

// Verifying message
var isVerified = ed25519.verify(signature, message, publicKey)

console.log(isVerified)

TS Examples

You can test typescript examples by running this command

node -r ts-node/register ./examples/createKeyPair.ts

TODOs

  • Write tests
  • Use Standard.js
  • Add PreCommit/Push hooks
  • Write an example to readme
  • License
  • Create NPM package
  • Migrate code to TS
  • Code examples in TS
  • Uglify/Minify
  • TSDoc
  • Compile library from C++ on the fly
  • More tests

License

Apache License 2.0