Skip to content

Conversation

@terrier989
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings November 21, 2025 15:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 maxDurationBeforeReseed nullable 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.

@terrier989 terrier989 force-pushed the refactor/rng branch 3 times, most recently from 4267868 to 0c3b9cc Compare November 21, 2025 15:43
@terrier989 terrier989 merged commit e93e286 into master Nov 21, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants