Skip to content
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

Provide a Kotlin MPP UUID generator #180

Closed
kggilmer opened this issue Mar 4, 2021 · 1 comment · Fixed by #419
Closed

Provide a Kotlin MPP UUID generator #180

kggilmer opened this issue Mar 4, 2021 · 1 comment · Fixed by #419
Assignees
Labels
feature-request A feature should be added or improved. good-first-task Good for newcomers
Milestone

Comments

@kggilmer
Copy link
Contributor

kggilmer commented Mar 4, 2021

This is required for the idempotentTokenGenerator task. Kotlin does not have any platform agnostic support for UUID generation.

The go SDK references: https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29

From smithy-go/rand/uuid.go

Verify fixes: awslabs/aws-sdk-kotlin#69

internal id: 175157019

@kggilmer kggilmer added feature-request A feature should be added or improved. good-first-task Good for newcomers jr1614819667645 labels Mar 4, 2021
@aajtodd aajtodd removed the kotlin label Mar 4, 2021
@aajtodd
Copy link
Contributor

aajtodd commented Mar 13, 2021

https://github.com/benasher44/uuid looks like a good candidate that we could leverage to bootstrap things and re-evalute the dependency later.

There is some discussion in KT-31880 about this library being a community driven proving grounds.

I've looked it over and the library is using:

  • java.util.UUID on JVM (uses SecureRandom)
  • delegates to /dev/urandom on native
  • BCryptGenRandom on windows
  • kotlin.random.Random on JS
    • note this should probably should be Crypto.getRandomValues() for browsers (but likely wouldn't work on node which is probably why they used the builtin RNG)

Alternatively we can go platform by platform and implement it ourselves. There is no builtin CSPRNG for KMP out of the box (KEEP 185 proposes adding one). If we are only going to use the uuid strictly for idempotency tokens then it's probably fine to use a non-cryptographically secure RNG but I'd be hesitant to put a general purpose uuid type/generator into our runtime lib without further considerations.

@aajtodd aajtodd added this to the M2 milestone Apr 9, 2021
@ianbotsf ianbotsf modified the milestones: M2, M3 Jun 7, 2021
@aajtodd aajtodd removed the kt-ea label Jun 14, 2021
@ianbotsf ianbotsf self-assigned this Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. good-first-task Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants