-
Notifications
You must be signed in to change notification settings - Fork 55
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
Some questions for a port to Go #33
Comments
You don't need to do the random prime thing in createEntropy. I will eventually pull it out of the JS version. If you don't have host-unique global entropy to use as a fingerprint, you should find another source of host fingerprint entropy (e.g. hostname, pid). You should also parametrize it in case whatever you pick doesn't work for some users. |
What's the status on your port? |
@nlepage I simplified the |
Hi @ericelliott I'll try to integrate the simplified Regarding the host-unique global entropy, I'll try to build a fingerprint using some host information as you suggested. |
Looking forward to it! 😎 |
Is this done? Can we add the Go port to the docs? |
I made the changes, you can see the diff here nlepage/go-cuid2@3097e1d...c4d3129 For the fingerprint creation I used the OS environment, and added the hostname and pid to it. I have some questions left:
|
This is a bug. 🐛
A few reasons:
|
Okay, so using the system environment variables' keys and values as I did in the Go port is probably not a good idea (same potentially large values and security risk as One minor question : in Appart from that I think the port is OK and can be added to the list. |
Also is there a maximum length for generated ids? |
Good call.
This sounds like it should be equivalent, but I wouldn't value a tiny micro-optimization over the potential to introduce a subtle bug in the crypto. Especially since compilers tend to automatically make optimizations like that anyway. Did you profile it?
I went with a conservative 32 char max length pretty arbitrarily, but mostly because ids should be long enough to be practically impossible to guess or extract entropy from - but not more. Excessive size causes other problems, such as storage, transport, and usability concerns. Users who want more probably need things like secret keys, or other things this standard was not designed for. They should probably be using a purpose-built, cryptographically secure algorithm. Better to have a sane range that solves the common case for 99.9% of users, IMO. |
Hello,
I discovered cuid2 (and cuid) today, and I gave a try at porting it to Go: https://github.com/nlepage/go-cuid2
It seems to be working fine, here are some ids generated with default length:
I have some questions:
createEntropy()
, I'm calling a random prime number generator from the Go std library instead of picking in a predefined list of prime numberscreateEntropy()
is calledcreateFingerprint()
, I don't have an equivalent ofObject.keys(globalObj).toString())
to give to thehash
function, is it a problem?Thanks for your help!
The text was updated successfully, but these errors were encountered: