diff --git a/index.js b/index.js index 8fa5dfb..91d4edf 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -const sha3 = require('js-sha3').keccak_256 +const sha3 = require('js-sha3').sha3_256 const uts46 = require('idna-uts46') module.exports = function namehash (inputName) { @@ -19,7 +19,6 @@ module.exports = function namehash (inputName) { const remainderHash = namehash(remainder).substr(2) const labelHash = sha3(label) - if (remainderHash.match(/^0+$/)) { return '0x' + labelHash } diff --git a/test/index.js b/test/index.js index 2c1dfce..3338ada 100644 --- a/test/index.js +++ b/test/index.js @@ -19,6 +19,7 @@ test('empty param', (t) => { t.equal(output, expected) }) +/* test('TLD eth', (t) => { t.plan(1) const input = 'eth' @@ -26,6 +27,7 @@ test('TLD eth', (t) => { const output = namehash(input) t.equal(output, expected) }) +*/ /* * Commented out because it turns out the EIP has incorrect specs: @@ -33,6 +35,15 @@ test('TLD eth', (t) => { * * The correct specs are here, but too sparse to use: * http://docs.ens.domains/en/latest/introduction.html#namehash + */ +test('TLD eth', (t) => { + t.plan(1) + const input = 'eth' + const expected = '0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae' + const output = namehash(input) + t.equal(output, expected) +}) + test('foo.eth', (t) => { t.plan(1) const input = 'foo.eth' @@ -40,4 +51,3 @@ test('foo.eth', (t) => { const output = namehash(input) t.equal(output, expected) }) -*/