signing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSigning 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 () by default, or from a wallet key path via
m/44'/1237'/0'/0/0.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派生密钥(默认路径)签名Nostr事件对象,也可通过
m/44'/1237'/0'/0/0指定钱包密钥路径。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:
- (required) — Structured data as a JSON string. Use type hints for explicit Clarity types:
--message- →
{"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 → boolnull → none
- +
--domain-name(required together) — Flat CLI domain fields--domain-version - (alternative) — MCP-style JSON object:
--domain(optional{"name":"My App","version":"1.0.0"})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"选项:
- (必填)—— 结构化数据的JSON字符串。使用类型提示指定明确的Clarity类型:
--message- →
{"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 → boolnull → none
- +
--domain-name(需同时填写)—— 扁平化CLI域名字段--domain-version - (替代方案)—— MCP风格的JSON对象:
--domain(可选{"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 hash from or .
verificationsip018-signsip018-hashbun run signing/signing.ts sip018-verify \
--message-hash <verificationHash> \
--signature <rsv65BytesHex> \
[--expected-signer <address>]Options:
- (required) — The SIP-018 verification hash (from
--message-hash/sip018-sign)sip018-hash - (required) — Signature in RSV format (65 bytes hex)
--signature - (optional) — Expected signer address to verify against
--expected-signer
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-signsip018-hashverificationbun run signing/signing.ts sip018-verify \
--message-hash <verificationHash> \
--signature <rsv65BytesHex> \
[--expected-signer <address>]选项:
- (必填)—— SIP-018验证哈希(来自
--message-hash/sip018-sign)sip018-hash - (必填)—— RSV格式的签名(65字节十六进制)
--signature - (可选)—— 待验证的预期签名者地址
--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:
- (required) — Structured data as a JSON string (same format as sip018-sign)
--message - +
--domain-name(required together) — Flat CLI domain fields--domain-version - (alternative) — MCP-style JSON object:
--domain(optional{"name":"My App","version":"1.0.0"})chainId - (optional) — Chain ID override (takes precedence over
--chain-id)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>]选项:
- (必填)—— 结构化数据的JSON字符串(格式与sip018-sign一致)
--message - +
--domain-name(需同时填写)—— 扁平化CLI域名字段--domain-version - (替代方案)—— MCP风格的JSON对象:
--domain(可选{"name":"My App","version":"1.0.0"})chainId - (可选)—— 链ID覆盖值(优先级高于
--chain-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 before hashing (SIWS-compatible). Requires an unlocked wallet.
\x17Stacks Signed Message:\nbun run signing/signing.ts stacks-sign --message "Hello, Stacks!"Options:
- (required) — Plain text message to sign
--message
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消息签名格式签名纯文本消息。消息在哈希前会添加前缀(兼容SIWS)。需要解锁钱包。
\x17Stacks Signed Message:\nbun 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:
- (required) — The original plain text message that was signed
--message - (required) — Signature in RSV format (65 bytes hex)
--signature - (optional) — Expected signer Stacks address
--expected-signer
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 - (必填)—— RSV格式的签名(65字节十六进制)
--signature - (可选)—— 预期签名者的Stacks地址
--expected-signer
输出:
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:
- (required) — Plain text message to sign
--message
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:
- (required) — The original plain text message that was signed
--message - (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
--signature - (optional) — Expected signer Bitcoin address to verify against
--expected-signer
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 - (必填)—— Bitcoin签名:传统/包装SegWit地址使用BIP-137(65字节,十六进制130字符或Base64 88字符);bc1q/bc1p地址使用BIP-322 "simple"(见证序列化,Base64)
--signature - (可选)—— 待验证的预期签名者Bitcoin地址
--expected-signer
输出:
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 returns the digest for review. Requires an unlocked wallet with Taproot keys.
--confirm-blind-signbun run signing/signing.ts schnorr-sign-digest \
--digest <64-char-hex> \
[--aux-rand <64-char-hex>] \
[--confirm-blind-sign]Options:
- (required) — 32-byte hex-encoded digest to sign (e.g., BIP-341 transaction sighash)
--digest - (optional) — 32-byte hex auxiliary randomness for BIP-340 (improves side-channel resistance)
--aux-rand - (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.
--confirm-blind-sign
Output (without ):
--confirm-blind-signjson
{
"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-signjson
{
"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签名的场景。包含盲签安全机制 —— 首次调用未携带时,会返回摘要供审核。需要包含Taproot密钥的解锁钱包。
--confirm-blind-signbun run signing/signing.ts schnorr-sign-digest \
--digest <64-char-hex> \
[--aux-rand <64-char-hex>] \
[--confirm-blind-sign]选项:
- (必填)—— 待签名的32字节十六进制编码摘要(如BIP-341交易sighash)
--digest - (可选)—— 32字节十六进制辅助随机数,用于BIP-340(提升侧信道攻击抗性)
--aux-rand - (可选)—— 设置该参数表示已审核摘要并接受盲签风险。未携带该参数时,会返回警告及待审核的摘要。
--confirm-blind-sign
未携带时的输出:
--confirm-blind-signjson
{
"warning": "schnorr-sign-digest signs a raw 32-byte digest...",
"digestToReview": "abc123...",
"instructions": "Review the digest above. If you trust its origin..."
}携带时的输出:
--confirm-blind-signjson
{
"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:
- (required) — 32-byte hex-encoded digest that was signed
--digest - (required) — 64-byte hex-encoded BIP-340 Schnorr signature
--signature - (required) — 32-byte hex-encoded x-only public key of the signer
--public-key
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>选项:
- (必填)—— 已签名的32字节十六进制编码摘要
--digest - (必填)—— 64字节十六进制编码的BIP-340 Schnorr签名
--signature - (必填)—— 32字节十六进制编码的签名者x-only公钥
--public-key
输出:
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 () from the wallet mnemonic, producing an that matches NIP-06 compliant Nostr clients (e.g. Amethyst, Damus, Snort). Requires an unlocked wallet.
m/44'/1237'/0'/0/0npubbun run signing/signing.ts nostr-sign-event \
--event '{"kind":1,"created_at":1700000000,"tags":[],"content":"Hello, Nostr!"}' \
[--key-source nostr|taproot|segwit]Options:
- (required) — Nostr event JSON object (NIP-01 format). Fields
--event,id, andpubkeyare computed and returned; do not include them in the input.sig - (optional, default:
--key-source) — Which wallet key to use for signing:"nostr"- (default) — NIP-06 derived key (
"nostr"). Use this for new identities and compatibility with all NIP-06 Nostr clients.m/44'/1237'/0'/0/0 - — BIP-86 Taproot key (
"taproot"). Use if you already have an existing Nostr identity on your Taproot key.m/86'/0'/0'/0/0 - — BIP-84 native SegWit key (
"segwit"). Use if you already have an existing Nostr identity on your SegWit key.m/84'/0'/0'/0/0
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 source uses NIP-06 (), the standard Nostr derivation path defined in the NIP-06 spec. Agents should use this default for all Nostr interactions. The override is only needed when an existing Nostr identity was previously established on a different key path.
"nostr"m/44'/1237'/0'/0/0keySource使用钱包的Nostr密钥签名Nostr事件对象(NIP-01格式)。默认从钱包助记词通过NIP-06派生密钥(路径),生成的兼容NIP-06标准的Nostr客户端(如Amethyst、Damus、Snort)。需要解锁钱包。
m/44'/1237'/0'/0/0npubbun run signing/signing.ts nostr-sign-event \
--event '{"kind":1,"created_at":1700000000,"tags":[],"content":"Hello, Nostr!"}' \
[--key-source nostr|taproot|segwit]选项:
- (必填)—— NIP-01格式的Nostr事件JSON对象。
--event、id和pubkey字段会自动计算并返回,无需在输入中包含。sig - (可选,默认值:
--key-source)—— 签名使用的钱包密钥来源:"nostr"- (默认)—— NIP-06派生密钥(路径
"nostr")。用于创建新身份,兼容所有NIP-06标准的Nostr客户端。m/44'/1237'/0'/0/0 - —— BIP-86 Taproot密钥(路径
"taproot")。适用于已在Taproot密钥上创建Nostr身份的场景。m/86'/0'/0'/0/0 - —— BIP-84原生SegWit密钥(路径
"segwit")。适用于已在SegWit密钥上创建Nostr身份的场景。m/84'/0'/0'/0/0
输出:
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."
}密钥派生说明:默认的来源使用NIP-06(路径),这是NIP-06规范定义的标准Nostr派生路径。所有Nostr交互应使用此默认值。仅当已在其他密钥路径上创建过Nostr身份时,才需要使用覆盖默认设置。
"nostr"m/44'/1237'/0'/0/0keySourceSigning Standards Reference
签名标准参考
| Standard | Prefix | Use Case | On-Chain Verifiable? |
|---|---|---|---|
| SIP-018 | | Structured Clarity data | Yes ( |
| Stacks | | Auth, ownership proof | No (off-chain only) |
| BIP-137 / BIP-322 | | Bitcoin auth, ownership proof (BIP-137 for 1.../3...; BIP-322 for bc1q/bc1p) | No (off-chain only) |
| BIP-340 | None (raw digest) | Taproot multisig, script-path spending | Yes (OP_CHECKSIG/OP_CHECKSIGADD) |
| NIP-06 (Nostr) | None (event hash) | Nostr event signing (NIP-01) | No (Nostr network only) |
| 标准 | 前缀 | 使用场景 | 是否可链上验证? |
|---|---|---|---|
| SIP-018 | | 结构化Clarity数据 | 是(通过 |
| Stacks | | 身份验证、所有权证明 | 否(仅链下) |
| BIP-137 / BIP-322 | | 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)
- , both
sip018-hashsubcommands, and*-verifydo NOT require an unlocked walletschnorr-verify-digest - 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)