Created
January 16, 2022 09:32
-
-
Save adraffy/37ee0039f9cb8b99a61ddd5ca7c7c3b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {keccak} from '@adraffy/keccak'; | |
function namehash(name) { | |
let buf = new Uint8Array(64); | |
if (name.length > 0) { | |
for (let label of name.split('.').reverse()) { | |
buf.set(keccak().update(label).bytes, 32); | |
buf.set(keccak().update(buf).bytes, 0); | |
} | |
} | |
return buf.slice(0, 32); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment