
Research
Security News
Malicious npm Packages Use Telegram to Exfiltrate BullX Credentials
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
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.
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);
The 'bitcoinjs-lib' package is a comprehensive library for Bitcoin-related operations, including key generation, transaction creation, and WIF encoding/decoding. It offers more extensive functionality compared to 'wif', making it suitable for broader Bitcoin application development.
The 'bitcore-lib' package is another full-featured library for Bitcoin development. It includes utilities for WIF encoding/decoding, as well as other features like transaction building and blockchain interaction. It is similar to 'bitcoinjs-lib' but is part of the BitPay ecosystem.
Bitcoin Wallet Import Format encoding/decoding module.
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
FAQs
Bitcoin Wallet Import Format (WIF) decoding/encoding module
The npm package wif receives a total of 318,642 weekly downloads. As such, wif popularity was classified as popular.
We found that wif demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.
Security News
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.