当前位置: 首页>>代码示例>>Python>>正文


Python MiniNero.addScalars方法代码示例

本文整理汇总了Python中MiniNero.addScalars方法的典型用法代码示例。如果您正苦于以下问题:Python MiniNero.addScalars方法的具体用法?Python MiniNero.addScalars怎么用?Python MiniNero.addScalars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MiniNero的用法示例。


在下文中一共展示了MiniNero.addScalars方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: proveRange

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import addScalars [as 别名]
def proveRange(amount):
    bb = d2b(amount, ATOMS) #gives binary form of bb in "digits" binary digits
    print("amount, amount in binary", amount, bb)
    ai = [None] * len(bb)
    Ci = [None] * len(bb)
    CiH = [None] * len(bb) #this is like Ci - 2^i H
    H2 = getH2ForCT()
    a = MiniNero.sc_0()
    ii = [None] * len(bb)
    indi = [None] * len(bb)
    for i in range(0, ATOMS):
        ai[i] = PaperWallet.skGen()
        a = MiniNero.addScalars(a, ai[i]) #creating the total mask since you have to pass this to receiver...
        if bb[i] == 0:
            Ci[i] =  MiniNero.scalarmultBase(ai[i])
        if bb[i] == 1:
            Ci[i] = MiniNero.addKeys(MiniNero.scalarmultBase(ai[i]), H2[i])
        CiH[i] = MiniNero.subKeys(Ci[i], H2[i])
        
    A = asnlSig()
    A.L1, A.s2, A.s = AggregateSchnorr.GenASNL(ai, Ci, CiH, bb)
    
    R = rangeSig()
    R.asig = A
    R.Ci = Ci
    
    mask = a
    C = sumCi(Ci)
    return C, mask, R
开发者ID:ShenNoether,项目名称:research-lab,代码行数:31,代码来源:RingCT2.py

示例2: genRangeProof

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import addScalars [as 别名]
def genRangeProof(b, digits):
    bb = binary(b, digits) #gives binary form of bb in "digits" binary digits
    print("b, b in binary", b, bb)
    ai = [None] * len(bb)
    Ci = [None] * len(bb)
    CiH = [None] * len(bb) #this is like Ci - 2^i H
    a = MiniNero.intToHex(0)
    ii = [None] * len(bb)
    indi = [None] * len(bb)
    for i in range(0, len(bb)):
        ai[i] = PaperWallet.skGen()
        a = MiniNero.addScalars(a, ai[i]) #creating the total mask since you have to pass this to receiver...
        Ci[i] = MiniNero.addKeys(MiniNero.scalarmultBase(ai[i]), MiniNero.scalarmultKey(getHForCT(), MiniNero.intToHex(bb[i] * 2 ** i)))
        CiH[i] = MiniNero.subKeys(Ci[i], MiniNero.scalarmultKey(getHForCT(), MiniNero.intToHex(2 ** i)))
    L1, s2, s = AggregateSchnorr.GenASNL(ai, Ci, CiH, bb)
    return sumCi(Ci), Ci, L1, s2, s, a
开发者ID:ShenNoether,项目名称:research-lab,代码行数:18,代码来源:RingCT.py

示例3: print

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import addScalars [as 别名]
        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(ss1, skb),MiniNero.addScalars(ss2, MiniNero.intToHex(b)), Cib, 9)
        print("Finding received amount corresponding to Cic")
        RingCT.ComputeReceivedAmount(pe, sr, MiniNero.addScalars(ss1, skc), MiniNero.addScalars(ss2, MiniNero.intToHex(c)), Cic, 9)
    if sys.argv[1] == "MLSAG":
        #below is example usage. Uncomment each line for testing
        N = 3 #cols
        R = 3 #rows
        x = [[None]*N] #just used to generate test public keys
        sk = [None] * R #vector of secret keys
        P = [[None]*N] #stores the public keys

        ind = 2
        for j in range(0, R):
            if j > 0:
                x.append([None]*N)
                P.append([None]*N)
开发者ID:ShenNoether,项目名称:research-lab,代码行数:33,代码来源:Test.py


注:本文中的MiniNero.addScalars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。