| Crates.io | decentralized_governance_lib |
| lib.rs | decentralized_governance_lib |
| version | 0.1.0 |
| created_at | 2025-09-29 13:18:44.215033+00 |
| updated_at | 2025-09-29 13:18:44.215033+00 |
| description | A library for decentralized decision making, fair division algorithms, and governance mathematics |
| homepage | |
| repository | https://github.com/iunknow588/decentralized_governance_lib |
| max_upload_size | |
| id | 1859539 |
| size | 56,625 |
A library for decentralized decision making, fair division algorithms, and random number generation. This library focuses on consensus-friendly, objective algorithms.
Add this to your Cargo.toml:
[dependencies]
decentralized_governance_lib = "0.1.0"
use decentralized_governance_lib::{
// Fair Division
calculate_fair_division_equal_weights,
calculate_fair_division_weighted,
// Random Generation
get_one_dd_rand_num,
get_k_dd_rand_num,
};
// Fair division example
let bids = [100i128, 200, 300];
let mut allocation = [0i128; 3];
calculate_fair_division_equal_weights(&bids, &mut allocation).unwrap();
// allocation: [66, 133, -199] (sum = 0)
// Random selection example
let group1 = [100u128, 200, 300];
let group2 = [150u128, 250, 350];
let group3 = [120u128, 220, 320];
let groups = [group1.as_slice(), group2.as_slice(), group3.as_slice()];
let mut selected = [0usize; 3];
get_k_dd_rand_num(&groups, 3, 3, &mut selected).unwrap();
// selected: [1, 2, 0] (unique participant indices)
algorithmsMathematical algorithms for fair division and random number generation:
calculate_fair_division_equal_weights() - Fair division with equal weightscalculate_fair_division_weighted() - Fair division with custom weightsget_one_dd_rand_num() - Generate single decentralized random numberget_k_dd_rand_num() - Generate multiple unique random numberstypesCommon data types and enums:
VotingPower - Voting power type aliasParticipantId - Participant identifier typeTimestamp - Timestamp type aliasFairDivisionResult - Result structure for fair division (if used)RandomSelectionResult - Result structure for random selection (if used)Implements super fair division algorithms that ensure:
Decentralized random number generation with:
See the examples/ directory for comprehensive usage examples:
governance_example.rs - Complete demonstration of all featuresfunction_names_test.rs - Function name verification and testingThis project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Follow this checklist to publish a new version of this crate to crates.io.
cargo login <YOUR_API_TOKEN>
Ensure the following fields are correct: name, version, description, license, repository, documentation, readme, keywords, categories, rust-version. This crate defaults to no_std and offers optional std, serde, and log_tests features.
cargo clean
cargo test
# Optional: show test logs
cargo test --features log_tests -- --nocapture
# Local docs
cargo doc --no-deps
cargo package
cargo publish --dry-run
cargo publish
# Bump version in Cargo.toml first
git tag -a v0.1.0 -m "Release v0.1.0"
git push --tags
cargo owner --add <github-user-or-team>
cargo owner --list
cargo package and adjust include/exclude in Cargo.toml or .gitignore.no_std docs on docs.rs, ensure default features don’t pull in std. This crate uses #![no_std] by default.log_tests feature to keep default no_std behavior.Crates cannot be overwritten. Bump the version and republish. You can yank a bad version:
cargo yank --vers <version>
# Undo if necessary
cargo yank --vers <version> --undo