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

BUG: CBOR Transformation Breaks Script Integrity #25

Open
fallen-icarus opened this issue Jul 31, 2024 · 0 comments
Open

BUG: CBOR Transformation Breaks Script Integrity #25

fallen-icarus opened this issue Jul 31, 2024 · 0 comments

Comments

@fallen-icarus
Copy link

fallen-icarus commented Jul 31, 2024

I opened this issue under the cardano-hw-cli repo, but it looks like this library is used to actually transform the transaction (here). So the bug is actually here. If I am wrong about this, feel free to close this issue.

The TLDR is that transforming a transaction using a redeemer with internal fields will result in an invalid transformation. Submitting this transaction results in a ScriptIntegrity mismatch error. For example, transforming a transaction using the unit redeemer:

{"constructor":0,"fields":[]}

is fine, but transforming a transaction using this more complicated redeemer:

{"constructor":0,"fields":[{"constructor":1,"fields":[{"bytes":"c0f8644a01a6bf5db02f4afe30d604975e63dd274f1098a1738e561d"}]}]}

results in the ScriptIntegrity mismatch error upon submission.

You can verify this bug by trying to mint test tokens using the always succeeding minting policy which can be used with any redeemer:

{
    "type": "PlutusScriptV2",
    "description": "",
    "cborHex": "484701000022120011"
}

When I tested it, I got these results:

Redeemer Transformed Result
Unit Yes Success
Unit No Success
Complex Yes Fail
Complex No Success

This bug makes it impossible to use cardano-hw-cli to verify transactions involving smart contracts that use more complicated redeemers.


This is just a guess, but I am assuming the transformation is changing the redeemer's internal constructor index from 1 to 0 in order to comply with "integers must be as small as possible" (spec). The transformation should not touch the redeemer since the constructor index specifies which action is being taken.

EDIT: My guess was wrong. I tried using the complex redeemer with an internal constructor index of 0 and it still failed with a ScriptIntegrity error.

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

1 participant