Skip to content

v8 implementation details #4

@20k

Description

@20k

Hi there. There's an implementation detail of v8 that means that this only works for the first 1000 numbers generated or so, then itll start randomly encountering failures to work

The reason for this is a bug filed over here https://bugs.chromium.org/p/v8/issues/detail?id=8212 which probably explains it better

The tl;dr is that seeds in v8 are taken in a roundtrip through doubles (basically a reinterpret_cast), and every double is checked if its nan and the payload removed if it is nan (nan packing). This means that when the seeds are stored in the array at the end of each 62 long cycle, for this code to work correctly you actually need to check if they're any nan, and if they are, remove the payload (or set it to the default nan)

It does lead to a much shorter method to crack the rng though, which is while(Math.random() != 0.15567932943235995857);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions