Thank you for your interest in contributing to nonce-cracker!
- Rust 1.75+
- Git
- make (optional, for convenience commands)
# Clone your fork
git clone https://github.com/sachncs/nonce-cracker.git
cd nonce-cracker
# Add upstream remote
git remote add upstream https://github.com/sachncs/nonce-cracker.git
# Install pre-commit hooks
make install-hooks# Create a feature branch
git checkout -b feature/your-feature-name
# Or a bugfix branch
git checkout -b fix/issue-description# Make your changes to the code
# ...
# Run tests
cargo test
# Run lints
cargo clippy --all-targets --all-features -- -D warnings
# Format code
cargo fmt --allWe follow Conventional Commits:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesrefactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Examples:
git commit -m "feat(recover): add recover command with user-specified argument order"
git commit -m "fix(hex): handle uppercase 0X prefix in range parsing"
git commit -m "docs: update README with new CLI examples"# Push your branch
git push origin feature/your-feature-name
# Create pull request via GitHubWe follow the Rust Style Guide:
- Indentation: 4 spaces
- Line width: 100 characters (soft limit)
- Trailing commas: In multiline constructs
- Naming:
- Types:
UpperCamelCase - Functions/variables:
snake_case - Constants:
SCREAMING_SNAKE_CASE
- Types:
Document all public items with rustdoc:
/// Computes the modular inverse using extended Euclidean algorithm.
///
/// # Arguments
///
/// * `a` - The value to invert
/// * `n` - The modulus
///
/// # Returns
///
/// The value a⁻¹ mod n, or `Error::Calculation` if no inverse exists.
///
/// # Example
///
/// ```
/// let n = parse_hex(CURVE_ORDER_HEX).unwrap();
/// let inv = mod_inverse(&7, &n)?;
/// ```
pub fn mod_inverse(a: &BigInt, n: &BigInt) -> Result<BigInt> {
// ...
}- Use
Resulttypes with customErrorenum - Prefer
?operator overunwrap()in non-test code - Provide actionable error messages
- Unit tests in
#[cfg(test)]modules - Integration tests in
tests/directory - All tests must pass:
cargo test
# Run all tests
cargo test
# Run specific test
cargo test test_mod_inverse
# Run with output
cargo test -- --nocapture
# Run doc tests
cargo test --doc#[cfg(test)]
mod tests {
use super::*;
/// Tests that modular inverse of a number equals 1 when multiplied.
#[test]
fn test_mod_inverse() {
let n = parse_hex(CURVE_ORDER_HEX).unwrap();
let a = BigInt::from(7u64);
let inv = mod_inverse(&a, &n).unwrap();
let prod = (a * inv) % &n;
assert_eq!(prod, BigInt::one());
}
}Before pushing:
- Code is formatted:
cargo fmt --all - No clippy warnings:
cargo clippy --all-targets --all-features -- -D warnings - All tests pass:
cargo test - Documentation updated (if applicable)
- Commit message follows conventional format
Follow conventional commits:
feat(recover): add new CLI commandfix(crypto): correct modular inverse calculationdocs: update installation instructions
Include:
- What: Brief description of changes
- Why: Motivation and context
- How: Technical approach (if non-obvious)
- Testing: How the changes were tested
- Automated checks must pass (CI)
- At least one review approval required
- Address reviewer feedback
Include:
- Rust version:
rustc --version - nonce-cracker version:
nonce-cracker --version - OS and architecture
- Minimal reproducible example
- Expected vs actual behavior
Include:
- Clear use case
- Proposed solution (if any)
- Alternative solutions considered
This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to security@example.com.
By contributing, you agree that your contributions will be licensed under the MIT License.