1. 引言
ZCash, Monero, 以及所有基于CryptoNote的coins,都支持confidential transactions 隐私交易。
1.1 Bitcoin transaction
Bitcoin transaction的结构为: ,其中 为input addresses, 为output addresses, 为the amounts that go to each output。
在Bitcoin中,each transaction appears unencrypted for the whole world to see in the public ledger,使得比特币中的交易容易被跟踪,even when the coins go through multiple owners。解决交易跟踪问题的方式可为:
- 使用tumbler:takes in Bitcoin from many sources, mixes them around, and hands back some fresh uncorrelated coins。(类似于money laundering)
- confidential transaction:仅允许交易的参与方看见
values,而对于其他非参与方均隐藏不可见。同时要求非参与方能够发现伪造的交易的。(don’t want a user to be able to print money by spending more than they actually have.)对于非参与方,account contents和output values都是保密的secret,怎么来验证交易是有效的呢?
需要用到的技术主要有:
** Schnorr Signature。
** AOS Ring Signature。
** Borromean Ring Signatures。
** Pedersen Commitments。
** Hiding Transaction Amounts。
** Rangeproofs。
2. Schnorr Signature
详细可参见博客 ECDSA VS Schnorr signature VS BLS signature 第2节内容。
主要内容为:
- an abelian group of prime order with generator .
- public key , where is secret key。
- hash function .
- message to be signed
Schnorr 签名过程为:
- 选择随机数 ,设置 ;
- 计算
- 计算
- 发送Schnorr signature
Schnorr验签过程为:
- 计算
- 验证 是否成立。
3. AOS Ring Signatures
confindential transactions底层使用的签名机制为ring signatures。ring signature 与普通签名类似,除了:
a ring signature of the message
over the public keys
proves that someone with knowledge of one of the private keys
has seen the message
。
普通签名为ring signature
的特例。
ring signature的主要目的是:
隐藏实际进行签名的private key,具有signer ambiguity特性。(not reveal which private key it was that performed the signature.)
Abe,Okhubo,Suzuki 2002年论文《1-out-of-n Signatures from a Variety of Keys》中所构建的ring signature是Schnorr Signautre的generalization。
3.1 AOS Ring Signatures签名过程
假设 个 public keys 中,签名方实际仅知道 的私钥 ,即该签名方实际仅能用 对消息 进行签名。具体的AOS签名流程为:【注意下面的 等计算均做modulus 运算,保证实际下标不超过 。】
- 随机数 ,计算 ;
- 的取值从 开始, ,依次选择随机数 ,依次计算 。
- 设置 。
- 最终的AOS signature为 。
举例:
已知
个 public keys
,签名者(我,I)的拥有的私钥为
满足
,进行AOS signature流程为:
- start making the ring at index 2: ;
- continue making the ring: ;
- continue making the ring: ;
- Now notice that has been determined in two ways: from before, , and also from the property which must hold for every value: . The only that satisfies these constraints is , which I can easily compute, since I know .
- 最终的AOS ring signature为: 。
3.2 AOS Ring Signatures验签过程
对AOS ring signature 的验签过程为:
- 计算 ;
- 计算 ;
- 计算 ;
- 验证 是否成立。
验签者无法知道哪个
值是真正的随机值,从而实现混淆签名者的作用。
【其实即为博客 基于Sigma protocol实现的零知识证明protocol集锦中2.3节的OR证明,或者博客 Proof Systems for General Statements about Discrete Logarithms 学习笔记中2.3和3节中的generalized OR证明】
实际实现时,在签名和验签过程中,没必要在计算每个 时都hash ,可以调整为: ,而每个除 之外的 。
4. Borromean Ring Signatures
针对的场景为:
有multiple sets of public keys
,签名者(我,I)拥有one private key in each
,然后需要sign a message
in each of these rings. In doing so, I am proving "Some key in
signed
AND Some key in
signed
AND Some key in
signed
"。
最直观的实现方式是:
make a separate AOS signature for each set of public keys, giving us a final signature of
。
但是以上方式的签名长度过长,Gregory Maxwell,Andrew Poelstra 2015年论文《Borromean Ring Signatures》对此做了优化:
- pinning
as a shared
value for all rings
,该论文中
,其中
when
, and
otherwise。
表示第
个ring的public key数量,
表示在第
个ring中所知道的private key的序号。
该算法的要点为:每个ring 的 the last 和 值(其实对应index为 ,无论是否对应为the known private key)都包含在 值中。
最终的Borromean Ring Signatures为:
Borreomean ring signature的总长度为 ,相比于separate AOS signature for each set of public keys方案,可以节约 个数值。
5. Pedersen Commitments
A commitment is a value that is published prior to the revealing of some information. The commitment proves that you knew that information before it was revealed.
Pedersen commitment具有Hash函数所不具有的一些特性。
Pedersen commitment 要素有:
- an abelian group of prime order ;
- two public and unrelated generators and 。(即无法找到 ,使得 成立。)
commit to value 的流程为:
- 选择随机blinding factor ;
- 计算 。
若存在不同的
使得其commitment也为
,则有:
,违背了之前的
和
unrelated假设。
Pedersen commitment具有binding和hiding属性。同时具有加法同态属性:
6. Hiding Transaction Amounts隐藏交易金额
交易内金额主要有:(都 )
- input amount ;
- output amount ;
- transaction fee 。
交易内金额要满足公式
,total input equals total output, so no money appears out of thin air and no money disappears into nothingess.
该公式可借助Pedersen commitment来实现 without revealing any of the values:
- 选择随机数 ,计算 ;
- 计算Pedersen commitments 。在交易中发送 。
- 注意,仅仅验证
成立,只能证明
成立,而不是
成立。
举例为:若 ,input为1,output为9,transaction fee 5时, 仍然成立, 验证也会通过。
但是存在溢出问题overflowed and ended up wrapping around the modulus。可借助Rangeproofs来解决。
7. Rangeproofs
为了overflowed and ended up wrapping around the modulus问题,且避免考虑负数情况,验证等式 成立改为验证 成立。同时要求 。
将
和
以
bit二进制形式表示,则有
,
。
对于
,分别计算
个Pedersen commitments,其中每个
value 要么为0要么为power of 2,这
个commitments之和即为the commitment of
or
。【——Michael Rosenberg博文 Confidential Transactions from Basic Principles写于2017年,其实可以考虑采用bulletproofs方案来做range proof。】
为证明vallue 表示为 bits二进制:
- 取随机数 ,构建commitment 。
- 将 以 bits 二进制表示为: 。
- :选择随机数 ,设置 ,对所有的 ,计算 。
- Verifier验证 成立。只能证明所commit的值相等。怎么证明是拆分为二进制呢?即每个 仅能为0或者1值,而不是 等。 可借助ring signature来实现,构建 ,将其看作是a set of public keys for a ring signature。有:
从而为证明 ,构建a ring signature over 。由于ring signature具有signer-ambiguous属性,verifier无法确定具体signing的是哪个key,从而实现对所有bits的hide,也同时证明了 确实为bits。
采用Borromean ring signature,将有
个signtures,每个signature有2个数值。最终的rangeproof of value
为:
其中
为第i个ring signature的s值。
8. confidential transcation——Put it all together
- input amount ;
- output amount ;
- transaction fee 。
Pedersen Commitment
可证明
。
range proofs
可证明不存在溢出情况。
以上两者结合即可实现confidential transaction:
I can conduct a confidential transaction that make public, and then privately reveal the commitments for so that they can be sure that I actually sent what I claim. 因为commitments有binding属性,they can be certain that I can’t claim to someone else that I sent different values。
参考资料:
[1] Michael Rosenberg 2017年博文 Confidential Transactions from Basic Principles
[2] Monero Confidential Transactions 问答:https://monero.stackexchange.com/questions/10181/hiding-transaction-values-using-pederson-commitments-and-range-proofs-in-account
[3] https://elementsproject.org/elements/confidential-transactions/