def verRctMG(MG, pubs, outPk): #mg is an mgsig (list [ss, cc, II] of keymatrix ss, keyvector II and key cc] #pubs is a matrix of ctkeys [P, C] #outPk is a list of output ctkeys [P, C] for the transaction #returns true or false rows = len(pubs[0]) cols = len(pubs) M = MLSAG2.keyMatrix( rows + 1, cols ) #just a simple way to initialize a keymatrix, doesn't need to be random.. for j in range(0, cols): M[j][rows] = MiniNero.identity() for i in range(0, rows): 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, cols): for i in range(0, len(outPk)): M[j][rows] = MiniNero.subKeys( M[j][rows], outPk[i].mask) # subtract commitment part return MLSAG2.MLSAG_Ver(M, MG.II, MG.cc, MG.ss)
#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" ], [ "d3ef77673ee441b2ca3b1f9e7f628df9f6306d89d8c5155c3c6ee4c9f5f51408", "5423f77332aa6a015ddc70a82e27fe52c68ab47e08b5c07d03641194de4ea1fb", "ec564efa1511f73f91649d942fff0921763e4be37ee114036bd584f7a8fb9fd9"