input-output-hk / cardano-js-sdk

JavaScript SDK for interacting with Cardano, providing various key management options, with support for popular hardware wallets
https://input-output-hk.github.io/cardano-js-sdk/
Apache License 2.0
212 stars 57 forks source link

Empty List Using Indefinite Encoding #1318

Closed EzePze closed 4 weeks ago

EzePze commented 2 months ago

Summary

When constructing an empty PlutusList, calling toCbor serialises it with indefinite encoding, which is not canonical and can cause problems with scripts, particularly the serialise builtin.

Steps to reproduce the bug

console.log((new PlutusList()).toCbor())
console.log(PlutusList.fromCbor(HexBlob("80")).toCbor())

Actual Result

9fff
9fff

Which is the encoding for an indefinite list

Expected Result

80
80

Which is the encoding for a definite list

SDK version

0.30.2

Environment type

Environment details

No response

AngelCastilloB commented 2 months ago

Thanks for the bug report @EzePze, I opened a PR with the fix here https://github.com/input-output-hk/cardano-js-sdk/pull/1319, should be fixed in the next version of the SDK

AngelCastilloB commented 2 months ago

@EzePze we just published version 0.33.0 of the @cardano-sdk/core package which should have this fixed, give it a try and let us know

AngelCastilloB commented 2 months ago

It seems that the issue was not properly fixed, see https://github.com/input-output-hk/cardano-js-sdk/pull/1319#issuecomment-2151584168 . Is being addressed in this PR https://github.com/input-output-hk/cardano-js-sdk/pull/1322

AngelCastilloB commented 2 months ago

You can try the latest release 0.33.1, that should have this fixed :)