TypeScript bindings for the libblsct library used by the
Navio blockchain to construct confidential transactions based
on the BLS12-381 curve.
npm install navio-blsct
The npm package includes:
For Node.js, installation includes building native C++ libraries from source (may take a few minutes). Browser/WASM usage works immediately without any build step.
import { Scalar, Point, BlsctChain, setChain } from 'navio-blsct';
// Set the network
setChain(BlsctChain.Mainnet);
// Generate a random scalar
const scalar = Scalar.random();
console.log('Random scalar:', scalar.toHex());
// Generate a point from the scalar
const point = Point.fromScalar(scalar);
console.log('Point:', point.toHex());
For browser usage, import from the /browser subpath and initialize the WASM
module first. The WASM files are pre-built and included in the npm package,
so no additional build steps are needed:
import {
loadBlsctModule,
Scalar,
Point,
BlsctChain,
setChain,
} from 'navio-blsct/browser';
// Initialize WASM module (required before using any functions)
// This loads the pre-built WASM files from the package
await loadBlsctModule();
// Now use the library as normal
setChain(BlsctChain.Mainnet);
const scalar = Scalar.random();
console.log('Random scalar:', scalar.toHex());
If your bundler automatically resolves the browser field in package.json,
you may be able to use the standard import:
import { loadBlsctModule, Scalar } from 'navio-blsct';
await loadBlsctModule();
// ...
Full API reference and usage examples are available in the documentation.
Note: Building from source is only needed for development or if you want to modify the library. Users installing from npm get pre-built WASM files and don't need to build them.
cd ffi/ts
npm install
Pre-built WASM files are included in the npm package for browser usage. Building from source is only needed if you're developing or modifying the library.
To build WASM files from source, Emscripten must be installed and activated:
cd ffi/ts
npm install --ignore-scripts
npm run build:wasm
npm run build:browser
The WASM build process:
blsct.js and blsct.wasm to the wasm/ directoryMIT