Zcash中的description

1. 引言

Zcash 中支持的description类型有:

  • JoinSplit description
  • Spend description
  • Output description

JoinSplit transfer不支持Sapling notes。在Sapling中,有单独的Spend transfer for each shielded input 和 单独的Output transfer for each shielded output。

Sapling中的每一笔交易,都由一系列的Spend descriptions和一系列的Output descriptions组成。
为了保证平衡,需利用Pedersen commitment的加法同态属性,满足:
C o m ( v 1 ) + C o m ( v 2 ) = C o m ( v 1 + v 2 ) Com(v_1)+Com(v_2)=Com(v_1+v_2) Com(v1)+Com(v2)=Com(v1+v2)

保证交易平衡的具体方法为:【该方案支持所有的zk-SNARK statement为相互独立的,从而增加precomputation的可能机会。】

  • 将所有shielded inputs的value commitments相加,减去,所有shielded outputs的value commitments。结果为result commitment。
  • 借助Sapling binding signature来证明result commitment为a commit to a value consistent with the net transparent value change。

2. JoinSplit transfer and description

JoinSplit description为:
描述JoinSplit transfer 交易中包含的数据。

所谓JoinSplit transfer即为a shielded value transfer。在Sprout中,这种类型的value transfer是主要的Zcash-specific operation performed by transactions。

3. Spend transfer and description

Spend description为Spend transfer交易中包含的数据。

在Spend transfer中花费note n o l d n^{old} nold,则其对应的Spend description中包含:

  • a Pedersen value commitment to the value of the note。

该Pedersen value commitment与Spend statement instance有关,而Spend statement instance可提供相应的zk-SNARK proof。

在Spend description中指定了 anchor,该anchor指向 前一区块中的output Sapling treestate。

同时,在Spend description中也reveal了nullifier,借助nullifier可发现双花问题。

在Sapling中并不需要Interstitial treestates,因为特定交易中的Spend transfer不支持spend any of the shielded outputs of the same transaction。【实际这种约束并不麻烦,Sprout中要求每个JoinSplit transfer必须是单独平衡的,而在Sapling中,仅要求整个交易是平衡的就足够了。】

相关共识规则为:

  • 交易中的Spend transfer和Action transfer必须与其 v b a l a n c e S a p l i n g v^{balanceSapling} vbalanceSapling值一致。
  • Spend description中的anchor必需指向some earlier block’s final Sapling treestate。

在每笔交易中,可有0个或多个Spend descriptions。

每个Spend description由一个signature 来授权,该signature称为spend authorization signature,可表示为 S p e n d A u t h S i g S a p l i n g SpendAuthSig^{Sapling} SpendAuthSigSapling

而ZKSpend为Sapling Spend statement对应的zero-knowledge proving system。

Spend description组成可表示为 ( c v , r t S a p l i n g , n f , r k , π Z K S p e n d , s p e n d A u t h S i g ) (cv, rt^{Sapling},nf,rk,\pi_{ZKSpend}, spendAuthSig) (cv,rtSapling,nf,rk,πZKSpend,spendAuthSig),其中:

  • c v cv cv V a l u e C o m m i t S a p l i n g ValueCommit^{Sapling} ValueCommitSapling。输出为the value commitment to the value of the input note。
  • r t S a p l i n g rt^{Sapling} rtSapling B [ l M e r k l e S a p l i n g ] \mathbb{B}^{[l_{Merkle}^{Sapling}]} B[lMerkleSapling]为an anchor for the output treestate of a previous block。
  • n f nf nf B Y [ l P R F n f S a p l i n g / 8 ] \mathbb{B}^{\mathbb{Y}^{[l_{PRFnfSapling}/8]}} BY[lPRFnfSapling/8] 为the nullifier for the input note。
  • r k rk rk S p e n d A u t h S i g S a p l i n g . P u b l i c SpendAuthSig^{Sapling}.Public SpendAuthSigSapling.Public 为a randomized validating key,用于validate spendAuthSig。
  • π Z K S p e n d \pi_{ZKSpend} πZKSpend Z K S p e n d . P r o o f ZKSpend.Proof ZKSpend.Proof 为a zk-SNAKR proof with primary input ( c v , r t S a p l i n g , n f , r k ) (cv, rt^{Sapling},nf,rk) (cv,rtSapling,nf,rk) for the Spend statement。
  • s p e n d A u t h S i g spendAuthSig spendAuthSig S p e n d A u t h S i g S a p l i n g . S i g n a t u r e SpendAuthSig^{Sapling}.Signature SpendAuthSigSapling.Signature 为a spend authorization signature。

相关共识规则有:

  • Spending description中的elements必须为valid encodings of the types given above。
  • c v cv cv r k rk rk不能是small order的,即 [ h J ] c v = O J [h_{\mathbb{J}}]cv=\mathcal{O}_{\mathbb{J}} [hJ]cv=OJ [ h J ] r k = O J [h_{\mathbb{J}}]rk=\mathcal{O}_{\mathbb{J}} [hJ]rk=OJ必须均不成立。
  • proof π Z K S p e n d \pi_{ZKSpend} πZKSpend在给定的除 s p e n d A u t h S i g spendAuthSig spendAuthSig之外的primary input情况下 必须是valid的,即 Z K S p e n d . V e r i f y ( ( c v , r t S a p l i n g , n f , r k ) , π Z K S p e n d ) = 1 ZKSpend.Verify((cv, rt^{Sapling},nf,rk),\pi_{ZKSpend})=1 ZKSpend.Verify((cv,rtSapling,nf,rk),πZKSpend)=1 成立。
  • S i g H a s h SigHash SigHash为该交易的SIGHASH transaction hash,与任何input均无关。则spend authorization signature 必须为a valid S p e n d A u t h S i g S a p l i n g SpendAuthSig^{Sapling} SpendAuthSigSapling signature over SigHash using r k rk rk as the validating key,即 S p e n d A u t h S i g S a p l i n g . V a l i d a t e r k ( S i g H a s h , s p e n d A u t h S i g ) = 1 SpendAuthSig^{Sapling}.Validate_{rk}(SigHash,spendAuthSig)=1 SpendAuthSigSapling.Validaterk(SigHash,spendAuthSig)=1成立。

相关非规范性说明:

  • 验证 r k rk rk不是small order,从技术上来说不需要在Spend circuit中去check,在circuit之外去check会更简单和便宜。
  • 约束 r k rk rk c v cv cv不能是small order有助于防范non-canonical encodings of theses fields。即要求 r e p r J ( a b s t J ( c v ) ) = c v repr_{\mathbb{J}}(abst_{\mathbb{J}}(cv))=cv reprJ(abstJ(cv))=cv r e p r J ( a b s t J ( r k ) ) = r k repr_{\mathbb{J}}(abst_{\mathbb{J}}(rk))=rk reprJ(abstJ(rk))=rk均成立。

Spend description相应的编码组成为:
在这里插入图片描述

4. Output transfer and description

Output description为Output transfer交易中包含的数据。

在Output transfer中创建note n n e w n^{new} nnew,则其对应的Output description中包含:

  • a Pedersen value commitment to the value of the note。

该Pedersen value commitment与Output statement instance有关,而Output statement instance可提供相应的zk-SNARK proof。

在每笔交易中,可包含0个或多个Output descriptions。在Output description中没有任何相关signatures。

而ZKOutput为Sapling Output statement对应的zero-knowledge proving system。

Output description的组成可表示为 ( c v , c m u , e p k , C e n c , C o u t , π Z K O u t p u t ) (cv, cm_{u}, epk, C^{enc}, C^{out}, \pi_{ZKOutput}) (cv,cmu,epk,Cenc,Cout,πZKOutput),其中:

  • c v cv cv V a l u e C o m m i t S a p l i n g ValueCommit^{Sapling} ValueCommitSapling。输出为the value commitment to the value of the output note。
  • c m u cm_u cmu B [ l M e r k l e S a p l i n g ] \mathbb{B}^{[l_{Merkle}^{Sapling}]} B[lMerkleSapling]为the result of applying E x t r a c t J ( r ) Extract_{\mathbb{J}^{(r)}} ExtractJ(r) to the note commitment for the output note。
  • e p k epk epk K A S a p l i n g . P u b l i c KA^{Sapling}.Public KASapling.Public为a key agreement public key,用于derive the key for encryption of the transmitted note ciphertext。
  • C e n c C^{enc} Cenc S y m . C Sym.C Sym.C 为a ciphertext component for the encrypted output note。
  • C o u t C^{out} Cout S y m . C Sym.C Sym.C 为a ciphertext component,其支持用于full viewing key的人恢复the diversified transimission key p k d pk_d pkd和the ephemeral private key e s k esk esk,甚至可恢复整个note plaintext。
  • π Z K O u t p u t \pi_{ZKOutput} πZKOutput Z K O u t p u t . P r o o f ZKOutput.Proof ZKOutput.Proof为a zk-SNARK proof with primary input ( c v , c m u , e p k ) (cv,cm_u, epk) (cv,cmu,epk) for the Output statement。

相关共识规则有:

  • Output description中的elements必须是valid encodings of the types given above。
  • c v 和 e p k cv和epk cvepk 必须不能是small order的,即 [ h J ] c v = O J [h_{\mathbb{J}}]cv=\mathcal{O}_{\mathbb{J}} [hJ]cv=OJ [ h J ] e p k = O J [h_{\mathbb{J}}]epk=\mathcal{O}_{\mathbb{J}} [hJ]epk=OJ必须均不成立。
  • proof π Z K O u t p u t \pi_{ZKOutput} πZKOutput在给定的除 C e n c 和 C o u t C^{enc}和C^{out} CencCout之外的primary input情况下 必须是valid的,即 Z K O u t p u t . V e r i f y ( ( c v , c m u , e p k ) , π Z K O u t p u t ) = 1 ZKOutput.Verify((cv, cm_u,epk),\pi_{ZKOutput})=1 ZKOutput.Verify((cv,cmu,epk),πZKOutput)=1 成立。

相关非规范说明:

  • 约束 c v 和 e p k cv和epk cvepk不能为small order,有助于防范non-canonical encodings of these fields。即要求 r e p r J ( a b s t J ( c v ) ) = c v repr_{\mathbb{J}}(abst_{\mathbb{J}}(cv))=cv reprJ(abstJ(cv))=cv r e p r J ( a b s t J ( e p k ) ) = e p k repr_{\mathbb{J}}(abst_{\mathbb{J}}(epk))=epk reprJ(abstJ(epk))=epk均成立。

Output description相应的编码组成为:
在这里插入图片描述

参考资料

[1] Zcash Protocol Specification

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值