ed25519.js
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i ed25519.js

Weekly Downloads

28

Version

1.3.0

License

Apache-2.0

Unpacked Size

214 kB

Total Files

11

Last publish

Collaborators

  • 6r1d
  • stefanpopov
  • soramitsu-admin
  • lasintez