Failed to sign by python library

Hello, I want to sign transaction by python3.
But, nem-py didn’t maintained and didn’t work no pyton3.
So I edit and works.
I checked creation address & pubkey from privatekey, I signed and verified message.

library is here.
ed25519.py https://pastebin.com/8j9HBrJA
python_sha3.py https://pastebin.com/t5QSPrkz

Next, I try to sign with the library, but signeture isn’t same with correct one.

import ed25519

ADDR = 'TA7CKYFLAKGE26BWROOI3TCCR27MSFWSVUA66D5J'
PUB = '0cda844db921f4bdf58eb8e9c2741e56194b9890e956bb39a68bbbd100cc4cd0'
PRI = '87e669de05ea6e814bf86e6a78d0b869509084a4e944e05348c55dbce6a06dce'
rawtx = '0101000001000098461f7704200000000cda844db921f4bdf58eb8e9c2741e56194b9890e956bb39a68bbbd100cc4cd0a086010000000000562d7704280000005444454b33444f4b4e353458574556554e584a4f4c57444a4d59454632473748504b324c5255355740420f000000000023000000010000001b000000492074657374207369676e696e67207769746820707974686f6e2e'

ecc = ed25519.Ed25519()

signature = ecc.sign(rawtx, PRI, PUB)
print("sign:", signature)
assert ecc.verify(rawtx, signature, PUB), "verification failed"
print("signature OK!")

rawtx is http://bob.nem.ninja:8765/#/transfer/4c1f520c7ed47458ee92eaa4df087f75df33c47b5d6ab93baae350f1967decb7

THe library output 23ce215b6dcea07b82a20c6fc58f91b597d43d8b1e747775257170da2a655b5475a8f3ba453e26086df81433271678eb7fa135e9ded640d51be62143745b5f00
However correct signature is a7c7dbaeb6c81fcf79b85e343b2a26cc8f0bf5173bb35d057a7460a7761af6e8e7bc5b18a009e9356e2c4a441c769e629057342f40f9bea404279406c070a203

library verification is completed, so I confused, what’s wrong???

@gimre If you have time, we would be pleased if you could tell us.

Thank you for reply.
Can @gimre help me about signature?
I will wait for him. :slight_smile:

start by checking if library that you’re using output matches test vectors:

keep in mind that nis1 is actually using keccak not sha3
sha3 implementation attached to nem-py should give correct results

Thank you very much.

Thank you for reply. :laughing:

I checked with nem-test-vectors.
I find Import error, so I moved hash fnction to above and correct PATH.
I put three parameter

PUB = '0cda844db921f4bdf58eb8e9c2741e56194b9890e956bb39a68bbbd100cc4cd0'
PRI = '87e669de05ea6e814bf86e6a78d0b869509084a4e944e05348c55dbce6a06dce'
rawtx = '0101000001000098461f7704200000000cda844db921f4bdf58eb8e9c2741e56194b9890e956bb39a68bbbd100cc4cd0a086010000000000562d7704280000005444454b33444f4b4e353458574556554e584a4f4c57444a4d59454632473748504b324c5255355740420f000000000023000000010000001b000000492074657374207369676e696e67207769746820707974686f6e2e'

I test nem_test_vectors.py with Python2. It works!
It may be solved.

1 Like