#bitcoin #private-key #signature #crypto #bsv

no-std bsv-wasm

A Bitcoin SV library with WASM in mind

41 releases (14 stable)

1.3.4 Jun 5, 2022
1.3.0-beta.7 Mar 18, 2022
1.3.0-beta.3 Dec 7, 2021
1.2.3 Nov 30, 2021
0.9.9 Jul 4, 2021

#2854 in Magic Beans

Download history 98/week @ 2024-01-19 4/week @ 2024-01-26 31/week @ 2024-02-16 47/week @ 2024-02-23 3/week @ 2024-03-01

81 downloads per month
Used in twetch-sdk

MIT license

480KB
9K SLoC

Rust 5.5K SLoC // 0.1% comments JavaScript 3K SLoC // 0.4% comments TypeScript 1K SLoC // 0.6% comments

BSV.WASM

A Rust/WASM Library to interact with Bitcoin SV

Installation

NodeJS 14.6+:
npm i bsv-wasm --save

Web:
npm i bsv-wasm-web --save

Webpack:
npm i bsv-wasm-bundler --save

Rust:
https://crates.io/crates/bsv-wasm

Deno:

import init, { Transaction } from "https://deno.land/x/bsv_wasm@{VERSION}/bsv_wasm.js"
await init();

Usage

Note: Rust and JS/TS method names and structs are the same

  • Eg. Derive private key from XPriv and log out P2PKH String ExtendedPrivateKey.fromWIF('LMyWif...').toPrivateKey().toPublicKey().toAddress().toString()

Features

  • Hash (SHA256, SHA256d, SHA1, RIPEMD160, Hash160, SHA512)
  • KDF (PBKDF2)
  • Encryption (AES-CBC, AES-CTR)
  • ECDSA (Private Key, Public Key, Signatures)
  • Transaction (Building, Serialising, Deserialising)
  • Script (Serialising, Deserialising)
  • Script Matching (ScriptTemplate)
  • Addresses (P2PKH)
  • Sighash Support
  • Extended Private Keys and Child Derivation (BIP32, BIP42)
  • Testnet support

TODO:

  • Isomorphic Package for JS
  • Write documentation (Inline on functions and structs)

Will not do:

  • Mnemonics

Thanks

Dependencies

~8MB
~149K SLoC