Bip47

BIP 47:Bob 的第一個接收地址?

  • February 25, 2019

在通知事務發生後,我正在嘗試根據BIP 47 規範創建 Bob 的第一個接收(臨時)地址,我認為這是:

141fi7TY3h936vRUKh1qfUZr8rSBuYbVBK

根據這些測試向量。我無法通過以下方式計​​算出與該地址對應的正確臨時公鑰 (B’):

B' = B + sG

或通過以下方式獲得臨時地址的正確私鑰 (b’):

b' = b + s

到目前為止,我為第一個地址提出的變數包括:

// Alice selects the 0th private key derived from her payment code:
a = 8d6a8ecd8ee5e0042ad0cb56e3a971c760b5145c3917a8e7beaf0ed92d7a520c

// Alice selects the next unused public key derived from Bob's payment code, 
// starting from zero:
B = 024ce8e3b04ea205ff49f529950616c3db615b1e37753858cc60c1ce64d17e2ad8

// Alice calculates a secret point:
S = 03f5bb84706ee366052471e6139e6a9a969d586e5fe6471a9b96c3d8caefe86fef

// Alice calculates a scalar shared secret using the x value of S:
// x value = f5bb84706ee366052471e6139e6a9a969d586e5fe6471a9b96c3d8caefe86fef
// SHA256(x value)
s = d24366e662da47c0cccca4cc2d2d817af54e4d21039c0cc4fc441624efe273f7

// s multiplied by generator point
sG = 0283850c6835576554261fbab5845a099638859528b2725455e6a48e7566415c02

// Alice uses the scalar shared secret to calculate the ephemeral public key 
// used to generate the P2PKH address for this transaction:
B' = 0344b4795e48df097bd87e6cf87a70e4f0c30b2d847b6e34cddde64af10296952d



// Bob's first private key
b = 04448fd1be0c9c13a5ca0b530e464b619dc091b299b98c5cab9978b32b4a1b8b

b' = d687f6b820e6e3d47296b01f3b73ccdc930eded39d559921a7dd8ed81b2c8f82

這些變數中是否有任何不正確,如果是,如何獲得正確的變數?

Felix Engelmann和我今晚坐下來,我們使用了bxvia libbitcoin。我們已經能夠從測試向量中生成地址以及您的中間結果

a='8d6a8ecd8ee5e0042ad0cb56e3a971c760b5145c3917a8e7beaf0ed92d7a520c'
B='024ce8e3b04ea205ff49f529950616c3db615b1e37753858cc60c1ce64d17e2ad8'
S=$(bx ec-multiply $B $a)
echo $S
> 03f5bb84706ee366052471e6139e6a9a969d586e5fe6471a9b96c3d8caefe86fef

s=$(bx sha256 'f5bb84706ee366052471e6139e6a9a969d586e5fe6471a9b96c3d8caefe86fef')
echo $s
> d24366e662da47c0cccca4cc2d2d817af54e4d21039c0cc4fc441624efe273f7

sG=$(bx ec-to-public $s)
echo $sG
> 0283850c6835576554261fbab5845a099638859528b2725455e6a48e7566415c02

B_prime=$(bx ec-add $B $s)
echo $B_prime
> 0344b4795e48df097bd87e6cf87a70e4f0c30b2d847b6e34cddde64af10296952d

addr=$(bx ec-to-address -v 0 $B_prime)
echo $addr
> 141fi7TY3h936vRUKh1qfUZr8rSBuYbVBK

請注意,我們的價值如您B_prime0344b4795e48df097bd87e6cf87a70e4f0c30b2d847b6e34cddde64af10296952d建議的那樣。實際上將其編碼為比特幣地址似乎有點棘手,因為如果不通過-v 0它將使用測試網地址。也許你在使用比特幣核心時也有類似的問題?我不知道用於將 pub key / ec 點轉換為比特幣核心中的地址的 API。

無論如何,我認為你做的一切都是正確的,你只是在編碼 P2PKH 地址時犯了一個錯誤。

引用自:https://bitcoin.stackexchange.com/questions/84774