google/uuid

uuid.NewString use UUID v7 instead of v4

codenoid opened this issue · 6 comments

uuid.NewString use UUID v7 instead of v4

this could have an impact on the security of UUIDs as the number of bits of randomness decreases from 122 to 48. Please provide a strong justification for this request.

@bormanp I see, but is that the only reason to choose v4 as the default of uuid.NewString ?

image

source: https://x.com/maciejwalkowiak/status/1809164757959938376

UUIDv7 clearly has better performance, better DX as the first part are a timestamp and more future-proof as it's newer version of UUID

It is an unexpected change in behavior. You are free to generate v7 UUIDs but it is not reasonable to request that applications that have been generating v4 UUIDs to start generating v7 UUIDs. The security implications are important as v4 UUIDs are much more difficult to guess than v7 UUIDs. In many applications this is more important. UUIDs are not just for SQL databases.

uuid.Must(uuid.NewV7()).String()

I agree, this might pose a risk to applications relying on the randomness of UUIDs, therefore it would at least be a breaking change. However, we could maybe make people more aware of the existence of UUID V7 in this package and the potential advantage.

I don't see why uuid.NewString() just exist on the first place, anyway, I'm closing this issue.