Skip to content

Latest commit

 

History

History
48 lines (30 loc) · 2.29 KB

install.md

File metadata and controls

48 lines (30 loc) · 2.29 KB

Installation

Welcome! Libauth is designed to be low-level and lightweight: all functionality is exported as simple functions, so your bundler can eliminate the code you don't use.

Libauth is a pure ESM package, so Node.js v12 or higher is required (or Deno), and using ESM is recommended.

Node.js Usage

To get started, install @bitauth/libauth in your environment:

npm install @bitauth/libauth
# OR
yarn add @bitauth/libauth

And import the functionality you need:

import { secp256k1 } from '@bitauth/libauth';
import { msgHash, pubkey, sig } from 'somewhere';

secp256k1.verifySignatureDERLowS(sig, pubkey, msgHash)
  ? console.log('🚀 Signature valid')
  : console.log('❌ Signature invalid');

Web Usage

For web projects, a bundler with dead-code elimination (A.K.A. "tree shaking") is strongly recommended – Libauth is designed to minimize application code size, and dead-code elimination will improve load performance in nearly all applications.

Consider Vite (recommended), Parcel, Rollup, Webpack, or a bundler designed for your web framework.

Deno Usage

For Deno usage, Libauth can be imported with the npm: protocol:

import { hexToBin } from 'npm:@bitauth/libauth';

console.log(hexToBin('beef'));

Using Typescript Types

Libauth should work with modern TypeScript projects without any configuration.

If you're having trouble, note that Libauth uses BigInt, WebAssembly, and es2017 features for some functionality. To type-check this library in you application (without skipLibCheck), your tsconfig.json will need a minimum target of es2020 or lib must include es2017 and esnext.bigint. If your application is not already importing types for WebAssembly, you may also need to add dom to lib.