Socket
Book a DemoInstallSign in
Socket

@projectsophon/hashing

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@projectsophon/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.

Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
0
-100%
Maintainers
2
Weekly downloads
 
Created
Source

@projectsophon/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 @projectsophon/hashing
yarn add @projectsophon/hashing

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

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

Table of contents

Interfaces

  • IntegerVector

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[]) => bigint

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): bigint

Parameters
NameType
...inputsnumber[]
Returns

bigint

mimcSponge

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

Parameters

NameType
inputsbigint[]
nOutputsnumber
roundsnumber
keynumber

Returns

bigint[]

modPBigInt

modPBigInt(x): bigint

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

bigint

modPBigIntNative

modPBigIntNative(x): bigint

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

Parameters

NameTypeDescription
xbigintThe number to modulo against LOCATION_ID_UB

Returns

bigint

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

FAQs

Package last updated on 13 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts