Hash script data

Thanks for the references! I was able to reproduce the hash from cardano-cli using libsodium generic-hash and converting the 42 number into CBOR (182a) prior to hashing.

I was trying to do the same for objects though, without luck:

For example, the object mentioned in the other topic:

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

I convert it to CBOR A26B636F6E7374727563746F7200666669656C647381A163696E7404 and then try to hash it and I get 9aa23c572ebf5d39113f516d4bbf69d1b9650e55ea63cdd7fb4ee77975def5b0, while if I put that data in a json file and use cardano-cli transaction hash-script-data --script-data-file ./tests/sample.json I get 8bb54ceaee2f57731094a2e96b8ad87bcc8988b1fa838e8c833eb3b72eae29a1

Also tried using bytes instead of UTF string in the CBOR encoding: A24B636F6E7374727563746F7200466669656C647381A143696E7404
which gives me 5677bf1048dad6dce36483d2bec0fafc71f5dc9b01a2b1326c6443c2cd264b50

Even when reading the source code I’m not sure what I may be missing here :frowning:

Anyone has any idea?