Skip to content

@lelantos-org/sdk / primitives / Poseidon

Class: Poseidon ​

Defined in: @lelantos-org/sdk/dist/crypto/poseidon.d.ts:6

Properties ​

backend ​

ts
readonly backend: PoseidonBackend;

Defined in: @lelantos-org/sdk/dist/crypto/poseidon.d.ts:8

Which implementation serves hashes. "js" means the wasm module did not load.


hash ​

ts
readonly hash: (xs) => bigint;

Defined in: @lelantos-org/sdk/dist/crypto/poseidon.d.ts:22

Inputs must already be canonical field elements, i.e. in [0, r).

poseidon-lite reduces mod r internally, so x and x + r hash identically. Every domain-separated construction in the SDK routes through here, so without this check distinct decoded records or merkle leaves could collide: the decoders that feed it (notes/codec.ts, keys/address.ts) read raw 32-byte slices and can produce unreduced values. The wasm backend also rejects unreduced input; checking here keeps the error identical across backends.

A bound property rather than a prototype method, so the class stays structurally { backend, hash } and the backend is captured per instance instead of branched on per hash.

Parameters ​

ParameterType
xsbigint[]

Returns ​

bigint

Methods ​

build() ​

ts
static build(): Promise<Poseidon>;

Defined in: @lelantos-org/sdk/dist/crypto/poseidon.d.ts:28

Initialises the wasm backend. Failure is not fatal: the instance loads the JS tables instead and logs a warning, since the slowdown has no other symptom.

Returns ​

Promise<Poseidon>