@gibme/crypto
v22.0.2
Published
Advanced Cryptographic Functions
Readme
Standalone Cryptography Library
A standalone cryptographic primitive wrapper library that can be included in various projects across a variety of development environments, including:
- Node.js >= 22.x (native C++ addon)
- WASM
- Javascript (asm.js)
It wraps gibme-c/crypto and exposes much of the functionality of that package to the supported development environments.
Note: Due to the size of the resulting WASM/Javascript module(s), only English mnemonic words are compiled by default.
Note: If you are looking to use this package in a browser, please read the browser directions below for a lighter installation path and minimal package size.
Features
- Hashing (Argon2d/i/id, SHA-256, Keccak, Blake2b, and more)
- Key derivation and HD keys (BIP32/BIP44/SLIP-0010)
- Mnemonic seed generation and restoration
- Digital signatures (Ed25519, ring signatures, CLSAG, Triptych)
- Range proofs (Bulletproofs, Bulletproofs+)
- RingCT (Pedersen commitments, pseudo commitments, amount masking)
- Multisig support
- Automatic module selection: native C++ addon > WASM > asm.js fallback
Node.js Library
Prebuilds of the Node.js native addon module and WASM/JS binaries are included with the npm-distributed package. If a prebuild for your platform does not exist, the native addon will be compiled automatically via CMake.
Dependencies
- Node.js >= 22.x
- Compiler supporting C++17 (gcc/clang/MSVC)
Installation
Yarn
yarn add @gibme/cryptoNPM
npm install @gibme/cryptoInitialization
TypeScript
import Crypto from '@gibme/crypto';
const crypto = await Crypto.init();CommonJS
const Crypto = require('@gibme/crypto').default;
const crypto = await Crypto.init();Forcing a Specific Module
By default, the library selects the best available module (native > WASM > JS). You can override this:
import Crypto from '@gibme/crypto';
const crypto = await Crypto.init();
// Force WASM module
await Crypto.force_wasm_library();
// Force JS (asm.js) module
await Crypto.force_js_library();Subpath Exports
The package provides subpath exports for directly importing specific module loaders:
import Crypto from '@gibme/crypto/wasm'; // WASM loader
import Crypto from '@gibme/crypto/asm'; // asm.js loader
import Crypto from '@gibme/crypto/node'; // Native addon loaderBrowser Usage / Installation
For browser environments, use the dedicated browser package which provides a lighter installation without the native C++ addon.
Yarn
yarn add @gibme/crypto-browserNPM
npm install @gibme/crypto-browserInitialization
TypeScript
import Crypto from '@gibme/crypto-browser';
const crypto = await Crypto.init();CommonJS
const Crypto = require('@gibme/crypto-browser').default;
const crypto = await Crypto.init();Documentation
Full TypeScript/JS API documentation is available at gibme-npm.github.io/crypto.
License
External references are provided via libraries in the Public Domain (Unlicense), MIT, and/or BSD from their respective parties.
This wrapper library is provided under the BSD-3-Clause license found in the LICENSE file.
Please make sure when using this library that you follow the licensing requirements set forth in all licenses.
