本文へスキップ
ecdsa.com
Bitcoin Core RPCWeb3 ウォレットと署名

エラーメッセージ

Address does not refer to key

別の表記

  • error code: -3 error message: Address does not refer to key

`bitcoin-cli` は、メッセージ本文の前の行に「error code: -3」と「error message:」を出力します。JSON-RPC クライアントには `{"code": -3, "message": "Address does not refer to key"}` が返されます。

Bitcoin Core RPC — verifymessage / signmessage with a non-P2PKH address

このエラーの意味

Bitcoin Core のメッセージ署名(`signmessage`/`verifymessage`)は、初期の「Bitcoin Signed Message」方式を実装しており、この方式はレガシー P2PKH アドレスでしか機能しません。署名から公開鍵を復元し、Core がそのハッシュをアドレスと比較する仕組みです。ネイティブ SegWit(`bc1q…`)、Taproot(`bc1p…`)、P2SH(`3…`)のアドレスは、この意味で「鍵」を指すアドレスではないため、Core は true や false を返すのではなく、RPC エラー -3 で拒否します。

発生する理由

修正方法

  1. 1.

    Core のレガシーアドレスで署名する

    相手方が必要としているのがウォレット内の鍵を管理していることの証明だけであれば、証明用にレガシーアドレスを作成してください。

    bash
    # Bitcoin Core signs and verifies messages only for legacy P2PKH addresses (1... / m... / n...)
    addr=$(bitcoin-cli getnewaddress "proof" legacy)
    sig=$(bitcoin-cli signmessage "$addr" "I own this address")
    bitcoin-cli verifymessage "$addr" "$sig" "I own this address"
  2. 2.

    SegWit と Taproot には BIP-322 を使う

    BIP-322 は、すべてのアドレスタイプに対応したメッセージ署名を定義しています。BIP-322 を実装したライブラリまたはウォレットを使い、検証者とも BIP-322 を使うことで合意してください。

    js
    // SegWit / Taproot addresses: BIP-322 "simple" signatures, e.g. with the bip322-js library
    import { Verifier } from "bip322-js";
    
    const ok = Verifier.verifySignature("bc1q...", "I own this address", signatureBase64);

関連するエラー

署名エラーデータベースをすべて見る