wallet-encrypt-decrypt

majiayu000 的头像作者 majiayu000

使用 BSV 密钥和 ECDH 加密和解密消息。使用@bsv/sdk进行加密操作。

📖 中文导读:使用 BSV 密钥和 ECDH 加密和解密消息。使用@bsv/sdk进行加密操作。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: wallet-encrypt-decrypt description: Encrypt and decrypt messages using BSV keys and ECDH. Uses @bsv/sdk for cryptographic operations. allowed-tools: "Bash(bun:*)"

Wallet Encrypt/Decrypt

Encrypt and decrypt messages using BSV keys (ECDH).

When to Use

  • Encrypt messages to a public key
  • Decrypt messages with private key
  • Secure communication between BSV addresses
  • End-to-end encrypted messaging

Usage

# Encrypt message to public key
bun run /path/to/skills/wallet-encrypt-decrypt/scripts/encrypt-message.ts <public-key> "message"

# Decrypt message with private key
bun run /path/to/skills/wallet-encrypt-decrypt/scripts/decrypt-message.ts <private-wif> <encrypted-hex>

Encryption Method

Uses ECDH (Elliptic Curve Diffie-Hellman):

  • Sender: Ephemeral key + recipient public key = shared secret
  • Encrypt with AES using shared secret
  • Send: ephemeral public key + encrypted data
  • Recipient: private key + ephemeral public key = same shared secret
  • Decrypt with AES

Requirements

  • @bsv/sdk package for ECDH and AES
  • Valid BSV public/private keys