Skip to Content
QR 署名Solana
このページの内容

Solana

Solana のオフライン署名用 UR レジストリタイプ。

データ型

  • リクエスト UR: sol-sign-request (トランザクション/メッセージのバイト列 + BIP-44 パス)
  • レスポンス UR: sol-signature

フロー

  1. Solana のトランザクションまたはメッセージのバイト列と導出パスを準備
  2. sol-sign-request を構築し、アニメーション QR として表示
  3. デバイスのレスポンスをスキャン → sol-signature をデコード → トランザクションに添付
  4. Solana ネットワークに送信

例

@keystonehq/bc-ur-registry-sol および @ngraveio/bc-ur をインストールします。例には Buffer の実装が必要です。レジストリのエンコードだけではデバイスの対応は確認できません。対象ファームウェアが受け付ける UR タイプを検証してください。

ウォレットは、未署名のトランザクションデータと、デバイスからエクスポートした実際のアカウントパスおよびマスターフィンガープリントを提供します。QR レンダラーはタイマーで nextFrame() を定期的に呼び出し、署名ダイアログが閉じたら停止します。これらのスニペットは転送データのエンコードとデコードを行うもので、トランザクションを送信するものではありません。

Solana 署名リクエストを構築 (UR)

import { SolSignRequest, SignType, CryptoKeypath, PathComponent } from '@keystonehq/bc-ur-registry-sol'; // BIP44: m/44'/501'/0' const keypath = new CryptoKeypath([ new PathComponent({ index: 44, hardened: true }), new PathComponent({ index: 501, hardened: true }), new PathComponent({ index: 0, hardened: true }), ], Buffer.from(masterFingerprintHex, 'hex')); const requestId = globalThis.crypto.randomUUID(); const requestIdBytes = Buffer.from(requestId.replace(/-/g, ''), 'hex'); const req = new SolSignRequest({ requestId: requestIdBytes, signData: Buffer.from(rawTxBytes), // transaction or message bytes derivationPath: keypath, signType: SignType.Transaction, // or SignType.Message }); const encoder = req.toUREncoder(200); const nextFrame = () => encoder.nextPart(); // Call from your QR animation timer.

Solana 署名をデコード (UR)

import { URDecoder } from '@ngraveio/bc-ur'; import { SolSignature } from '@keystonehq/bc-ur-registry-sol'; const dec = new URDecoder(); // dec.receivePart(frameString) for each scanned frame if (dec.isError()) throw new Error('QR decoding failed'); if (dec.isSuccess()) { const ur = dec.resultUR(); if (ur.type !== 'sol-signature') throw new Error('Expected sol-signature'); const sig = SolSignature.fromCBOR(ur.cbor); const returnedId = sig.getRequestId(); if (!returnedId || !returnedId.equals(requestIdBytes)) { throw new Error('Signature request ID does not match'); } const signature = sig.getSignature(); // Verify the signer and signature against the original payload before use. // Attach transaction signatures to the original transaction; return message signatures to the caller. }
最終更新日