It can be checked with either a Synchronizer object or a UserState object. See: 4. Epoch Key Proof.
Check if global state tree root exists in the current UniRep state
const fromEpoch = Number(finalTransitionProof.transitionFromEpoch)
const GSTRoot = finalTransitionProof.fromGlobalStateTree.toString()
const isGSTRootExisted = await userState.GSTRootExists(
GSTRoot,
fromEpoch
)
console.log(isGSTRootExisted) // false then the proof will be invalid
Check if epoch tree root matches the epoch
const fromEpoch = Number(finalTransitionProof.transitionFromEpoch)
const epochTreeRoot = finalTransitionProof.fromEpochTree.toString()
const isEpochTreeExisted = await userState.epochTreeRootExists(
epochTreeRoot,
fromEpoch
)
console.log(isEpochTreeExisted) // false then the proof will be invalid
Check epoch key nullifiers are not existed
const epkNullifiers = finalTransitionProof.epkNullifiers.map((i) => i.toString())
for (const nullifier of epkNullifiers) {
if (await userState.nullifierExist(nullifier)) {
return false // then the proof will be invalid
}
}