I need help decoding an hash in sway… The fuel book only shows how to hash and not how to decode. Is that feature present?
Hashing some data is strictly a one-way function. There is mathematically no way to undo a hash or decode it. The original data must be provided to verify that a hash digest is correct.
However, one can recover the public key derived from the private key used to sign a message with the
std::ecr::ec_recover() function in the Sway std-lib.
I was trying to implement a sway version of a solution that uses “abi.encode” and abi.decode()" in solidity. Do you mean this kind of operation is not possible with sway?
Ah you are referring to serialization and deserialization into bytes. This is something we have been working on for a while now and have made some significant progress recently. Progress on this can be tracked here: Serialization and encoding/decoding · Issue #4769 · FuelLabs/sway · GitHub