-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fingerprints for non-JS ports #27
Comments
Be careful with env vars.. how will those be allocated across different environments? Is generally ok if these values CAN collide across hosts, as long as that is unlikely. In CUID, I often used multiple sources of host entropy to create fingerprints less likely to collide. |
Hmm, I guess whether env vars are appropriate would depend on what the purpose of the My assumption is that it should be as unique as possible for any given "instance" of a process/thread producing CUIDs. So if I have 10 machines running 10 docker containers, with each container spinning up 2 processes with 2 threads each, I'd expect we'd want 10 * 10 * 2 * 2 = 400 unique fingerprints going into the CUIDs, to help ensure that no two instances can ever generate duplicate IDs. My worry with just including |
Experimentally, it seems like the random data plus proc and thread IDs will probably generally be sufficient. Can update later if it isn't. |
Working on adding
cuid2
to the Rustcuid
port, and trying to figure out how to do the fingerprint.The JS version is a hash of:
global
(in node) orwindow
(in browser)In Rust, we don't have anything like the
global
object in node or thewindow
object in the browser. So far, I've got:That gives different fingerprints for different processes & threads generating CUIDs on the same system, but doesn't guarantee anything across systems.
It looks like the Python port uses the system hostname, but that would reduce portability and prevents compiling the Rust to target-independent WASM.
One option that springs to mind is environment variables: the specific env var keys and values available to the process are likely to vary a fair bit across systems. On docker, this will include the
HOSTNAME
env var, which is generally set to the container ID. This is what I'm defaulting to for the moment, but would be curious to hear your thoughts.We could also just rely on the random number, process ID, thread ID, and the hash entropy.
The text was updated successfully, but these errors were encountered: