constproofIndexes:ethers.BigNumber[] = []awaittx.wait() // should wait until the transaction is confirmedconstproofHash=startTransitionProof.hash()constproofIndex=awaitcontract.getProofIndex(proofHash)proofIndexes.push(proofIndex)
Submit process attestations proofs
Submit all process attestations proofs and get the proof indexes.
for (let i =0; i <processAttestationProofs.length; i++) {consttx=awaitcontract.processAttestations( processAttestationProofs[i].publicSignals, processAttestationProofs[i].proof )awaittx.wait() // wait until the transaction is confirmedconstproofHash= processAttestationProofs[i].hash()constproofIndex=awaitcontract.getProofIndex(proofHash)proofIndexes.push(proofIndex)}
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
constfromEpoch=Number(finalTransitionProof.transitionFromEpoch)constGSTRoot=finalTransitionProof.fromGlobalStateTree.toString()constisGSTRootExisted=awaituserState.GSTRootExists( GSTRoot, fromEpoch)console.log(isGSTRootExisted) // false then the proof will be invalid
Check if epoch tree root matches the epoch
constfromEpoch=Number(finalTransitionProof.transitionFromEpoch)constepochTreeRoot=finalTransitionProof.fromEpochTree.toString()constisEpochTreeExisted=awaituserState.epochTreeRootExists( epochTreeRoot, fromEpoch)console.log(isEpochTreeExisted) // false then the proof will be invalid
Check epoch key nullifiers are not existed
constepkNullifiers=finalTransitionProof.epkNullifiers.map((i) =>i.toString())for (constnullifierof epkNullifiers) {if (awaituserState.nullifierExist(nullifier)) {returnfalse// then the proof will be invalid }}