Beispiel #1
0
def proveRctMG(pubs, inSk, outSk, outPk, index):
    #pubs is a matrix of ctkeys [P, C]
    #inSk is the keyvector of [x, mask] secret keys
    #outMasks is a keyvector of masks for outputs
    #outPk is a list of output ctkeys [P, C]
    #index is secret index of where you are signing (integer)
    #returns a list (mgsig) [ss, cc, II] where ss is keymatrix, cc is key, II is keyVector of keyimages

    #so we are calling MLSAG2.MLSAG_Gen from here, we need a keymatrix made from pubs
    #we also need a keyvector made from inSk
    rows = len(pubs[0])
    cols = len(pubs)
    print("rows in mg", rows)
    print("cols in mg", cols)
    M = MLSAG2.keyMatrix(
        rows + 1, cols
    )  #just a simple way to initialize a keymatrix, doesn't need to be random..
    sk = MLSAG2.keyVector(rows + 1)

    for j in range(0, cols):
        M[j][rows] = MiniNero.identity()
    sk[rows] = MiniNero.sc_0()
    for i in range(0, rows):
        sk[i] = inSk[i].dest  #get the destination part
        sk[rows] = MiniNero.sc_add_keys(sk[rows],
                                        inSk[i].mask)  #add commitment part
        for j in range(0, cols):
            M[j][i] = pubs[j][i].dest  # get the destination part
            M[j][rows] = MiniNero.addKeys(
                M[j][rows], pubs[j][i].mask)  #add commitment part
    #next need to subtract the commitment part of all outputs..
    for j in range(0, len(outSk)):
        sk[rows] = MiniNero.sc_sub_keys(sk[rows], outSk[j].mask)
        for i in range(0, len(outPk)):
            M[j][rows] = MiniNero.subKeys(
                M[j][rows], outPk[i].mask)  # subtract commitment part
    MG = mgSig()
    MG.II, MG.cc, MG.ss = MLSAG2.MLSAG_Gen(M, sk, index)

    return MG  #mgSig
Beispiel #2
0
        print("x", x)
        II, cc, ss = MLSAG.MLSAG_Sign(P, sk, ind)
        print("Sig verified?", MLSAG.MLSAG_Ver(P, II, cc, ss))
    if sys.argv[1] == "MLSAG2":
        #below is example usage. Uncomment each line for testing
        rows = 3  #cols
        cols = 3  #rows
        ind = 1

        x = MLSAG2.skmGen(rows, cols)
        sk = x[ind]
        P = MLSAG2.keyMatrix(rows, cols)
        for i in range(0, cols):
            P[i] = MLSAG2.vScalarMultBase(x[i])

        II, cc, ss = MLSAG2.MLSAG_Gen(P, sk, ind)
        print("I", II)
        print("c0", cc)
        print("s", ss)
        print("Sig verified?", MLSAG2.MLSAG_Ver(P, II, cc, ss))
    if sys.argv[1] == "MLSAGc":
        P = [[
            "4a199991d80915f99870b702fb6b3fa7b127853c4ed12ac2bb071534b9b5dee6",
            "86e2c2ec0262c465749fdb1940de954d87d1e6b96beda093bc185f329e157c53",
            "e9e83e74299bd3cdad4c87c6548dba859680000740660d1f783486d4cafef79f"
        ],
             [
                 "78656dbba0fdfd14fc99b4da8b73c81314b9e65eeaa4eac510ca4dd28bae63a0",
                 "987f7b1b498e6ec25ad2ce304300388396a374721a24602b16905eeeb9a42fb0",
                 "b1a9c583747a8815fa7a80452efb4f93042dc64db08b3d2f7ac5016ea2b882eb"
             ],