{"id":16572661,"url":"https://github.com/lemire/crackingxoroshiro128plus","last_synced_at":"2025-03-16T20:31:23.902Z","repository":{"id":66054826,"uuid":"101015068","full_name":"lemire/crackingxoroshiro128plus","owner":"lemire","description":"How to \"crack\" xoroshiro128+: from two outputs, derive a possible seed","archived":false,"fork":false,"pushed_at":"2024-09-09T19:07:30.000Z","size":16,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-16T05:31:43.915Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lemire.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-22T03:03:05.000Z","updated_at":"2025-03-06T03:35:12.000Z","dependencies_parsed_at":"2024-10-27T11:23:50.558Z","dependency_job_id":"e938f219-e098-48a7-86e5-b7c857543114","html_url":"https://github.com/lemire/crackingxoroshiro128plus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Fcrackingxoroshiro128plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Fcrackingxoroshiro128plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Fcrackingxoroshiro128plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Fcrackingxoroshiro128plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemire","download_url":"https://codeload.github.com/lemire/crackingxoroshiro128plus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243928337,"owners_count":20370275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T21:28:12.680Z","updated_at":"2025-03-16T20:31:23.312Z","avatar_url":"https://github.com/lemire.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crackingxoroshiro128plus\n\nXoroshiro128+ is a popular random generator. Given a couple of outputs of xoroshiro128+, you can often derive the seed necessary to generate the desired output. See my post  [“Cracking” random number generators (xoroshiro128+)](https://lemire.me/blog/2017/08/22/cracking-random-number-generators-xoroshiro128/)\n\n## Usage\n\n- I assume you have either macOS or a Linux shell.\n- Install z3, the theorem prover, make sure to include Python support. If you have pip, type ``pip install z3-solver --user``. If you do not have pip, you should [install it](https://pip.readthedocs.io/en/stable/installing/).\n- Have some 16-byte string you wish to generate (such as \" Daniel Lemire  \").\n- Type\n```\ncc -o xoroshift xoroshift.c \u0026\u0026 ./xoroshift $(python xoroshift.py \" Daniel Lemire  \") |hexdump -C|more\n```\n- It works with \" Daniel Lemire  \", but it is not possible to generate all outputs. When it is not possible to generate the desired output, a seed to generate the output \"Sorry,  I can't.\" will be generated instead.\n- There could be several possible 128-bit seeds able to generate a given 64-bit output. The script solves for one possible seed, but a modification of the script could generate all of the solutions.\n\n- The script ``xoroshiftall.py`` finds all possible seeds for a given output sequence of numbers. Try ``python xoroshiftall.py 0 0xdeadbeef``.\n\n## Source code of the generator\n\n```C\n// http://vigna.di.unimi.it/xorshift/xoroshiro128plus.c\n\nuint64_t s[2];\n\nstatic inline uint64_t rotl(const uint64_t x, int k) {\n        return (x \u003c\u003c k) | (x \u003e\u003e (64 - k));\n}\n\nuint64_t next(void) {\n        const uint64_t s0 = s[0];\n        uint64_t s1 = s[1];\n        const uint64_t result = s0 + s1;\n\n        s1 ^= s0;\n        s[0] = rotl(s0, 55) ^ s1 ^ (s1 \u003c\u003c 14); // a, b\n        s[1] = rotl(s1, 36); // c\n        return result;\n}\n```\n\n## Further Work\n\n\nWe could also use [cryptol](https://github.com/GaloisInc/cryptol).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemire%2Fcrackingxoroshiro128plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemire%2Fcrackingxoroshiro128plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemire%2Fcrackingxoroshiro128plus/lists"}