Skip to content

Range of GenerateRandomGuid is too small #4012

@OnedgeLee

Description

@OnedgeLee

Libplanet offers pseudo-random GUID generator on RandomExtensions, but its range seems quite small for general use.

Above generates GUID, which codomain is 16-bytes, but its range is less than 4-bytes, since its domain is int.

GUID is designed to be have 2^128 diversity, but with current implementation, it can cover only 2^32

With estimation with Birthday Problem
(sqrt(-2 * N * log(1 - probability)) where N = 2^32, probability = 0.5, 0.95),
GUID collision can happen with 50% probability with 77,163 samples,
and 95% probability with 160,416 samples, which is quite easy to happen.

We need to generate GUID with larger domain, for example, result hash of SHA-256.

Belows are some candidates.

  • Proof of VRF (not merged on main branch yet)
  • PreEvaluationHash
  • StateRootHash
  • BlockHash

Seems like better to choose from above two, but since impossitility of manipulation is not so important for GUID feature, won't be matter so much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions