Payment code
BIP47
samourai が PayNym を実装
Sparrow wallet が対応
Release 1.6.2 · sparrowwallet/sparrow
BDK にも入りそう
Feature Request: BIP47 payment codes for private donations (PayNym) · Issue #549 · bitcoindevkit/bdk
Luke Dashjr さんが反対しているけど、技術的な理由が不明
Comments:BIP 0047 · bitcoin/bips Wiki
新しいバージョンのドラフトがある
rfc/obpp-05.mediawiki at master · OpenBitcoinPrivacyProject/rfc
bips/bip-0047.mediawiki at master · bitcoin/bips
BIP47 test vectors
再利用可能なペイメントコードを使った二者間の決済アドレスの導出方法を定義したBIP-47 - Develop with pleasure!
privacy - How do Reusable Payment Codes work? - Bitcoin Stack Exchange
BIP-47: Reusable payment codes
bip47 - BIP 47: Bob's first receive address? - Bitcoin Stack Exchange
Ruby実装
BIP47_Prague_Discussion.md by Ruben Somsen
Discussions
https://twitter.com/BitcoinQ_A/status/1356296850874236931?s=20
BIP21
Payment Code generation
Payment code = BIP32 の xpub key をエンコードしたもの
Derivation Path は m/47'/ 0' /0'
ルールは BIP に記載
https://github.com/bitcoin/bips/blob/master/bip-0047.mediawiki#representation
A payment code contains the following elements:
Byte 0: version. required value: 0x01
Byte 1: features bit field. All bits must be zero except where specified elsewhere in this specification
Bit 0: Bitmessage notification
Bits 1-7: reserved
Byte 2: sign
compressed pubkey の偶奇を表すフラグ
Bytes 3 - 34: x value, must be a member of the secp256k1 group
m/47'/ 0' /0' の compressed pubkey の x 軸の値
Bytes 35 - 66: chain code
Bytes 67 - 79: reserved for future expansion, zero-filled unless otherwise noted
Notification Transaction
送金相手に自分の Payment Code を伝えるための transaction
notification address に対して送金する
notification address とは
Notification address: the P2PKH address associated with the 0th public key derived from a payment code
47'/0'/0'/0
最後は non hurdend
notification address は常に同じ?
自分のPayment Code をマスクして OP_RETURN に入れておく
マスクする値は ECDH で送金相手に共有されるため、送金相手だけが Payment Code を知ることができる
Payment Code 自体は公開されていても問題ないものであるが、notification 内に生で書かれていると、Payment Code の持ち主の transaction であることが、Payment Code の持ち主を知っている人にはわかってしまう。
unmask するためには shared secret と outpoint がわかればよい
outpoint は既知
shared secret は ECDH で共有
Payment Codeへの transaction: sending
Alice to Bob
Payment code とは xpubkey である
HD wallet の原理で決定的に pubkey を導出することが可能
Alice は自身の private key と Bob の未使用 publickey から Shared Secret を生成する。
未使用の定義は Alice と Bob 間での話である。
すなわち、Alice から Bob への一番目 transaction と Chrol から Bob への一番目の transaction に用いられる Bob のpublic key は同じ
Alice と Charol は private key が異なるからBob の同じ pubkey を使っても送金先 public key は異なるものになる
Bob は Alice の pubkey がわかっていれば、pubkey を導出することが可能
notification tx が必要
Alice の payment code の最初の子pubkey
https://gyazo.com/333c4533b3decd15399687d9eb513e3e
Recovery
自分が受け取った tx については blockchain があれば復元可能
自分が送ったものは、相手の payment code の情報は blockchain にはないので復元できない
別の backup が必要
Downside
notification tx が必要
すぐに送金できない
blockスペースを消費する
コスト