Repository navigation
Add native cryptographically secure random source - #837
Closed
victormeloasm wants to merge 1 commit into
Closed
victormeloasm wants to merge 1 commit into
victormeloasm wants to merge 1 commit into
Conversation
victormeloasm
force-pushed
the
native-csprng
branch
from
September 18, 2026 23:57
fdf5529 to
5e8eff1
Compare
VictorTaelin
added a commit
that referenced
this pull request
Sep 19, 2026
…ble seed had to carry its own effect; IO.random_u32 now answers one word from getrandom on Linux, arc4random_buf on macOS and crypto.getRandomValues on the JS lane (#837) Co-authored-by: Victor Duarte Melo <[email protected]>
Contributor
|
Taken in part, in 2.0.13: Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself. |
Phylliida
pushed a commit
to Phylliida/bend
that referenced
this pull request
Sep 27, 2026
…ble seed had to carry its own effect; IO.random_u32 now answers one word from getrandom on Linux, arc4random_buf on macOS and crypto.getRandomValues on the JS lane (bendlang#837) Co-authored-by: Victor Duarte Melo <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a native cryptographically secure random source through
IO.random_u32.The existing deterministic RNG API remains unchanged for source and behavioral compatibility:
rnewrnextrrangeThe original xorshift32 behavior is preserved exactly, including the existing
rand.bendresult of4323489.A separate cryptographically secure API is added:
rnew.securernext.securerrange.securerclose.secureThe native entropy source uses:
Linux:
getrandom()macOS:
arc4random_buf()JavaScript:
node:crypto.randomFillSync()rrange.secureuses rejection sampling to avoid modulo bias and limits rejection attempts to 128 draws.The implementation fails closed if the host cryptographic random source is unavailable and does not fall back to a deterministic PRNG.
The legacy API remains unchanged so existing consumers continue to compile and behave exactly as before.