1

I'd like to verify a MLSAG signature with a real transaction but it doesn't work..

I chose a transaction 886687fdd30ad46ef1f7c7c18402d82212b4ae1fd2cf6b4dfc549e46be7e22f6

And here is the code written with mininero

import MiniNero

def MLSAG_Ver(msg, pk, n, m, m1, I, c0, s):
    c = c0
    i = 0
    while i < n:
        tohash = msg
        j = 0
        while j < m:
            tohash = tohash + pk[j][i]
            L = MiniNero.addKeys(MiniNero.scalarmultBase(s[j][i]), MiniNero.scalarmultKey(pk[j][i], c))
            tohash = tohash + L
            if j < m1:
                HP = MiniNero.hashToPointCN(pk[j][i])
                R = MiniNero.addKeys(MiniNero.scalarmultKey(HP, s[j][i]), MiniNero.scalarmultKey(I, c))
                tohash = tohash + R
            j = j+1
        c = MiniNero.cn_fast_hash(tohash)
        i = i+1
    if c == c0:
        print("true")
    else:
        print("false")

msg = "1d990b4638ef747f8ec8a1fa3507eec0c32ceffb3d8e650bcddebe97245469fd"
I = "3352ef16ca15e8cbc67cd1ddd66ae3dc8ea904ab19db9a29de287a5d948b152e"
pk = ["b7abbe863058eb4ed373feae10cfb372848bbe9511fdf4ffaaf69a512482d296",\
      "e926338f8a94751cd38a7c2c70a8b4c6b213eae28efb97cac686c7ef394be396",\
      "e92043567e7e0a6bd942bd765578c132174f496b21c78823a16be6e57e24aaeb",\
      "0377caa3292617487ba32d5a748750eebcca55ad8ac85e06bc772d32354f63af",\
      "a4792780889e5e55bffe1524dcf965d1908d198b5fe698ba7840869c0ecdd6df",\
      "7e684049c73626fa4704a43ace24dc3f1cd467bc22e22cbeba78659f36d14bc9",\
      "177ce3b8bb9c9e0475c6eb5500771cd828b36b1baab0e0eb46abc84ee811bc36",\
      "730e3a22f72b5c2724e822d92332ffd2c2803fba8ba50b5f46a645e719efdc50",\
      "7eb748799bfd30c60214f23ccc4e01b107b10c74435190410ce01aadd46b33e0",\
      "397dce6fadb5b8e37c80340f8a1eea01d2e794cf6faa806e160fa52f991a3bdb",\
      "757be6485a7b4370ac062389ae15b1b46d19b38dcadfde38436fb7c1ce056d59"],\
     ["fd2eca4d0506d9111359add3448be42ba6dbe28d732b5bc3a42cbd5613caaf13",\
      "71929d17d1863471663c7febdf3bace7cc9d366a9bfd1345c2cac43c35d68f8e",\
      "d450e032ba466dd0fadbe831ee5e91187711b37fa4f3c124629066b152ca599b",\
      "2aa4ac5a7d30e375af9153955b510dc3939dd8ceaf58992595356f663469fdac",\
      "7d0d91712e3ddc33c2fd92ce7216b319b3acb1b16aa8147976517e64b4158b67",\
      "4a0acfbe0a869589e66616681e93b9c311b6374d0873541295bc0a8437565376",\
      "e5990b5701085aec19c11d19edd8abf670ad1e53a77b4f0e82d142efdbfb28a0",\
      "75eb46a7b72b2f394d647d6c3b3de290f39238bf3034a381024d6b938e95ba97",\
      "4b4eb4b434f85102c728fe9134feec6cebfbefff881fa673feefc62d02527516",\
      "132cead5678f1902066ee4169de0d94b957360ec4d1e92340907c44a3d5440ad",\
      "cd334425475a8bc219a71c94c0c4b8e277cba0791fb545222dd5fe18e99e6712"]


s =  ["a3628fda5306c2c91986c05e0c939acb1c498c47276863c6b8b4b14381455d05",\
      "4f84565268d4cadd909f626bc85325d968364e5044de9decead91ecb824be60f",\
      "4cd282c891ac453902b0c7cf13a02bbcf328ff8ac4d2fafb20bbb0b67860db07",\
      "9a6e3526b4f28c448c830494e3f98cd0831351a1e5289a3f5c8363687d728206",\
      "733759bb10fc8e228b7ca8b257852418e31ba9b82488355f1fdb2abc9193f90e",\
      "1ece317df2d04b0c783740776362c2ba3c2d5a30fd63852b60d8d535cd92c701",\
      "405b4e3ce3e41be8e36d1d52b64d34a69d5f8eb0aff311202ee41c1cb3787508",\
      "aa2946443c0b2549da165eacd208d84e966e91db8cab27e5b07ec401580ed000",\
      "3ae2b18ce171311c711678d5829ebea65457b52ed7c6085c40782f0c9d8a380b",\
      "e93cf157e4d7c4505b249042a4ae7687354ffb815bf4d53717ea0678daee3407",\
      "b1c559a9140b090217905288ce8f16a961baed949102ad860afb9622259dd600"],\
     ["24a21c6d227540074830b7b4757fc086aba6d5c93babb913e37994f3fb6bb909",\
      "dd50708d2791d39a68caffb22fc99f5b663bf7df0f317913070e08150a0c830d",\
      "bf0d9a648c1c24530e1c9f1c3475b04a3f73de8ce8bc31904bd183da7fd1170e",\
      "13e3a1ced79931086e1682c446af97c58a2604e21df647869f1bb88919e5d602",\
      "df5816a00c64b3a1eced8ad30a1820b4785aaf6c10ff44dfbc71153ab2eb940e",\
      "7ae078de9bc0fe585c4d80ba8ebfea941c6a3a56105b4a6244737b9d0d0ced0e",\
      "a7d589bffc68febe0cbc59c56be34accc1c6847770480ca08a2826b611b9de02",\
      "bc09262d136f22a7c2af6c6a174283bb2f3c398838305f4934b3ea0a05083d0b",\
      "80e21b02139f40d5cc834ca3130a211141aca1a824ce073f26d82a72cafcae07",\
      "14550c61a8111d6a8e9def65195747d406c276e9f4f26b590e02b7b29278150d",\
      "35fc89f428f536dcd2264c9918f29bafa08d9f583b97593229ac8bf4befb7100"]

c0 = "0c7b9e033d4846dbee0d5bb9587d380ee0ae9f635e6376d37fa6f66c94ec3505"

MLSAG_Ver(msg, pk, 11, 2, 1, I, c0, s)

I get commitment manually and get msg from formula:

m = H(H(tx_prefix), H(ss), H(range proofs))

Please help to point out any problem on it.. Many thanks!

I am so sorry for posting this long-winded question... But I am stuck here for a long time..

Here is how I generate msg:

import MiniNero

L = "02000102000bda97ba08a9d6019dcd0194fa01ec458a0ce803bb01d202a401b2263352ef16ca15e8cbc67cd1ddd66ae3dc8ea904ab19db9a29de287a5d948b152e0200026ae6652253f1c77e93410f85bf0e495b306d2e5f4f2297ee4b4fc10fe871435c00028d703e7041838d747e5634b7ca6b990720c57f93e65f7f266b05e0dad6ca8b912c01ad79af52c10613be3b4a9a71bd2e8b92cdfa5fa2f548ba985fdd8385bb30947f020901d79d2e801fa7c27a"
M = "049091a309fed5f2ae3250548eb60f5f3eb89676f186063e218c62711ff1991d89b3adb9824a26f3ee8e1c0e5ecbebf2951fb90b7d90716d8a6edc1bfdfba054fa5576d086056a7f3036956468e22148f0522fd6d4"
R = "0143ceca385ba0d58b8a4f1740430130db045ad593e03f9a51bf1a66b0b2dd2b986a55f12a12ded59360d23271ceb518375c34e3e69cfff8578f2a77409fb7ddbf8ba64620054a4ef1f67a55d978e484ad891fb92e113b8cc88885f3c43632db38b55f16aa5328e7d7b296d9d6852e999c3c129cda31144392820d47e727b4a009cf2b47c99832dbfdc3358ecfd5db44f3d0d3aab9f269aefab130796d5206b702e916663e10ef7213504a3d14e87863d57528bf2c4f96957d8592e831f45c110507db0e4204cc15e34e775212c293b35f133f0ab21aa209ab4dbc88fcef359b46a08ec2236f70fb8bd3516e3c875a832d2de51659e25fef0b5a311c394a1f740859872b292334d934008e4c01b70826b278f8efc87933ef2d520542538bce9c62f197ef5461013d0b30f780ff089d27cd2c320b6fa26b159e8c4e5d60538a57c6c7004a54aecb38e3cca49b76fb27c95c23b4b5e42c5dcdaf1992dec119a9e6bd390c4ef356b0b61a4e865a9a0135905a9db7f2494fc0ff42e04302e405512fa2934b75a3dba15d8b6cf184a93bdd8956b0b1eca0fe7740545d5cf5559c6f8817d207bea0798be8166038312d3baa3037d16603978b5098cffb858d6f9f350e54f3396eed2f6f1ac98adb8df1981d646146622a5d8c14ce6bc726ea471ff60169a0e63c376abbd7b022f4a6b388095a1697cc55f1ea0292a9742653c734eefe7f3bf7b90cd936a72de9cd59c3f0171ea2496fefcc8693460f27a4c2e03c1d79cc35f8249f23e3ca3da67ff536df7477202cbfe99be75fb609677a8b7acdc312aafd331b90d57eaf2731a042ae0955905608e4c02401f50fbd9b61f8320a68ca82fc4ce713c19973f2de1baedb0d0cd4776a2c51f843d07b205924c246cd8bd93dfa3c5d249c4b1ef31c91040839edda8282d9dacb1e739343084a6626c57aec778c0e49d725342bb828b303257552d56c00b63545256b9af3ee69a10d597e893eea0a5e34f91f569b94c7d3d83a38012a804752174bfeed91f8150544591f98db9b0f"

L1 = MiniNero.cn_fast_hash(L)
M1 = MiniNero.cn_fast_hash(M)
R1 = MiniNero.cn_fast_hash(R)

print(MiniNero.cn_fast_hash(L1+M1+R1))

L1 = H(tx_prefix) -> including version, unlock_time, vin, vout, extra.
M1 = H(ss) -> rct_signatures part.
R1 = H(range_proofs) -> rctsig_prunable part.

  • 2
    There is no guarantee the message formula is 100% accurate. You'll have to refer to get_pre_mlsag_hash() for the exact computation. – koe Jun 3 at 15:32
  • 1
    I believe the MLSAG construction you wrote here is correct, although it's good to check it against a known implementation too. – koe Jun 4 at 3:17
  • 1
    M1 is surely wrong as it should be hash of serialize_rctsig_base not H(ss). That said, the values you have used for L, M and R look ok to me at a casual glance. – jtgrassie Jun 4 at 3:25
  • 1
    "I get them from explore manually." <- They look wrong. The first key should be b7abbe8630.... – jtgrassie Jun 4 at 15:44
  • 1
    Where are you seeing 8b5...? xmrchain.net/tx/… Shows the first ring member is b7abbe.... – koe Jun 4 at 17:36
1

Here is the answer and it works well.
The key point is that commitments should be subtracted by pseudoOuts first.

def MLSAG_Ver(msg, pk, n, m, m1, I, c0, s):
    c = c0
    i = 0
    while i < n:
        tohash = msg
        j = 0
        while j < m:
            if j == 1:
                pk[j][i] = MiniNero.subKeys(pk[j][i], pseu)

            tohash = tohash + pk[j][i]

            L = MiniNero.addKeys(MiniNero.scalarmultBase(s[j][i]), MiniNero.scalarmultKey(pk[j][i], c))
            tohash = tohash + L
            if j < m1:
                HP = MiniNero.hashToPointCN(pk[j][i])

                R = MiniNero.addKeys(MiniNero.scalarmultKey(HP, s[j][i]), MiniNero.scalarmultKey(I, c))
                tohash = tohash + R
            j = j+1
        c = MiniNero.sc_reduce_key(MiniNero.cn_fast_hash(tohash))
        i = i+1
    if c == c0:
        print("true")
    else:
        print("false")

msg = "25d83d029ac3eb919038b422326084e8aa4c7ff7db2f8891428d8bfe66c4abb5"
I = "3352ef16ca15e8cbc67cd1ddd66ae3dc8ea904ab19db9a29de287a5d948b152e"
pk = ["b7abbe863058eb4ed373feae10cfb372848bbe9511fdf4ffaaf69a512482d296",\
      "e926338f8a94751cd38a7c2c70a8b4c6b213eae28efb97cac686c7ef394be396",\
      "e92043567e7e0a6bd942bd765578c132174f496b21c78823a16be6e57e24aaeb",\
      "0377caa3292617487ba32d5a748750eebcca55ad8ac85e06bc772d32354f63af",\
      "a4792780889e5e55bffe1524dcf965d1908d198b5fe698ba7840869c0ecdd6df",\
      "7e684049c73626fa4704a43ace24dc3f1cd467bc22e22cbeba78659f36d14bc9",\
      "177ce3b8bb9c9e0475c6eb5500771cd828b36b1baab0e0eb46abc84ee811bc36",\
      "730e3a22f72b5c2724e822d92332ffd2c2803fba8ba50b5f46a645e719efdc50",\
      "7eb748799bfd30c60214f23ccc4e01b107b10c74435190410ce01aadd46b33e0",\
      "397dce6fadb5b8e37c80340f8a1eea01d2e794cf6faa806e160fa52f991a3bdb",\
      "757be6485a7b4370ac062389ae15b1b46d19b38dcadfde38436fb7c1ce056d59"],\
     ["fd2eca4d0506d9111359add3448be42ba6dbe28d732b5bc3a42cbd5613caaf13",\
      "71929d17d1863471663c7febdf3bace7cc9d366a9bfd1345c2cac43c35d68f8e",\
      "d450e032ba466dd0fadbe831ee5e91187711b37fa4f3c124629066b152ca599b",\
      "2aa4ac5a7d30e375af9153955b510dc3939dd8ceaf58992595356f663469fdac",\
      "7d0d91712e3ddc33c2fd92ce7216b319b3acb1b16aa8147976517e64b4158b67",\
      "4a0acfbe0a869589e66616681e93b9c311b6374d0873541295bc0a8437565376",\
      "e5990b5701085aec19c11d19edd8abf670ad1e53a77b4f0e82d142efdbfb28a0",\
      "75eb46a7b72b2f394d647d6c3b3de290f39238bf3034a381024d6b938e95ba97",\
      "4b4eb4b434f85102c728fe9134feec6cebfbefff881fa673feefc62d02527516",\
      "132cead5678f1902066ee4169de0d94b957360ec4d1e92340907c44a3d5440ad",\
      "cd334425475a8bc219a71c94c0c4b8e277cba0791fb545222dd5fe18e99e6712"]


s =  ["a3628fda5306c2c91986c05e0c939acb1c498c47276863c6b8b4b14381455d05",\
      "4f84565268d4cadd909f626bc85325d968364e5044de9decead91ecb824be60f",\
      "4cd282c891ac453902b0c7cf13a02bbcf328ff8ac4d2fafb20bbb0b67860db07",\
      "9a6e3526b4f28c448c830494e3f98cd0831351a1e5289a3f5c8363687d728206",\
      "733759bb10fc8e228b7ca8b257852418e31ba9b82488355f1fdb2abc9193f90e",\
      "1ece317df2d04b0c783740776362c2ba3c2d5a30fd63852b60d8d535cd92c701",\
      "405b4e3ce3e41be8e36d1d52b64d34a69d5f8eb0aff311202ee41c1cb3787508",\
      "aa2946443c0b2549da165eacd208d84e966e91db8cab27e5b07ec401580ed000",\
      "3ae2b18ce171311c711678d5829ebea65457b52ed7c6085c40782f0c9d8a380b",\
      "e93cf157e4d7c4505b249042a4ae7687354ffb815bf4d53717ea0678daee3407",\
      "b1c559a9140b090217905288ce8f16a961baed949102ad860afb9622259dd600"],\
     ["24a21c6d227540074830b7b4757fc086aba6d5c93babb913e37994f3fb6bb909",\
      "dd50708d2791d39a68caffb22fc99f5b663bf7df0f317913070e08150a0c830d",\
      "bf0d9a648c1c24530e1c9f1c3475b04a3f73de8ce8bc31904bd183da7fd1170e",\
      "13e3a1ced79931086e1682c446af97c58a2604e21df647869f1bb88919e5d602",\
      "df5816a00c64b3a1eced8ad30a1820b4785aaf6c10ff44dfbc71153ab2eb940e",\
      "7ae078de9bc0fe585c4d80ba8ebfea941c6a3a56105b4a6244737b9d0d0ced0e",\
      "a7d589bffc68febe0cbc59c56be34accc1c6847770480ca08a2826b611b9de02",\
      "bc09262d136f22a7c2af6c6a174283bb2f3c398838305f4934b3ea0a05083d0b",\
      "80e21b02139f40d5cc834ca3130a211141aca1a824ce073f26d82a72cafcae07",\
      "14550c61a8111d6a8e9def65195747d406c276e9f4f26b590e02b7b29278150d",\
      "35fc89f428f536dcd2264c9918f29bafa08d9f583b97593229ac8bf4befb7100"]

c0 = "0c7b9e033d4846dbee0d5bb9587d380ee0ae9f635e6376d37fa6f66c94ec3505"
pseu = "8c3a4f1bb2ffce27aaed405f84b70d8e04ee00774399f8efd28b5f19f1c3d333"

MLSAG_Ver(msg, pk, 11, 2, 1, I, c0, s)
| improve this answer | |
  • can you accept this answer for that beautiful green? – koe Jun 14 at 22:51
  • Sure, thanks! :) – Mooooo Jun 15 at 1:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.