unique-names-generator icon indicating copy to clipboard operation
unique-names-generator copied to clipboard

Using Ethereum addresses as seed issue

Open alexishecf opened this issue 2 years ago • 2 comments

Hello,

I am using your package with Ethereum addresses as a seed (with the 0x prefix removed) and the dictionaries adjectives and animals. It appears that some adjectives and animals will never (or extremely rarely?) be used when calling uniqueNamesGenerator with the address as a seed but others will be very often.

For instance, if I want to generate a vanity name (i.e. I want my name generated from the ETH address to contains whale, see script below)

  • I generate an ETH address and generate the unique name from it
  • I check if the name contains whale
  • If yes I return the keypair, else I continue

The expected outcome is that every time I run the vanity name generator, I get an {adjective} + Whale nickname, where {adjective} is one of the many adjectives in the dictionary.

But in reality, it will very often be the same adjective, here is a sample of 100 generated names that includes Whale (each one was generated using a different ETH address):

InternalWhale
RemarkableWhale
InternalWhale
InternalWhale
InternalWhale
InternalWhale
InternalWhale
RemarkableWhale
InternalWhale
RemarkableWhale
DigitalWhale
RemarkableWhale
InternalWhale
RemarkableWhale
InternalWhale
DigitalWhale
InternalWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
RemarkableWhale
DigitalWhale
InternalWhale
InternalWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
RemarkableWhale
DigitalWhale
RemarkableWhale
RemarkableWhale
DigitalWhale
DigitalWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
InternalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
RemarkableWhale
InternalWhale
RemarkableWhale
InternalWhale
InternalWhale
InternalWhale
RemarkableWhale
DigitalWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
InternalWhale
DigitalWhale
DigitalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
DigitalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
InternalWhale

I think there is an issue in how the seed is generated from a string, perhaps it is too big? Also, if tou try using a VERY big number as a seed, you will always end up with the same name, so I think there is an issue with the seed.

Script to generate vanity names:

const { uniqueNamesGenerator, adjectives, colors, animals } = require('unique-names-generator');
var Web3 = require('web3');

const arg = process.argv[2];

const web3 = new Web3();

if (!arg) {
  const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
  });
  readline.question('Vanity name should include: ', (contains) => {
    console.log(`Searching name with ${contains}!`);
    readline.close();
    
    generateVanityName(contains);
  });
} else {
  console.log(`Searching name with ${arg}!`);
  generateVanityName(arg);
}

function generateNameFromAddress(address) {
  const customConfig = {
    dictionaries: [adjectives, animals],
    separator: '',
    length: 2,
    seed: address,
    style: 'capital',
  };

  return uniqueNamesGenerator(customConfig);
}

function generateVanityName(contains) {
  let account;
  let name;
  do {
    account = web3.eth.accounts.create();
    name = generateNameFromAddress(account.address.replace('0x', ''));
  } while (!name || !name.toLowerCase().includes(contains.toLowerCase()));

  console.log(account);
  console.log(name);
  return;
}

alexishecf avatar Mar 16 '22 16:03 alexishecf

I also have a problem that seems to be similar. I use as seed ID's from html elements. However, it happens that different seeds lead to the same names.

like: id__square-red-ocelot

seed:          w-node-aaa2dd9a-d07e-f025-8e3a-d68f7302a969-7302a968
uniqueName:    id__silly-emerald-shrimp
----------------------------
seed:          w-node-aaa2dd9a-d07e-f025-8e3a-d68f7302a96b-7302a968
uniqueName:    id__ethnic-gold-caribou
----------------------------
seed:          w-node-aaa2dd9a-d07e-f025-8e3a-d68f7302a970-7302a968
uniqueName:    id__hot-tan-blackbird
----------------------------
seed:          w-node-_1eb647e8-2264-3644-e5c7-c6b89ffc5d1b-9ffc5d1a
uniqueName:    id__wittering-turquoise-turkey
----------------------------
seed:          w-node-_1eb647e8-2264-3644-e5c7-c6b89ffc5d1d-9ffc5d1a
uniqueName:    id__selfish-tan-sole
----------------------------
seed:          w-node-_1eb647e8-2264-3644-e5c7-c6b89ffc5d1f-9ffc5d1a
uniqueName:    id__extraordinary-beige-moth
----------------------------
seed:          w-node-_1eb647e8-2264-3644-e5c7-c6b89ffc5d26-9ffc5d1a
uniqueName:    id__cheap-copper-silverfish
----------------------------
seed:          w-node-_9fe443dc-e2f2-401c-e8da-697ef6821c29-f6821c28
uniqueName:    id__high-orange-sturgeon
----------------------------
seed:          w-node-_9fe443dc-e2f2-401c-e8da-697ef6821c2b-f6821c28
uniqueName:    id__interim-teal-cuckoo
----------------------------
seed:          w-node-_9fe443dc-e2f2-401c-e8da-697ef6821c2d-f6821c28
uniqueName:    id__fashionable-green-hoverfly
----------------------------
>> seed:          w-node-_9fe443dc-e2f2-401c-e8da-697ef6821c34-f6821c28
>> uniqueName:    id__square-red-ocelot
----------------------------
seed:          w-node-_17b33b5a-7885-2683-d59b-db6f5cf1c829-5cf1c828
uniqueName:    id__yearling-lavender-toucan
----------------------------
>> seed:          w-node-_17b33b5a-7885-2683-d59b-db6f5cf1c82b-5cf1c828
>> uniqueName:    id__square-red-ocelot
----------------------------
seed:          w-node-_17b33b5a-7885-2683-d59b-db6f5cf1c832-5cf1c828
uniqueName:    id__skinny-sapphire-pheasant
----------------------------
seed:          w-node-e3589836-a859-3f95-bfd0-ed7b002df5a6-002df5a5
uniqueName:    id__spicy-red-mole
----------------------------
seed:          w-node-e3589836-a859-3f95-bfd0-ed7b002df5ad-002df5a5
uniqueName:    id__likely-copper-manatee
----------------------------
seed:          w-node-e3589836-a859-3f95-bfd0-ed7b002df5af-002df5a5
uniqueName:    id__detailed-gray-hedgehog
----------------------------
seed:          w-node-e3589836-a859-3f95-bfd0-ed7b002df5b2-002df5a5
uniqueName:    id__fast-coral-rook
----------------------------
seed:          w-node-e3589836-a859-3f95-bfd0-ed7b002df5b5-002df5a5
uniqueName:    id__spicy-red-mole
----------------------------
seed:          w-node-e3589836-a859-3f95-bfd0-ed7b002df5b8-002df5a5
uniqueName:    id__nosy-violet-antelope
----------------------------
seed:          w-node-f3f6141e-0b56-d993-c70f-ef7317377454-17377453
uniqueName:    id__immediate-amethyst-mammal
----------------------------
seed:          w-node-f3f6141e-0b56-d993-c70f-ef731737745b-17377453
uniqueName:    id__rainy-azure-scorpion
----------------------------
seed:          w-node-bdfbe371-20ef-f282-4550-e9b9c955c474-c955c473
uniqueName:    id__unable-blush-quokka
----------------------------
seed:          w-node-bdfbe371-20ef-f282-4550-e9b9c955c47b-c955c473
uniqueName:    id__efficient-coral-chickadee
----------------------------
seed:          w-node-bdfbe371-20ef-f282-4550-e9b9c955c47d-c955c473
uniqueName:    id__electronic-maroon-crocodile
----------------------------
seed:          w-node-bdfbe371-20ef-f282-4550-e9b9c955c499-c955c473
uniqueName:    id__skinny-plum-xerinae
----------------------------
seed:          w-node-bdfbe371-20ef-f282-4550-e9b9c955c49b-c955c473
uniqueName:    id__electronic-maroon-crocodile
----------------------------

Code for generation:

const randomName =
  "id__" +
  uniqueNamesGenerator({
    dictionaries: [adjectives, colors, animals],
    separator: "-",
    length: 3,
    seed: divID,
  });

misterboe avatar Mar 17 '22 06:03 misterboe