-
Notifications
You must be signed in to change notification settings - Fork 0
Signing identical transaction results in different raw tx #53
Comments
Hello @ashchan It's indeed an expected behavior. Secp256k1 library from Bitcoin allows to supply an additional entropy when signing, and it's utilized by web3swift. In addition, an explicit public key recovery from the signature is done to ensure that recovered signer key matches the private key. Sincerely, Alex |
Thanks for responding quickly. I looked at the Secp256k1 wrapper and found that it indeed uses a random entropy while calling On a second thoughts, one issue with this behavior is the txhash would change when signing the same tx multiple times.
|
Yes, TX hash can change, but nevertheless it's completely determined by the content and signature and can not change after being signed and sent, so identifier after a successfully sending it will stay. I'm not aware of any case when knowledge of completely deterministic signature is required before production of the signature (you can not get it without a private key anyway), but if you do - please post here. Sincerely, Alex |
I've added an extra test for deterministic (without extra entropy) signature, although it fails in 50% cases in simulator and on iOS device. Sincerely, Alex |
I've found an error that made a signature fail 50% of time without extra entropy. Now deterministic signatures work and I can set them as defaults if necessary, although having some extra entropy is usually a good option. |
@shamatar Awesome! Just did some tests, now Ethereum transaction sign is consistent. Also checked that with MEW and they produce the same raw tx for the same transaction. Thank you! |
When creating
EthereumTransaction
multiple times (all data includingnonce
are identical) and signing with the same private key, it gets different raw tx(rlped tx) withEthereumTransaction.encode(forSignature: false)
. Is this expected behavior?Looks like
r
ands
from secp256k1 are changing each time.The text was updated successfully, but these errors were encountered: