
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
bech32-label
Advanced tools
Convert 32-byte public keys to DNS-safe bech32 labels for per-identity subdomains
A tiny, zero-dependency JavaScript library and CLI that converts 32-byte public keys (64-char hex) ↔ DNS-safe bech32 data-only labels (52 chars) for per-identity subdomains.
Problem: You want per-user subdomains like <user-id>.<provider-domain>
to isolate browser origins (cookies, localStorage, service workers) and reduce cross-tenant XSS/CSRF attacks.
Challenge: 64-char hex public keys exceed DNS label limits (63 chars), and full npub...
encodings are display-oriented with HRP/checksum that aren't suitable as normative origin identifiers.
Solution: Convert 32-byte keys to exactly 52-char bech32 data-only labels that:
npm install bech32-label
import { encodeHexToLabel, decodeLabelToHex, isValidHex, isValidLabel } from 'bech32-label';
// Convert 64-char hex to 52-char bech32 label
const hex = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
const label = encodeHexToLabel(hex);
console.log(label); // "qgplqa02h2wqvdnn54k2vdnrpznrpznrpznrpznrpznrpznrpzn"
// Convert back
const decodedHex = decodeLabelToHex(label);
console.log(decodedHex === hex.toLowerCase()); // true
// Validation
console.log(isValidHex(hex)); // true
console.log(isValidLabel(label)); // true
# Install globally
npm install -g bech32-label
# Encode hex to label
bech32-label encode 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
# Decode label to hex
bech32-label decode qgplqa02h2wqvdnn54k2vdnrpznrpznrpznrpznrpznrpznrpzn
qpzry9x8gf2tvdw0s3jn54khce6mua7l
/^[0-9a-f]{64}$/i
(case-insensitive input, lowercase output)pad=true
)/^[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{52}$/
"Expected 64-char hex"
- Invalid hex input"Invalid bech32 character"
- Non-alphabet character in label"Invalid label length"
- Label not exactly 52 characters"Decoded length is not 32 bytes"
- Invalid padding or corruption"Non-canonical encoding"
- Label doesn't round-trip correctly"type": "module"
)node:test
for testingimport { encodeHexToLabel } from 'bech32-label';
// User's public key
const userPubkey = '1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef';
const userLabel = encodeHexToLabel(userPubkey);
// Create isolated subdomain
const userOrigin = `https://${userLabel}.myapp.com`;
// → https://qgplqkq5h2wqvdnn54k2vdnrpznrpznrpznrpznrpznrpznrpzn.myapp.com
// Each user gets their own origin for complete isolation
MIT
This package prioritizes simplicity and compliance with the functional specification. Please ensure any changes maintain:
FAQs
Convert 32-byte public keys to DNS-safe bech32 labels for per-identity subdomains
We found that bech32-label demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.