Questions tagged [random]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
7 votes
2 answers
629 views

Secure random number generation?

I've been watching Substrate_ tutorials for a while now, with the goal of learning a little more about their technology. My question is: Would random number generation using Randomness be feasible in ...
Alberto's user avatar
  • 73
4 votes
2 answers
455 views

Generating random numbers in ink!

I've been trying to use most common let mut rng = rand::thread_rng(); let winner_pos = rng.gen_range(0..10); way to get a random number and use it in one of the contract's messages. But it throws a ...
CREESTL's user avatar
  • 474
4 votes
1 answer
84 views

On-chain pseudo-random numbers - agreed by all

I'm looking for a source of random numbers - doesn't need to be cryptographically secure, just hard to predict in advance but agreed by and visible to all participants. I'm thinking about using the ...
JelliedOwl - Paul's user avatar
3 votes
1 answer
56 views

What does `no particular order` mean for storage iterations?

I am always curious what the documentation for the storage means when I see the following. Enumerate all elements in the map in no particular order. https://paritytech.github.io/substrate/master/...
Chralt's user avatar
  • 543
2 votes
1 answer
47 views

How to select n random keys from a `StorageMap`?

Assume I have the following storage map: ZAccounts: StorageMap(AccountId -> AccountInfoOf<T>) Is there a simple way to draw n AccountId's randomly. I assume that I already have a secure ...
Chralt's user avatar
  • 543
1 vote
1 answer
204 views

Is the random number generation safe for pallet_lottery?

I read this post of Shawn https://substrate.stackexchange.com/a/128/2484 and found out, that random numbers for lotteries are not reliable, even with VRF on GRANDPA since the validators could earn ...
Chralt's user avatar
  • 543
1 vote
1 answer
130 views

Test panic with Randomness::random() 'attempt to subtract with overflow'

Sorry for the title but I don't know how to explain it better. I have this simple custom pallet and I try to test the create_random_number dispatchable function with a simple assert_ok! but I get this ...
viac92's user avatar
  • 107
0 votes
1 answer
67 views

How to use "A secure, local entropy source for random number generation" in offchain worker?

The official website tells us there is " A secure, local entropy source for random number generation" . I think it means that I can make use of this feature to generate random number or even ...
kugool's user avatar
  • 161
0 votes
0 answers
49 views

How to generate random number of a specific length in Substrate pallet

I want to generate random number of a specific length. I can't use insecure-randomness-collective-flip because it's not recommended for production. I also can't use rand package because it doesn't ...
Boleng's user avatar
  • 475