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


Python MiniNero.intToHex方法代码示例

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


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

示例1: genRct

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def genRct(inSk, inPk, destinations, amounts, mixin):
    #inputs:
    #inSk is signers secret ctkeyvector 
    #inPk is signers public ctkeyvector 
    #destinations is a keyvector of output addresses 
    #amounts is a list of amounts corresponding to above output addresses
    #mixin is an integer which is the desired mixin 
    #outputs:
    #rctSig is a list [ rangesigs, MG, mixRing, ecdhInfo, outPk] 
    #rangesigs is a list of one rangeproof for each output
    #MG is the mgsig [ss, cc, II] 
    #mixRing is a ctkeyMatrix 
    #ecdhInfo is a list of masks / amounts for each output
    #outPk is a vector of ctkeys (since we have computed the commitment for each amount)
    rv = rctSig()
    rv.outPk = ctkeyV( len(destinations))
    rv.rangeSigs = [None] * len(destinations)
    outSk = ctkeyV(len(destinations))
    rv.ecdhInfo = [None] * len(destinations)
    for i in range(0, len(destinations)):
        rv.ecdhInfo[i] = ecdhTuple()
        rv.outPk[i] = ctkey()
        rv.outPk[i].dest = destinations[i]
        rv.outPk[i].mask, outSk[i].mask, rv.rangeSigs[i] = proveRange(amounts[i])
        #do ecdhinfo encode / decode 
        rv.ecdhInfo[i].mask = outSk[i].mask
        rv.ecdhInfo[i].amount = MiniNero.intToHex(amounts[i])
        rv.ecdhInfo[i] = ecdhEncode(rv.ecdhInfo[i], destinations[i])
    rv.mixRing, index = populateFromBlockchain(inPk, mixin)
    rv.MG = proveRctMG(rv.mixRing, inSk, outSk, rv.outPk, index)
    return rv
开发者ID:ShenNoether,项目名称:research-lab,代码行数:33,代码来源:RingCT2.py

示例2: genRangeProof

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [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: out_commitments

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def out_commitments(values):
    #do this first
    n = len(values)
    values2 = [None] * n
    for i in range(0, n):
        values2[i] = [MiniNero.intToHex(j) for j in binary(MiniNero.hexToInt(values[i]))]
    #returns a list of commitments C_i = y_iG + value_i * H for outputs (these masks are created randomly)
    masks = [None] * n 
    sumMasks = [None] * n
    for i in range(0, n):
        masks[i] = [PaperWallet.skGen() for jj in values2[i]] #binary decomposition for range proofs (could also use another base)
        sumMasks[i] = MiniNero.intToHex(sum([MiniNero.hexToInt(a) for a in masks[i]])) #sum is what actually goes into the ring..
    C = [None] * n
    for i in range(0, n):
        C[i] = MiniNero.addKeys(MiniNero.scalarmultBase(sumMasks[i]), MiniNero.scalarmultKey(H_ct, values[i]))
    return C, masks, sumMasks, values2
开发者ID:Coder420,项目名称:MiniNero,代码行数:18,代码来源:Old_Ring_CT.py

示例4: sumCiExp

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def sumCiExp(Cis, Exp):
    #Cis is a vector
    #Exp is a vector
    CSum = MiniNero.identity()
    for i in range(0, len(Cis)):
        CSum = MiniNero.addKeys(CSum, MiniNero.scalarmultKey(Cis[i], MiniNero.intToHex(10 ** Exp[i])))
    return CSum
开发者ID:ShenNoether,项目名称:research-lab,代码行数:9,代码来源:RingCT.py

示例5: ctskpkGen

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def ctskpkGen(amount):
    sk = ctkey()
    pk = ctkey()
    sk.dest, pk.dest = PaperWallet.skpkGen()
    sk.mask, pk.mask = PaperWallet.skpkGen()
    am = MiniNero.intToHex(amount)
    aH = MiniNero.scalarmultKey(getHForCT(), am)
    pk.mask = MiniNero.addKeys(pk.mask, aH)
    return sk, pk
开发者ID:ShenNoether,项目名称:research-lab,代码行数:11,代码来源:RingCT2.py

示例6: getH2ForCT

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def getH2ForCT():
    A = MiniNero.publicFromInt(1)
    HPow2 = MiniNero.hashToPoint_ct(A)
    two = MiniNero.intToHex(2)
    H2 = [None] * ATOMS
    for i in range(0, ATOMS):
        #Translator.hexToCComma(HPow2) 
        H2[i] = HPow2
        HPow2 = MiniNero.scalarmultKey(HPow2, two)
    return H2
开发者ID:ShenNoether,项目名称:research-lab,代码行数:12,代码来源:RingCT2.py

示例7: GenASNL

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def GenASNL(x, P1, P2, indices):
    #Aggregate Schnorr Non-Linkable
    #x, P1, P2, are key vectors here, but actually you 
    #indices specifices which column of the given row of the key vector you sign.
    #the key vector with the first or second key
    n = len(x)
    print("Generating Aggregate Schnorr Non-linkable Ring Signature")
    L1 = [None] * n
    s1 = [None] * n
    s2 = [None] * n
    s = MiniNero.intToHex(0)
    for j in range(0, n):
        L1[j], s1[j], s2[j] = GenSchnorrNonLinkable(x[j], P1[j], P2[j], indices[j])
        s = MiniNero.sc_add_keys(s, s1[j])
    return L1, s2, s
开发者ID:Coder420,项目名称:MiniNero,代码行数:17,代码来源:ASNL.py

示例8: VerASNL

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def VerASNL(P1, P2, L1, s2, s):
    #Aggregate Schnorr Non-Linkable
    print("Verifying Aggregate Schnorr Non-linkable Ring Signature")
    n = len(P1)
    LHS = MiniNero.scalarmultBase(MiniNero.intToHex(0))
    RHS = MiniNero.scalarmultBase(s)
    for j in range(0, n):
        c2 = MiniNero.cn_fast_hash(L1[j])
        L2 = MiniNero.addKeys(MiniNero.scalarmultBase(s2[j]), MiniNero.scalarmultKey(P2[j], c2))
        LHS = MiniNero.addKeys(LHS, L1[j])
        c1 = MiniNero.cn_fast_hash(L2)
        RHS = MiniNero.addKeys(RHS, MiniNero.scalarmultKey(P1[j], c1))
    if LHS == RHS:
        print"Verified"
        return 0
    else:
        print "Didn't verify"
        print(LHS,"!=",  RHS)
        return -1
开发者ID:Coder420,项目名称:MiniNero,代码行数:21,代码来源:ASNL.py

示例9: deterministicVK

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def deterministicVK():
    while True:
        print("."),
        tmp = MiniNero.intToHex(rand.getrandbits(64 * 8))  # 8 bits to a byte ...
        sk = MiniNero.sc_reduce_key(MiniNero.cn_fast_hash(tmp))

        # s = "3c817618dcbfed122a64e592bb441d73300da9123686224a84e0eab1f075117e"; for testing
        # sk = MiniNero.sc_reduce_key(s)
        vk = MiniNero.getViewMM(sk)  # note this is the sc_reduced version..
        worked = 1
        try:
            MiniNero.toPoint(vk)
        except:
            worked = 0
            print("bad vk")
        if vk == MiniNero.sc_reduce_key(vk) and worked == 1:  # already reduced + vk on curve
            break

    print("found keys")
    print("secret spend key:", sk)
    print("secret view key:", vk)
    vk2 = MiniNero.cn_fast_hash(MiniNero.scalarmultKey(vk, 2))
    print("secret view key2:", vk2)
    vk3 = MiniNero.cn_fast_hash(MiniNero.scalarmultKey(vk, 3))
    print("secret view key3:", vk3)

    pk = MiniNero.publicFromSecret(sk)
    print("public spend key:", pk)
    pvk = MiniNero.publicFromSecret(vk)
    print("public view key:", pvk)
    pvk2 = MiniNero.publicFromSecret(vk2)
    print("public view key2:", pvk2)
    pvk3 = MiniNero.publicFromSecret(vk3)
    print("public view key3:", pvk3)

    addr = MiniNero.getAddrMM(sk)
    print("in future this will get all addresses")
    print("receiving address", addr)
    wl = mnemonic.mn_encode(s)
    cks = MiniNero.electrumChecksum(wl)
    print(cks)
    print("mnemonic:", wl + " " + cks)
开发者ID:Coder420,项目名称:MiniNero,代码行数:44,代码来源:Deterministic.py

示例10: verRangeProof

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def verRangeProof(Ci, L1, s2, s):
    n = len(Ci) #note there will be some fixed length eventually so you can't just get the top digit
    CiH = [None] * n
    for i in range(0, n):
        CiH[i] = MiniNero.subKeys(Ci[i], MiniNero.scalarmultKey(getHForCT(), MiniNero.intToHex(2 ** i)))
    return AggregateSchnorr.VerASNL(Ci, CiH, L1, s2, s) 
开发者ID:ShenNoether,项目名称:research-lab,代码行数:8,代码来源:RingCT.py

示例11: point_compress

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def point_compress(P):
    zinv = modp_inv(P[2])
    x = P[0] * zinv % p
    y = P[1] * zinv % p
    return MiniNero.intToHex(y | ((x & 1) << 255)  )
开发者ID:monero-project,项目名称:mininero,代码行数:7,代码来源:ed25519ietf.py

示例12: print

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
q = 2**255 - 19
l = 2**252 + 27742317777372353535851937790883648493
import MiniNero
import PaperWallet

a = 3655169758690262480859172686034352748701568204867449275194046101565641063400
b = 2196281112309589493539510630657048805544016132079821556435431458072258858680
c = 1680308020000391016811131033972168547846809685867129675902005632340344199616
d = 3102886190919558838979092227453570755967767872654511102581747930112259050736
e = a + b + c + d
print(e, e % l)
pk = MiniNero.publicFromSecret(MiniNero.intToHex(e))
pka = MiniNero.publicFromSecret(MiniNero.intToHex(a))
pkb = MiniNero.publicFromSecret(MiniNero.intToHex(b))
pkc = MiniNero.publicFromSecret(MiniNero.intToHex(c))
pkd = MiniNero.publicFromSecret(MiniNero.intToHex(d))
A = MiniNero.addKeys(pka, pkb)
B = MiniNero.addKeys(A, pkc)
C = MiniNero.addKeys(B, pkd)
print(C)
print(pk)

开发者ID:Coder420,项目名称:MiniNero,代码行数:23,代码来源:TacoTimeExample.py

示例13: skGen

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def skGen():
    return MiniNero.intToHex( 8 * (rand.getrandbits(64 * 8)) % l)
开发者ID:Coder420,项目名称:MiniNero,代码行数:4,代码来源:PaperWallet.py

示例14: pkGen

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def pkGen():
    #The point of this is in testing functions where you need some arbitrary public key to test against
    return MiniNero.scalarmultBase(MiniNero.intToHex( 8 * (rand.getrandbits(64 * 8)) % l))
开发者ID:Coder420,项目名称:MiniNero,代码行数:5,代码来源:PaperWallet.py

示例15: in_commitments

# 需要导入模块: import MiniNero [as 别名]
# 或者: from MiniNero import intToHex [as 别名]
def in_commitments(input_value, sk, masks):
    #for now, assume there is one input, generalized after get that working
    sum_masks = MiniNero.intToHex(sum([MiniNero.hexToInt(a) for a in masks]))
    z = MiniNero.sc_sub_keys(sk, sum_masks) # z +  sum of input mask values = sk
    C = MiniNero.addKeys(MiniNero.scalarmultBase(sk), MiniNero.scalarmultKey(H_ct, input_value)) #input_value = sum output values
    return C, z #z is the sk you need to sign for this commitment
开发者ID:Coder420,项目名称:MiniNero,代码行数:8,代码来源:Old_Ring_CT.py


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