Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mcl-wasm

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mcl-wasm

mcl ; A portable and fast pairing-based cryptography library for Node.js by WebAssembly

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is mcl-wasm?

The mcl-wasm package is a WebAssembly (WASM) implementation of the MCL (Multiprecision Complex Library) which provides cryptographic functionalities, particularly focusing on pairing-based cryptography. It is designed to be used in web applications and Node.js environments.

What are mcl-wasm's main functionalities?

Pairing-based Cryptography

This code demonstrates the use of pairing-based cryptography with the mcl-wasm package. It initializes the BLS12-381 curve, generates random elements in the field, computes points on the elliptic curve, and then performs a pairing operation.

const mcl = require('mcl-wasm');
(async () => {
  await mcl.init(mcl.BLS12_381);
  const a = new mcl.Fr();
  a.setByCSPRNG();
  const b = new mcl.Fr();
  b.setByCSPRNG();
  const P = mcl.mul(mcl.g1(), a);
  const Q = mcl.mul(mcl.g2(), b);
  const ePQ = mcl.pairing(P, Q);
  console.log('e(P, Q) =', ePQ.getStr());
})();

Elliptic Curve Operations

This code demonstrates basic elliptic curve operations such as point addition. It initializes the BLS12-381 curve, creates points on the curve, and adds them together.

const mcl = require('mcl-wasm');
(async () => {
  await mcl.init(mcl.BLS12_381);
  const P = mcl.g1();
  const Q = mcl.g1();
  Q.setStr('1 2');
  const R = mcl.add(P, Q);
  console.log('P + Q =', R.getStr());
})();

Field Arithmetic

This code demonstrates field arithmetic operations such as addition. It initializes the BLS12-381 curve, generates random field elements, and adds them together.

const mcl = require('mcl-wasm');
(async () => {
  await mcl.init(mcl.BLS12_381);
  const a = new mcl.Fr();
  a.setByCSPRNG();
  const b = new mcl.Fr();
  b.setByCSPRNG();
  const c = mcl.add(a, b);
  console.log('a + b =', c.getStr());
})();

Other packages similar to mcl-wasm

Keywords

FAQs

Package last updated on 20 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc