Exemplo n.º 1
0
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])
Exemplo n.º 2
0
def MLSAG_Gen(pk, xx, index ):
    rows = len(xx)
    cols = len(pk[0])
    print("Generating MG sig of size ", rows, "x", cols)
    c= [None] * cols
    alpha = skvGen(rows)
    I = keyImageV(xx)
    L = keyMatrix(rows, cols)
    R = keyMatrix(rows, cols)
    s = keyMatrix(rows, cols)
    m = ''.join(pk[0])
    for i in range(1, cols):
        m = m + ''.join(pk[i])
    L[index] = [MiniNero.scalarmultBase(aa) for aa in alpha] #L = aG
    Hi = hashKeyVector(pk[index])
    R[index] = [MiniNero.scalarmultKey(Hi[ii], alpha[ii]) for ii in range(0, rows)] #R = aI
    oldi = index
    i = (index + 1) % cols
    c[i] = MiniNero.cn_fast_hash(m+''.join(L[oldi]) + ''.join(R[oldi]))
    
    while i != index:
        s[i] = skvGen(rows)
        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) % cols
        c[i] = MiniNero.cn_fast_hash(m+''.join(L[oldi]) + ''.join(R[oldi]))
    print("L", L)
    print("R", R)
    s[index] = [MiniNero.sc_mulsub_keys(alpha[j], c[index], xx[j]) for j in range(0, rows)] #alpha - c * x
    return I, c[0], s
Exemplo n.º 3
0
def MLSAG_Ver(pk, I, c0, s):
    rows = len(pk[0])
    cols = len(pk)
    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])
Exemplo n.º 4
0
def MLSAG_Gen(pk, xx, index):
    rows = len(xx)
    cols = len(pk)
    print("Generating MG sig of size ", rows, "x", cols)
    print("index is:", index)
    print("checking if I can actually sign")
    print(pk[index])
    print([MiniNero.scalarmultBase(x) for x in xx])
    c = [None] * cols
    alpha = skvGen(rows)
    I = keyImageV(xx)
    L = keyMatrix(rows, cols)
    R = keyMatrix(rows, cols)
    s = keyMatrix(rows, cols)
    m = ''.join(pk[0])
    for i in range(1, cols):
        m = m + ''.join(pk[i])
    L[index] = [MiniNero.scalarmultBase(aa) for aa in alpha]  #L = aG
    Hi = hashKeyVector(pk[index])
    R[index] = [
        MiniNero.scalarmultKey(Hi[ii], alpha[ii]) for ii in range(0, rows)
    ]  #R = aI
    oldi = index
    i = (index + 1) % cols
    c[i] = MiniNero.cn_fast_hash(m + ''.join(L[oldi]) + ''.join(R[oldi]))

    while i != index:
        s[i] = skvGen(rows)
        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) % cols
        c[i] = MiniNero.cn_fast_hash(m + ''.join(L[oldi]) + ''.join(R[oldi]))
    print("L", L)
    print("R", R)
    s[index] = [
        MiniNero.sc_mulsub_keys(alpha[j], c[index], xx[j])
        for j in range(0, rows)
    ]  #alpha - c * x
    return I, c[0], s
Exemplo n.º 5
0
     h="247a9b60e8a31c18bfab9f6bf7b5079bc8c1955ea6726ea3f2bc38a3ec1bc658"
     pubb="ff33f4df1f8f44bfed3572134814f83c890495bd4714a0aaff0e0239c1acc927"
     sec="9d5f81503e5280cd8fdcd12c94bea81bdf4c2f87ebc0992ab177fba51db92c0a" 
     r, c = ASNL.GenSchnorr(h,pubb, sec, PaperWallet.skGen())
     Translator.sigToC(r, c)
     print("verd?", ASNL.VerSchnorr(h, pubb, r, c))
 if sys.argv[1] == "data":
     skv = ["ae5934fe1e8065ec19afc80f2f06fc3f36730405a022813e2b18dc9da929da02", "2a9f99b0313157ba599bde727e04d6bfe87163f1d7dc93a352b1a648d7178205", "f0fb4504b06785caac17f4c554526685eed71d21b9b542f50c6e396b6152a403", "e5f7c934aa59c2ea21efeb4695d09bb95402d0dcc92d5bbec59eb1fc5912cf0f", "795f05824fb9e4a0808a523ecc9fefcb9e563e152d9b101224cb18169d3a4a05"]
     pkv = MLSAG2.vScalarMultBase(skv)
     print(pkv)
 if sys.argv[1] == "addKeys":
   a, A = ('13e467e9c0034e6878af5c801a81ee0543b1096b5ab01356b349cc3235cd1909', 'a50e5e751a9906f9ff086c734591d0ee87be6ca58fe7208b8e070e54d2eda0da')
   b, B = ('cd43ec6b80dd5ea2668e141fc6dc1191258b5eb58bf7dbef9e647aca3ba09707', '4f31e64eb9017ac02c6313294d0554d4532fbd6ffd15bc175422060867ab33f4')
   Translator.hexToC(a)
   Translator.hexToC(b)
   print(MiniNero.addKeys1(a, b, B))
   print(MiniNero.addKeys2(a, A, b, B))
 if sys.argv[1] == "bighash":
   from bighash import *
   print(MiniNero.cn_fast_hash(a))
   b = "d99e55005f1736e5d843dd11ce80e3e989f3eea52a42e14f6c541620568569ed"
 if sys.argv[1] == "ch":
     a = "18a5f3cf50ae2207d8ccd70179a13b4fc339d0cd6d9138c6d764f8e4cef8f006c87b1367fef3f02ed5ffd42a7ea212c2b8899af3af8f4b1e34139e1e390f3af1"
     print(MiniNero.cn_fast_hash(a))
 if sys.argv[1] == "fastbin":
     b = "0123456789abcdef"
     c = MiniNero.hexToInt(b)
     c = 6000
     print(b, c)
     Translator.hexToC(b)
     b = RingCT.binary(c, 64)
Exemplo n.º 6
0
         "f0fb4504b06785caac17f4c554526685eed71d21b9b542f50c6e396b6152a403",
         "e5f7c934aa59c2ea21efeb4695d09bb95402d0dcc92d5bbec59eb1fc5912cf0f",
         "795f05824fb9e4a0808a523ecc9fefcb9e563e152d9b101224cb18169d3a4a05"
     ]
     pkv = MLSAG2.vScalarMultBase(skv)
     print(pkv)
 if sys.argv[1] == "addKeys":
     a, A = (
         '13e467e9c0034e6878af5c801a81ee0543b1096b5ab01356b349cc3235cd1909',
         'a50e5e751a9906f9ff086c734591d0ee87be6ca58fe7208b8e070e54d2eda0da')
     b, B = (
         'cd43ec6b80dd5ea2668e141fc6dc1191258b5eb58bf7dbef9e647aca3ba09707',
         '4f31e64eb9017ac02c6313294d0554d4532fbd6ffd15bc175422060867ab33f4')
     Translator.hexToC(a)
     Translator.hexToC(b)
     print(MiniNero.addKeys1(a, b, B))
     print(MiniNero.addKeys2(a, A, b, B))
 if sys.argv[1] == "bighash":
     from bighash import *
     print(MiniNero.cn_fast_hash(a))
     b = "d99e55005f1736e5d843dd11ce80e3e989f3eea52a42e14f6c541620568569ed"
 if sys.argv[1] == "ch":
     a = "18a5f3cf50ae2207d8ccd70179a13b4fc339d0cd6d9138c6d764f8e4cef8f006c87b1367fef3f02ed5ffd42a7ea212c2b8899af3af8f4b1e34139e1e390f3af1"
     print(MiniNero.cn_fast_hash(a))
 if sys.argv[1] == "fastbin":
     b = "0123456789abcdef"
     c = MiniNero.hexToInt(b)
     c = 6000
     print(b, c)
     Translator.hexToC(b)
     b = RingCT.binary(c, 64)