Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v1 source pure

Entropy generates fully deterministic, cost-effective, and hard to guess numbers.

Readme View source

gno.land/p/moul/entropy/v1

A cheap, deterministic pseudo-entropy source for gno realms (seeded from block height / time / caller), useful for demos and non-security-critical randomness.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.

Overview

Entropy generates fully deterministic, cost-effective, and hard to guess numbers.

It is designed both for single-usage, like seeding math/rand or for being reused which increases the entropy and its cost effectiveness.

Disclaimer: this package is unsafe and won't prevent others to guess values in advance.

It uses the Bernstein's hash djb2 to be CPU-cycle efficient.

Functions 2

Types 1

type Instance

struct
1type Instance struct {
2	value uint32
3}
source

Methods on Instance

func Seed

method on Instance
1func (i *Instance) Seed() uint32
source

func Value

method on Instance
1func (i *Instance) Value() uint32
source

func Value64

method on Instance
1func (i *Instance) Value64() uint64
source

Imports 4

  • chain/runtime stdlib
  • chain/runtime/unsafe stdlib
  • math stdlib
  • time stdlib

Source Files 3