Skip to content

Latest commit

 

History

History
188 lines (84 loc) · 4.7 KB

simple_rng.md

File metadata and controls

188 lines (84 loc) · 4.7 KB

Module 0x3::simple_rng

A simple random number generator in Move language.

Constants

const ErrorInvalidArg: u64 = 0;

const ErrorInvalidSeed: u64 = 3;

const ErrorInvalidU128: u64 = 2;

const ErrorInvalidU64: u64 = 1;

Function bytes_to_u64

public fun bytes_to_u64(bytes: vector<u8>): u64

Function bytes_to_u128

public fun bytes_to_u128(bytes: vector<u8>): u128

Function rand_u64

Generate a random u64 from seed

public fun rand_u64(): u64

Function rand_u64_with_count

Generate a random u64 value with a count parameter to ensure unique randomness within a transaction.

public fun rand_u64_with_count(count: u64): u64

Function rand_u128

Generate a random u128 from seed

public fun rand_u128(): u128

Function rand_u128_with_count

Generate a random u128 value with a count parameter to ensure unique randomness within a transaction.

public fun rand_u128_with_count(count: u64): u128

Function rand_u64_range

Generate a random integer range in [low, high) for u64.

public fun rand_u64_range(low: u64, high: u64): u64

Function rand_u64_range_with_count

Generate a random integer range in [low, high) for u64 with count.

public fun rand_u64_range_with_count(low: u64, high: u64, count: u64): u64

Function rand_u128_range

Generate a random integer range in [low, high) for u128.

public fun rand_u128_range(low: u128, high: u128): u128

Function rand_u128_range_with_count

Generate a random integer range in [low, high) for u128 with count.

public fun rand_u128_range_with_count(low: u128, high: u128, count: u64): u128