6.7.29 • Published 3 years ago

@darkforest_eth/hashing v6.7.29

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@darkforest_eth/hashing

This package contains MiMC hashing utilities for use with Dark Forest. The MiMC algorithm is used for both finding planet hashes and calculating the perlin in-game. Among other things, these values are often needed for generating Snarks.

Installation

You can install this package using npm or yarn by running:

npm install --save @darkforest_eth/hashing
yarn add @darkforest_eth/hashing

When using this in a plugin, you might want to load it with skypack

import * as hashing from 'http://cdn.skypack.dev/@darkforest_eth/hashing';

Table of contents

Interfaces

Variables

Functions

Variables

Fraction

Fraction: IFraction


MAX_PERLIN_VALUE

Const MAX_PERLIN_VALUE: 32

Functions

getRandomGradientAt

getRandomGradientAt(point, scale, randFn): Vector

Parameters

NameType
pointVector
scaleIFraction
randFnHashFn

Returns

Vector


mimcHash

mimcHash(key): (...inputs: number[]) => BigInteger

The primary function used to build any MiMC hashing algorithm for Dark Forest.

Parameters

NameTypeDescription
keynumberThe key for the MiMC algorithm. Will usually be PLANETHASH_KEY, SPACETYPE_KEY, or BIOMEBASE_KEY.

Returns

fn

▸ (...inputs): BigInteger

Parameters
NameType
...inputsnumber[]
Returns

BigInteger


mimcSponge

mimcSponge(inputs, nOutputs, rounds, key): BigInteger[]

Parameters

NameType
inputsBigInteger[]
nOutputsnumber
roundsnumber
keynumber

Returns

BigInteger[]


modPBigInt

modPBigInt(x): BigInteger

Modulo a number with the LOCATION_ID_UB constant. If the result is < 0, the LOCATION_ID_UB will then be added.

Parameters

NameTypeDescription
xnumberThe number to modulo against LOCATION_ID_UB

Returns

BigInteger


modPBigIntNative

modPBigIntNative(x): BigInteger

Modulo a BigInt with the LOCATION_ID_UB constant. If the result is < 0, the LOCATION_ID_UB will then be added.

Parameters

NameTypeDescription
xBigIntegerThe number to modulo against LOCATION_ID_UB

Returns

BigInteger


perlin

perlin(coords, options): number

Calculates the perlin for a location, given the x,y pair and the PerlinConfig for the game.

Parameters

NameTypeDescription
coordsIntegerVectorAn object of the x,y coordinates for which perlin is being calculated.
optionsPerlinConfigAn object containing the configuration for the perlin algorithm.

Returns

number


rand

rand(key): (...args: number[]) => number

Parameters

NameType
keynumber

Returns

fn

▸ (...args): number

Parameters
NameType
...argsnumber[]
Returns

number


seededRandom

seededRandom(seed): number

Generate a random number based on some seed. Useful for procedural generation.

Parameters

NameTypeDescription
seednumberThe seed of the random number.

Returns

number

6.7.23

3 years ago

6.7.24

3 years ago

6.7.25

3 years ago

6.7.26

3 years ago

6.7.27

3 years ago

6.7.28

3 years ago

6.7.29

3 years ago

6.7.20

3 years ago

6.7.21

3 years ago

6.7.22

3 years ago

6.7.12

3 years ago

6.7.13

3 years ago

6.7.14

3 years ago

6.7.15

3 years ago

6.7.16

3 years ago

6.7.17

3 years ago

6.7.18

3 years ago

6.7.19

3 years ago

6.7.10

3 years ago

6.7.11

3 years ago

6.7.4

3 years ago

6.7.6

3 years ago

6.7.5

3 years ago

6.7.8

3 years ago

6.7.7

3 years ago

6.7.9

3 years ago

6.6.7

3 years ago

6.6.9

3 years ago

6.6.8

3 years ago

6.7.0

3 years ago

6.7.2

3 years ago

6.7.1

3 years ago

6.7.3

3 years ago

6.6.10

3 years ago

6.6.6

3 years ago

6.6.1

3 years ago

6.6.3

3 years ago

6.6.2

3 years ago

6.6.5

3 years ago

6.6.4

3 years ago

6.5.6

3 years ago

6.5.5

3 years ago

6.5.2

3 years ago

6.5.4

3 years ago

6.5.3

3 years ago

6.5.1

3 years ago

6.5.0

3 years ago

6.3.0

3 years ago

6.2.17

3 years ago

6.2.15

3 years ago

6.2.16

3 years ago

6.2.14

3 years ago

6.2.13

3 years ago

6.2.11

3 years ago

6.2.12

3 years ago

6.2.10

3 years ago

6.2.9

3 years ago

6.2.8

3 years ago

6.2.5

3 years ago

6.2.4

3 years ago

6.2.7

3 years ago

6.2.6

3 years ago

6.2.1

3 years ago

6.2.3

3 years ago

6.2.2

3 years ago

6.2.0

4 years ago

6.1.28

4 years ago

6.1.17

4 years ago

6.1.16

4 years ago

6.1.15

4 years ago

6.1.14

4 years ago

6.1.19

4 years ago

6.1.18

4 years ago

6.1.13

4 years ago

6.1.12

4 years ago

6.1.11

4 years ago

6.1.10

4 years ago

6.1.27

4 years ago

6.1.26

4 years ago

6.1.25

4 years ago

6.1.20

4 years ago

6.1.24

4 years ago

6.1.23

4 years ago

6.1.22

4 years ago

6.1.21

4 years ago

6.1.8

4 years ago

6.1.9

4 years ago

6.1.7

4 years ago

6.1.6

4 years ago

6.1.5

4 years ago

6.1.4

4 years ago

6.1.3

4 years ago

6.1.2

4 years ago

6.1.1

4 years ago

6.1.0

4 years ago

6.0.2

4 years ago

6.0.1

4 years ago

6.0.0

4 years ago

0.6.0-phated5.1

4 years ago

0.6.0-phated5.0

4 years ago

0.6.0-staging4

4 years ago

0.6.0-staging3

4 years ago

0.6.0-staging1

4 years ago

0.6.0-dev22

4 years ago

0.6.0-dev21

4 years ago

0.6.0-dev20

4 years ago

0.6.0-dev19

4 years ago

0.6.0-dev18

4 years ago

0.6.0-dev17

4 years ago

0.6.0-dev16

4 years ago

0.6.0-dev14

4 years ago

0.6.0-dev13

4 years ago

0.6.0-dev12

4 years ago

0.6.0-dev11

4 years ago

0.6.0-dev9

4 years ago

0.6.0-dev8

4 years ago

0.6.0-dev

4 years ago