Skip to content

@lelantos-org/sdk / primitives / rootFromPath

Function: rootFromPath() ​

ts
function rootFromPath(
   P, 
   leaf, 
   pathElements, 
   pathIndices
): bigint;

Defined in: @lelantos-org/sdk/dist/crypto/path.d.ts:9

Recompute the root a (leaf, path) pair attests to.

The path is relayer-supplied, so it is validated rather than coerced: splice would clamp an out-of-range pathIndices[lvl] to a valid slot and yield a plausible root for a position the path does not name, and a level without exactly three siblings is not a quaternary node.

Parameters ​

ParameterType
PPoseidon
leafbigint
pathElementsbigint[][]
pathIndicesnumber[]

Returns ​

bigint