#tetcoin #framework #blockchain #crypto

no-std noble-randomness-collective-flip

FABRIC randomness collective flip noble

Show the crate…

1 stable release

2.0.0 Apr 4, 2021

#37 in #tetcore

Download history 10/week @ 2023-11-30 14/week @ 2023-12-07 19/week @ 2023-12-14 17/week @ 2023-12-21 8/week @ 2023-12-28 14/week @ 2024-01-04 34/week @ 2024-01-11 8/week @ 2024-01-18 2/week @ 2024-01-25 5/week @ 2024-02-01 18/week @ 2024-02-08 26/week @ 2024-02-15 34/week @ 2024-02-22 43/week @ 2024-02-29 59/week @ 2024-03-07 19/week @ 2024-03-14

157 downloads per month
Used in 12 crates (3 directly)

Apache-2.0

1MB
23K SLoC

Randomness Module

The Randomness Collective Flip module provides a random function that generates low-influence random values based on the block hashes from the previous 81 blocks. Low-influence randomness can be useful when defending against relatively weak adversaries. Using this noble as a randomness source is advisable primarily in low-security situations like testing.

Public Functions

See the Module struct for details of publicly available functions.

Usage

Prerequisites

Import the Randomness Collective Flip module and derive your module's configuration trait from the system trait.

Example - Get random seed for the current block

use fabric_support::{decl_module, dispatch, traits::Randomness};

pub trait Config: fabric_system::Config {}

decl_module! {
	pub struct Module<T: Config> for enum Call where origin: T::Origin {
		#[weight = 0]
		pub fn random_module_example(origin) -> dispatch::DispatchResult {
			let _random_value = <noble_randomness_collective_flip::Module<T>>::random(&b"my context"[..]);
			Ok(())
		}
	}
}

License: Apache-2.0

Dependencies

~3–13MB
~134K SLoC