Skip to main content

Memorable Unique Identifier

Project description

muid

Memorable Unique Identifiers

Wait you say ... this cannot make sense!

Memorable unique identifiers are a provocative misnomer, for naturally when generating unique identifiers such as privately used keys, memorability is antithetical to uniqueness.

To be more correct, MUIDs are a subset of UUIDs whose SHA-1 hashes are memorable.

Usage

Install

pip install muid

Just like uuid.uuid4() ... only it takes longer

import muid
key  = muid.muid4()  

The SHA-1 hash is memorable

print( muid.mhash(key) )    
f01dab1e-ca70-403a-a0c7-00f6c29596c4

Don't see it yet? How about...

print( muid.mnemonic( key ) )
Foldable Cat  

The call muid.mnemonic uses a corpus of readable hex-like scrabble words to infer that only the first 11 characters are intended to be memorable.

Mining

Got nothing better to do? Rates are better than bitcoin!

muid.mine(min_len=12)

More details on monetizing mining will be supplied at www.microprediction.com in due course.

Verificaton

muid.verify(key,min_len=7)

Example application

Memorable unique identifiers are used at www.microprediction.com to circumvent the need to maintain a lookup between user keys and public user identities. New users burn themselves a verifiably memorable private identity. The longer the mnemonic, the more leeway they receive.

The benefits are

  • No need for central registration or key provision
  • No ability to generate vast numbers of keys
  • Enforced computational timeout after drawdown makes other Sybil style attacks harder.

We hope you have your own uses. Many applications can benefit from "one less join".

Details

Hash

This library standardized on a version of SHA-1 hash, literally:

code = str(uuid.uuid5(uuid.NAMESPACE_DNS, key))

which takes UUID's to string representation of the hash of the UUID.

Readable hex

The image of mhash contains only strings with characters a,b,e,d,e,f plus digits. That's not such a fun game of scrabble so muid introduces the notion of readable hex strings. These are the image under the map which swaps out characters as follows:

Hex Readable
5 s
1 l
7 t
0 o

Scrabble

If you enjoy generating words using vowels a,c,e,o and consonants c,b,d,f,s,l,t then please do contribute pull requests for muid.corpus.

Collisions are a non-issue

It is well appreciated that approximately 2.71 quintillion uuid4() can be generated before the risk of collision exceeds fifty percent (Wikipedia).

Collision probabilities for muid

Because MUID's are a tiny subset of UUID's, the collision probabilities per muid are higher but still small typically.

  • With min_len=8 say, then there will typically be a few million attempts per muid generated. Thus one can generate a trillion muid before any there is any risk of collision in the underlying uuid's (whether used or not) because a few quintillion / a few million = one trillion.

This is a defensive calculation.

It is also a somewhat irrelevant calculation and there is a stronger reason not to worry.

Your users will be limited in their capacity to produce muid's in a way that they are not limited with uuid's. A moment's reflection should convince you that the computational capacity required to create MUID collisions over any interval of time is at least as large as the computational capacity employed to create UUID collisions.

So stop worrying and love MUIDs.

For the true worry warts ...

If you are not convinced by logic, in place of the default method=uuid.uuid4 you can supply a method of generating candidate unique identifiers with even longer string representations - for example concatenating a UUID with the last min_len characters of another independent UUID.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

muid-0.0.6.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

muid-0.0.6-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file muid-0.0.6.tar.gz.

File metadata

  • Download URL: muid-0.0.6.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for muid-0.0.6.tar.gz
Algorithm Hash digest
SHA256 4856bf22a731c2ec4b43e9e39e00ea75839e075987627cf20a02e99073a7663d
MD5 76589dc4920656e2226f4a86ed9ec5ec
BLAKE2b-256 3cd2c619340326df5122fee56b0fa045b0d44ceb8c7af11e820ca71d5961f997

See more details on using hashes here.

File details

Details for the file muid-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: muid-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for muid-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 16f9bd0cdc2013195c60bcee4090e33f1caccf5f46376b6d3e2b69d3e0987aea
MD5 cfd761172ef25239efb18a71cecd80c0
BLAKE2b-256 ab682a4a181cb03d3cfd82c241f96739389ff30528640c621b9f4d41e31adcbc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page