Different hash values using sha256tree and get_tree_hash

Hello,
I’m testing a simple example to use sha256tree in chialisp and get_tree_hash in Python. But I’m obtaining different values.
#Python
cc = Program.To([“hello”, “hello”])
hash_pyhton_value = cc.get_tree_hash()

#Chialisp
(sha256tree (q (“hello” “hello”)))

And the hash values are different
Anyone could help me with this issue??

thanks!

The q operator creates a quoted list, unless you use the cons operator. To quote it as a value, use (q . ("hello" "hello")) instead. Essentially, you were ending up with the value (("hello" "hello")) instead of ("hello" "hello").

2 Likes

Hello!
I am still trying to sign a list.

#snippet of my python program
cc_solution = Program.to(
[[cc.name(), cc.name()],])

cc_spend = CoinSpend(
cc,
load_clvm(MY_CLSP, package_or_requirement=name),
cc_solution
)
print(cc_solution.get_tree_hash())

#snippet of my Chialisp program
(mod (my_list)
(list
(list AGG_SIG_ME PUBKEY (sha256tree my_list))
)
)

and when I execute cdv inspect spendbundles ./myjson.json -db

the (sha256tree my_list) is different to print(cc_solution.get_tree_hash())

I can’t see where is my error.

You are getting the tree hash of the solution in the Python code, but in the Chialisp code, a single argument of the solution called “my_list” is tree hashed. Try using (mod my_list instead of (mod (my_list) to get the whole solution, or pass the tree hash of the value into the solution instead of tree hashing the whole solution.

2 Likes