I am curious how you would implement a smart contract which registers a (sub)domain on ens. The documentations I have found all specify that ENS uses SHA3 to hash the domains. I thought Keecak256 was supposed to be the equivalent to SHA3. However, there are several questions in this forum (here, here and here) that prove the contrary. Also looking at the output from online hashes for keecak256 and sha3 I see different outputs for the same inputs.
Some pseudocode of how to implement the namehash algorithm I found here looks like this:
def namehash(name): if name == '': return '\0' * 32 else: label, _, remainder = name.partition('.') return sha3(namehash(remainder) + sha3(label))
My understanding was so far, that Keecak256 in Solidity is supposed to have the same results as SHA3. So I would have implemented this namehash algorithm in Solidity like this but with Keecak256 instead of SHA3. Since this does not seem to yield the correct results though, what would be the proper implementation of this algorithm in Solidity?