This script will hash "all" possible Handshake names (plus some invalids) and log the "smaller" (based on its position on the Urkel Tree)
Currently, the first name on the Urkel Tree is swaffield
const sha3 = require('bcrypto/lib/sha3'); | |
const hash = str => sha3.digest(Buffer.from(str)).toString('hex'); | |
const toInt = str => parseInt(str, 16); | |
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789-_' | |
// optional: start from a random seed: | |
.split('').sort(() => Math.random() - 0.5).join(''); | |
function* permutator(length = 63, prev = "") { | |
if (length <= 0) { | |
yield prev; | |
return; | |
} | |
for (const char of [...chars]) | |
yield* permutator(length - 1, prev + char); | |
} | |
let min = toInt(hash('swaffield')); | |
// let min = Infinity; | |
function bruteForce() { | |
let i=1; | |
while(i++<=63) { | |
const it = permutator(i); | |
while (true) { | |
const next = it.next(); | |
if (next.done) break; | |
const n = next.value; | |
const h = hash(n); | |
const s = toInt(h); | |
const m = Math.min(s, min); | |
if (m !== min) { | |
// console.clear(); | |
console.log('New smaller', h, n); | |
min = m; | |
} | |
} | |
} | |
} | |
bruteForce(); |