Hash

What is the reason to separate domains in the internal hash algorithm of a merkle tree hash?

  • September 11, 2019

From rfc 6962 It is stated that:

Note that the hash calculations for leaves and nodes differ. This domain separation is required to give second preimage resistance.

That means that whenever the hash computes on leaves a distinct known element is preappend to the element [Math Processing Error] $ e $ :

[Math Processing Error]$$ H(0\mathbin|e) $$ and whenever hash applied to parent nodes for leaves [Math Processing Error] $ h_0=H(0\mathbin|e_0) $ [Math Processing Error] $ h_1=H(0\mathbin|e_1) $ then [Math Processing Error] $ 1 $ is being put in the beggining: [Math Processing Error]$$ h_2=H(1\mathbin|h_0\mathbin|h_1) $$ 目前尚不清楚如果 $ 0,1 $ 不附加到散列以分隔兩個域。作者指出,這樣做是為了防止第二原像攻擊。但是從 Merkle 樹雜湊我們需要從雜湊函式[Math Processing Error] $ H $ 防碰撞

您參考的文件描述了一種散列數據條目列表的方法。假設你不預先[數學處理錯誤] [數學處理錯誤] $ 0 $ 或者 $ 1 $ . 然後,列表的雜湊 $ (e_1, e_2) $ 是 $ H(h_1 | h_2) $ 為了 $ h_1 = H(e_1) $ 和 $ h_2 = H(e_2) $ . 現在很容易找到它的第二個原像,即帶有單個條目的“列表” $ h_1 | h_2 $ ,這將被散列到 $ H(h_1 | h_2) $ .

如果你假裝這個攻擊不起作用 $ 0 $ 沙 $ 1 $ s 建議:列表的雜湊 $ (e_1, e_2) $ 那麼是 $ H(1 | h_0 | h_1) $ 為了 $ h_0 = H(0 | e_0) $ 和 $ h_1 = H(0 | e_1) $ . 您現在無法輕易找到它的原像:單一條目列表 $ h_1 | h_2 $ 被雜湊到 $ H(0 | h_0 | h_1) $ , 和 $ 1 | h_0 | h_1 $ 被雜湊到 $ H(0 | 1 | h_0 | h_1) $ .

引用自:https://crypto.stackexchange.com/questions/43430