An ultra-lightweight JavaScript library for Bitcoin, Bitcoin Cash, and Bitauth applications.
Explore API Reference »
An ultra-lightweight JavaScript library for Bitcoin, Bitcoin Cash, and Bitauth applications.
Libauth has no dependencies and works in all JavaScript environments, including Node.js, Deno, and browsers.
Libauth is designed to be flexible, lightweight, and easily auditable. Rather than providing a single, overarching, object-oriented API, all functionality is composed from simple functions. This has several benefits:
To get started, install @bitauth/libauth
:
npm install @bitauth/libauth
# OR
yarn add @bitauth/libauth
And import the functionality you need:
import { instantiateSecp256k1 } from '@bitauth/libauth';
import { msgHash, pubkey, sig } from './somewhere';
(async () => {
const secp256k1 = await instantiateSecp256k1();
secp256k1.verifySignatureDERLowS(sig, pubkey, msgHash)
? console.log('�� Signature valid')
: console.log('❌ Signature invalid');
})();
Note: @bitauth/libauth
uses BigInt
, WebAssembly
, and es2017
features for some functionality. While support is required to use this functionality (Node.js v10 LTS or later), other parts of the library will continue to work in older environments. To include the necessary TypeScript library files in you application, add "lib": ["es2017", "esnext.bigint", "dom"]
to your tsconfig.json
.
Deno is a great runtime for quickly working with Libauth. You can import from the latest module build:
import { hexToBin } from 'https://unpkg.com/@bitauth/libauth/build/module/index.js';
console.log(hexToBin('beef'));
The following APIs are considered stable, and will only include breaking changes in major version upgrades.
Libauth also exports new, potentially unstable APIs. As these APIs stabilize, they will be included in the above reference.
Pull Requests welcome! Please see CONTRIBUTING.md
for details.
This library requires Yarn for development. If you don't have Yarn, make sure you have Node.js
installed (which ships with npm
), then run npm install -g yarn
. Once Yarn is installed:
# use --recursive to clone the secp256k1 submodule
git clone --recursive https://github.com/bitauth/libauth.git && cd libauth
Install the development dependencies:
yarn
Then try running the test suite:
yarn test
You can also run the benchmarks (this will take a while):
yarn bench
During development, you may find it helpful to use the testing watch
tasks:
yarn watch # rebuild everything on save
yarn watch:test # run only the fast tests
yarn watch:test-slow # test everything
For more information about the available package scripts, run:
yarn run info