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


Python MiniNero类代码示例

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


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

示例1: getHForCT

def getHForCT():
    return "8b655970153799af2aeadc9ff1add0ea6c7251d54154cfa92c173a0dd39c1f94"
    A = MiniNero.publicFromInt(1)
    H = MiniNero.hashToPoint_ct(A)
    Translator.hexToC(H) 
    print(H)
    return H
开发者ID:ShenNoether,项目名称:research-lab,代码行数:7,代码来源:RingCT2.py

示例2: MLSAG_Ver

def MLSAG_Ver(pk, I, c0, s ):
    rows = len(pk)
    cols = len(pk[0])
    print("verifying MG sig of dimensions ",rows ,"x ", cols)
    c= [None] * (cols + 1)
    c[0] = c0
    L = keyMatrix(rows, cols)
    R = keyMatrix(rows, cols)
    m = ''.join(pk[0])
    for i in range(1, cols):
        m = m + ''.join(pk[i])
    i = 0
    while i < cols:
        L[i] = [MiniNero.addKeys1(s[i][j], c[i], pk[i][j]) for j in range(0, rows)]

        Hi = hashKeyVector(pk[i])
        R[i] = [MiniNero.addKeys2( s[i][j], Hi[j], c[i], I[j]) for j in range(0, rows)]

        oldi = i
        i = i + 1
        c[i] = MiniNero.cn_fast_hash(m+''.join(L[oldi]) + ''.join(R[oldi]))
    print("L", L)
    print("R", R) 
    print("c", c)

    return (c0 == c[cols])
开发者ID:Coder420,项目名称:MiniNero,代码行数:26,代码来源:MLSAG2.py

示例3: sumCiExp

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,代码行数:7,代码来源:RingCT.py

示例4: keyImage

def keyImage(x, rows):
    HP = keyVector(rows)
    KeyImage = keyVector(rows)
    for i in range(0, rows):
      HP[i] = MiniNero.hashToPoint_cn(MiniNero.scalarmultBase(x[i]))
      KeyImage[i] = MiniNero.scalarmultKey(HP[i], x[i])
    return KeyImage
开发者ID:Coder420,项目名称:MiniNero,代码行数:7,代码来源:MLSAG.py

示例5: importMM

def importMM(wordlist):
    print("for testing purposes only!")
    sk = MiniNero.recoverSK(wordlist)
    print("vk", vk)
    print("pvk", MiniNero.publicFromSecret(vk))
    key = mnemonic.mn_encode(sk)
    cks = MiniNero.electrumChecksum(key)
    print(key + " "+cks)
开发者ID:Coder420,项目名称:MiniNero,代码行数:8,代码来源:MyMoneroImport.py

示例6: ecdhDecode

def ecdhDecode(masked, receiverSk):
    rv = ecdhTuple()
    #compute shared secret
    sharedSec1 = MiniNero.cn_fast_hash(MiniNero.scalarmultKey(masked.senderPk, receiverSk))
    sharedSec2 = MiniNero.cn_fast_hash(sharedSec1)
    #encode
    rv.mask = MiniNero.sc_sub_keys(masked.mask, sharedSec1)
    rv.amount = MiniNero.sc_sub_keys(masked.amount, sharedSec1)
    return rv
开发者ID:ShenNoether,项目名称:research-lab,代码行数:9,代码来源:RingCT2.py

示例7: ctskpkGen

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,代码行数:9,代码来源:RingCT2.py

示例8: getH2ForCT

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,代码行数:10,代码来源:RingCT2.py

示例9: ecdhEncode

def ecdhEncode(unmasked, receiverPk):    
    rv = ecdhTuple()
    #compute shared secret
    esk, rv.senderPk =  PaperWallet.skpkGen()
    sharedSec1 = MiniNero.cn_fast_hash(MiniNero.scalarmultKey(receiverPk, esk));
    sharedSec2 = MiniNero.cn_fast_hash(sharedSec1)
    #encode
    rv.mask = MiniNero.sc_add_keys(unmasked.mask, sharedSec1)
    rv.amount = MiniNero.sc_add_keys(unmasked.amount, sharedSec1)
    return rv
开发者ID:ShenNoether,项目名称:research-lab,代码行数:10,代码来源:RingCT2.py

示例10: MLSAG_Ver

def MLSAG_Ver(pk, keyimage, c1, s ):
    rows = len(pk)
    cols = len(pk[0])
    print("verifying MLSAG sig of dimensions ",rows ,"x ", cols)
    L = [[None]*cols]
    R = [[None]*cols]
    pj = ''.join(pk[0])
    for i in range(1, rows):
      L.append([None] * cols)
      R.append([None] * cols)
      pj = pj + ''.join(pk[i])
    c= [None]*(cols+1) #you do an extra one, and then check the wrap around 
    HP = [[MiniNero.hashToPoint_cn(i) for i in pk[0]]]
    for j in range(1, rows):
      HP.append([MiniNero.hashToPoint_cn(i) for i in pk[j]])
    c[0] = c1
    j = 0
    while j < cols:
      tohash = pj
      for i in range(0, rows):
        L[i][j] = MiniNero.addKeys(MiniNero.scalarmultBase(s[i][j]), MiniNero.scalarmultKey(pk[i][j], c[j]))
        R[i][j] = MiniNero.addKeys(MiniNero.scalarmultKey(HP[i][j], s[i][j]), MiniNero.scalarmultKey(keyimage[i], c[j]))
        tohash = tohash + L[i][j] + R[i][j]
      j = j + 1
      c[j] = MiniNero.cn_fast_hash(tohash)

    rv = (c[0] == c[cols])
    print("c", c)
    print("sig verifies?", rv)
    
    return rv
开发者ID:Coder420,项目名称:MiniNero,代码行数:31,代码来源:MLSAG.py

示例11: rangeProof

def rangeProof(C_out_i, masks_i):
    n = len(masks_i)
    I_Proofs = [None] * n
    c0s = [None] * n
    ss = [None] * n
    C_is = [None] * n
    for i in range(0, n):
        C_i = MiniNero.addKeys(MiniNero.scalarmultBase(masks_i[i]), MiniNero.scalarmultKey(H_ct, C_out_i[i])) # masks_i * G + C_out_i * H
        C_i_prime = MiniNero.subKeys(C_i, H_ct) #C_i - H
        C_is[i] = [C_i_prime, C_i]
        print("generating LLWsig for range proof from Cis, masks, couts", C_is[i], masks_i[i], C_out_i[i])
        I_Proofs[i], c0s[i], ss[i] = LLW_Sigs.LLW_Sig(C_is[i], masks_i[i], MiniNero.hexToInt(C_out_i[i]))
        #ring sig on the above, with sk masks_i
    return I_Proofs, c0s, ss, C_is
开发者ID:Coder420,项目名称:MiniNero,代码行数:14,代码来源:Old_Ring_CT.py

示例12: GenASNL

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,代码行数:15,代码来源:ASNL.py

示例13: CT_ring_sig

def CT_ring_sig(pk, C_in, C_out, xz, index):
    print("Generating Ct ring sig")
    n = len(pk)
    pk2 = [None] * 2
    for i in range(0, n):
        pk2[i] = MiniNero.addKeys(pk[i], C_in)
        for j in C_out:
            pk2[i] = MiniNero.subKeys(pk2[i], j)
    print("check validity", pk2[index], MiniNero.scalarmultBase(xz))
    if pk2[index] != MiniNero.scalarmultBase(xz):
        print("stop lying, you don't know a key")
        exit()
    I, c0, s = LLW_Sigs.LLW_Sig(pk2, xz, index)
    print("Ct ring sig generated")
    return I, c0, s, pk2
开发者ID:Coder420,项目名称:MiniNero,代码行数:15,代码来源:Old_Ring_CT.py

示例14: verRange

def verRange(Ci, ags):
    n = ATOMS
    CiH = [None] * n
    H2 = getH2ForCT()
    for i in range(0, n):
        CiH[i] = MiniNero.subKeys(ags.Ci[i], H2[i])
    return AggregateSchnorr.VerASNL(ags.Ci, CiH, ags.asig.L1, ags.asig.s2, ags.asig.s) 
开发者ID:ShenNoether,项目名称:research-lab,代码行数:7,代码来源:RingCT2.py

示例15: genRct

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,代码行数:31,代码来源:RingCT2.py


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