Repository navigation
open source changes #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| name: Bug Report | ||
| about: Report a bug in the project | ||
| title: "[BUG] " | ||
| labels: bug | ||
| assignees: "" | ||
| --- | ||
|
|
||
| ### Description | ||
| Describe the unexpected behavior. | ||
|
|
||
| ### Steps to Reproduce | ||
| 1. ... | ||
| 2. ... | ||
| 3. ... | ||
|
|
||
| ### Expected Behavior | ||
| Describe what you expected to happen. | ||
|
|
||
| ### Environment | ||
| - OS: | ||
| - Rust version: | ||
| - Crate version: |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| blank_issues_enabled: false |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: Feature Request | ||
| description: Suggest a new feature or improvement | ||
| title: "[Feature] " | ||
| labels: ["enhancement"] | ||
| body: | ||
| - type: textarea | ||
| id: motivation | ||
| attributes: | ||
| label: Motivation | ||
| description: What problem do you want to solve? | ||
| placeholder: Explain why this feature would be useful. | ||
| validations: | ||
| required: true | ||
| - type: textarea | ||
| id: solution | ||
| attributes: | ||
| label: Proposed Solution | ||
| placeholder: Describe your idea or implementation approach. | ||
| - type: checkboxes | ||
| id: impact | ||
| attributes: | ||
| label: Impact | ||
| options: | ||
| - label: Changes public API | ||
| - label: Requires new tests | ||
| - label: Affects documentation |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ## Description | ||
| Briefly describe what this PR does and why it’s needed. | ||
|
|
||
| ## Changes | ||
| - [ ] Main feature or fix implemented | ||
| - [ ] Tests added | ||
| - [ ] Documentation updated | ||
|
|
||
| ## Checklist | ||
| - [ ] Code compiles without warnings | ||
| - [ ] All tests pass (`cargo test`) | ||
| - [ ] Commit messages are clear and descriptive | ||
| - [ ] PR linked to an issue if applicable (`Fixes #XX`) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: Rust Vulnerability Scan | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| paths: | ||
| - '**/Cargo.toml' | ||
| - '**/Cargo.lock' | ||
| # schedule: | ||
| # # Run daily at midnight to catch newly disclosed vulnerabilities | ||
| # - cron: '0 0 * * *' | ||
|
|
||
| jobs: | ||
| audit: | ||
| name: Run cargo-audit | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install cargo-audit | ||
| uses: taiki-e/install-action@cargo-audit | ||
|
|
||
| - name: Run cargo-audit | ||
| run: cargo audit |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: Rust | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Build | ||
| run: cargo build --verbose | ||
| - name: Run tests | ||
| run: cargo test --verbose |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Code of Conduct | ||
|
|
||
| ## Our Pledge | ||
|
|
||
| In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. | ||
|
|
||
| ## Our Standards | ||
|
|
||
| Examples of behavior that contributes to creating a positive environment include: | ||
| - Using welcoming and inclusive language | ||
| - Being respectful of differing viewpoints and experiences | ||
| - Gracefully accepting constructive criticism | ||
| - Focusing on what is best for the community | ||
| - Showing empathy towards other community members | ||
|
|
||
| Examples of unacceptable behavior by participants include: | ||
| - The use of sexualized language or imagery and unwelcome sexual attention or advances | ||
| - Trolling, insulting/derogatory comments, and personal or political attacks | ||
| - Public or private harassment | ||
| - Publishing others' private information, such as a physical or electronic address, without explicit permission | ||
| - Other conduct which could reasonably be considered inappropriate in a professional setting | ||
|
|
||
| ## Our Responsibilities | ||
|
|
||
| Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. | ||
| Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, codes, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. | ||
|
|
||
| ## Scope | ||
|
|
||
| This Code of Conduct applies to all project spaces and events, including issue trackers, pull requests, mailing lists, chat channels, video calls, in-person events, and any other project-related communications. | ||
|
|
||
| ## Reporting | ||
|
|
||
| To report an incident, contact the project conduct team at [[email protected]](mailto:[email protected]) or reach out to any maintainer. If you prefer, you may submit an anonymous report via a form or third-party service (link/placeholders should be added). Please include as much detail as possible, including links, timestamps, and any relevant context. | ||
|
|
||
| ## Confidentiality and Anonymity | ||
|
|
||
| Reports will be handled confidentially. Reporters may request anonymity; the conduct team will make reasonable efforts to protect identities and sensitive information when requested. | ||
|
|
||
| ## Consequences | ||
|
|
||
| Consequences for violations may include private warnings, required remediation (for example, apologies or training), temporary suspension of repository or event access, removal of privileges, or permanent bans. The chosen action will be proportional to the severity and frequency of the behavior. | ||
|
|
||
| ## Anti-Retaliation | ||
|
|
||
| Retaliation against anyone who reports misconduct or participates in an investigation is strictly prohibited and will itself be treated as a serious violation of this Code of Conduct. | ||
|
|
||
| ## Conflict of Interest & Recusal | ||
|
|
||
| If a conduct team member has a conflict of interest in a case, they will recuse themselves and another impartial member will handle the investigation. | ||
|
|
||
| ## Contact & Upkeep | ||
|
|
||
| For questions about this policy or to update contact details, contact [[email protected]](mailto:[email protected]). | ||
|
|
||
| This policy was last updated: 2026-03-28 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Project Context | ||
|
|
||
| Rust library providing bindings for two statistical RNG test suites: **TestU01** and **PractRand**. Any type implementing `RngCore` can be tested. | ||
|
|
||
| ## Background | ||
|
|
||
| Statistical test suites check if an RNG's output looks like true randomness. They run batteries of hypothesis tests, each looking for a specific pattern or correlation that a weak generator might produce. A generator that passes these suites isn't proven secure, but one that fails them is considered broken. | ||
|
|
||
| ### TestU01 | ||
|
|
||
| TestU01 is a C library by Pierre L'Ecuyer and Richard Simard (Université de Montréal, 2007). It's the most widely cited academic framework for empirical RNG testing. Three predefined batteries, in increasing order of rigor: | ||
|
|
||
| - **SmallCrush**: 10 tests, runs in seconds. Quick sanity check. | ||
| - **Crush**: 96 tests, ~1 hour. Catches most common generator weaknesses. | ||
| - **BigCrush**: 106 tests, several hours. The standard academic benchmark for generator quality. | ||
|
|
||
| Each test produces a p-value. Values outside [0.001, 0.999] are flagged suspect; values outside [1e-10, 1 - 1e-10] are outright failures. TestU01 requires a C function-pointer callback to pull random bits, which is why this crate uses FFI with a global mutex to bridge Rust's `RngCore` trait. | ||
|
|
||
| ### PractRand | ||
|
|
||
| PractRand (Practically Random) is a C++ toolkit by Chris Doty-Humphrey. Unlike TestU01's fixed batteries, PractRand reads a byte stream from stdin and runs tests at geometrically increasing data thresholds (256KB, 512KB, 1MB, 2MB, ...). This makes it good for open-ended testing: a generator that passes at 1GB may fail at 16TB. | ||
|
|
||
| PractRand is particularly good at catching short-range correlations and low-bit weaknesses. Key config knobs: | ||
|
|
||
| - **-tf (folding)**: 0 = raw data only; 1 (default) = also tests a transform emphasizing low bits; 2 = wider variety of transforms. | ||
| - **-te (expanded)**: 0 (default) = core tests, optimized for sensitivity per time; 1 = expanded set, optimized per byte consumed. | ||
|
|
||
| Since PractRand's `RNG_test` reads from stdin, this crate just spawns it as a subprocess and pipes bytes to it. No FFI needed. | ||
|
|
||
| ## Architecture | ||
|
|
||
| - `src/lib.rs` — Re-exports `testu01` and `practrand` modules behind cfg flags | ||
| - `src/testu01.rs` — FFI bindings to the C TestU01 library. Uses a global `Mutex<Option<RngAdapter>>` to bridge Rust's `RngCore` trait to TestU01's C callback (`extern "C" fn`). Bindings are auto-generated by `bindgen` | ||
| - `src/practrand.rs` — Spawns the `RNG_test` binary as a subprocess, pipes random bytes to its stdin, and parses the exit code. No FFI involved | ||
| - `build.rs` — Downloads, compiles, and installs both TestU01 (C, autotools) and PractRand (C++, manual g++ compilation) into `vendor/`. Sets cfg flags `has_testu01_bindings` and `has_practrand` | ||
|
|
||
| ## Build | ||
|
|
||
| The build script automatically downloads and compiles the C/C++ dependencies on first build. Requires: Rust toolchain, C/C++ compiler (gcc/g++), `make`, `curl`, `tar`, `unzip`. | ||
|
|
||
| ```bash | ||
| cargo build # downloads + compiles vendored C/C++ deps on first run | ||
| cargo test # runs smoke tests (SmallCrush for TestU01, 1MB for PractRand) | ||
| ``` | ||
|
|
||
| The `vendor/` directory is gitignored — it's created at build time, not checked in. | ||
|
|
||
| ## Key design decisions | ||
|
|
||
| - **TestU01 uses FFI** because it needs a C function pointer callback to pull random data. The global mutex is required because TestU01's callback signature has no user-data parameter | ||
| - **PractRand uses subprocess** because it's simpler — the `RNG_test` tool reads from stdin, so we just pipe bytes to it | ||
| - **Conditional compilation** (`#[cfg(has_testu01_bindings)]` / `#[cfg(has_practrand)]`) — modules are only available when their C/C++ deps compiled successfully | ||
|
|
||
| ## Tests | ||
|
|
||
| - `tests/testu01_test.rs` — Runs SmallCrush on `OsRng` | ||
| - `tests/practrand_test.rs` — Runs PractRand on `ChaCha20Rng` with 1MB of data | ||
|
|
||
| Tests are slow (SmallCrush takes ~30s, PractRand is faster at small sizes). Both are gated behind cfg flags. | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Contributing to statistical-verification | ||
|
|
||
| We welcome contributions to statistical-verification! Whether it's fixing a bug, adding a new feature, improving documentation, or suggesting new ideas, your contributions are highly appreciated. | ||
|
|
||
| ## How to Contribute | ||
|
|
||
| 1. **Fork the Repository**: Start by forking the statistical-verification repository to your GitHub account. | ||
| 2. **Create a Branch**: Create a new branch for your contribution. Use a descriptive name for the branch, such as `fix-issue-123` or `add-new-feature`. Only lowercase letters, numbers, and hyphens are allowed in branch names. | ||
| 3. **Make Your Changes**: Make the necessary changes in your branch. Ensure that your code follows the project's coding standards and includes appropriate tests if applicable. | ||
| 4. **Commit Your Changes**: Commit your changes with a clear and concise commit message that describes the purpose of the change. | ||
| 5. **Push to GitHub**: Push your branch to your forked repository on GitHub. | ||
| 6. **Create a Pull Request**: Go to the original statistical-verification repository and create a pull request from your branch. Provide a detailed description of your changes and why they are necessary. | ||
| 7. **Review Process**: The maintainers will review your pull request and may request changes or provide feedback. Be responsive to any comments and make the necessary adjustments. | ||
| 8. **Merge**: Once your pull request is approved, it will be merged into the main branch. | ||
|
|
||
| ## Code of Conduct | ||
|
|
||
| Please note that we have a [Code of Conduct](CODE_OF_CONDUCT.md) in place to ensure a welcoming and inclusive environment for all contributors. By participating in this project, you agree to abide by its terms. | ||
|
|
||
| ## Reporting Issues | ||
|
|
||
| If you encounter any issues or have suggestions for improvements, please feel free to open an issue in the GitHub repository. Provide as much detail as possible to help us understand and address the problem effectively. | ||
|
|
||
| --- | ||
|
|
||
| Thank you for your interest in contributing to statistical-verification! We look forward to your contributions and working together to make statistical-verification even better. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2026 SpaceComputer | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.