Crypto Library in Javascript - Refact of Apache Milagro Crypto Library

this package has been deprecated
Last updated 2 years ago by todinov .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install milagro-crypto-js 
SYNC missed versions from official npm registry.

MCJS - Milagro Crypto JavaScript

Master Branch Master Build Status Coverage Status


MCJS - Milagro Crypto JavaScript

  • MCJS is a standards compliant JavaScript cryptographic library with no external dependencies except for the random seed source.

  • MCJS is a refactor of the JavaScript code of AMCL. For a detailed explanation about this library please read: doc/AMCL.pdf. For info about the refactoring process contact

  • MCJS supports the standards for RSA, ECDH, ECIES, ECDSA and M-PIN, AES-GCM encryption/decryption, SHA256, SHA384, SHA512 and SHA3 hash functions and a cryptographically secure random number generator. Furthermore we recently added New Hope, a post-quantum key exchange.

  • MCJS is Node.js compatible and browser compatible (see some examples below).

Install and run tests

Node.js and npm are required in order to build the library and run the tests. Install also the node.js modules required with the command

npm install

Run all the tests with the following command

npm test

Quick Start

Elliptic Curves

Suppose you want to implement ECDH with NIST256 elliptic curve. First you need to initialize the context:

var CTX = require("milagro-crypto-js");

var ctx = new CTX("NIST256");

then you can call the functions as follows:


If you need to use more than one elliptic curve in the same script you only need to initialize two different contexts, for example

var ctx1 = new CTX("NIST256");
var ctx2 = new CTX("C25519");

The following is the list of all elliptic curves supported by MCJS

['ED25519', 'C25519', 'C41417', 'GOLDILOCKS', 'NIST256', 'NIST384','NIST521', 'BRAINPOOL', 'ANSSI', 'HIFIVE', 'NUMS256W', 'NUMS256E', 'NUMS384W', 'NUMS384E', 'NUMS512W', 'NUMS512E', 'BN254', 'BN254CX', 'BLS383'];


This library supports also RSA encryption/decryption and RSA signature. The following is a quick example on how to use RSA. First initialize the context

var CTX = require("milagro-crypto-js");

var ctx = new CTX("RSA2048");

then you can call the RSA functions as follows:


The following is the list of all the RSA security level supported by MCJS


Other functions

MCJS supports SHA256, SHA384, SHA512, AES-GCM encryption and Marsaglia & Zaman random number generator. Those functions are contained in every context initialized with RSA or with an elliptic curve. If you want to create a context supporting only those general functions then initialize it with no parameter as follows:

var CTX = require("milagro-crypto-js");

var ctx = new CTX();

In the /example directory there are many simple script that show how to use this library.

Run examples

Node.js examples are provided - please see ./examples/node. Use the following command to run an example

node ./examples/node/example_ECC_NIST256.js


The library source code is browser compatible. The browser examples are locates in ./examples/browser.

Current Tags

  • 3.3.0                                ...           latest (2 years ago)

1 Versions

  • 3.3.0 [deprecated]           ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 22
Last Day 0
Last Week 3
Last Month 12
Dependencies (0)
Dev Dependencies (7)

Copyright 2014 - 2017 © |