|
|
|
@ -1,20 +1,20 @@
|
|
|
|
|
const sha3 = require('js-sha3').keccak_256
|
|
|
|
|
const uts46 = require('idna-uts46')
|
|
|
|
|
var sha3 = require('js-sha3').keccak_256
|
|
|
|
|
var uts46 = require('idna-uts46')
|
|
|
|
|
|
|
|
|
|
module.exports = function namehash (inputName) {
|
|
|
|
|
// Reject empty names:
|
|
|
|
|
let node = ''
|
|
|
|
|
for (let i = 0; i < 32; i++) {
|
|
|
|
|
var node = ''
|
|
|
|
|
for (var i = 0; i < 32; i++) {
|
|
|
|
|
node += '00'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = normalize(inputName)
|
|
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
|
const labels = name.split('.')
|
|
|
|
|
var labels = name.split('.')
|
|
|
|
|
|
|
|
|
|
for(var i = labels.length - 1; i >= 0; i--) {
|
|
|
|
|
const labelSha = sha3(labels[i])
|
|
|
|
|
var labelSha = sha3(labels[i])
|
|
|
|
|
node = sha3(new Buffer(node + labelSha, 'hex'))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|