signing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Signing Skill

签名Skill

Provides cryptographic message signing for the Stacks and Bitcoin ecosystems. Four signing standards are supported:
  • SIP-018 — Structured Clarity data signing. Signatures are verifiable both off-chain and by on-chain smart contracts via
    secp256k1-recover?
    .
  • Stacks messages — SIWS-compatible plain-text signing. Used for wallet authentication and proving address ownership.
  • Bitcoin messages — BIP-137/BIP-322 hybrid. BIP-137 for legacy (1...) and wrapped SegWit (3...) addresses; BIP-322 "simple" for native SegWit (bc1q) and Taproot (bc1p) addresses. Compatible with Electrum, Bitcoin Core, and modern wallets.
  • Schnorr (BIP-340) — Taproot-native signing over raw 32-byte digests. Used for Taproot script-path spending, multisig coordination, and OP_CHECKSIGADD witness assembly.
  • Nostr events (NIP-06) — Sign Nostr event objects using the NIP-06 derived key (
    m/44'/1237'/0'/0/0
    ) by default, or from a wallet key path via
    keySource
    .
为Stacks和Bitcoin生态系统提供加密消息签名功能,支持以下四种签名标准:
  • SIP-018 —— 结构化Clarity数据签名。签名可在链下验证,也可通过链上智能合约的
    secp256k1-recover?
    方法验证。
  • Stacks消息 —— 兼容SIWS的纯文本签名。用于钱包身份验证和地址所有权证明。
  • Bitcoin消息 —— BIP-137/BIP-322混合标准。传统(1...)和包装SegWit(3...)地址使用BIP-137;原生SegWit(bc1q)和Taproot(bc1p)地址使用BIP-322 "simple"。兼容Electrum、Bitcoin Core及现代钱包。
  • Schnorr (BIP-340) —— 基于原始32字节摘要的Taproot原生签名。用于Taproot脚本路径支出、多签协作和OP_CHECKSIGADD见证组装。
  • Nostr事件 (NIP-06) —— 使用NIP-06派生密钥(默认路径
    m/44'/1237'/0'/0/0
    )签名Nostr事件对象,也可通过
    keySource
    指定钱包密钥路径。

Usage

使用方法

bun run signing/signing.ts <subcommand> [options]
bun run signing/signing.ts <子命令> [选项]

Subcommands

子命令

sip018-sign

sip018-sign

Sign structured Clarity data using the SIP-018 standard. The domain binding (name + version + chain-id) prevents cross-app and cross-chain replay attacks. Requires an unlocked wallet.
bun run signing/signing.ts sip018-sign \
  --message '{"amount":{"type":"uint","value":100}}' \
  --domain-name "My App" \
  --domain-version "1.0.0"
Options:
  • --message
    (required) — Structured data as a JSON string. Use type hints for explicit Clarity types:
    • {"type":"uint","value":100}
      uint
    • {"type":"int","value":-50}
      int
    • {"type":"principal","value":"SP..."}
      principal
    • {"type":"ascii","value":"hello"}
      string-ascii
    • {"type":"utf8","value":"hello"}
      string-utf8
    • {"type":"buff","value":"0x1234"}
      buff
    • {"type":"bool","value":true}
      bool
    • {"type":"none"}
      none
    • {"type":"some","value":...}
      (some ...)
    • {"type":"list","value":[...]}
      list
    • {"type":"tuple","value":{...}}
      tuple
    • Implicit:
      string → string-utf8
      ,
      number → int
      ,
      boolean → bool
      ,
      null → none
  • --domain-name
    +
    --domain-version
    (required together) — Flat CLI domain fields
  • --domain
    (alternative) — MCP-style JSON object:
    {"name":"My App","version":"1.0.0"}
    (optional
    chainId
    )
Output:
json
{
  "success": true,
  "signature": "abc123...",
  "signatureFormat": "RSV (65 bytes hex)",
  "signer": "SP...",
  "network": "testnet",
  "chainId": 2147483648,
  "hashes": {
    "message": "...",
    "domain": "...",
    "encoded": "...",
    "verification": "...",
    "prefix": "0x534950303138"
  },
  "domain": { "name": "My App", "version": "1.0.0", "chainId": 2147483648 },
  "verificationNote": "Use sip018-verify with the 'verification' hash..."
}
使用SIP-018标准签名结构化Clarity数据。域名绑定(名称+版本+链ID)可防止跨应用和跨链重放攻击。需要解锁钱包。
bun run signing/signing.ts sip018-sign \
  --message '{"amount":{"type":"uint","value":100}}' \
  --domain-name "My App" \
  --domain-version "1.0.0"
选项:
  • --message
    (必填)—— 结构化数据的JSON字符串。使用类型提示指定明确的Clarity类型:
    • {"type":"uint","value":100}
      uint
    • {"type":"int","value":-50}
      int
    • {"type":"principal","value":"SP..."}
      principal
    • {"type":"ascii","value":"hello"}
      string-ascii
    • {"type":"utf8","value":"hello"}
      string-utf8
    • {"type":"buff","value":"0x1234"}
      buff
    • {"type":"bool","value":true}
      bool
    • {"type":"none"}
      none
    • {"type":"some","value":...}
      (some ...)
    • {"type":"list","value":[...]}
      list
    • {"type":"tuple","value":{...}}
      tuple
    • 隐式转换:
      string → string-utf8
      number → int
      boolean → bool
      null → none
  • --domain-name
    +
    --domain-version
    (需同时填写)—— 扁平化CLI域名字段
  • --domain
    (替代方案)—— MCP风格的JSON对象:
    {"name":"My App","version":"1.0.0"}
    (可选
    chainId
输出:
json
{
  "success": true,
  "signature": "abc123...",
  "signatureFormat": "RSV (65 bytes hex)",
  "signer": "SP...",
  "network": "testnet",
  "chainId": 2147483648,
  "hashes": {
    "message": "...",
    "domain": "...",
    "encoded": "...",
    "verification": "...",
    "prefix": "0x534950303138"
  },
  "domain": { "name": "My App", "version": "1.0.0", "chainId": 2147483648 },
  "verificationNote": "Use sip018-verify with the 'verification' hash..."
}

sip018-verify

sip018-verify

Verify a SIP-018 signature and recover the signer's Stacks address. Provide the
verification
hash from
sip018-sign
or
sip018-hash
.
bun run signing/signing.ts sip018-verify \
  --message-hash <verificationHash> \
  --signature <rsv65BytesHex> \
  [--expected-signer <address>]
Options:
  • --message-hash
    (required) — The SIP-018 verification hash (from
    sip018-sign
    /
    sip018-hash
    )
  • --signature
    (required) — Signature in RSV format (65 bytes hex)
  • --expected-signer
    (optional) — Expected signer address to verify against
Output:
json
{
  "success": true,
  "recoveredPublicKey": "03...",
  "recoveredAddress": "SP...",
  "network": "testnet",
  "verification": {
    "expectedSigner": "SP...",
    "isValid": true,
    "message": "Signature is valid for the expected signer"
  }
}
验证SIP-018签名并恢复签名者的Stacks地址。需提供
sip018-sign
sip018-hash
输出中的
verification
哈希值。
bun run signing/signing.ts sip018-verify \
  --message-hash <verificationHash> \
  --signature <rsv65BytesHex> \
  [--expected-signer <address>]
选项:
  • --message-hash
    (必填)—— SIP-018验证哈希(来自
    sip018-sign
    /
    sip018-hash
  • --signature
    (必填)—— RSV格式的签名(65字节十六进制)
  • --expected-signer
    (可选)—— 待验证的预期签名者地址
输出:
json
{
  "success": true,
  "recoveredPublicKey": "03...",
  "recoveredAddress": "SP...",
  "network": "testnet",
  "verification": {
    "expectedSigner": "SP...",
    "isValid": true,
    "message": "Signature is valid for the expected signer"
  }
}

sip018-hash

sip018-hash

Compute the SIP-018 message hash without signing. Returns all hash components needed for off-chain or on-chain verification. Does not require an unlocked wallet.
bun run signing/signing.ts sip018-hash \
  --message '{"amount":{"type":"uint","value":100}}' \
  --domain-name "My App" \
  --domain-version "1.0.0" \
  [--chain-id <id>]
Options:
  • --message
    (required) — Structured data as a JSON string (same format as sip018-sign)
  • --domain-name
    +
    --domain-version
    (required together) — Flat CLI domain fields
  • --domain
    (alternative) — MCP-style JSON object:
    {"name":"My App","version":"1.0.0"}
    (optional
    chainId
    )
  • --chain-id
    (optional) — Chain ID override (takes precedence over
    domain.chainId
    )
Output:
json
{
  "success": true,
  "hashes": {
    "message": "...",
    "domain": "...",
    "encoded": "...",
    "verification": "..."
  },
  "hashConstruction": {
    "prefix": "0x534950303138",
    "formula": "verification = sha256(prefix || domainHash || messageHash)"
  },
  "domain": { "name": "My App", "version": "1.0.0", "chainId": 2147483648 },
  "clarityVerification": {
    "example": "(secp256k1-recover? (sha256 encoded-data) signature)"
  }
}
计算SIP-018消息哈希,无需签名。返回链下或链上验证所需的所有哈希组件。无需解锁钱包。
bun run signing/signing.ts sip018-hash \
  --message '{"amount":{"type":"uint","value":100}}' \
  --domain-name "My App" \
  --domain-version "1.0.0" \
  [--chain-id <id>]
选项:
  • --message
    (必填)—— 结构化数据的JSON字符串(格式与sip018-sign一致)
  • --domain-name
    +
    --domain-version
    (需同时填写)—— 扁平化CLI域名字段
  • --domain
    (替代方案)—— MCP风格的JSON对象:
    {"name":"My App","version":"1.0.0"}
    (可选
    chainId
  • --chain-id
    (可选)—— 链ID覆盖值(优先级高于
    domain.chainId
输出:
json
{
  "success": true,
  "hashes": {
    "message": "...",
    "domain": "...",
    "encoded": "...",
    "verification": "..."
  },
  "hashConstruction": {
    "prefix": "0x534950303138",
    "formula": "verification = sha256(prefix || domainHash || messageHash)"
  },
  "domain": { "name": "My App", "version": "1.0.0", "chainId": 2147483648 },
  "clarityVerification": {
    "example": "(secp256k1-recover? (sha256 encoded-data) signature)"
  }
}

stacks-sign

stacks-sign

Sign a plain text message using the Stacks message signing format. The message is prefixed with
\x17Stacks Signed Message:\n
before hashing (SIWS-compatible). Requires an unlocked wallet.
bun run signing/signing.ts stacks-sign --message "Hello, Stacks!"
Options:
  • --message
    (required) — Plain text message to sign
Output:
json
{
  "success": true,
  "signature": "abc123...",
  "signatureFormat": "RSV (65 bytes hex)",
  "signer": "SP...",
  "network": "testnet",
  "message": {
    "original": "Hello, Stacks!",
    "prefix": "\u0017Stacks Signed Message:\n",
    "prefixHex": "...",
    "hash": "..."
  },
  "verificationNote": "Use stacks-verify with the original message and signature to verify."
}
使用Stacks消息签名格式签名纯文本消息。消息在哈希前会添加前缀
\x17Stacks Signed Message:\n
(兼容SIWS)。需要解锁钱包。
bun run signing/signing.ts stacks-sign --message "Hello, Stacks!"
选项:
  • --message
    (必填)—— 待签名的纯文本消息
输出:
json
{
  "success": true,
  "signature": "abc123...",
  "signatureFormat": "RSV (65 bytes hex)",
  "signer": "SP...",
  "network": "testnet",
  "message": {
    "original": "Hello, Stacks!",
    "prefix": "\u0017Stacks Signed Message:\n",
    "prefixHex": "...",
    "hash": "..."
  },
  "verificationNote": "Use stacks-verify with the original message and signature to verify."
}

stacks-verify

stacks-verify

Verify a Stacks message signature and recover the signer's Stacks address. Compatible with SIWS authentication flows.
bun run signing/signing.ts stacks-verify \
  --message "Hello, Stacks!" \
  --signature <rsv65BytesHex> \
  [--expected-signer <address>]
Options:
  • --message
    (required) — The original plain text message that was signed
  • --signature
    (required) — Signature in RSV format (65 bytes hex)
  • --expected-signer
    (optional) — Expected signer Stacks address
Output:
json
{
  "success": true,
  "signatureValid": true,
  "recoveredPublicKey": "03...",
  "recoveredAddress": "SP...",
  "network": "testnet",
  "message": {
    "original": "Hello, Stacks!",
    "prefix": "\u0017Stacks Signed Message:\n",
    "hash": "..."
  },
  "verification": {
    "expectedSigner": "SP...",
    "signerMatches": true,
    "isFullyValid": true,
    "message": "Signature is valid and matches expected signer"
  }
}
验证Stacks消息签名并恢复签名者的Stacks地址。兼容SIWS身份验证流程。
bun run signing/signing.ts stacks-verify \
  --message "Hello, Stacks!" \
  --signature <rsv65BytesHex> \
  [--expected-signer <address>]
选项:
  • --message
    (必填)—— 原始待签名纯文本消息
  • --signature
    (必填)—— RSV格式的签名(65字节十六进制)
  • --expected-signer
    (可选)—— 预期签名者的Stacks地址
输出:
json
{
  "success": true,
  "signatureValid": true,
  "recoveredPublicKey": "03...",
  "recoveredAddress": "SP...",
  "network": "testnet",
  "message": {
    "original": "Hello, Stacks!",
    "prefix": "\u0017Stacks Signed Message:\n",
    "hash": "..."
  },
  "verification": {
    "expectedSigner": "SP...",
    "signerMatches": true,
    "isFullyValid": true,
    "message": "Signature is valid and matches expected signer"
  }
}

btc-sign

btc-sign

Sign a plain text message using Bitcoin message signing. Automatically selects the signing format based on address type: BIP-137 (65-byte compact signature) for legacy (1...) and wrapped SegWit (3...) addresses; BIP-322 "simple" (witness-serialized) for native SegWit (bc1q) and Taproot (bc1p) addresses. Compatible with Electrum, Bitcoin Core, and modern wallets. Requires an unlocked wallet with Bitcoin keys.
bun run signing/signing.ts btc-sign --message "Hello, Bitcoin!"
Options:
  • --message
    (required) — Plain text message to sign
Output:
json
{
  "success": true,
  "signature": "abc123...",
  "signatureBase64": "...",
  "signatureFormat": "BIP-137 (65 bytes: 1 header + 32 r + 32 s)",
  "signer": "bc1q...",
  "network": "mainnet",
  "addressType": "P2WPKH (native SegWit)",
  "message": {
    "original": "Hello, Bitcoin!",
    "prefix": "\u0018Bitcoin Signed Message:\n",
    "prefixHex": "...",
    "formattedHex": "...",
    "hash": "..."
  },
  "header": { "value": 39, "recoveryId": 0, "addressType": "P2WPKH (native SegWit)" },
  "verificationNote": "Use btc-verify with the original message and signature to verify."
}
使用Bitcoin消息签名格式签名纯文本消息。会根据地址类型自动选择签名格式:传统(1...)和包装SegWit(3...)地址使用BIP-137(65字节紧凑签名);原生SegWit(bc1q)和Taproot(bc1p)地址使用BIP-322 "simple"(见证序列化)。兼容Electrum、Bitcoin Core及现代钱包。需要包含Bitcoin密钥的解锁钱包。
bun run signing/signing.ts btc-sign --message "Hello, Bitcoin!"
选项:
  • --message
    (必填)—— 待签名的纯文本消息
输出:
json
{
  "success": true,
  "signature": "abc123...",
  "signatureBase64": "...",
  "signatureFormat": "BIP-137 (65 bytes: 1 header + 32 r + 32 s)",
  "signer": "bc1q...",
  "network": "mainnet",
  "addressType": "P2WPKH (native SegWit)",
  "message": {
    "original": "Hello, Bitcoin!",
    "prefix": "\u0018Bitcoin Signed Message:\n",
    "prefixHex": "...",
    "formattedHex": "...",
    "hash": "..."
  },
  "header": { "value": 39, "recoveryId": 0, "addressType": "P2WPKH (native SegWit)" },
  "verificationNote": "Use btc-verify with the original message and signature to verify."
}

btc-verify

btc-verify

Verify a Bitcoin message signature (BIP-137 or BIP-322) and recover the signer's Bitcoin address. Automatically detects the format: BIP-137 (65-byte compact, hex 130 chars or base64 88 chars) for legacy/wrapped-SegWit addresses, and BIP-322 "simple" (witness-serialized, base64) for native SegWit (bc1q) and Taproot (bc1p) addresses.
bun run signing/signing.ts btc-verify \
  --message "Hello, Bitcoin!" \
  --signature <hexOrBase64Sig> \
  [--expected-signer <btcAddress>]
Options:
  • --message
    (required) — The original plain text message that was signed
  • --signature
    (required) — Bitcoin signature: BIP-137 (65 bytes as hex [130 chars] or base64 [88 chars]) for legacy/wrapped-SegWit, or BIP-322 "simple" (witness-serialized, base64) for bc1q/bc1p addresses
  • --expected-signer
    (optional) — Expected signer Bitcoin address to verify against
Output:
json
{
  "success": true,
  "signatureValid": true,
  "recoveredPublicKey": "03...",
  "recoveredAddress": "bc1q...",
  "network": "mainnet",
  "message": { "original": "Hello, Bitcoin!", "prefix": "...", "hash": "..." },
  "header": { "value": 39, "recoveryId": 0, "addressType": "P2WPKH (native SegWit)" },
  "verification": {
    "expectedSigner": "bc1q...",
    "signerMatches": true,
    "isFullyValid": true,
    "message": "Signature is valid and matches expected signer"
  }
}
验证Bitcoin消息签名(BIP-137或BIP-322)并恢复签名者的Bitcoin地址。会自动检测签名格式:传统/包装SegWit地址使用BIP-137(65字节紧凑格式,十六进制130字符或Base64 88字符);原生SegWit(bc1q)和Taproot(bc1p)地址使用BIP-322 "simple"(见证序列化,Base64)。
bun run signing/signing.ts btc-verify \
  --message "Hello, Bitcoin!" \
  --signature <hexOrBase64Sig> \
  [--expected-signer <btcAddress>]
选项:
  • --message
    (必填)—— 原始待签名纯文本消息
  • --signature
    (必填)—— Bitcoin签名:传统/包装SegWit地址使用BIP-137(65字节,十六进制130字符或Base64 88字符);bc1q/bc1p地址使用BIP-322 "simple"(见证序列化,Base64)
  • --expected-signer
    (可选)—— 待验证的预期签名者Bitcoin地址
输出:
json
{
  "success": true,
  "signatureValid": true,
  "recoveredPublicKey": "03...",
  "recoveredAddress": "bc1q...",
  "network": "mainnet",
  "message": { "original": "Hello, Bitcoin!", "prefix": "...", "hash": "..." },
  "header": { "value": 39, "recoveryId": 0, "addressType": "P2WPKH (native SegWit)" },
  "verification": {
    "expectedSigner": "bc1q...",
    "signerMatches": true,
    "isFullyValid": true,
    "message": "Signature is valid and matches expected signer"
  }
}

schnorr-sign-digest

schnorr-sign-digest

Sign a raw 32-byte digest with Schnorr (BIP-340) using the wallet's Taproot private key. Use for Taproot script-path spending, multisig coordination, or any case where you need a BIP-340 Schnorr signature over a pre-computed hash (e.g., BIP-341 sighash). Includes a blind-signing safety gate — the first call without
--confirm-blind-sign
returns the digest for review. Requires an unlocked wallet with Taproot keys.
bun run signing/signing.ts schnorr-sign-digest \
  --digest <64-char-hex> \
  [--aux-rand <64-char-hex>] \
  [--confirm-blind-sign]
Options:
  • --digest
    (required) — 32-byte hex-encoded digest to sign (e.g., BIP-341 transaction sighash)
  • --aux-rand
    (optional) — 32-byte hex auxiliary randomness for BIP-340 (improves side-channel resistance)
  • --confirm-blind-sign
    (optional) — Set to confirm you have reviewed the digest and accept blind-signing risk. Without this flag, returns a warning with the digest for review.
Output (without
--confirm-blind-sign
):
json
{
  "warning": "schnorr-sign-digest signs a raw 32-byte digest...",
  "digestToReview": "abc123...",
  "instructions": "Review the digest above. If you trust its origin..."
}
Output (with
--confirm-blind-sign
):
json
{
  "success": true,
  "signature": "abc123...",
  "publicKey": "def456...",
  "address": "bc1p...",
  "network": "mainnet",
  "signatureFormat": "BIP-340 Schnorr (64 bytes)",
  "publicKeyFormat": "x-only (32 bytes)",
  "note": "For Taproot script-path spending, append sighash type byte..."
}
使用钱包的Taproot私钥,通过Schnorr(BIP-340)签名原始32字节摘要。用于Taproot脚本路径支出、多签协作,或任何需要对预计算哈希(如BIP-341 sighash)进行BIP-340 Schnorr签名的场景。包含盲签安全机制 —— 首次调用未携带
--confirm-blind-sign
时,会返回摘要供审核。需要包含Taproot密钥的解锁钱包。
bun run signing/signing.ts schnorr-sign-digest \
  --digest <64-char-hex> \
  [--aux-rand <64-char-hex>] \
  [--confirm-blind-sign]
选项:
  • --digest
    (必填)—— 待签名的32字节十六进制编码摘要(如BIP-341交易sighash)
  • --aux-rand
    (可选)—— 32字节十六进制辅助随机数,用于BIP-340(提升侧信道攻击抗性)
  • --confirm-blind-sign
    (可选)—— 设置该参数表示已审核摘要并接受盲签风险。未携带该参数时,会返回警告及待审核的摘要。
未携带
--confirm-blind-sign
时的输出:
json
{
  "warning": "schnorr-sign-digest signs a raw 32-byte digest...",
  "digestToReview": "abc123...",
  "instructions": "Review the digest above. If you trust its origin..."
}
携带
--confirm-blind-sign
时的输出:
json
{
  "success": true,
  "signature": "abc123...",
  "publicKey": "def456...",
  "address": "bc1p...",
  "network": "mainnet",
  "signatureFormat": "BIP-340 Schnorr (64 bytes)",
  "publicKeyFormat": "x-only (32 bytes)",
  "note": "For Taproot script-path spending, append sighash type byte..."
}

schnorr-verify-digest

schnorr-verify-digest

Verify a BIP-340 Schnorr signature over a 32-byte digest. Takes the digest, signature, and x-only public key, returns whether the signature is valid. Use for verifying Taproot signatures from other agents in multisig coordination.
bun run signing/signing.ts schnorr-verify-digest \
  --digest <64-char-hex> \
  --signature <128-char-hex> \
  --public-key <64-char-hex>
Options:
  • --digest
    (required) — 32-byte hex-encoded digest that was signed
  • --signature
    (required) — 64-byte hex-encoded BIP-340 Schnorr signature
  • --public-key
    (required) — 32-byte hex-encoded x-only public key of the signer
Output:
json
{
  "success": true,
  "isValid": true,
  "digest": "abc123...",
  "signature": "def456...",
  "publicKey": "789abc...",
  "message": "Signature is valid for the given digest and public key",
  "note": "BIP-340 Schnorr verification. Use for validating signatures in Taproot multisig coordination."
}
验证基于32字节摘要的BIP-340 Schnorr签名。需提供摘要、签名和x-only公钥,返回签名是否有效。用于验证多签协作中其他节点的Taproot签名。
bun run signing/signing.ts schnorr-verify-digest \
  --digest <64-char-hex> \
  --signature <128-char-hex> \
  --public-key <64-char-hex>
选项:
  • --digest
    (必填)—— 已签名的32字节十六进制编码摘要
  • --signature
    (必填)—— 64字节十六进制编码的BIP-340 Schnorr签名
  • --public-key
    (必填)—— 32字节十六进制编码的签名者x-only公钥
输出:
json
{
  "success": true,
  "isValid": true,
  "digest": "abc123...",
  "signature": "def456...",
  "publicKey": "789abc...",
  "message": "Signature is valid for the given digest and public key",
  "note": "BIP-340 Schnorr verification. Use for validating signatures in Taproot multisig coordination."
}

nostr-sign-event

nostr-sign-event

Sign a Nostr event object (NIP-01 format) using the wallet's Nostr key. By default the key is derived via NIP-06 (
m/44'/1237'/0'/0/0
) from the wallet mnemonic, producing an
npub
that matches NIP-06 compliant Nostr clients (e.g. Amethyst, Damus, Snort). Requires an unlocked wallet.
bun run signing/signing.ts nostr-sign-event \
  --event '{"kind":1,"created_at":1700000000,"tags":[],"content":"Hello, Nostr!"}' \
  [--key-source nostr|taproot|segwit]
Options:
  • --event
    (required) — Nostr event JSON object (NIP-01 format). Fields
    id
    ,
    pubkey
    , and
    sig
    are computed and returned; do not include them in the input.
  • --key-source
    (optional, default:
    "nostr"
    ) — Which wallet key to use for signing:
    • "nostr"
      (default) — NIP-06 derived key (
      m/44'/1237'/0'/0/0
      ). Use this for new identities and compatibility with all NIP-06 Nostr clients.
    • "taproot"
      — BIP-86 Taproot key (
      m/86'/0'/0'/0/0
      ). Use if you already have an existing Nostr identity on your Taproot key.
    • "segwit"
      — BIP-84 native SegWit key (
      m/84'/0'/0'/0/0
      ). Use if you already have an existing Nostr identity on your SegWit key.
Output:
json
{
  "success": true,
  "event": {
    "id": "abc123...",
    "pubkey": "def456...",
    "created_at": 1700000000,
    "kind": 1,
    "tags": [],
    "content": "Hello, Nostr!",
    "sig": "789abc..."
  },
  "npub": "npub1...",
  "keySource": "nostr",
  "derivationPath": "m/44'/1237'/0'/0/0",
  "note": "Key derived via NIP-06. npub matches NIP-06 compliant Nostr clients."
}
Key derivation note: The default
"nostr"
source uses NIP-06 (
m/44'/1237'/0'/0/0
), the standard Nostr derivation path defined in the NIP-06 spec. Agents should use this default for all Nostr interactions. The
keySource
override is only needed when an existing Nostr identity was previously established on a different key path.
使用钱包的Nostr密钥签名Nostr事件对象(NIP-01格式)。默认从钱包助记词通过NIP-06派生密钥(路径
m/44'/1237'/0'/0/0
),生成的
npub
兼容NIP-06标准的Nostr客户端(如Amethyst、Damus、Snort)。需要解锁钱包。
bun run signing/signing.ts nostr-sign-event \
  --event '{"kind":1,"created_at":1700000000,"tags":[],"content":"Hello, Nostr!"}' \
  [--key-source nostr|taproot|segwit]
选项:
  • --event
    (必填)—— NIP-01格式的Nostr事件JSON对象。
    id
    pubkey
    sig
    字段会自动计算并返回,无需在输入中包含。
  • --key-source
    (可选,默认值:
    "nostr"
    )—— 签名使用的钱包密钥来源:
    • "nostr"
      (默认)—— NIP-06派生密钥(路径
      m/44'/1237'/0'/0/0
      )。用于创建新身份,兼容所有NIP-06标准的Nostr客户端。
    • "taproot"
      —— BIP-86 Taproot密钥(路径
      m/86'/0'/0'/0/0
      )。适用于已在Taproot密钥上创建Nostr身份的场景。
    • "segwit"
      —— BIP-84原生SegWit密钥(路径
      m/84'/0'/0'/0/0
      )。适用于已在SegWit密钥上创建Nostr身份的场景。
输出:
json
{
  "success": true,
  "event": {
    "id": "abc123...",
    "pubkey": "def456...",
    "created_at": 1700000000,
    "kind": 1,
    "tags": [],
    "content": "Hello, Nostr!",
    "sig": "789abc..."
  },
  "npub": "npub1...",
  "keySource": "nostr",
  "derivationPath": "m/44'/1237'/0'/0/0",
  "note": "Key derived via NIP-06. npub matches NIP-06 compliant Nostr clients."
}
密钥派生说明:默认的
"nostr"
来源使用NIP-06(路径
m/44'/1237'/0'/0/0
),这是NIP-06规范定义的标准Nostr派生路径。所有Nostr交互应使用此默认值。仅当已在其他密钥路径上创建过Nostr身份时,才需要使用
keySource
覆盖默认设置。

Signing Standards Reference

签名标准参考

StandardPrefixUse CaseOn-Chain Verifiable?
SIP-018
SIP018
(hex)
Structured Clarity dataYes (
secp256k1-recover?
)
Stacks
\x17Stacks Signed Message:\n
Auth, ownership proofNo (off-chain only)
BIP-137 / BIP-322
\x18Bitcoin Signed Message:\n
Bitcoin auth, ownership proof (BIP-137 for 1.../3...; BIP-322 for bc1q/bc1p)No (off-chain only)
BIP-340None (raw digest)Taproot multisig, script-path spendingYes (OP_CHECKSIG/OP_CHECKSIGADD)
NIP-06 (Nostr)None (event hash)Nostr event signing (NIP-01)No (Nostr network only)
标准前缀使用场景是否可链上验证?
SIP-018
SIP018
(十六进制)
结构化Clarity数据是(通过
secp256k1-recover?
Stacks
\x17Stacks Signed Message:\n
身份验证、所有权证明否(仅链下)
BIP-137 / BIP-322
\x18Bitcoin Signed Message:\n
Bitcoin身份验证、所有权证明(1.../3...地址用BIP-137;bc1q/bc1p地址用BIP-322)否(仅链下)
BIP-340无(原始摘要)Taproot多签、脚本路径支出是(通过OP_CHECKSIG/OP_CHECKSIGADD)
NIP-06 (Nostr)无(事件哈希)Nostr事件签名(NIP-01)否(仅Nostr网络内)

Notes

注意事项

  • SIP-018 signing and Stacks signing require an unlocked wallet (
    bun run wallet/wallet.ts unlock
    )
  • BTC signing additionally requires Bitcoin keys (automatically present in managed wallets)
  • Schnorr signing requires Taproot keys (automatically derived in managed wallets)
  • sip018-hash
    , both
    *-verify
    subcommands, and
    schnorr-verify-digest
    do NOT require an unlocked wallet
  • All ECDSA signatures use the secp256k1 curve; Schnorr uses BIP-340 (x-only pubkeys, 64-byte sigs)
  • SIP-018 chain IDs: mainnet = 1, testnet = 2147483648 (0x80000000)
  • SIP-018签名和Stacks签名需要解锁钱包(执行
    bun run wallet/wallet.ts unlock
  • BTC签名还需要Bitcoin密钥(托管钱包会自动包含)
  • Schnorr签名需要Taproot密钥(托管钱包会自动派生)
  • sip018-hash
    、所有
    *-verify
    子命令和
    schnorr-verify-digest
    无需解锁钱包
  • 所有ECDSA签名使用secp256k1曲线;Schnorr使用BIP-340(x-only公钥,64字节签名)
  • SIP-018链ID:主网 = 1,测试网 = 2147483648(0x80000000)