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 #177

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

BUG: CBOR Transformation Breaks Script Integrity #177

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

Comments

@fallen-icarus
Copy link

$ cardano-hw-cli version
Cardano HW CLI Tool version 1.16.0-rc.1
Commit hash: e7225d91e0ddc6152ad973ba803d6c016cb14d7e

The script integrity involves hashing the script, redeemer, and datum that will be used for its execution (spec). When transforming a tx.body file with a smart contract using a redeemer that contains internal fields, the cbor transformation incorrectly changes the redeemer which invalidates the script integrity hash.

Consider the always succeeding minting policy (policy id c0f8644a01a6bf5db02f4afe30d604975e63dd274f1098a1738e561d):

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

This script can be executed with any redeemer. For example, the unit redeemer:

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

Everything is fine when the minting policy is executed with the unit redeemer. However, if the redeemer has extra fields like:

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

the transformed transaction submission will now fail with a ScriptIntegrity error. The transaction submission succeeds as long as you do not transform it with cardano-hw-cli transaction transform.

To confirm this, try minting some test tokens using both the unit redeemer and the more involved redeemer. And also try not transforming the transactions. You will need to use keys generated with cardano-cli since cardano-hw-cli will automatically prevent witnessing transactions that have not been transformed. Below are my results:

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

Since cardano-hw-cli requires the transaction to be transformed when witnessing with hardware wallets, this bug makes it impossible to use hardware wallets with any smart contract that is using more involved redeemers.

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