使用 UTXO 須要私鑰簽名,私鑰到底都簽了什麼東西呢?一直比較好奇.
比特幣的私鑰簽名總共有五中類型,具體見 btcd 代碼,以下:安全
// SigHashType represents hash type bits at the end of a signature. type SigHashType uint32 // Hash type bits from the end of a signature. const ( SigHashOld SigHashType = 0x0 SigHashAll SigHashType = 0x1 SigHashNone SigHashType = 0x2 SigHashSingle SigHashType = 0x3 SigHashAnyOneCanPay SigHashType = 0x80 // sigHashMask defines the number of bits of the hash type which is used // to identify which outputs are signed. sigHashMask = 0x1f )
從代碼看,二者是同樣的.具體簽名內容見圖.
主要內容:
全部的 TxIn,全部的 TxOut, 可是不包含簽名自己(這個是不可能作到包含自身的).
這是目前主要的簽名用法.
ide
主要內容:
全部TxIn, 可是不包含 TxOut
我不知道這種簽名用在什麼地方, TxOut能夠讓別人隨便改.ui
對全部的 TxIn和某個 TxOut 進行簽名
不清楚用途
3d
對當前TxIn 和全部 TxOut 進行簽名
這個能夠保證輸入輸出的安全,可是由於沒有包含TxIn 之間的順序關係. 全部這個 Tx 的 ID 是能夠被修改的.
code