Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid transaction signature when its VALID on quoted repost with Node key #264

Open
donhardman opened this issue Mar 16, 2022 · 8 comments

Comments

@donhardman
Copy link
Contributor

donhardman commented Mar 16, 2022

This transaction has a valid signature, but the core says it's invalid.

We tried to do the same, but WITHOUT an extra data key (Node) passed, and the transaction passed through.

So my thoughts are somehow, when transaction parsed/converted to bytes again feels like the Node key missed and the signature checked using a wrong hash. But it's just thought from pattern we can see. Maybe wrong, but the issue persists when Node extra data key is presented in transaction.

Here is the transaction (inputs may or not be spent)

019b4fd0f7d2c8970b4e289d753ccb369dfdea11dca9ca012ce9a90ca3d123ee96010102a0b40718cf8e70aa2ac59236df101a9979ef0df756457cd239c74c9fb48cad99a9dfd56d05900100007f7b22426f6479223a224920626574205c22446973636f7665725c222077696c6c20626520746865206d6f7374206f6674656e20766973697465642070616765206f6e20404f766572636c6f7574206166746572206c61756e6368203a295c6e5c6e234f766572636c6f757420697320636f6d696e6720666f7220796f75227d904ed4618084a1fc9bfdb6ee16002102a0b40718cf8e70aa2ac59236df101a9979ef0df756457cd239c74c9fb48cad9903044e6f64650232360f497351756f7465645265636c6f75740101115265636c6f75746564506f73744861736820432d355a19f3487a8b5f639bf7e128dc8c6e1bece9acd160e6814aaacef35a1e4730450220687d524614a397c77070de2f72768b550008dc2c8494dae047897c9796070c30022100aa7945537bc8971ffe7ed30cd23a344e3de8098cc2ea61a8933152e7578bc06d

The result of submitting it

image

{"error":"SubmitTransaction: Problem processing transaction: VerifyAndBroadcastTransaction: Problem validating txn: ValidateTransaction: Problem validating transaction: : ConnectTransaction: : _connectSubmitPost: : _connectBasicTransfer: Problem verifying txn signature: : RuleErrorInvalidTransactionSignature"}

It works when we are doing a normal post with Node extra key. When do quoted post with Node extra key – never works! We manually build transactions, so we take the signature of full hex with all data in without reparsing it.

@donhardman donhardman changed the title Invalid transaction when its VALID on quoted repost Invalid transaction signature when its VALID on quoted repost with Node key Mar 16, 2022
@lazynina
Copy link
Member

@donhardman can you provide the transaction before you converted to hex please?

@donhardman
Copy link
Contributor Author

donhardman commented Mar 17, 2022

Here is binary transaction
tx.bin.zip

@lazynina
Copy link
Member

@donhardman - your extra data keys are not sorted alphabetically. In order to properly serialize the transaction, we sort the keys of the extra data object and then encode them in sorted order. Can you try sorting the keys and let me know if the issue persists?

@donhardman
Copy link
Contributor Author

Ohhh. So you mean we need to sort it bulid tx in bin format and ONLY AFTER that sign it? Am I right?

@donhardman
Copy link
Contributor Author

So final tx is sorted and converted to bytes when it's checked with signature, right? Thats why it's invalid in core, and really valid in real life

@donhardman
Copy link
Contributor Author

We will try and I will back during a day with results. Thanks! Dont you think this sorting is really important? I mean why just to not respect original order, it's just map?

@lazynina
Copy link
Member

@donhardman - I need to see some code on how you're constructing transaction to really understand what's happening. Without code, I'm missing some details. When a transaction is converted to bytes, we order the extra data keys so that transactions are serialized the same by all nodes.

@donhardman
Copy link
Contributor Author

OK seems like sorting extra data keys before building the transaction solved the issue. Thanks for helping to figure it out! But anyway.

But I guess it should be a kind of check on top of consensus that will reject transactions with non-alphabetical sorting in extra data. As for now, it says that the signature is incorrect just because of rebuilding bytes for the signature check.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants