Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the SecureRandom class to improve code organization and maintainability. The changes include extracting reseeding logic into a separate method, adding a new factory constructor, improving documentation with inline comments, and enhancing test coverage with more comprehensive distribution tests.
Key Changes:
- Introduced a new public factory constructor
SecureRandom.chaCha20()for creating ChaCha20-based random number generators - Refactored the reseeding logic by extracting it into a dedicated
_mixSystemRandom()method - Made
maxDurationBeforeReseednullable to allow disabling time-based reseeding - Enhanced test suite with additional distribution validation tests and better test descriptions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| cryptography/lib/src/cryptography/secure_random.dart | Refactored SecureRandom implementation: added factory constructor, extracted reseeding logic into _mixSystemRandom(), made maxDurationBeforeReseed nullable, renamed _seed to _seedForDeterministicSequence, improved inline documentation, and enhanced modulo bias handling with clearer comments |
| cryptography/test/secure_random_test.dart | Updated tests to use new naming conventions, added comprehensive distribution tests for nextBool(), nextInt(), nextDouble(), and nextUint52(), increased sample sizes for better statistical validation, and added bounds checking for distribution tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4267868 to
0c3b9cc
Compare
0c3b9cc to
08962d6
Compare
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.
No description provided.