-
Notifications
You must be signed in to change notification settings - Fork 310
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
Hidden assumptions within multisig transaction signing #962
Comments
Admittedly, this was a design oversight in SIP-005 (but one we're stuck with for the time being). We're considering relaxing this in the Stacks 2.1 upgrade to make it so the signatures can be generated in any order. |
Better support for uncompressed keys was just added to |
can this be closed now? |
No objection to closing on my end. |
Describe the bug
When submitting a P2SH multisig transaction to the mainnet/testnet that was signed with compressed keys, the network responds with the error:
Signer hash does not equal hash of public key(s)
. Close reading of SIP-005 as well as thestacks-blockchain
source code, indicate that there are a lot of underlying assumptions abstracted by the library, further aggravated by incorrect generalizations in the example comments.Code to Reproduce
Expected Behavior
The code as given above will fail with the aforementioned error. The reason for it is that the keys in the fields are in the wrong order and thus the
hash160
of the redeem script mismatches.Additional Context
The solution with the current state of the verify function to this must be the following:
Even after meeting the
numSignatures
requirement, the signatures as well as the public keys of the participants who did not sign must end up IN THE SAME ORDER in the spending condition fields relative to the public key order used to generate the redeem script.Also unmentioned (at least in this library) and yet expected is that the private key compression byte is used to generate the "type" in the transaction that is read by the signature verification to regenerate the public key. Each of these must match the format (i.e., compressed or uncompressed) for the corresponding public key passed to
makeUnsignedSTXTokenTransfer
. See SIP-005.Workarounds
checkOversign
tofalse
which would remove the guardrails but allow the following:signOrigin
. Great care must be taken to ensure the sighash generation is consistent.Related Issues
The text was updated successfully, but these errors were encountered: