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

TransactionHash Mistmatch #314

Closed
solidsnakedev opened this issue Mar 2, 2024 · 4 comments · Fixed by #321
Closed

TransactionHash Mistmatch #314

solidsnakedev opened this issue Mar 2, 2024 · 4 comments · Fixed by #321

Comments

@solidsnakedev
Copy link

I'm not sure why CML produces a different tx hash compared to Lucid CML

CML example

const txhashCML = CML.hash_transaction(CML.TransactionBody.from_cbor_hex(("a500838258200d31e3060edc0422bab792b414b6920534fb61f72a24cb76c911fea670601518008258205a4a961c2ff22b870f06f5303dcfffaaf3afdb819b12f5f0e60f0540e0e7490700825820f9178e7551be72eb512f8b1b739346c84e9cda4ef8be4feada9bfff6fe47e80000018182583900bc83d1474fafc0669e360c6ef389d3874f5eff99c31f343ff2cdab0bcb68eb5507f1a2a0cb4ddb095125f0f9878568cfe2466f2969db1ed3821a02050c95a9581c748a7026de606c27c06e4b90cb2e1844b566b89fba0d282debe4b40aa14d4d794d696e746564546f6b656e01581ca11c0e63717ac9d8d7bd50c6b29111003e765d199915a02613069641a14d4d794d696e746564546f6b656e181e581ca49d85bfbd193446051e644e7ad448682a1bc1b02d5a15f78429a1f0a14d4d794d696e746564546f6b656e0a581cc7e5e285a6ca1fdd6b8b0293b4d825a9c92ae69f8fc35ae2252a697da14d4d794d696e746564546f6b656e0a581cfed7a8ee8af612b08a05304ba434ef18f37be06f144fbc190d377942a14d4d794d696e746564546f6b656e0a581c92db8682a9e00473968130a7d3ee6d1bd331812543a8584ba739c74ca14d4d794d696e746564546f6b656e01581cd3c9b677c3e599ac2eb0a455e4d5d027d5ef860caf72b5dc27ba0e16a14d4d794d696e746564546f6b656e01581ce2085cebe2ce09d4ec0cbfe965f332941686c9288199440d45e95ff0a14d4d794d696e746564546f6b656e01581c2fce0a65bac1267022f94296e3d55fb862979b13bed38521a31cd200a14d4d794d696e746564546f6b656e01021a0002fb89031a0333a0f509a1581c2fce0a65bac1267022f94296e3d55fb862979b13bed38521a31cd200a14d4d794d696e746564546f6b656e01")))
console.log("txhash CML", txhashCML.to_hex())

the output is the following
txhash CML 3ea6919295e402b9cf13afdc0f45104f9a91d299b896812f363bb8cc0f80f0a3

Lucid example

const lucidTxHash = C.hash_transaction(C.TransactionBody.from_bytes(fromHex("a500838258200d31e3060edc0422bab792b414b6920534fb61f72a24cb76c911fea670601518008258205a4a961c2ff22b870f06f5303dcfffaaf3afdb819b12f5f0e60f0540e0e7490700825820f9178e7551be72eb512f8b1b739346c84e9cda4ef8be4feada9bfff6fe47e80000018182583900bc83d1474fafc0669e360c6ef389d3874f5eff99c31f343ff2cdab0bcb68eb5507f1a2a0cb4ddb095125f0f9878568cfe2466f2969db1ed3821a02050c95a9581c748a7026de606c27c06e4b90cb2e1844b566b89fba0d282debe4b40aa14d4d794d696e746564546f6b656e01581ca11c0e63717ac9d8d7bd50c6b29111003e765d199915a02613069641a14d4d794d696e746564546f6b656e181e581ca49d85bfbd193446051e644e7ad448682a1bc1b02d5a15f78429a1f0a14d4d794d696e746564546f6b656e0a581cc7e5e285a6ca1fdd6b8b0293b4d825a9c92ae69f8fc35ae2252a697da14d4d794d696e746564546f6b656e0a581cfed7a8ee8af612b08a05304ba434ef18f37be06f144fbc190d377942a14d4d794d696e746564546f6b656e0a581c92db8682a9e00473968130a7d3ee6d1bd331812543a8584ba739c74ca14d4d794d696e746564546f6b656e01581cd3c9b677c3e599ac2eb0a455e4d5d027d5ef860caf72b5dc27ba0e16a14d4d794d696e746564546f6b656e01581ce2085cebe2ce09d4ec0cbfe965f332941686c9288199440d45e95ff0a14d4d794d696e746564546f6b656e01581c2fce0a65bac1267022f94296e3d55fb862979b13bed38521a31cd200a14d4d794d696e746564546f6b656e01021a0002fb89031a0333a0f509a1581c2fce0a65bac1267022f94296e3d55fb862979b13bed38521a31cd200a14d4d794d696e746564546f6b656e01")))
console.log("lucidTxHash", lucidTxHash.to_hex())

the output is the following
lucidTxHash 2548148ad0fb809b5756c6f8b8e1d3e705f0c4cda44af6163d6b766786d061ec

The problem I have is when using CML, Blockfrost returns the following error

Error: "transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (FromAlonzoUtxowFail (WrappedShelleyEraFailure (InvalidWitnessesUTXOW [VKey (VerKeyEd25519DSIGN \"4f26d9d8185481167e5647039d4f390c8c74a5fbca1f115709a2998e93180f39\")])))])"
@SebastienGllmt
Copy link
Contributor

@rooooooooob is this the same as the other issue you've been investigating?

@rooooooooob
Copy link
Contributor

@SebastienGllmt no it's not. Mine was I think a Plutus script hash mismatch or missing witness (due to script hash mismatch I think because it was there) or something to do with Plutus.

@solidsnakedev
Copy link
Author

This issue happens when you make a time lock script (native minting policy) , and you add the minted asset to the Tx, when you remove the mint field the Tx hashes from lucid and CML match, but when you add the mint field they returned different hashes.

{
    0: [
        [
            h'0d31e3060edc0422bab792b414b6920534fb61f72a24cb76c911fea670601518',
            0,
        ],
        [
            h'5a4a961c2ff22b870f06f5303dcfffaaf3afdb819b12f5f0e60f0540e0e74907',
            0,
        ],
        [
            h'f9178e7551be72eb512f8b1b739346c84e9cda4ef8be4feada9bfff6fe47e800',
            0,
        ],
    ],
    1: [
        [
            h'00bc83d1474fafc0669e360c6ef389d3874f5eff99c31f343ff2cdab0bcb68eb5507f1a2a0cb4ddb095125f0f9878568cfe2466f2969db1ed3',
            [
                33885333_2,
                {
                    h'748a7026de606c27c06e4b90cb2e1844b566b89fba0d282debe4b40a': {h'4d794d696e746564546f6b656e': 1},
                    h'a11c0e63717ac9d8d7bd50c6b29111003e765d199915a02613069641': {h'4d794d696e746564546f6b656e': 30_0},
                    h'a49d85bfbd193446051e644e7ad448682a1bc1b02d5a15f78429a1f0': {h'4d794d696e746564546f6b656e': 10},
                    h'c7e5e285a6ca1fdd6b8b0293b4d825a9c92ae69f8fc35ae2252a697d': {h'4d794d696e746564546f6b656e': 10},
                    h'fed7a8ee8af612b08a05304ba434ef18f37be06f144fbc190d377942': {h'4d794d696e746564546f6b656e': 10},
                    h'92db8682a9e00473968130a7d3ee6d1bd331812543a8584ba739c74c': {h'4d794d696e746564546f6b656e': 1},
                    h'd3c9b677c3e599ac2eb0a455e4d5d027d5ef860caf72b5dc27ba0e16': {h'4d794d696e746564546f6b656e': 1},
                    h'e2085cebe2ce09d4ec0cbfe965f332941686c9288199440d45e95ff0': {h'4d794d696e746564546f6b656e': 1},
                    h'2fce0a65bac1267022f94296e3d55fb862979b13bed38521a31cd200': {h'4d794d696e746564546f6b656e': 1},
                },
            ],
        ],
    ],
    2: 195465_2,
    3: 53715189_2,
    9: {
        h'2fce0a65bac1267022f94296e3d55fb862979b13bed38521a31cd200': {h'4d794d696e746564546f6b656e': 1},
    },
}

so basically the time lock script needs requires these 2 fields, 3 -> ttl and 9 -> mint

3: 53715189_2,
9: {
        h'2fce0a65bac1267022f94296e3d55fb862979b13bed38521a31cd200': {h'4d794d696e746564546f6b656e': 1},
    },

. I can send you the Tx example, if needed

rooooooooob added a commit that referenced this issue Mar 11, 2024
This only concerns the free-floating `hash_transaction()`.

Fixes #314
@rooooooooob
Copy link
Contributor

@solidsnakedev immediate workaround: use tx_body.hash() instead of hash_transaction(tx_body) and you'll get the right one.

For some reason the free-floating one was hashing the canonical CBOR. You would want to have canonical CBOR for e.g. hardware wallets, but your entire TX should be canonical not just when you go to hash it or otherwise it won't match up with the CBOR.

Eventual fix: #321

SebastienGllmt pushed a commit that referenced this issue Mar 11, 2024
* TX hash mismatch for non-canonical TXs

This only concerns the free-floating `hash_transaction()`.

Fixes #314

* *TxBody.hash() for multi-era rework

Use `TransactionBody` instead of of [u8; 32] to be consistent with
`hash_transaction()`.

Moves all the functions that were added directly to `mod.rs` in #298 files to
`utils.rs` files where they should be since they aren't auto-generated.
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

Successfully merging a pull request may close this issue.

3 participants