Two hash function in Daml, keccak256 and sha256 both require utf-8 for their inputs. Is there a way to hash raw binary data in daml, without presuming the encoding?
There is currently no built-in way in Daml to hash generic raw binary data without going through Text and its UTF-8 encoding.
If you really need to hash arbitrary bytes, you’ll have to:
-
do it outside Daml (off-ledger) and bring the hash in, or
-
redesign the protocol so that the “message” being hashed is a canonical UTF-8 Text.