您当前的位置: 首页 > 

mutourend

暂无认证

  • 2浏览

    0关注

    661博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Zcash中的hash函数

mutourend 发布时间:2021-04-16 11:52:17 ,浏览量:2

1. 引言

Zcash中的hash函数主要有:

  • BLAKE2 Hash Function
  • Group Hash into Jubjub
  • Pedersen Hash Function
  • Mixing Pedersen Hash Function
  • Merkle Tree Hash Function
  • C R H i v k CRH^{ivk} CRHivk Hash Function
  • D i v e r s i f y H a s h S a p l i n g DiversifyHash^{Sapling} DiversifyHashSapling Hash Function
2. BLAKE2 Hash Function

BLAKE2 定义在 [ANWW2013-BLAKE2: simpler, smaller, fast as MD5] 中。BLAKE2比MD5、SHA-1、SHA-2和SHA-3的速度都快, 但是其安全性与当前最新的standard SHA-3安全性相当。 BLAKE2 主要有2个分支:

  • BLAKE2b (或直接简称为BLAKE2) :针对64-bit平台(含NEON-enabled ARM平台)进行了优化,输出的digest长度为1byte 到 64bytes。
  • BLAKE2s:针对8-bit或32-bit 平台进行了优化,输出的digest长度为1byte 到32 bytest。

在这里插入图片描述 Zcash使用了 BLAKE2b 和 BLAKE2s 的变种:

  • B L A K E 2 b − l ( p , x ) BLAKE2b-l(p,x) BLAKE2b−l(p,x):为unkeyed B L A K E 2 b − l : B Y [ 16 ] × B Y [ N ] → B Y [ l / 8 ] BLAKE2b-l: \mathbb{B}^{\mathbb{Y}^{[16]}}\times \mathbb{B}^{\mathbb{Y}^{[\mathbb{N}]}}\rightarrow \mathbb{B}^{\mathbb{Y}^{[l/8]}} BLAKE2b−l:BY[16]×BY[N]→BY[l/8] in sequential mode,其中 p p p为16-byte personalization string, x x x为input,输出的digest length为 l / 8 l/8 l/8 bytes。 BLAKE2b已用于 i S i g C R H , E q u i h a h s G e n , P R F e x p a n d , P R F o c k S a p l i n g , K D F S a p l i n g iSigCRH, EquihahsGen,PRF^{expand},PRF^{ockSapling}, KDF^{Sapling} iSigCRH,EquihahsGen,PRFexpand,PRFockSapling,KDFSapling 以及 RedJubjub signature scheme中的 S p e n d A u t h S i g S a p l i n g SpendAuthSig^{Sapling} SpendAuthSigSapling 和 B i n d i n g S i g S a p l i n g BindingSig^{Sapling} BindingSigSapling。
  • B L A K E 2 s − l ( p , x ) BLAKE2s-l(p,x) BLAKE2s−l(p,x):为unkeyed B L A K E 2 s − l : B Y [ 8 ] × B Y [ N ] → B Y [ l / 8 ] BLAKE2s-l: \mathbb{B}^{\mathbb{Y}^{[8]}}\times \mathbb{B}^{\mathbb{Y}^{[\mathbb{N}]}}\rightarrow \mathbb{B}^{\mathbb{Y}^{[l/8]}} BLAKE2s−l:BY[8]×BY[N]→BY[l/8] in sequential mode,其中 p p p为8-byte personalization string, x x x为input,输出的digest length为 l / 8 l/8 l/8 bytes。 BLAKE2s已用于 P R F n f S a p l i n g , C R H i v k , G r o u p H a s h J ( r ) ∗ PRF^{nfSapling},CRH^{ivk}, GroupHash^{\mathbb{J}^{(r)*}} PRFnfSapling,CRHivk,GroupHashJ(r)∗ 。
3. Group Hash into Jubjub
  • U R S URS URS:为MPC randomness beacon。
  • G r o u p H a s h J ( r ) ∗ . I n p u t = B Y [ 8 ] × B Y [ N ] GroupHash^{\mathbb{J}^{(r)*}}.Input=\mathbb{B}^{\mathbb{Y}^{[8]}}\times \mathbb{B}^{\mathbb{Y}^{[\mathbb{N}]}} GroupHashJ(r)∗.Input=BY[8]×BY[N],其中的 B Y [ 8 ] \mathbb{B}^{\mathbb{Y}^{[8]}} BY[8]是“personalization”参数,用于区分不同用途的group hash。
  • D : B Y [ 8 ] D:\mathbb{B}^{\mathbb{Y}^{[8]}} D:BY[8]:为8-byte domain separator。
  • M : B Y [ N ] M:\mathbb{B}^{\mathbb{Y}^{[\mathbb{N}]}} M:BY[N]:为 hash input。

G r o p H a s h U R S J ( r ) ∗ ( D , M ) : J ( r ) ∗ GropHash_{URS}^{\mathbb{J}^{(r)*}}(D,M):\mathbb{J}^{(r)*} GropHashURSJ(r)∗​(D,M):J(r)∗ hash运算过程为: 1) H = B L A K E 2 s − 256 ( D , U R S ∣ ∣ M ) H=BLAKE2s-256(D,URS||M) H=BLAKE2s−256(D,URS∣∣M)。 2) P = a b s t J ( L E O S 2 B S P 256 ( H ) ) P=abst_{\mathbb{J}}(LEOS2BSP_{256}(H)) P=abstJ​(LEOS2BSP256​(H)),若 P = ⊥ P=\perp P=⊥,则返回 ⊥ \perp ⊥。 3) Q = [ h J ] P Q=[h_{\mathbb{J}}]P Q=[hJ​]P,若 Q = O J Q=\mathcal{O}_{\mathbb{J}} Q=OJ​,则返回 ⊥ \perp ⊥,否则返回 Q Q Q。

F i n d G r o u p H a s h J ( r ) ∗ ( D , M ) FindGroupHash^{\mathbb{J}^{(r)*}}(D,M) FindGroupHashJ(r)∗(D,M) 通过 引入byte i i i,使得返回的为有效的prime group point: 在这里插入图片描述

4. Pedersen Hash Function

P e d e r s e n H a s h PedersenHash PedersenHash 基于的安全假设为: the hardness of the Discrete Logarithm Problem on the Jubjub curve。

P e d e r s e n H a s h PedersenHash PedersenHash 具有collision resistance (for fixed input length)。【注意对于variable-length inputs不具有collision-resistant。】

P e d e r s e n H a s h PedersenHash PedersenHash 已用于:

  • Pedersen commitment —— Windowed Pedersen commitment。
  • Pedersen hash for the Sapling incremental Merkle tree —— M e r k l e C R H S a p l i n g MerkleCRH^{Sapling} MerkleCRHSapling Hash Function。

在这里插入图片描述

5. Mixing Pedersen Hash Function

Mixing Pedersen hash 用于 根据 c m cm cm和 p o s pos pos 计算 ρ \rho ρ。 在这里插入图片描述

6. Merkle Tree Hash Function

Merkle Tree Hash Function M e r k l e C R H S a p l i n g MerkleCRH^{Sapling} MerkleCRHSapling 用于对note commitment tree进行hash,其中:

  • prefix l l l 用于区分inputs所在的layer。
  • M e r k l e D e p t h S a p l i n g = 32 MerkleDepth^{Sapling}=32 MerkleDepthSapling=32
  • l M e r k l e S a p l i n g = 255 l_{Merkle}^{Sapling}=255 lMerkleSapling​=255

在这里插入图片描述

7. C R H i v k CRH^{ivk} CRHivk Hash Function

C R H i v k CRH^{ivk} CRHivk 用于派生 incoming viewing key i v k ivk ivk for a Sapling shielded payment address。 其中:

  • l i v k S a p l i n g = 251 l_{ivk}^{Sapling}=251 livkSapling​=251

在这里插入图片描述

8. D i v e r s i f y H a s h S a p l i n g DiversifyHash^{Sapling} DiversifyHashSapling Hash Function

D i v e r s i f y H a s h S a p l i n g DiversifyHash^{Sapling} DiversifyHashSapling 用于根据diversifier d d d 派生a diversified base g d g_d gd​,基于该 g d g_d gd​构建shielded payment address中的transmission key p k d = i v k ⋅ g d pk_d=ivk\cdot g_d pkd​=ivk⋅gd​,应满足unlinkable属性,即已知两个来自不同主题的shielded payment address,无法区分新来的shielded payment address与其中的哪个主体是一样的。 在这里插入图片描述

参考资料

[1] Zcash Protocol Specification [2] BLAKE2 hash函数

关注
打赏
1664532908
查看更多评论
立即登录/注册

微信扫码登录

0.0719s