Mastering Monero
  • 介绍
  • 前言
  • 快速术语检索
  • 介绍
    • 环签名
    • 隐藏地址
    • 环机密交易
    • 密钥镜像
    • 范围证明
  • 门罗币的原理
  • 门罗币客户端
  • 密钥、地址、钱包
    • 普通地址
    • 子地址
    • 多重签名地址
  • 交易
  • 门罗币网络
  • 区块链
  • 挖矿与共识
    • 算法介绍
    • 算法背景
    • 挖矿软件
    • 矿池
  • 门罗币安全
    • 升级机制
  • CryptoNote
    • Features
    • Inside
    • Wiki
    • whitepaper
  • 附录
  • 数据存储
  • 助记词
  • 数据结构
    • 区块链
    • 账号、钱包、地址
    • 底层
    • 其它
  • 有问有答
  • 硬件钱包
Powered by GitBook
On this page
  • RingCT protocol
  • 示例

Was this helpful?

  1. 介绍

环机密交易

RingCT protocol

  • genRct

  • verRct

  • decodeRct

示例

H_ct = RingCT.getHForCT()
print("H", H_ct)

sr, Pr = PaperWallet.skpkGen() #receivers private/ public
se, pe, ss = ecdh.ecdhgen(Pr) #compute shared secret ss

digits = 14 #in practice it will be 14
print("inputs")
Cia, L1a, s2a, sa, ska = RingCT.genRangeProof(10000, digits)
print("outputs")
Cib, L1b, s2b, sb, skb = RingCT.genRangeProof(7000, digits)
Cic, L1c, s2c, sc, skc = RingCT.genRangeProof(3000, digits)

print("verifying range proofs of outputs")
RingCT.verRangeProof(Cib, L1b, s2b, sb)
RingCT.verRangeProof(Cic, L1c, s2c, sc)

x, P1 = PaperWallet.skpkGen()
P2 = PaperWallet.pkGen()
C2 = PaperWallet.pkGen()

#some random commitment grabbed from the blockchain
ind = 0
Ca = RingCT.sumCi(Cia)
Cb = RingCT.sumCi(Cib)
Cc = RingCT.sumCi(Cic)

sk = [x, MiniNero.sc_sub_keys(ska, MiniNero.sc_add_keys(skb, skc))]
pk = [[P1, P2], [MiniNero.subKeys(Ca, MiniNero.addKeys(Cb, Cc)), MiniNero.subKeys(C2, MiniNero.addKeys(Cb, Cc)) ] ]

II, cc, ssVal = MLSAG.MLSAG_Sign(pk, sk, ind)

print("Sig verified?", MLSAG.MLSAG_Ver(pk, II, cc, ssVal))

print("Finding received amount corresponding to Cib")
RingCT.ComputeReceivedAmount(pe, sr, MiniNero.addScalars(ss, skb), Cib)

print("Finding received amount corresponding to Cic")
RingCT.ComputeReceivedAmount(pe, sr, MiniNero.addScalars(ss, skc), Cic)
Previous隐藏地址Next密钥镜像

Last updated 5 years ago

Was this helpful?