[]Struct pallet_randomness_collective_flip::Module

pub struct Module<T: Trait>(_);

Methods

impl<T: Trait + 'static> Module<T>[src]

pub fn random_material() -> Vec<T::Hash>[src]

Series of block headers from the last 81 blocks that acts as random seed material. This is arranged as a ring buffer with block_number % 81 being the index into the Vec of the oldest hash.

Trait Implementations

impl<T: Trait> Callable<T> for Module<T>

type Call = Call<T>

impl<T: Clone + Trait> Clone for Module<T>

impl<T: Copy + Trait> Copy for Module<T>

impl<T: Trait> Debug for Module<T> where
    T: Debug

impl<T: Eq + Trait> Eq for Module<T>

impl<T: Trait> ModuleErrorMetadata for Module<T>

impl<T: Trait> OffchainWorker<<T as Trait>::BlockNumber> for Module<T>

impl<T: Trait> OnFinalize<<T as Trait>::BlockNumber> for Module<T>

impl<T: Trait> OnInitialize<<T as Trait>::BlockNumber> for Module<T>

impl<T: PartialEq + Trait> PartialEq<Module<T>> for Module<T>

impl<T: Trait> Randomness<<T as Trait>::Hash> for Module<T>[src]

fn random(subject: &[u8]) -> T::Hash[src]

Get a low-influence "random" value.

Being a deterministic block chain, real randomness is difficult to come by. This gives you something that approximates it. subject is a context identifier and allows you to get a different result to other callers of this function; use it like random(&b"my context"[..]). This is initially implemented through a low-influence "triplet mix" convolution of previous block hash values. In the future it will be generated from a secure verifiable random function (VRF).

Security Notes

This randomness uses a low-influence function, drawing upon the block hashes from the previous 81 blocks. Its result for any given subject will be known far in advance by anyone observing the chain. Any block producer has significant influence over their block hashes bounded only by their computational resources. Our low-influence function reduces the actual block producer's influence over the randomness, but increases the influence of small colluding groups of recent block producers.

Some BABE blocks have VRF outputs where the block producer has exactly one bit of influence, either they make the block or they do not make the block and thus someone else makes the next block. Yet, this randomness is not fresh in all BABE blocks.

If that is an insufficient security guarantee then two things can be used to improve this randomness:

  • Name, in advance, the block number whose random value will be used; ensure your module retains a buffer of previous random values for its subject and then index into these in order to obviate the ability of your user to look up the parent hash and choose when to transact based upon it.
  • Require your user to first commit to an additional value by first posting its hash. Require them to reveal the value to determine the final result, hashing it with the output of this random function. This reduces the ability of a cabal of block producers from conspiring against individuals.

WARNING: Hashing the result of this function will remove any low-influence properties it has and mean that all bits of the resulting value are entirely manipulatable by the author of the parent block, who can determine the value of parent_hash.

impl<T: Trait> StructuralEq for Module<T>

impl<T: Trait> StructuralPartialEq for Module<T>

impl<T: Trait> WeighBlock<<T as Trait>::BlockNumber> for Module<T>

Auto Trait Implementations

impl<T> RefUnwindSafe for Module<T> where
    T: RefUnwindSafe

impl<T> Send for Module<T> where
    T: Send

impl<T> Sync for Module<T> where
    T: Sync

impl<T> Unpin for Module<T> where
    T: Unpin

impl<T> UnwindSafe for Module<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CheckedConversion for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, Outer> IsWrappedBy<Outer> for T where
    Outer: AsRef<T> + AsMut<T> + From<T>,
    T: From<Outer>, 

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeRefUnwindSafe for T where
    T: RefUnwindSafe

impl<T> Member for T where
    T: 'static + Clone + PartialEq<T> + Eq + Send + Sync + Debug
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SaturatedConversion for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 

impl<T, S> UniqueSaturatedInto<T> for S where
    S: TryInto<T>,
    T: Bounded

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,