navio-blsct
    Preparing search index...

    navio-blsct

    Navio BLS Confidential Transaction Library

    TypeScript bindings for the libblsct library used by the Navio blockchain to construct confidential transactions based on the BLS12-381 curve.

    • Node.js: Native C++ bindings for maximum performance
    • Browser: WebAssembly (WASM) module for browser compatibility
    • Node.js v18 or higher
    • g++, make, swig, autoconf, automake, libtool and pkg-config to build underlying C++ libraries
    • Modern browser with WebAssembly support
    • No native dependencies required
    npm install navio-blsct
    

    The npm package includes:

    • Pre-built WASM files for browser/WebAssembly use (no additional build required)
    • Source code for Node.js native bindings (automatically built during installation)

    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:

    1. Clones the navio-core repository (if not already present)
    2. Compiles the C++ source files to WebAssembly using Emscripten
    3. Outputs blsct.js and blsct.wasm to the wasm/ directory
    4. These files are included when publishing to npm but are gitignored during development

    MIT