You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

wif

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wif

Bitcoin Wallet Import Format (WIF) decoding/encoding module


Version published
Weekly downloads
187K
decreased by-2.63%
Maintainers
0
Created
Weekly downloads
 

Package description

What is wif?

The 'wif' npm package is used for encoding and decoding Wallet Import Format (WIF) keys, which are commonly used in cryptocurrency applications. It provides utilities to convert between WIF and private keys, ensuring secure handling of private keys.

What are wif's main functionalities?

Encoding a private key to WIF

This feature allows you to encode a private key into the Wallet Import Format (WIF). The 'encode' function takes the version, private key buffer, and a boolean indicating if the key is compressed.

const wif = require('wif');
const privateKey = Buffer.from('your_private_key_hex', 'hex');
const wifKey = wif.encode(128, privateKey, true);
console.log(wifKey);

Decoding a WIF key to a private key

This feature allows you to decode a WIF key back into its original private key. The 'decode' function returns an object containing the private key buffer and a boolean indicating if the key is compressed.

const wif = require('wif');
const wifKey = 'your_wif_key';
const decoded = wif.decode(wifKey);
console.log(decoded.privateKey.toString('hex'));
console.log(decoded.compressed);

Other packages similar to wif

Readme

Source

WIF

TRAVIS NPM

js-standard-style

Bitcoin Wallet Import Format encoding/decoding module.

Example

import * as wif from "wif"
var privateKey = Buffer.from('0000000000000000000000000000000000000000000000000000000000000001', 'hex')
var key = wif.encode({version: 128, privateKey, compressed: true}) // for the testnet use: wif.encode(239, ...
// => KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn

var obj = wif.decode(key)
// => {
//	version: 128,
//	privateKey: Uint8Array(32) [
//     0, 0, 0, 0, 0, 0, 0, 0, 0,
//     0, 0, 0, 0, 0, 0, 0, 0, 0,
//     0, 0, 0, 0, 0, 0, 0, 0, 0,
//     0, 0, 0, 0, 1
//   ],
//	compressed: true
//}

wif.decode(key, 0x09)
// => Error: Invalid network version

// alternative syntax
wif.encode(obj)
// => KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn

LICENSE MIT

Keywords

FAQs

Package last updated on 25 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc